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