kmod.mk revision 7192
1254721Semaste#	From: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
2254721Semaste#	$Id: bsd.kmod.mk,v 1.10 1995/02/25 20:51:11 phk Exp $
3254721Semaste
4254721Semaste.if exists(${.CURDIR}/../Makefile.inc)
5254721Semaste.include "${.CURDIR}/../Makefile.inc"
6254721Semaste.endif
7254721Semaste
8254721Semaste.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
9254721Semaste
10254721Semaste#
11254721Semaste# Assume that we are in /usr/src/foo/bar, so /sys is
12254721Semaste# ${.CURDIR}/../../sys.  We don't bother adding a .PATH since nothing
13254721Semaste# actually lives in /sys directly.
14254721Semaste#
15254721SemasteCFLAGS+=${COPTS} -DKERNEL -I${.CURDIR}/../../sys -W -Wcomment -Wredundant-decls
16254721Semaste
17254721SemasteKMODGRP?=	bin
18254721SemasteKMODOWN?=	bin
19254721SemasteKMODMODE?=	555
20254721Semaste
21254721Semaste.if defined(VFS_LKM)
22254721SemasteCFLAGS+= -DVFS_LKM -DMODVNOPS=${KMOD}vnops -I.
23254721SemasteSRCS+=	vnode_if.h
24254721SemasteCLEANFILES+=	vnode_if.h vnode_if.c
25254721Semaste.endif
26254721Semaste
27254721Semaste.if defined(PSEUDO_LKM)
28254721SemasteCFLAGS+= -DPSEUDO_LKM
29254721Semaste.endif
30254721Semaste
31254721SemasteDPSRCS+= ${SRCS:M*.h}
32254721SemasteOBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
33254721Semaste
34254721Semaste.if !defined(PROG)
35254721SemastePROG=	${KMOD}.o
36254721Semaste.endif
37254721Semaste
38254721Semaste${PROG}: ${DPSRCS} ${OBJS} ${DPADD} 
39254721Semaste	${LD} -r ${LDFLAGS} -o ${.TARGET} ${OBJS}
40254721Semaste
41254721Semaste.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
42254721Semaste	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
43254721Semaste	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
44254721SemasteMAN1=	${KMOD}.4
45254721Semaste.endif
46254721Semaste
47254721Semaste_PROGSUBDIR: .USE
48254721Semaste.if defined(SUBDIR) && !empty(SUBDIR)
49254721Semaste	@for entry in ${SUBDIR}; do \
50254721Semaste		(${ECHODIR} "===> $$entry"; \
51254721Semaste		if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
52254721Semaste			cd ${.CURDIR}/$${entry}.${MACHINE}; \
53254721Semaste		else \
54			cd ${.CURDIR}/$${entry}; \
55		fi; \
56		${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
57	done
58.endif
59
60.MAIN: all
61all: ${PROG} _PROGSUBDIR
62
63.if !target(clean)
64clean: _PROGSUBDIR
65	rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES} 
66.endif
67
68.if !target(cleandir)
69cleandir: _PROGSUBDIR
70	rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
71	rm -f ${.CURDIR}/tags .depend
72	cd ${.CURDIR}; rm -rf obj;
73.endif
74
75.if !target(install)
76.if !target(beforeinstall)
77beforeinstall:
78.endif
79.if !target(afterinstall)
80afterinstall:
81.endif
82
83realinstall: _PROGSUBDIR
84	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
85	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
86.if defined(LINKS) && !empty(LINKS)
87	@set ${LINKS}; \
88	while test $$# -ge 2; do \
89		l=${DESTDIR}$$1; \
90		shift; \
91		t=${DESTDIR}$$1; \
92		shift; \
93		${ECHO} $$t -\> $$l; \
94		rm -f $$t; \
95		ln ${LN_FLAGS} $$l $$t; \
96	done; true
97.endif
98
99install: afterinstall
100.if !defined(NOMAN)
101afterinstall: realinstall maninstall
102.else
103afterinstall: realinstall
104.endif
105realinstall: beforeinstall
106.endif
107
108DISTRIBUTION?=	bin
109.if !target(distribute)
110distribute:
111	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies
112.endif
113
114.if !target(obj)
115.if defined(NOOBJ)
116obj: _PROGSUBDIR
117.else
118obj: _PROGSUBDIR
119	@cd ${.CURDIR}; rm -rf obj; \
120	here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \
121	${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \
122	if test -d /usr/obj -a ! -d $$dest; then \
123		mkdir -p $$dest; \
124	else \
125		true; \
126	fi;
127.endif
128.endif
129
130.if !target(tags)
131tags: ${SRCS} _PROGSUBDIR
132.if defined(PROG)
133	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
134	    sed "s;\${.CURDIR}/;;" > tags
135.endif
136.endif
137
138.if !defined(NOMAN)
139.include <bsd.man.mk>
140.elif !target(maninstall)
141maninstall:
142.endif
143
144.if !target(load)
145load:	${PROG}
146	/sbin/modload -o ${KMOD} -e${KMOD} ${PROG}
147.endif
148
149.if !target(unload)
150unload:	${PROG}
151	/sbin/modunload -n ${KMOD}
152.endif
153
154KERN=	${.CURDIR}/../../sys/kern
155
156vnode_if.h:	${KERN}/vnode_if.sh ${KERN}/vnode_if.src
157	sh ${KERN}/vnode_if.sh ${KERN}/vnode_if.src
158
159./vnode_if.h:	vnode_if.h
160
161_DEPSUBDIR=	_PROGSUBDIR
162.include <bsd.dep.mk>
163