NetBSD/share/mk/bsd.kmod.mk

95 lines
2.2 KiB
Makefile
Raw Normal View History

# $NetBSD: bsd.kmod.mk,v 1.49 2002/02/28 15:55:50 pk Exp $
.include <bsd.init.mk>
##### Basic targets
1997-05-07 19:53:28 +04:00
.PHONY: cleankmod kmodinstall load unload
beforedepend: machine-links
clean: cleankmod
realinstall: kmodinstall
1997-05-07 00:54:31 +04:00
##### Default values
1997-05-07 23:25:16 +04:00
S?= /sys
1997-05-07 19:53:28 +04:00
KERN= $S/kern
2001-12-28 10:49:26 +03:00
CFLAGS+= -ffreestanding ${COPTS}
CPPFLAGS+= -nostdinc -I. -I${.CURDIR} -isystem $S -isystem $S/arch
2001-12-28 10:49:26 +03:00
CPPFLAGS+= -D_KERNEL -D_LKM
1997-05-09 17:40:34 +04:00
DPSRCS+= ${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c}
CLEANFILES+= ${DPSRCS} ${YHEADER:D${SRCS:M*.y:.y=.h}} \
machine ${MACHINE_CPU}
1996-08-28 03:31:47 +04:00
OBJS+= ${SRCS:N*.h:N*.sh:R:S/$/.o/g}
PROG?= ${KMOD}.o
MAN?= ${KMOD}.4
##### Build rules
realall: machine-links ${PROG}
.ORDER: machine-links ${OBJS}
${PROG}: ${DPSRCS} ${OBJS} ${DPADD}
${LD} -r ${LDFLAGS} -o tmp.o ${OBJS}
mv tmp.o ${.TARGET}
# XXX. This should be done a better way. It's @'d to reduce visual spew.
machine-links:
@rm -f machine && \
ln -s $S/arch/${MACHINE}/include machine
@rm -f ${MACHINE_CPU} && \
ln -s $S/arch/${MACHINE_CPU}/include ${MACHINE_CPU}
##### Install rules
1997-05-07 21:17:20 +04:00
.if !target(kmodinstall)
_PROG:= ${DESTDIR}${KMODDIR}/${PROG} # installed path
2000-06-06 13:22:00 +04:00
.if !defined(UPDATE)
${_PROG}! ${PROG} # install rule
.if !defined(BUILD) && !make(all) && !make(${PROG})
${_PROG}! .MADE # no build at install
.endif
.else
${_PROG}: ${PROG} # install rule
.if !defined(BUILD) && !make(all) && !make(${PROG})
${_PROG}: .MADE # no build at install
.endif
.endif
${INSTALL_FILE} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
${.ALLSRC} ${.TARGET}
2000-06-06 13:53:29 +04:00
kmodinstall:: ${_PROG}
.PRECIOUS: ${_PROG} # keep if install fails
.undef _PROG
.endif # !target(kmodinstall)
##### Clean rules
cleankmod:
rm -f a.out [Ee]rrs mklog core *.core \
${PROG} ${OBJS} ${LOBJS} ${CLEANFILES}
##### Custom rules
lint: ${LOBJS}
.if defined(LOBJS) && !empty(LOBJS)
${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD}
.endif
.if !target(load)
load: ${PROG}
/sbin/modload ${KMOD_LOADFLAGS} -o ${KMOD} ${PROG}
.endif
.if !target(unload)
unload:
/sbin/modunload -n ${KMOD}
.endif
##### Pull in related .mk logic
.include <bsd.man.mk>
.include <bsd.links.mk>
.include <bsd.dep.mk>
.include <bsd.sys.mk>
.-include "$S/arch/${MACHINE_CPU}/include/Makefile.inc"
.-include "$S/arch/${MACHINE}/include/Makefile.inc"