| @@ -1,276 +1,278 @@ | | | @@ -1,276 +1,278 @@ |
1 | # $NetBSD: bsd.kmodule.mk,v 1.75 2021/03/23 13:22:40 simonb Exp $ | | 1 | # $NetBSD: bsd.kmodule.mk,v 1.76 2021/03/29 05:22:49 simonb Exp $ |
2 | | | 2 | |
3 | # We are not building this with PIE | | 3 | # We are not building this with PIE |
4 | MKPIE=no | | 4 | MKPIE=no |
5 | | | 5 | |
6 | .include <bsd.init.mk> | | 6 | .include <bsd.init.mk> |
7 | .include <bsd.klinks.mk> | | 7 | .include <bsd.klinks.mk> |
8 | | | 8 | |
9 | .if ${MKCTF:Uno} == "yes" | | 9 | .if ${MKCTF:Uno} == "yes" |
10 | CFLAGS+= -g | | 10 | CFLAGS+= -g |
11 | # Only need symbols for ctf, strip them after converting to CTF | | 11 | # Only need symbols for ctf, strip them after converting to CTF |
12 | CTFFLAGS= -L VERSION | | 12 | CTFFLAGS= -L VERSION |
13 | CTFMFLAGS= -t -L VERSION | | 13 | CTFMFLAGS= -t -L VERSION |
14 | # Keep symbols if built with "-g" | | 14 | # Keep symbols if built with "-g" |
15 | .if !empty(COPTS:M*-g*) || ${MKDEBUG:Uno} == "yes" | | 15 | .if !empty(COPTS:M*-g*) || ${MKDEBUG:Uno} == "yes" |
16 | CTFFLAGS+= -g | | 16 | CTFFLAGS+= -g |
17 | CTFMFLAGS+= -g | | 17 | CTFMFLAGS+= -g |
18 | .endif | | 18 | .endif |
19 | .endif | | 19 | .endif |
20 | | | 20 | |
21 | .include <bsd.sys.mk> | | 21 | .include <bsd.sys.mk> |
22 | | | 22 | |
23 | ##### Basic targets | | 23 | ##### Basic targets |
24 | realinstall: kmodinstall | | 24 | realinstall: kmodinstall |
25 | | | 25 | |
26 | KERN= $S/kern | | 26 | KERN= $S/kern |
27 | MKLDSCRIPT?= no | | 27 | MKLDSCRIPT?= no |
28 | | | 28 | |
29 | CFLAGS+= -ffreestanding ${COPTS} | | 29 | CFLAGS+= -ffreestanding ${COPTS} |
30 | CPPFLAGS+= -nostdinc -I. -I${.CURDIR} -isystem $S -isystem $S/arch | | 30 | CPPFLAGS+= -nostdinc -I. -I${.CURDIR} -isystem $S -isystem $S/arch |
31 | CPPFLAGS+= -isystem ${S}/../common/include | | 31 | CPPFLAGS+= -isystem ${S}/../common/include |
32 | CPPFLAGS+= -D_KERNEL -D_MODULE -DSYSCTL_INCLUDE_DESCR | | 32 | CPPFLAGS+= -D_KERNEL -D_MODULE -DSYSCTL_INCLUDE_DESCR |
33 | | | 33 | |
34 | CWARNFLAGS.clang+= -Wno-error=constant-conversion | | 34 | CWARNFLAGS.clang+= -Wno-error=constant-conversion |
35 | | | 35 | |
36 | # XXX until the kernel is fixed again... | | 36 | # XXX until the kernel is fixed again... |
37 | CFLAGS+= -fno-strict-aliasing -Wno-pointer-sign | | 37 | CFLAGS+= -fno-strict-aliasing -Wno-pointer-sign |
38 | | | 38 | |
39 | # XXX This is a workaround for platforms that have relative relocations | | 39 | # XXX This is a workaround for platforms that have relative relocations |
40 | # that, when relocated by the module loader, result in addresses that | | 40 | # that, when relocated by the module loader, result in addresses that |
41 | # overflow the size of the relocation (e.g. R_PPC_REL24 in powerpc). | | 41 | # overflow the size of the relocation (e.g. R_PPC_REL24 in powerpc). |
42 | # The real solution to this involves generating trampolines for those | | 42 | # The real solution to this involves generating trampolines for those |
43 | # relocations inside the loader and removing this workaround, as the | | 43 | # relocations inside the loader and removing this workaround, as the |
44 | # resulting code would be much faster. | | 44 | # resulting code would be much faster. |
45 | .if ${MACHINE_CPU} == "aarch64" | | 45 | .if ${MACHINE_CPU} == "aarch64" |
46 | CFLAGS+= -march=armv8-a+nofp+nosimd | | 46 | CFLAGS+= -march=armv8-a+nofp+nosimd |
47 | .elif ${MACHINE_CPU} == "arm" | | 47 | .elif ${MACHINE_CPU} == "arm" |
48 | CFLAGS+= -fno-common -fno-unwind-tables | | 48 | CFLAGS+= -fno-common -fno-unwind-tables |
49 | .elif ${MACHINE_CPU} == "hppa" | | 49 | .elif ${MACHINE_CPU} == "hppa" |
50 | CFLAGS+= -mlong-calls -mno-space-regs -mfast-indirect-calls | | 50 | CFLAGS+= -mlong-calls -mno-space-regs -mfast-indirect-calls |
51 | .elif ${MACHINE_CPU} == "powerpc" | | 51 | .elif ${MACHINE_CPU} == "powerpc" |
52 | CFLAGS+= ${${ACTIVE_CC} == "gcc":? -mlongcall :} | | 52 | CFLAGS+= ${${ACTIVE_CC} == "gcc":? -mlongcall :} |
53 | CFLAGS+= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 9:? -mno-pltseq :} | | 53 | CFLAGS+= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 9:? -mno-pltseq :} |
54 | .elif ${MACHINE_CPU} == "vax" | | 54 | .elif ${MACHINE_CPU} == "vax" |
55 | CFLAGS+= -fno-pic | | 55 | CFLAGS+= -fno-pic |
56 | .elif ${MACHINE_CPU} == "riscv" | | 56 | .elif ${MACHINE_CPU} == "riscv" |
57 | CFLAGS+= -fPIC -Wa,-fno-pic | | 57 | CFLAGS+= -fPIC -Wa,-fno-pic |
58 | .elif ${MACHINE_ARCH} == "mips64eb" && !defined(BSD_MK_COMPAT_FILE) | | 58 | .elif ${MACHINE_ARCH} == "mips64eb" && !defined(BSD_MK_COMPAT_FILE) |
59 | CFLAGS+= -mabi=64 | | 59 | CFLAGS+= -mabi=64 |
| | | 60 | AFLAGS+= -mabi=64 |
60 | LDFLAGS+= -Wl,-m,elf64btsmip | | 61 | LDFLAGS+= -Wl,-m,elf64btsmip |
61 | .elif ${MACHINE_ARCH} == "mips64el" && !defined(BSD_MK_COMPAT_FILE) | | 62 | .elif ${MACHINE_ARCH} == "mips64el" && !defined(BSD_MK_COMPAT_FILE) |
62 | CFLAGS+= -mabi=64 | | 63 | CFLAGS+= -mabi=64 |
| | | 64 | AFLAGS+= -mabi=64 |
63 | LDFLAGS+= -Wl,-m,elf64ltsmip | | 65 | LDFLAGS+= -Wl,-m,elf64ltsmip |
64 | .endif | | 66 | .endif |
65 | | | 67 | |
66 | .if ${MACHINE_CPU} == "mips" | | 68 | .if ${MACHINE_CPU} == "mips" |
67 | # We can't use -msym32 with -mlong-calls as -msym32 forces all addresses | | 69 | # We can't use -msym32 with -mlong-calls as -msym32 forces all addresses |
68 | # to be 32-bit which defeats the whole purpose of long calls. | | 70 | # to be 32-bit which defeats the whole purpose of long calls. |
69 | CFLAGS+= -mlong-calls | | 71 | CFLAGS+= -mlong-calls |
70 | .endif | | 72 | .endif |
71 | | | 73 | |
72 | .if ${MACHINE_CPU} == "sparc64" | | 74 | .if ${MACHINE_CPU} == "sparc64" |
73 | # force same memory model as rest of the kernel | | 75 | # force same memory model as rest of the kernel |
74 | CFLAGS+= ${${ACTIVE_CC} == "gcc":? -mcmodel=medlow :} | | 76 | CFLAGS+= ${${ACTIVE_CC} == "gcc":? -mcmodel=medlow :} |
75 | CFLAGS+= ${${ACTIVE_CC} == "clang":? -mcmodel=small :} | | 77 | CFLAGS+= ${${ACTIVE_CC} == "clang":? -mcmodel=small :} |
76 | .endif | | 78 | .endif |
77 | | | 79 | |
78 | # evbppc needs some special help | | 80 | # evbppc needs some special help |
79 | .if ${MACHINE} == "evbppc" | | 81 | .if ${MACHINE} == "evbppc" |
80 | | | 82 | |
81 | . ifndef PPC_INTR_IMPL | | 83 | . ifndef PPC_INTR_IMPL |
82 | PPC_INTR_IMPL=\"powerpc/intr.h\" | | 84 | PPC_INTR_IMPL=\"powerpc/intr.h\" |
83 | . endif | | 85 | . endif |
84 | . ifndef PPC_PCI_MACHDEP_IMPL | | 86 | . ifndef PPC_PCI_MACHDEP_IMPL |
85 | PPC_PCI_MACHDEP_IMPL=\"powerpc/pci_machdep.h\" | | 87 | PPC_PCI_MACHDEP_IMPL=\"powerpc/pci_machdep.h\" |
86 | . endif | | 88 | . endif |
87 | CPPFLAGS+= -DPPC_INTR_IMPL=${PPC_INTR_IMPL} | | 89 | CPPFLAGS+= -DPPC_INTR_IMPL=${PPC_INTR_IMPL} |
88 | CPPFLAGS+= -DPPC_PCI_MACHDEP_IMPL=${DPPC_PCI_MACHDEP_IMPL} | | 90 | CPPFLAGS+= -DPPC_PCI_MACHDEP_IMPL=${DPPC_PCI_MACHDEP_IMPL} |
89 | | | 91 | |
90 | . ifdef PPC_IBM4XX | | 92 | . ifdef PPC_IBM4XX |
91 | CPPFLAGS+= -DPPC_IBM4XX | | 93 | CPPFLAGS+= -DPPC_IBM4XX |
92 | . elifdef PPC_BOOKE | | 94 | . elifdef PPC_BOOKE |
93 | CPPFLAGS+= -DPPC_BOOKE | | 95 | CPPFLAGS+= -DPPC_BOOKE |
94 | . elif ${MACHINE_ARCH} == "powerpc64" | | 96 | . elif ${MACHINE_ARCH} == "powerpc64" |
95 | CPPFLAGS+= -DPPC_OEA64 | | 97 | CPPFLAGS+= -DPPC_OEA64 |
96 | . else | | 98 | . else |
97 | CPPFLAGS+= -DPPC_OEA | | 99 | CPPFLAGS+= -DPPC_OEA |
98 | . endif | | 100 | . endif |
99 | | | 101 | |
100 | .endif | | 102 | .endif |
101 | | | 103 | |
102 | | | 104 | |
103 | _YKMSRCS= ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}} | | 105 | _YKMSRCS= ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}} |
104 | DPSRCS+= ${_YKMSRCS} | | 106 | DPSRCS+= ${_YKMSRCS} |
105 | CLEANFILES+= ${_YKMSRCS} | | 107 | CLEANFILES+= ${_YKMSRCS} |
106 | | | 108 | |
107 | .if exists($S/../sys/modules/xldscripts/kmodule) | | 109 | .if exists($S/../sys/modules/xldscripts/kmodule) |
108 | KMODSCRIPTSRC= $S/../sys/modules/xldscripts/kmodule | | 110 | KMODSCRIPTSRC= $S/../sys/modules/xldscripts/kmodule |
109 | .else | | 111 | .else |
110 | KMODSCRIPTSRC= ${DESTDIR}/usr/libdata/ldscripts/kmodule | | 112 | KMODSCRIPTSRC= ${DESTDIR}/usr/libdata/ldscripts/kmodule |
111 | .endif | | 113 | .endif |
112 | .if ${MKLDSCRIPT} == "yes" | | 114 | .if ${MKLDSCRIPT} == "yes" |
113 | KMODSCRIPT= kldscript | | 115 | KMODSCRIPT= kldscript |
114 | MKLDSCRIPTSH= | | 116 | MKLDSCRIPTSH= |
115 | .else | | 117 | .else |
116 | KMODSCRIPT= ${KMODSCRIPTSRC} | | 118 | KMODSCRIPT= ${KMODSCRIPTSRC} |
117 | .endif | | 119 | .endif |
118 | | | 120 | |
119 | PROG?= ${KMOD}.kmod | | 121 | PROG?= ${KMOD}.kmod |
120 | .if ${MKDEBUG:Uno} != "no" && !defined(NODEBUG) && !commands(${PROG}) && \ | | 122 | .if ${MKDEBUG:Uno} != "no" && !defined(NODEBUG) && !commands(${PROG}) && \ |
121 | empty(SRCS:M*.sh) | | 123 | empty(SRCS:M*.sh) |
122 | PROGDEBUG:= ${PROG}.debug | | 124 | PROGDEBUG:= ${PROG}.debug |
123 | .endif | | 125 | .endif |
124 | | | 126 | |
125 | ##### Build rules | | 127 | ##### Build rules |
126 | realall: ${PROG} ${PROGDEBUG} | | 128 | realall: ${PROG} ${PROGDEBUG} |
127 | | | 129 | |
128 | OBJS+= ${SRCS:N*.h:N*.sh:R:S/$/.o/g} | | 130 | OBJS+= ${SRCS:N*.h:N*.sh:R:S/$/.o/g} |
129 | | | 131 | |
130 | ${OBJS} ${LOBJS}: ${DPSRCS} | | 132 | ${OBJS} ${LOBJS}: ${DPSRCS} |
131 | | | 133 | |
132 | .if ${MKLDSCRIPT} == "yes" | | 134 | .if ${MKLDSCRIPT} == "yes" |
133 | ${KMODSCRIPT}: ${KMODSCRIPTSRC} ${OBJS} $S/conf/mkldscript.sh | | 135 | ${KMODSCRIPT}: ${KMODSCRIPTSRC} ${OBJS} $S/conf/mkldscript.sh |
134 | @rm -f ${.TARGET} | | 136 | @rm -f ${.TARGET} |
135 | @OBJDUMP=${OBJDUMP} ${HOST_SH} $S/conf/mkldscript.sh \ | | 137 | @OBJDUMP=${OBJDUMP} ${HOST_SH} $S/conf/mkldscript.sh \ |
136 | -t ${KMODSCRIPTSRC} ${OBJS} > ${.TARGET} | | 138 | -t ${KMODSCRIPTSRC} ${OBJS} > ${.TARGET} |
137 | .endif | | 139 | .endif |
138 | | | 140 | |
139 | .if ${MACHINE_CPU} == "arm" | | 141 | .if ${MACHINE_CPU} == "arm" |
140 | # The solution to limited branch space involves generating trampolines for | | 142 | # The solution to limited branch space involves generating trampolines for |
141 | # those relocations while creating the module, as the resulting code will | | 143 | # those relocations while creating the module, as the resulting code will |
142 | # be much faster and simplifies the loader. | | 144 | # be much faster and simplifies the loader. |
143 | ARCHDIR= $S/modules/arch/${MACHINE_CPU} | | 145 | ARCHDIR= $S/modules/arch/${MACHINE_CPU} |
144 | ASM_H= $S/arch/${MACHINE_CPU}/include/asm.h | | 146 | ASM_H= $S/arch/${MACHINE_CPU}/include/asm.h |
145 | CLEANFILES+= tmp.o tmp.S ${KMOD}_tmp.o ${KMOD}_tramp.o ${KMOD}_tramp.S | | 147 | CLEANFILES+= tmp.o tmp.S ${KMOD}_tmp.o ${KMOD}_tramp.o ${KMOD}_tramp.S |
146 | ${KMOD}_tmp.o: ${OBJS} ${DPADD} | | 148 | ${KMOD}_tmp.o: ${OBJS} ${DPADD} |
147 | ${_MKTARGET_LINK} | | 149 | ${_MKTARGET_LINK} |
148 | ${LD} -r -o tmp.o ${OBJS} | | 150 | ${LD} -r -o tmp.o ${OBJS} |
149 | ${LD} -r \ | | 151 | ${LD} -r \ |
150 | `${OBJDUMP} --syms --reloc tmp.o | \ | | 152 | `${OBJDUMP} --syms --reloc tmp.o | \ |
151 | ${TOOL_AWK} -f ${ARCHDIR}/kmodwrap.awk` \ | | 153 | ${TOOL_AWK} -f ${ARCHDIR}/kmodwrap.awk` \ |
152 | -o ${.TARGET} tmp.o | | 154 | -o ${.TARGET} tmp.o |
153 | | | 155 | |
154 | ${KMOD}_tramp.S: ${KMOD}_tmp.o ${ARCHDIR}/kmodtramp.awk ${ASM_H} | | 156 | ${KMOD}_tramp.S: ${KMOD}_tmp.o ${ARCHDIR}/kmodtramp.awk ${ASM_H} |
155 | ${_MKTARGET_CREATE} | | 157 | ${_MKTARGET_CREATE} |
156 | ${OBJDUMP} --syms --reloc ${KMOD}_tmp.o | \ | | 158 | ${OBJDUMP} --syms --reloc ${KMOD}_tmp.o | \ |
157 | ${TOOL_AWK} -f ${ARCHDIR}/kmodtramp.awk \ | | 159 | ${TOOL_AWK} -f ${ARCHDIR}/kmodtramp.awk \ |
158 | > tmp.S && \ | | 160 | > tmp.S && \ |
159 | ${MV} tmp.S ${.TARGET} | | 161 | ${MV} tmp.S ${.TARGET} |
160 | | | 162 | |
161 | ${PROG}: ${KMOD}_tmp.o ${KMOD}_tramp.o | | 163 | ${PROG}: ${KMOD}_tmp.o ${KMOD}_tramp.o |
162 | ${_MKTARGET_LINK} | | 164 | ${_MKTARGET_LINK} |
163 | .if exists(${ARCHDIR}/kmodhide.awk) | | 165 | .if exists(${ARCHDIR}/kmodhide.awk) |
164 | ${LD} -r -Map=${.TARGET}.map \ | | 166 | ${LD} -r -Map=${.TARGET}.map \ |
165 | -o tmp.o ${KMOD}_tmp.o ${KMOD}_tramp.o | | 167 | -o tmp.o ${KMOD}_tmp.o ${KMOD}_tramp.o |
166 | ${OBJCOPY} \ | | 168 | ${OBJCOPY} \ |
167 | `${NM} tmp.o | ${TOOL_AWK} -f ${ARCHDIR}/kmodhide.awk` \ | | 169 | `${NM} tmp.o | ${TOOL_AWK} -f ${ARCHDIR}/kmodhide.awk` \ |
168 | tmp.o ${.TARGET} && \ | | 170 | tmp.o ${.TARGET} && \ |
169 | rm tmp.o | | 171 | rm tmp.o |
170 | .else | | 172 | .else |
171 | ${LD} -r -Map=${.TARGET}.map \ | | 173 | ${LD} -r -Map=${.TARGET}.map \ |
172 | -o ${.TARGET} ${KMOD}_tmp.o ${KMOD}_tramp.o | | 174 | -o ${.TARGET} ${KMOD}_tmp.o ${KMOD}_tramp.o |
173 | .endif | | 175 | .endif |
174 | .else | | 176 | .else |
175 | ${PROG}: ${OBJS} ${DPADD} ${KMODSCRIPT} | | 177 | ${PROG}: ${OBJS} ${DPADD} ${KMODSCRIPT} |
176 | ${_MKTARGET_LINK} | | 178 | ${_MKTARGET_LINK} |
177 | ${CC} ${LDFLAGS} -nostdlib -r -Wl,-T,${KMODSCRIPT},-d \ | | 179 | ${CC} ${LDFLAGS} -nostdlib -r -Wl,-T,${KMODSCRIPT},-d \ |
178 | -Wl,-Map=${.TARGET}.map \ | | 180 | -Wl,-Map=${.TARGET}.map \ |
179 | -o ${.TARGET} ${OBJS} | | 181 | -o ${.TARGET} ${OBJS} |
180 | .endif | | 182 | .endif |
181 | .if defined(CTFMERGE) | | 183 | .if defined(CTFMERGE) |
182 | ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${OBJS} | | 184 | ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${OBJS} |
183 | .endif | | 185 | .endif |
184 | | | 186 | |
185 | .if defined(PROGDEBUG) | | 187 | .if defined(PROGDEBUG) |
186 | ${PROGDEBUG}: ${PROG} | | 188 | ${PROGDEBUG}: ${PROG} |
187 | ${_MKTARGET_CREATE} | | 189 | ${_MKTARGET_CREATE} |
188 | ( ${OBJCOPY} --only-keep-debug ${PROG} ${PROGDEBUG} \ | | 190 | ( ${OBJCOPY} --only-keep-debug ${PROG} ${PROGDEBUG} \ |
189 | && ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \ | | 191 | && ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \ |
190 | --add-gnu-debuglink=${PROGDEBUG} ${PROG} \ | | 192 | --add-gnu-debuglink=${PROGDEBUG} ${PROG} \ |
191 | ) || (rm -f ${PROGDEBUG}; false) | | 193 | ) || (rm -f ${PROGDEBUG}; false) |
192 | .endif | | 194 | .endif |
193 | | | 195 | |
194 | ##### Install rules | | 196 | ##### Install rules |
195 | .if !target(kmodinstall) | | 197 | .if !target(kmodinstall) |
196 | .if !defined(KMODULEDIR) | | 198 | .if !defined(KMODULEDIR) |
197 | .if ${KERNEL_DIR:Uno} == "yes" | | 199 | .if ${KERNEL_DIR:Uno} == "yes" |
198 | _INST_DIRS= /netbsd | | 200 | _INST_DIRS= /netbsd |
199 | _INST_DIRS+= /netbsd/modules | | 201 | _INST_DIRS+= /netbsd/modules |
200 | KMODULEDIR= /netbsd/modules/${KMOD} | | 202 | KMODULEDIR= /netbsd/modules/${KMOD} |
201 | .else | | 203 | .else |
202 | # Ensure these are recorded properly in METALOG on unprived installes: | | 204 | # Ensure these are recorded properly in METALOG on unprived installes: |
203 | _OSRELEASE!= ${HOST_SH} $S/conf/osrelease.sh -k | | 205 | _OSRELEASE!= ${HOST_SH} $S/conf/osrelease.sh -k |
204 | KMODULEARCHDIR?= ${MACHINE} | | 206 | KMODULEARCHDIR?= ${MACHINE} |
205 | _INST_DIRS= /stand/${KMODULEARCHDIR} | | 207 | _INST_DIRS= /stand/${KMODULEARCHDIR} |
206 | _INST_DIRS+= /stand/${KMODULEARCHDIR}/${_OSRELEASE} | | 208 | _INST_DIRS+= /stand/${KMODULEARCHDIR}/${_OSRELEASE} |
207 | _INST_DIRS+= /stand/${KMODULEARCHDIR}/${_OSRELEASE}/modules | | 209 | _INST_DIRS+= /stand/${KMODULEARCHDIR}/${_OSRELEASE}/modules |
208 | KMODULEDIR= /stand/${KMODULEARCHDIR}/${_OSRELEASE}/modules/${KMOD} | | 210 | KMODULEDIR= /stand/${KMODULEARCHDIR}/${_OSRELEASE}/modules/${KMOD} |
209 | .endif | | 211 | .endif |
210 | .endif | | 212 | .endif |
211 | | | 213 | |
212 | _INST_DIRS+= ${KMODULEDIR} | | 214 | _INST_DIRS+= ${KMODULEDIR} |
213 | _PROG:= ${DESTDIR}${KMODULEDIR}/${PROG} # installed path | | 215 | _PROG:= ${DESTDIR}${KMODULEDIR}/${PROG} # installed path |
214 | | | 216 | |
215 | .if defined(PROGDEBUG) | | 217 | .if defined(PROGDEBUG) |
216 | .for i in ${_INST_DIRS} | | 218 | .for i in ${_INST_DIRS} |
217 | _DEBUG_INST_DIRS += ${DEBUGDIR}${i} | | 219 | _DEBUG_INST_DIRS += ${DEBUGDIR}${i} |
218 | .endfor | | 220 | .endfor |
219 | _INST_DIRS += ${_DEBUG_INST_DIRS} | | 221 | _INST_DIRS += ${_DEBUG_INST_DIRS} |
220 | _PROGDEBUG:= ${DESTDIR}${DEBUGDIR}${KMODULEDIR}/${PROG}.debug | | 222 | _PROGDEBUG:= ${DESTDIR}${DEBUGDIR}${KMODULEDIR}/${PROG}.debug |
221 | .endif | | 223 | .endif |
222 | | | 224 | |
223 | .for _P P in ${_PROG} ${PROG} ${_PROGDEBUG} ${PROGDEBUG} | | 225 | .for _P P in ${_PROG} ${PROG} ${_PROGDEBUG} ${PROGDEBUG} |
224 | .if ${MKUPDATE} == "no" | | 226 | .if ${MKUPDATE} == "no" |
225 | ${_P}! ${P} # install rule | | 227 | ${_P}! ${P} # install rule |
226 | .if !defined(BUILD) && !make(all) && !make(${P}) | | 228 | .if !defined(BUILD) && !make(all) && !make(${P}) |
227 | ${_P}! .MADE # no build at install | | 229 | ${_P}! .MADE # no build at install |
228 | .endif | | 230 | .endif |
229 | .else | | 231 | .else |
230 | ${_P}: ${P} # install rule | | 232 | ${_P}: ${P} # install rule |
231 | .if !defined(BUILD) && !make(all) && !make(${P}) | | 233 | .if !defined(BUILD) && !make(all) && !make(${P}) |
232 | ${_P}: .MADE # no build at install | | 234 | ${_P}: .MADE # no build at install |
233 | .endif | | 235 | .endif |
234 | .endif | | 236 | .endif |
235 | ${_MKTARGET_INSTALL} | | 237 | ${_MKTARGET_INSTALL} |
236 | dirs=${_INST_DIRS:Q}; \ | | 238 | dirs=${_INST_DIRS:Q}; \ |
237 | for d in $$dirs; do \ | | 239 | for d in $$dirs; do \ |
238 | ${INSTALL_DIR} ${DESTDIR}$$d; \ | | 240 | ${INSTALL_DIR} ${DESTDIR}$$d; \ |
239 | done | | 241 | done |
240 | ${INSTALL_FILE} -o ${KMODULEOWN} -g ${KMODULEGRP} -m ${KMODULEMODE} \ | | 242 | ${INSTALL_FILE} -o ${KMODULEOWN} -g ${KMODULEGRP} -m ${KMODULEMODE} \ |
241 | ${.ALLSRC} ${.TARGET} | | 243 | ${.ALLSRC} ${.TARGET} |
242 | | | 244 | |
243 | kmodinstall:: ${_P} | | 245 | kmodinstall:: ${_P} |
244 | .PHONY: kmodinstall | | 246 | .PHONY: kmodinstall |
245 | .PRECIOUS: ${_P} # keep if install fails | | 247 | .PRECIOUS: ${_P} # keep if install fails |
246 | .endfor | | 248 | .endfor |
247 | | | 249 | |
248 | .undef _PPROG | | 250 | .undef _PPROG |
249 | .undef _PPROGDEBUG | | 251 | .undef _PPROGDEBUG |
250 | .endif # !target(kmodinstall) | | 252 | .endif # !target(kmodinstall) |
251 | | | 253 | |
252 | ##### Clean rules | | 254 | ##### Clean rules |
253 | CLEANFILES+= a.out [Ee]rrs mklog core *.core ${PROG} ${OBJS} ${LOBJS} | | 255 | CLEANFILES+= a.out [Ee]rrs mklog core *.core ${PROG} ${OBJS} ${LOBJS} |
254 | CLEANFILES+= ${PROGDEBUG} | | 256 | CLEANFILES+= ${PROGDEBUG} |
255 | CLEANFILES+= ${PROG}.map | | 257 | CLEANFILES+= ${PROG}.map |
256 | .if ${MKLDSCRIPT} == "yes" | | 258 | .if ${MKLDSCRIPT} == "yes" |
257 | CLEANFILES+= kldscript | | 259 | CLEANFILES+= kldscript |
258 | .endif | | 260 | .endif |
259 | | | 261 | |
260 | ##### Custom rules | | 262 | ##### Custom rules |
261 | lint: ${LOBJS} | | 263 | lint: ${LOBJS} |
262 | .if defined(LOBJS) && !empty(LOBJS) | | 264 | .if defined(LOBJS) && !empty(LOBJS) |
263 | ${LINT} ${LINTFLAGS} ${LDFLAGS:C/-L[ ]*/-L/Wg:M-L*} ${LOBJS} ${LDADD} | | 265 | ${LINT} ${LINTFLAGS} ${LDFLAGS:C/-L[ ]*/-L/Wg:M-L*} ${LOBJS} ${LDADD} |
264 | .endif | | 266 | .endif |
265 | | | 267 | |
266 | ##### Pull in related .mk logic | | 268 | ##### Pull in related .mk logic |
267 | LINKSOWN?= ${KMODULEOWN} | | 269 | LINKSOWN?= ${KMODULEOWN} |
268 | LINKSGRP?= ${KMODULEGRP} | | 270 | LINKSGRP?= ${KMODULEGRP} |
269 | LINKSMODE?= ${KMODULEMODE} | | 271 | LINKSMODE?= ${KMODULEMODE} |
270 | .include <bsd.man.mk> | | 272 | .include <bsd.man.mk> |
271 | .include <bsd.links.mk> | | 273 | .include <bsd.links.mk> |
272 | .include <bsd.dep.mk> | | 274 | .include <bsd.dep.mk> |
273 | .include <bsd.clean.mk> | | 275 | .include <bsd.clean.mk> |
274 | | | 276 | |
275 | .-include "$S/arch/${MACHINE_CPU}/include/Makefile.inc" | | 277 | .-include "$S/arch/${MACHINE_CPU}/include/Makefile.inc" |
276 | .-include "$S/arch/${MACHINE}/include/Makefile.inc" | | 278 | .-include "$S/arch/${MACHINE}/include/Makefile.inc" |