kmod.mk revision 12080
1#	From: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
2#	$Id: bsd.kmod.mk,v 1.15 1995/10/15 16:56:56 phk Exp $
3
4.if exists(${.CURDIR}/../Makefile.inc)
5.include "${.CURDIR}/../Makefile.inc"
6.endif
7
8.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
9
10#
11# Assume that we are in /usr/src/foo/bar, so /sys is
12# ${.CURDIR}/../../sys.  We don't bother adding a .PATH since nothing
13# actually lives in /sys directly.
14#
15CFLAGS+=${COPTS} -DKERNEL -DACTUALLY_LKM_NOT_KERNEL -I${.CURDIR}/../../sys \
16	-W -Wcomment -Wredundant-decls
17
18KMODGRP?=	bin
19KMODOWN?=	bin
20KMODMODE?=	555
21
22EXPORT_SYMS?= _${KMOD}
23
24.if defined(VFS_LKM)
25CFLAGS+= -DVFS_LKM -DMODVNOPS=${KMOD}vnops -I.
26SRCS+=	vnode_if.h
27CLEANFILES+=	vnode_if.h vnode_if.c
28.endif
29
30.if defined(PSEUDO_LKM)
31CFLAGS+= -DPSEUDO_LKM
32.endif
33
34DPSRCS+= ${SRCS:M*.h}
35OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
36
37.if !defined(PROG)
38PROG=	${KMOD}.o
39.endif
40
41${PROG}: ${DPSRCS} ${OBJS} ${DPADD} 
42	${LD} -r ${LDFLAGS} -o tmp.o ${OBJS}
43.if defined(EXPORT_SYMS)
44	@rm -f symb.tmp
45	@for i in ${EXPORT_SYMS} ; do echo $$i >> symb.tmp ; done
46	symorder -c symb.tmp tmp.o
47	@rm -f symb.tmp
48.endif
49	mv tmp.o ${.TARGET}
50
51.if	!defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \
52	!defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \
53	!defined(MAN7) && !defined(MAN8) && !defined(NOMAN)
54MAN1=	${KMOD}.4
55.endif
56
57_PROGSUBDIR: .USE
58.if defined(SUBDIR) && !empty(SUBDIR)
59	@for entry in ${SUBDIR}; do \
60		(${ECHODIR} "===> $$entry"; \
61		if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \
62			cd ${.CURDIR}/$${entry}.${MACHINE}; \
63		else \
64			cd ${.CURDIR}/$${entry}; \
65		fi; \
66		${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \
67	done
68.endif
69
70.MAIN: all
71all: ${PROG} all-man _PROGSUBDIR
72
73.if !target(clean)
74clean: _PROGSUBDIR
75	rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES} 
76.endif
77
78.if !target(cleandir)
79cleandir: _PROGSUBDIR
80	rm -f a.out [Ee]rrs mklog ${PROG} ${OBJS} ${CLEANFILES}
81	rm -f ${.CURDIR}/tags .depend
82	cd ${.CURDIR}; rm -rf obj;
83.endif
84
85.if !target(install)
86.if !target(beforeinstall)
87beforeinstall:
88.endif
89.if !target(afterinstall)
90afterinstall:
91.endif
92
93realinstall: _PROGSUBDIR
94	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
95	    ${INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}
96.if defined(LINKS) && !empty(LINKS)
97	@set ${LINKS}; \
98	while test $$# -ge 2; do \
99		l=${DESTDIR}$$1; \
100		shift; \
101		t=${DESTDIR}$$1; \
102		shift; \
103		${ECHO} $$t -\> $$l; \
104		rm -f $$t; \
105		ln ${LN_FLAGS} $$l $$t; \
106	done; true
107.endif
108
109install: afterinstall
110.if !defined(NOMAN)
111afterinstall: realinstall maninstall
112.else
113afterinstall: realinstall
114.endif
115realinstall: beforeinstall
116.endif
117
118DISTRIBUTION?=	bin
119.if !target(distribute)
120distribute:
121	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies
122.endif
123
124.if !target(obj)
125.if defined(NOOBJ)
126obj: _PROGSUBDIR
127.else
128obj: _PROGSUBDIR
129	@cd ${.CURDIR}; rm -rf obj; \
130	here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \
131	${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \
132	if test -d /usr/obj -a ! -d $$dest; then \
133		mkdir -p $$dest; \
134	else \
135		true; \
136	fi;
137.endif
138.endif
139
140.if !target(tags)
141tags: ${SRCS} _PROGSUBDIR
142.if defined(PROG)
143	-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \
144	    sed "s;\${.CURDIR}/;;" > tags
145.endif
146.endif
147
148.if !defined(NOMAN)
149.include <bsd.man.mk>
150.elif !target(maninstall)
151maninstall:
152all-man:
153.endif
154
155.if !target(load)
156load:	${PROG}
157	/sbin/modload -o ${KMOD} -e${KMOD} ${PROG}
158.endif
159
160.if !target(unload)
161unload:	${PROG}
162	/sbin/modunload -n ${KMOD}
163.endif
164
165KERN=	${.CURDIR}/../../sys/kern
166
167vnode_if.h:	${KERN}/vnode_if.sh ${KERN}/vnode_if.src
168	sh ${KERN}/vnode_if.sh ${KERN}/vnode_if.src
169
170./vnode_if.h:	vnode_if.h
171
172_DEPSUBDIR=	_PROGSUBDIR
173.include <bsd.dep.mk>
174