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