1 # $NetBSD: bsd.kmodule.mk,v 1.22 2009/12/14 01:00:46 matt Exp $
3 # We are not building this with PIE
7 .
include <bsd.klinks.mk
>
12 realinstall
: kmodinstall
16 CFLAGS
+= -ffreestanding
${COPTS}
17 CPPFLAGS
+= -nostdinc
-I.
-I
${.CURDIR
} -isystem
$S -isystem
$S/arch
18 CPPFLAGS
+= -isystem
${S}/..
/common
/include
19 CPPFLAGS
+= -D_KERNEL
-D_LKM
-D_MODULE
21 # XXX until the kernel is fixed again...
22 .if
(defined
(HAVE_GCC
) && ${HAVE_GCC} == 4) || defined
(HAVE_PCC
)
23 CFLAGS
+= -fno-strict-aliasing
-Wno-pointer-sign
26 _YKMSRCS
= ${SRCS
:M
*.
[ly
]:C
/\..
$/.c
/} ${YHEADER
:D
${SRCS
:M
*.y
:.y
=.h
}}
28 CLEANFILES
+= ${_YKMSRCS}
30 .if exists
($S/..
/sys
/modules
/xldscripts
/kmodule
)
31 KMODSCRIPT
= $S/..
/sys
/modules
/xldscripts
/kmodule
33 KMODSCRIPT
= ${DESTDIR}/usr
/libdata
/ldscripts
/kmodule
36 OBJS
+= ${SRCS
:N
*.h
:N
*.sh
:R
:S
/$/.o
/g
}
42 ${OBJS} ${LOBJS}: ${DPSRCS}
44 ${PROG}: ${OBJS} ${DPADD}
46 ${CC} ${LDFLAGS} -nostdlib
-r
-Wl
,-T
,${KMODSCRIPT},-d \
50 .if
!target
(kmodinstall
)
51 .if
!defined
(KMODULEDIR
)
52 _OSRELEASE
!= ${HOST_SH} $S/conf
/osrelease.sh
53 # Ensure these are recorded properly in METALOG on unprived installes:
54 _INST_DIRS
= ${DESTDIR}/stand
/${MACHINE}
55 _INST_DIRS
+= ${DESTDIR}/stand
/${MACHINE}/${_OSRELEASE}
56 _INST_DIRS
+= ${DESTDIR}/stand
/${MACHINE}/${_OSRELEASE}/modules
57 KMODULEDIR
= ${DESTDIR}/stand
/${MACHINE}/${_OSRELEASE}/modules
/${KMOD}
59 _PROG
:= ${KMODULEDIR}/${PROG} # installed path
61 .if
${MKUPDATE} == "no"
62 ${_PROG}! ${PROG} # install rule
63 .if
!defined
(BUILD
) && !make
(all) && !make
(${PROG})
64 ${_PROG}! .MADE
# no build at install
67 ${_PROG}: ${PROG} # install rule
68 .if
!defined
(BUILD
) && !make
(all) && !make
(${PROG})
69 ${_PROG}: .MADE
# no build at install
73 dirs
=${_INST_DIRS
:Q
}; \
77 ${INSTALL_DIR} ${KMODULEDIR}
78 ${INSTALL_FILE} -o
${KMODULEOWN} -g
${KMODULEGRP} -m
${KMODULEMODE} \
81 kmodinstall
:: ${_PROG}
83 .PRECIOUS
: ${_PROG} # keep if install fails
86 .
endif # !target(kmodinstall)
90 rm -f a.out
[Ee
]rrs mklog core
*.core \
91 ${PROG} ${OBJS} ${LOBJS} ${CLEANFILES}
95 .if defined
(LOBJS
) && !empty
(LOBJS
)
96 ${LINT} ${LINTFLAGS} ${LDFLAGS
:C
/-L
[ ]*/-L
/Wg
:M-L
*} ${LOBJS} ${LDADD}
99 ##### Pull in related .mk logic
100 LINKSOWN?
= ${KMODULEOWN}
101 LINKSGRP?
= ${KMODULEGRP}
102 LINKSMODE?
= ${KMODULEMODE}
103 .
include <bsd.man.mk
>
104 .
include <bsd.links.mk
>
105 .
include <bsd.dep.mk
>
107 .
-include "$S/arch/${MACHINE_CPU}/include/Makefile.inc"
108 .
-include "$S/arch/${MACHINE}/include/Makefile.inc"