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