xref: /freebsd/sys/conf/kmod.mk (revision 60983531238417437f632e5ab285e5e641aaa527)
1639a2e50SGarrett Wollman#	From: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
260983531SJordan K. Hubbard#	$Id: bsd.kmod.mk,v 1.7 1995/01/14 07:51:06 jkh Exp $
3639a2e50SGarrett Wollman
4639a2e50SGarrett Wollman.if exists(${.CURDIR}/../Makefile.inc)
5639a2e50SGarrett Wollman.include "${.CURDIR}/../Makefile.inc"
6639a2e50SGarrett Wollman.endif
7639a2e50SGarrett Wollman
8639a2e50SGarrett Wollman.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
9639a2e50SGarrett Wollman
10639a2e50SGarrett Wollman#
11639a2e50SGarrett Wollman# Assume that we are in /usr/src/foo/bar, so /sys is
12639a2e50SGarrett Wollman# ${.CURDIR}/../../sys.  We don't bother adding a .PATH since nothing
13639a2e50SGarrett Wollman# actually lives in /sys directly.
14639a2e50SGarrett Wollman#
15639a2e50SGarrett WollmanCFLAGS+=${COPTS} -DKERNEL -I${.CURDIR}/../../sys -W -Wcomment -Wredundant-decls
16639a2e50SGarrett Wollman
17639a2e50SGarrett WollmanKMODGRP?=	bin
18639a2e50SGarrett WollmanKMODOWN?=	bin
19639a2e50SGarrett WollmanKMODMODE?=	555
20639a2e50SGarrett Wollman
211aa57be3SGarrett Wollman.if defined(VFS_LKM)
221aa57be3SGarrett WollmanCFLAGS+= -DVFS_LKM -DMODVNOPS=${KMOD}vnops -I.
231aa57be3SGarrett WollmanSRCS+=	vnode_if.h
241aa57be3SGarrett WollmanCLEANFILES+=	vnode_if.h vnode_if.c
251aa57be3SGarrett Wollman.endif
261aa57be3SGarrett Wollman
27639a2e50SGarrett WollmanDPSRCS+= ${SRCS:M*.h}
28639a2e50SGarrett WollmanOBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
29639a2e50SGarrett Wollman
30639a2e50SGarrett Wollman.if !defined(PROG)
31639a2e50SGarrett WollmanPROG=	${KMOD}.o
32639a2e50SGarrett Wollman.endif
33639a2e50SGarrett Wollman
34639a2e50SGarrett Wollman${PROG}: ${DPSRCS} ${OBJS} ${DPADD}
35639a2e50SGarrett Wollman	${LD} -r ${LDFLAGS} -o ${.TARGET} ${OBJS}
36639a2e50SGarrett Wollman
37639a2e50SGarrett Wollman.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
38639a2e50SGarrett Wollman	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
39639a2e50SGarrett Wollman	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
40639a2e50SGarrett WollmanMAN1=	${KMOD}.4
41639a2e50SGarrett Wollman.endif
42639a2e50SGarrett Wollman
43639a2e50SGarrett Wollman_PROGSUBDIR: .USE
44639a2e50SGarrett Wollman.if defined(SUBDIR) && !empty(SUBDIR)
45639a2e50SGarrett Wollman	@for entry in ${SUBDIR}; do \
46639a2e50SGarrett Wollman		(${ECHODIR} "===> $$entry"; \
47639a2e50SGarrett Wollman		if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
48639a2e50SGarrett Wollman			cd ${.CURDIR}/$${entry}.${MACHINE}; \
49639a2e50SGarrett Wollman		else \
50639a2e50SGarrett Wollman			cd ${.CURDIR}/$${entry}; \
51639a2e50SGarrett Wollman		fi; \
52639a2e50SGarrett Wollman		${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
53639a2e50SGarrett Wollman	done
54639a2e50SGarrett Wollman.endif
55639a2e50SGarrett Wollman
56639a2e50SGarrett Wollman.MAIN: all
57639a2e50SGarrett Wollmanall: ${PROG} _PROGSUBDIR
58639a2e50SGarrett Wollman
59639a2e50SGarrett Wollman.if !target(clean)
60639a2e50SGarrett Wollmanclean: _PROGSUBDIR
61639a2e50SGarrett Wollman	rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
62639a2e50SGarrett Wollman.endif
63639a2e50SGarrett Wollman
64639a2e50SGarrett Wollman.if !target(cleandir)
65639a2e50SGarrett Wollmancleandir: _PROGSUBDIR
66639a2e50SGarrett Wollman	rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
67639a2e50SGarrett Wollman	rm -f ${.CURDIR}/tags .depend
68639a2e50SGarrett Wollman	cd ${.CURDIR}; rm -rf obj;
69639a2e50SGarrett Wollman.endif
70639a2e50SGarrett Wollman
71639a2e50SGarrett Wollman.if !target(install)
72639a2e50SGarrett Wollman.if !target(beforeinstall)
73639a2e50SGarrett Wollmanbeforeinstall:
74639a2e50SGarrett Wollman.endif
75639a2e50SGarrett Wollman.if !target(afterinstall)
76639a2e50SGarrett Wollmanafterinstall:
77639a2e50SGarrett Wollman.endif
78639a2e50SGarrett Wollman
79639a2e50SGarrett Wollmanrealinstall: _PROGSUBDIR
80639a2e50SGarrett Wollman	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
81639a2e50SGarrett Wollman	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
82639a2e50SGarrett Wollman.if defined(LINKS) && !empty(LINKS)
83639a2e50SGarrett Wollman	@set ${LINKS}; \
84639a2e50SGarrett Wollman	while test $$# -ge 2; do \
85639a2e50SGarrett Wollman		l=${DESTDIR}$$1; \
86639a2e50SGarrett Wollman		shift; \
87639a2e50SGarrett Wollman		t=${DESTDIR}$$1; \
88639a2e50SGarrett Wollman		shift; \
89639a2e50SGarrett Wollman		${ECHO} $$t -\> $$l; \
90639a2e50SGarrett Wollman		rm -f $$t; \
9160983531SJordan K. Hubbard		ln ${LN_FLAGS} $$l $$t; \
92639a2e50SGarrett Wollman	done; true
93639a2e50SGarrett Wollman.endif
94639a2e50SGarrett Wollman
95639a2e50SGarrett Wollmaninstall: afterinstall
96639a2e50SGarrett Wollman.if !defined(NOMAN)
97639a2e50SGarrett Wollmanafterinstall: realinstall maninstall
98639a2e50SGarrett Wollman.else
99639a2e50SGarrett Wollmanafterinstall: realinstall
100639a2e50SGarrett Wollman.endif
101639a2e50SGarrett Wollmanrealinstall: beforeinstall
102639a2e50SGarrett Wollman.endif
103639a2e50SGarrett Wollman
104d9584d76SJordan K. HubbardDISTRIBUTION?=	bin
10555ff8fb1SPoul-Henning Kamp.if !target(distribute)
10655ff8fb1SPoul-Henning Kampdistribute:
10755ff8fb1SPoul-Henning Kamp	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${RELEASEDIR}/${DISTRIBUTION} SHARED=copies
10855ff8fb1SPoul-Henning Kamp.endif
10955ff8fb1SPoul-Henning Kamp
110639a2e50SGarrett Wollman.if !target(obj)
111639a2e50SGarrett Wollman.if defined(NOOBJ)
112639a2e50SGarrett Wollmanobj: _PROGSUBDIR
113639a2e50SGarrett Wollman.else
114639a2e50SGarrett Wollmanobj: _PROGSUBDIR
115639a2e50SGarrett Wollman	@cd ${.CURDIR}; rm -rf obj; \
116639a2e50SGarrett Wollman	here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \
117639a2e50SGarrett Wollman	${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \
118639a2e50SGarrett Wollman	if test -d /usr/obj -a ! -d $$dest; then \
119639a2e50SGarrett Wollman		mkdir -p $$dest; \
120639a2e50SGarrett Wollman	else \
121639a2e50SGarrett Wollman		true; \
122639a2e50SGarrett Wollman	fi;
123639a2e50SGarrett Wollman.endif
124639a2e50SGarrett Wollman.endif
125639a2e50SGarrett Wollman
126639a2e50SGarrett Wollman.if !target(tags)
127639a2e50SGarrett Wollmantags: ${SRCS} _PROGSUBDIR
128639a2e50SGarrett Wollman.if defined(PROG)
129639a2e50SGarrett Wollman	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
130639a2e50SGarrett Wollman	    sed "s;\${.CURDIR}/;;" > tags
131639a2e50SGarrett Wollman.endif
132639a2e50SGarrett Wollman.endif
133639a2e50SGarrett Wollman
134639a2e50SGarrett Wollman.if !defined(NOMAN)
135639a2e50SGarrett Wollman.include <bsd.man.mk>
136639a2e50SGarrett Wollman.elif !target(maninstall)
137639a2e50SGarrett Wollmanmaninstall:
138639a2e50SGarrett Wollman.endif
139639a2e50SGarrett Wollman
140639a2e50SGarrett Wollman.if !target(load)
141639a2e50SGarrett Wollmanload:	${PROG}
142639a2e50SGarrett Wollman	/sbin/modload -o ${KMOD} -e${KMOD} ${PROG}
143639a2e50SGarrett Wollman.endif
144639a2e50SGarrett Wollman
145639a2e50SGarrett Wollman.if !target(unload)
146639a2e50SGarrett Wollmanunload:	${PROG}
147639a2e50SGarrett Wollman	/sbin/modunload -n ${KMOD}
148639a2e50SGarrett Wollman.endif
149639a2e50SGarrett Wollman
1501aa57be3SGarrett WollmanKERN=	${.CURDIR}/../../sys/kern
1511aa57be3SGarrett Wollman
1521aa57be3SGarrett Wollmanvnode_if.h:	${KERN}/vnode_if.sh ${KERN}/vnode_if.src
1531aa57be3SGarrett Wollman	sh ${KERN}/vnode_if.sh ${KERN}/vnode_if.src
1541aa57be3SGarrett Wollman
1551aa57be3SGarrett Wollman./vnode_if.h:	vnode_if.h
1561aa57be3SGarrett Wollman
157639a2e50SGarrett Wollman.include <bsd.dep.mk>
158