xref: /freebsd/sys/conf/kmod.mk (revision 27a15c94ede5ae1f6d81d843782520096a673c0c)
1639a2e50SGarrett Wollman#	From: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
227a15c94SGarrett Wollman#	$Id: bsd.kmod.mk,v 1.10 1995/02/25 20:51:11 phk 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
2727a15c94SGarrett Wollman.if defined(PSEUDO_LKM)
2827a15c94SGarrett WollmanCFLAGS+= -DPSEUDO_LKM
2927a15c94SGarrett Wollman.endif
3027a15c94SGarrett Wollman
31639a2e50SGarrett WollmanDPSRCS+= ${SRCS:M*.h}
32639a2e50SGarrett WollmanOBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
33639a2e50SGarrett Wollman
34639a2e50SGarrett Wollman.if !defined(PROG)
35639a2e50SGarrett WollmanPROG=	${KMOD}.o
36639a2e50SGarrett Wollman.endif
37639a2e50SGarrett Wollman
38639a2e50SGarrett Wollman${PROG}: ${DPSRCS} ${OBJS} ${DPADD}
39639a2e50SGarrett Wollman	${LD} -r ${LDFLAGS} -o ${.TARGET} ${OBJS}
40639a2e50SGarrett Wollman
41639a2e50SGarrett Wollman.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
42639a2e50SGarrett Wollman	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
43639a2e50SGarrett Wollman	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
44639a2e50SGarrett WollmanMAN1=	${KMOD}.4
45639a2e50SGarrett Wollman.endif
46639a2e50SGarrett Wollman
47639a2e50SGarrett Wollman_PROGSUBDIR: .USE
48639a2e50SGarrett Wollman.if defined(SUBDIR) && !empty(SUBDIR)
49639a2e50SGarrett Wollman	@for entry in ${SUBDIR}; do \
50639a2e50SGarrett Wollman		(${ECHODIR} "===> $$entry"; \
51639a2e50SGarrett Wollman		if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
52639a2e50SGarrett Wollman			cd ${.CURDIR}/$${entry}.${MACHINE}; \
53639a2e50SGarrett Wollman		else \
54639a2e50SGarrett Wollman			cd ${.CURDIR}/$${entry}; \
55639a2e50SGarrett Wollman		fi; \
56639a2e50SGarrett Wollman		${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
57639a2e50SGarrett Wollman	done
58639a2e50SGarrett Wollman.endif
59639a2e50SGarrett Wollman
60639a2e50SGarrett Wollman.MAIN: all
61639a2e50SGarrett Wollmanall: ${PROG} _PROGSUBDIR
62639a2e50SGarrett Wollman
63639a2e50SGarrett Wollman.if !target(clean)
64639a2e50SGarrett Wollmanclean: _PROGSUBDIR
65639a2e50SGarrett Wollman	rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
66639a2e50SGarrett Wollman.endif
67639a2e50SGarrett Wollman
68639a2e50SGarrett Wollman.if !target(cleandir)
69639a2e50SGarrett Wollmancleandir: _PROGSUBDIR
70639a2e50SGarrett Wollman	rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
71639a2e50SGarrett Wollman	rm -f ${.CURDIR}/tags .depend
72639a2e50SGarrett Wollman	cd ${.CURDIR}; rm -rf obj;
73639a2e50SGarrett Wollman.endif
74639a2e50SGarrett Wollman
75639a2e50SGarrett Wollman.if !target(install)
76639a2e50SGarrett Wollman.if !target(beforeinstall)
77639a2e50SGarrett Wollmanbeforeinstall:
78639a2e50SGarrett Wollman.endif
79639a2e50SGarrett Wollman.if !target(afterinstall)
80639a2e50SGarrett Wollmanafterinstall:
81639a2e50SGarrett Wollman.endif
82639a2e50SGarrett Wollman
83639a2e50SGarrett Wollmanrealinstall: _PROGSUBDIR
84639a2e50SGarrett Wollman	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
85639a2e50SGarrett Wollman	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
86639a2e50SGarrett Wollman.if defined(LINKS) && !empty(LINKS)
87639a2e50SGarrett Wollman	@set ${LINKS}; \
88639a2e50SGarrett Wollman	while test $$# -ge 2; do \
89639a2e50SGarrett Wollman		l=${DESTDIR}$$1; \
90639a2e50SGarrett Wollman		shift; \
91639a2e50SGarrett Wollman		t=${DESTDIR}$$1; \
92639a2e50SGarrett Wollman		shift; \
93639a2e50SGarrett Wollman		${ECHO} $$t -\> $$l; \
94639a2e50SGarrett Wollman		rm -f $$t; \
9560983531SJordan K. Hubbard		ln ${LN_FLAGS} $$l $$t; \
96639a2e50SGarrett Wollman	done; true
97639a2e50SGarrett Wollman.endif
98639a2e50SGarrett Wollman
99639a2e50SGarrett Wollmaninstall: afterinstall
100639a2e50SGarrett Wollman.if !defined(NOMAN)
101639a2e50SGarrett Wollmanafterinstall: realinstall maninstall
102639a2e50SGarrett Wollman.else
103639a2e50SGarrett Wollmanafterinstall: realinstall
104639a2e50SGarrett Wollman.endif
105639a2e50SGarrett Wollmanrealinstall: beforeinstall
106639a2e50SGarrett Wollman.endif
107639a2e50SGarrett Wollman
108d9584d76SJordan K. HubbardDISTRIBUTION?=	bin
10955ff8fb1SPoul-Henning Kamp.if !target(distribute)
11055ff8fb1SPoul-Henning Kampdistribute:
111ffd87c07SPoul-Henning Kamp	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies
11255ff8fb1SPoul-Henning Kamp.endif
11355ff8fb1SPoul-Henning Kamp
114639a2e50SGarrett Wollman.if !target(obj)
115639a2e50SGarrett Wollman.if defined(NOOBJ)
116639a2e50SGarrett Wollmanobj: _PROGSUBDIR
117639a2e50SGarrett Wollman.else
118639a2e50SGarrett Wollmanobj: _PROGSUBDIR
119639a2e50SGarrett Wollman	@cd ${.CURDIR}; rm -rf obj; \
120639a2e50SGarrett Wollman	here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \
121639a2e50SGarrett Wollman	${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \
122639a2e50SGarrett Wollman	if test -d /usr/obj -a ! -d $$dest; then \
123639a2e50SGarrett Wollman		mkdir -p $$dest; \
124639a2e50SGarrett Wollman	else \
125639a2e50SGarrett Wollman		true; \
126639a2e50SGarrett Wollman	fi;
127639a2e50SGarrett Wollman.endif
128639a2e50SGarrett Wollman.endif
129639a2e50SGarrett Wollman
130639a2e50SGarrett Wollman.if !target(tags)
131639a2e50SGarrett Wollmantags: ${SRCS} _PROGSUBDIR
132639a2e50SGarrett Wollman.if defined(PROG)
133639a2e50SGarrett Wollman	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
134639a2e50SGarrett Wollman	    sed "s;\${.CURDIR}/;;" > tags
135639a2e50SGarrett Wollman.endif
136639a2e50SGarrett Wollman.endif
137639a2e50SGarrett Wollman
138639a2e50SGarrett Wollman.if !defined(NOMAN)
139639a2e50SGarrett Wollman.include <bsd.man.mk>
140639a2e50SGarrett Wollman.elif !target(maninstall)
141639a2e50SGarrett Wollmanmaninstall:
142639a2e50SGarrett Wollman.endif
143639a2e50SGarrett Wollman
144639a2e50SGarrett Wollman.if !target(load)
145639a2e50SGarrett Wollmanload:	${PROG}
146639a2e50SGarrett Wollman	/sbin/modload -o ${KMOD} -e${KMOD} ${PROG}
147639a2e50SGarrett Wollman.endif
148639a2e50SGarrett Wollman
149639a2e50SGarrett Wollman.if !target(unload)
150639a2e50SGarrett Wollmanunload:	${PROG}
151639a2e50SGarrett Wollman	/sbin/modunload -n ${KMOD}
152639a2e50SGarrett Wollman.endif
153639a2e50SGarrett Wollman
1541aa57be3SGarrett WollmanKERN=	${.CURDIR}/../../sys/kern
1551aa57be3SGarrett Wollman
1561aa57be3SGarrett Wollmanvnode_if.h:	${KERN}/vnode_if.sh ${KERN}/vnode_if.src
1571aa57be3SGarrett Wollman	sh ${KERN}/vnode_if.sh ${KERN}/vnode_if.src
1581aa57be3SGarrett Wollman
1591aa57be3SGarrett Wollman./vnode_if.h:	vnode_if.h
1601aa57be3SGarrett Wollman
161cdaec7b1SBruce Evans_DEPSUBDIR=	_PROGSUBDIR
162639a2e50SGarrett Wollman.include <bsd.dep.mk>
163