1# $Id: $ 2 3.if !defined(NOINCLUDE) && exists(${.CURDIR}/../Makefile.inc) 4.include "${.CURDIR}/../Makefile.inc" 5.endif 6 7.SUFFIXES: .out .o .c .y .l .s .9 .8 .7 .6 .5 .4 .3 .2 .1 .0 8 9.9.0 .8.0 .7.0 .6.0 .5.0 .4.0 .3.0 .2.0 .1.0: 10 nroff -mandoc ${.IMPSRC} > ${.TARGET} 11 12.if exists(${.CURDIR}/../include) 13I=${.CURDIR}/../include 14.endif 15.if !exists($I) 16# No kernel include directory! 17I=/usr/include/nonstd/kernel # XXX 18.endif 19 20.if !exists(machine) 21FOO!=ln -s $I/$(MACHINE) machine 22.endif 23 24CFLAGS+=${COPTS} -D__MODULE__ -DKERNEL -I$I ${NONSTDINC} 25LDFLAGS+= -x -r 26 27# STRIP?= -s 28 29BINGRP?= bin 30BINOWN?= bin 31BINMODE?= 555 32 33#LIBSCSI,LIBCDROM? 34# LIBCRT0?= /usr/lib/crt0.o 35# LIBC?= /usr/lib/libc.a 36 37INCDEV?= -I$I/dev 38INCFS?= -I$I/fs 39INCIC?= -I$I/ic 40INCNET?= -I$I/net 41INCDOMAIN?= -I$I/domain 42 43.if defined(MODULE) && defined(SRCS) 44 45OBJS+= ${SRCS:R:S/$/.o/g} 46 47.else defined(MODULE) 48 49SRCS= ${MODULE}.c 50OBJS= ${MODULE}.o 51MKDEP= -p 52 53.endif 54 55${MODULE}: ${OBJS} ${DPADD} 56 ${LD} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} 57 58.if !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ 59 !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ 60 !defined(MAN7) && !defined(MAN8) && !defined(MAN9) && \ 61 !defined(NOMAN) 62MAN4= ${MODULE}.0 63.endif 64MANALL= ${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8} ${MAN9} 65 66_MODULESUBDIR: .USE 67.if defined(SUBDIR) && !empty(SUBDIR) 68 @for entry in ${SUBDIR}; do \ 69 (echo "===> $$entry"; \ 70 if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \ 71 cd ${.CURDIR}/$${entry}.${MACHINE}; \ 72 else \ 73 cd ${.CURDIR}/$${entry}; \ 74 fi; \ 75 ${MAKE} ${.TARGET:S/realinstall/install/:S/.depend/depend/}); \ 76 done 77.endif 78 79.MAIN: all 80all: ${MODULE} ${MANALL} _MODULESUBDIR 81 82.if !target(clean) 83clean: _MODULESUBDIR 84 rm -f a.out [Ee]rrs mklog core ${MODULE} ${OBJS} ${CLEANFILES} ${MANALL} 85.endif 86 87.if !target(cleandir) 88cleandir: _MODULESUBDIR 89 rm -f a.out [Ee]rrs mklog core ${MODULE} ${OBJS} ${CLEANFILES} 90 rm -f .depend ${MANALL} 91.endif 92 93# some of the rules involve .h sources, so remove them from mkdep line 94.if !target(depend) 95depend: .depend _MODULESUBDIR 96.depend: ${SRCS} 97.if defined(MODULE) 98 mkdep ${MKDEP} ${CFLAGS:M-[ID]*} ${.ALLSRC:M*.c} 99.endif 100.endif 101 102.if !target(install) 103.if !target(beforeinstall) 104beforeinstall: 105.endif 106.if !target(afterinstall) 107afterinstall: 108.endif 109 110realinstall: _MODULESUBDIR 111.if defined(MODULE) 112 install ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ 113 ${MODULE} ${DESTDIR}${BINDIR} 114.endif 115.if defined(LINKS) && !empty(LINKS) 116 @set ${LINKS}; \ 117 while test $$# -ge 2; do \ 118 l=${DESTDIR}$$1; \ 119 shift; \ 120 t=${DESTDIR}$$1; \ 121 shift; \ 122 echo $$t -\> $$l; \ 123 rm -f $$t; \ 124 ln $$l $$t; \ 125 done; true 126.endif 127 128install: maninstall 129maninstall: afterinstall 130afterinstall: realinstall 131realinstall: beforeinstall 132.endif 133 134.if !target(lint) 135lint: ${SRCS} _MODULESUBDIR 136.if defined(MODULE) 137 @${LINT} ${LINTFLAGS} ${CFLAGS} ${.ALLSRC} | more 2>&1 138.endif 139.endif 140 141.if !target(obj) 142.if defined(NOOBJ) 143obj: _MODULESUBDIR 144.else 145obj: _MODULESUBDIR 146 @cd ${.CURDIR}; rm -rf obj; \ 147 here=`pwd`; dest=/usr/obj/`echo $$here | sed 's,/usr/src/,,'`; \ 148 echo "$$here -> $$dest"; ln -s $$dest obj; \ 149 if test -d /usr/obj -a ! -d $$dest; then \ 150 mkdir -p $$dest; \ 151 else \ 152 true; \ 153 fi; 154.endif 155.endif 156 157.if !target(tags) 158tags: ${SRCS} _MODULESUBDIR 159.if defined(MODULE) 160 -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC} | \ 161 sed "s;\${.CURDIR}/;;" > tags 162.endif 163.endif 164 165.if !defined(NOMAN) 166.include <bsd.man.mk> 167.endif 168