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