xref: /freebsd/sys/conf/kmod.mk (revision 639a2e50351b36fa290789e8641c47ac92870cf6)
1639a2e50SGarrett Wollman#	From: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
2639a2e50SGarrett Wollman#	$Id: bsd.prog.mk,v 1.5 1994/09/11 21:28:30 rgrimes 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
21639a2e50SGarrett WollmanINSTALL?=	install
22639a2e50SGarrett Wollman
23639a2e50SGarrett WollmanDPSRCS+= ${SRCS:M*.h}
24639a2e50SGarrett WollmanOBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
25639a2e50SGarrett Wollman
26639a2e50SGarrett Wollman.if !defined(PROG)
27639a2e50SGarrett WollmanPROG=	${KMOD}.o
28639a2e50SGarrett Wollman.endif
29639a2e50SGarrett Wollman
30639a2e50SGarrett Wollman${PROG}: ${DPSRCS} ${OBJS} ${DPADD}
31639a2e50SGarrett Wollman	${LD} -r ${LDFLAGS} -o ${.TARGET} ${OBJS}
32639a2e50SGarrett Wollman
33639a2e50SGarrett WollmanMKDEP=	-p
34639a2e50SGarrett Wollman
35639a2e50SGarrett Wollman.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
36639a2e50SGarrett Wollman	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
37639a2e50SGarrett Wollman	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
38639a2e50SGarrett WollmanMAN1=	${KMOD}.4
39639a2e50SGarrett Wollman.endif
40639a2e50SGarrett Wollman
41639a2e50SGarrett Wollman_PROGSUBDIR: .USE
42639a2e50SGarrett Wollman.if defined(SUBDIR) && !empty(SUBDIR)
43639a2e50SGarrett Wollman	@for entry in ${SUBDIR}; do \
44639a2e50SGarrett Wollman		(${ECHODIR} "===> $$entry"; \
45639a2e50SGarrett Wollman		if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
46639a2e50SGarrett Wollman			cd ${.CURDIR}/$${entry}.${MACHINE}; \
47639a2e50SGarrett Wollman		else \
48639a2e50SGarrett Wollman			cd ${.CURDIR}/$${entry}; \
49639a2e50SGarrett Wollman		fi; \
50639a2e50SGarrett Wollman		${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
51639a2e50SGarrett Wollman	done
52639a2e50SGarrett Wollman.endif
53639a2e50SGarrett Wollman
54639a2e50SGarrett Wollman.MAIN: all
55639a2e50SGarrett Wollmanall: ${PROG} _PROGSUBDIR
56639a2e50SGarrett Wollman
57639a2e50SGarrett Wollman.if !target(clean)
58639a2e50SGarrett Wollmanclean: _PROGSUBDIR
59639a2e50SGarrett Wollman	rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
60639a2e50SGarrett Wollman.endif
61639a2e50SGarrett Wollman
62639a2e50SGarrett Wollman.if !target(cleandir)
63639a2e50SGarrett Wollmancleandir: _PROGSUBDIR
64639a2e50SGarrett Wollman	rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
65639a2e50SGarrett Wollman	rm -f ${.CURDIR}/tags .depend
66639a2e50SGarrett Wollman	cd ${.CURDIR}; rm -rf obj;
67639a2e50SGarrett Wollman.endif
68639a2e50SGarrett Wollman
69639a2e50SGarrett Wollman.if !target(install)
70639a2e50SGarrett Wollman.if !target(beforeinstall)
71639a2e50SGarrett Wollmanbeforeinstall:
72639a2e50SGarrett Wollman.endif
73639a2e50SGarrett Wollman.if !target(afterinstall)
74639a2e50SGarrett Wollmanafterinstall:
75639a2e50SGarrett Wollman.endif
76639a2e50SGarrett Wollman
77639a2e50SGarrett Wollmanrealinstall: _PROGSUBDIR
78639a2e50SGarrett Wollman	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
79639a2e50SGarrett Wollman	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
80639a2e50SGarrett Wollman.if defined(LINKS) && !empty(LINKS)
81639a2e50SGarrett Wollman	@set ${LINKS}; \
82639a2e50SGarrett Wollman	while test $$# -ge 2; do \
83639a2e50SGarrett Wollman		l=${DESTDIR}$$1; \
84639a2e50SGarrett Wollman		shift; \
85639a2e50SGarrett Wollman		t=${DESTDIR}$$1; \
86639a2e50SGarrett Wollman		shift; \
87639a2e50SGarrett Wollman		${ECHO} $$t -\> $$l; \
88639a2e50SGarrett Wollman		rm -f $$t; \
89639a2e50SGarrett Wollman		ln $$l $$t; \
90639a2e50SGarrett Wollman	done; true
91639a2e50SGarrett Wollman.endif
92639a2e50SGarrett Wollman
93639a2e50SGarrett Wollmaninstall: afterinstall
94639a2e50SGarrett Wollman.if !defined(NOMAN)
95639a2e50SGarrett Wollmanafterinstall: realinstall maninstall
96639a2e50SGarrett Wollman.else
97639a2e50SGarrett Wollmanafterinstall: realinstall
98639a2e50SGarrett Wollman.endif
99639a2e50SGarrett Wollmanrealinstall: beforeinstall
100639a2e50SGarrett Wollman.endif
101639a2e50SGarrett Wollman
102639a2e50SGarrett Wollman.if !target(obj)
103639a2e50SGarrett Wollman.if defined(NOOBJ)
104639a2e50SGarrett Wollmanobj: _PROGSUBDIR
105639a2e50SGarrett Wollman.else
106639a2e50SGarrett Wollmanobj: _PROGSUBDIR
107639a2e50SGarrett Wollman	@cd ${.CURDIR}; rm -rf obj; \
108639a2e50SGarrett Wollman	here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \
109639a2e50SGarrett Wollman	${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \
110639a2e50SGarrett Wollman	if test -d /usr/obj -a ! -d $$dest; then \
111639a2e50SGarrett Wollman		mkdir -p $$dest; \
112639a2e50SGarrett Wollman	else \
113639a2e50SGarrett Wollman		true; \
114639a2e50SGarrett Wollman	fi;
115639a2e50SGarrett Wollman.endif
116639a2e50SGarrett Wollman.endif
117639a2e50SGarrett Wollman
118639a2e50SGarrett Wollman.if !target(tags)
119639a2e50SGarrett Wollmantags: ${SRCS} _PROGSUBDIR
120639a2e50SGarrett Wollman.if defined(PROG)
121639a2e50SGarrett Wollman	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
122639a2e50SGarrett Wollman	    sed "s;\${.CURDIR}/;;" > tags
123639a2e50SGarrett Wollman.endif
124639a2e50SGarrett Wollman.endif
125639a2e50SGarrett Wollman
126639a2e50SGarrett Wollman.if !defined(NOMAN)
127639a2e50SGarrett Wollman.include <bsd.man.mk>
128639a2e50SGarrett Wollman.elif !target(maninstall)
129639a2e50SGarrett Wollmanmaninstall:
130639a2e50SGarrett Wollman.endif
131639a2e50SGarrett Wollman
132639a2e50SGarrett Wollman.if !target(load)
133639a2e50SGarrett Wollmanload:	${PROG}
134639a2e50SGarrett Wollman	/sbin/modload -o ${KMOD} -e${KMOD} ${PROG}
135639a2e50SGarrett Wollman.endif
136639a2e50SGarrett Wollman
137639a2e50SGarrett Wollman.if !target(unload)
138639a2e50SGarrett Wollmanunload:	${PROG}
139639a2e50SGarrett Wollman	/sbin/modunload -n ${KMOD}
140639a2e50SGarrett Wollman.endif
141639a2e50SGarrett Wollman
142639a2e50SGarrett Wollman.include <bsd.dep.mk>
143