2008-11-05 03:54:25 +03:00
|
|
|
# $NetBSD: bsd.kmodule.mk,v 1.14 2008/11/05 00:54:25 elad Exp $
|
|
|
|
|
|
|
|
# We are not building this with PIE
|
|
|
|
MKPIE=no
|
2008-05-02 18:20:50 +04:00
|
|
|
|
|
|
|
.include <bsd.init.mk>
|
|
|
|
.include <bsd.klinks.mk>
|
2008-05-20 23:01:10 +04:00
|
|
|
.include <bsd.sys.mk>
|
2008-05-02 18:20:50 +04:00
|
|
|
|
|
|
|
##### Basic targets
|
|
|
|
clean: cleankmod
|
|
|
|
realinstall: kmodinstall
|
|
|
|
|
|
|
|
KERN= $S/kern
|
|
|
|
|
2008-05-20 16:18:45 +04:00
|
|
|
CFLAGS+= -ffreestanding ${COPTS}
|
2008-05-02 18:20:50 +04:00
|
|
|
CPPFLAGS+= -nostdinc -I. -I${.CURDIR} -isystem $S -isystem $S/arch
|
|
|
|
CPPFLAGS+= -isystem ${S}/../common/include
|
|
|
|
CPPFLAGS+= -D_KERNEL -D_LKM -D_MODULE
|
|
|
|
|
|
|
|
# XXX until the kernel is fixed again...
|
2008-08-24 10:27:00 +04:00
|
|
|
.if (defined(HAVE_GCC) && ${HAVE_GCC} == 4) || defined(HAVE_PCC)
|
2008-05-02 18:20:50 +04:00
|
|
|
CFLAGS+= -fno-strict-aliasing -Wno-pointer-sign
|
|
|
|
.endif
|
|
|
|
|
|
|
|
_YKMSRCS= ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
|
|
|
|
DPSRCS+= ${_YKMSRCS}
|
|
|
|
CLEANFILES+= ${_YKMSRCS}
|
2008-05-20 23:01:10 +04:00
|
|
|
|
2008-10-14 22:31:42 +04:00
|
|
|
.if exists($S/../gnu/usr.bin/binutils/ld/xldscripts/kmodule)
|
|
|
|
KMODSCRIPT= $S/../gnu/usr.bin/binutils/ld/xldscripts/kmodule
|
2008-05-20 23:01:10 +04:00
|
|
|
.else
|
2008-10-13 03:00:53 +04:00
|
|
|
KMODSCRIPT= ${DESTDIR}/usr/libdata/ldscripts/kmodule
|
2008-05-20 23:01:10 +04:00
|
|
|
.endif
|
2008-05-02 18:20:50 +04:00
|
|
|
|
|
|
|
OBJS+= ${SRCS:N*.h:N*.sh:R:S/$/.o/g}
|
|
|
|
PROG?= ${KMOD}.kmod
|
|
|
|
|
|
|
|
##### Build rules
|
|
|
|
realall: ${PROG}
|
|
|
|
|
|
|
|
${OBJS} ${LOBJS}: ${DPSRCS}
|
|
|
|
|
|
|
|
${PROG}: ${OBJS} ${DPADD}
|
|
|
|
${_MKTARGET_LINK}
|
2008-05-20 16:17:48 +04:00
|
|
|
${LD} -T ${KMODSCRIPT} -r -d -o ${.TARGET} ${OBJS}
|
2008-05-02 18:20:50 +04:00
|
|
|
|
|
|
|
##### Install rules
|
|
|
|
.if !target(kmodinstall)
|
2008-05-20 23:01:10 +04:00
|
|
|
.if !defined(KMODULEDIR)
|
|
|
|
_OSRELEASE!= ${HOST_SH} $S/conf/osrelease.sh
|
2008-05-21 23:56:30 +04:00
|
|
|
# Ensure these are recorded properly in METALOG on unprived installes:
|
|
|
|
_INST_DIRS= ${DESTDIR}/stand/${MACHINE}
|
|
|
|
_INST_DIRS+= ${DESTDIR}/stand/${MACHINE}/${_OSRELEASE}
|
|
|
|
_INST_DIRS+= ${DESTDIR}/stand/${MACHINE}/${_OSRELEASE}/modules
|
2008-05-31 23:58:35 +04:00
|
|
|
KMODULEDIR= ${DESTDIR}/stand/${MACHINE}/${_OSRELEASE}/modules/${KMOD}
|
|
|
|
.endif
|
|
|
|
_PROG:= ${KMODULEDIR}/${PROG} # installed path
|
2008-05-02 18:20:50 +04:00
|
|
|
|
|
|
|
.if ${MKUPDATE} == "no"
|
|
|
|
${_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
|
|
|
|
${_MKTARGET_INSTALL}
|
2008-05-21 23:56:30 +04:00
|
|
|
for d in ${_INST_DIRS}; do \
|
|
|
|
${INSTALL_DIR} $$d; \
|
|
|
|
done
|
2008-05-20 23:01:10 +04:00
|
|
|
${INSTALL_DIR} ${KMODULEDIR}
|
2008-05-02 18:20:50 +04:00
|
|
|
${INSTALL_FILE} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
|
|
|
|
${.ALLSRC} ${.TARGET}
|
|
|
|
|
|
|
|
kmodinstall:: ${_PROG}
|
|
|
|
.PHONY: kmodinstall
|
|
|
|
.PRECIOUS: ${_PROG} # keep if install fails
|
|
|
|
|
|
|
|
.undef _PROG
|
|
|
|
.endif # !target(kmodinstall)
|
|
|
|
|
|
|
|
##### Clean rules
|
|
|
|
cleankmod: .PHONY
|
|
|
|
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:C/-L[ ]*/-L/Wg:M-L*} ${LOBJS} ${LDADD}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
##### Pull in related .mk logic
|
|
|
|
.include <bsd.man.mk>
|
|
|
|
.include <bsd.links.mk>
|
|
|
|
.include <bsd.dep.mk>
|
|
|
|
|
|
|
|
.-include "$S/arch/${MACHINE_CPU}/include/Makefile.inc"
|
|
|
|
.-include "$S/arch/${MACHINE}/include/Makefile.inc"
|