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