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