| @@ -1,585 +1,595 @@ | | | @@ -1,585 +1,595 @@ |
1 | # $NetBSD: Makefile.kern.inc,v 1.298 2023/07/26 03:39:55 rin Exp $ | | 1 | # $NetBSD: Makefile.kern.inc,v 1.299 2023/07/28 02:41:31 rin Exp $ |
2 | # | | 2 | # |
3 | # This file contains common `MI' targets and definitions and it is included | | 3 | # This file contains common `MI' targets and definitions and it is included |
4 | # at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}. | | 4 | # at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}. |
5 | # | | 5 | # |
6 | # Each target in this file should be protected with `if !target(target)' | | 6 | # Each target in this file should be protected with `if !target(target)' |
7 | # or `if !commands(target)' and each variable should only be conditionally | | 7 | # or `if !commands(target)' and each variable should only be conditionally |
8 | # assigned `VAR ?= VALUE', so that everything can be overridden. | | 8 | # assigned `VAR ?= VALUE', so that everything can be overridden. |
9 | # | | 9 | # |
10 | # DEBUG is set to -g if debugging. | | 10 | # DEBUG is set to -g if debugging. |
11 | # PROF is set to -pg if profiling. | | 11 | # PROF is set to -pg if profiling. |
12 | # | | 12 | # |
13 | # To specify debugging, add the config line: makeoptions DEBUG="-g" | | 13 | # To specify debugging, add the config line: makeoptions DEBUG="-g" |
14 | # A better way is to specify -g only for a few files. | | 14 | # A better way is to specify -g only for a few files. |
15 | # | | 15 | # |
16 | # makeoptions DEBUGLIST="uvm* trap if_*" | | 16 | # makeoptions DEBUGLIST="uvm* trap if_*" |
17 | # | | 17 | # |
18 | # all ports are expected to include bsd.own.mk for toolchain settings | | 18 | # all ports are expected to include bsd.own.mk for toolchain settings |
19 | | | 19 | |
20 | # Default DEBUG to -g if kernel debug info is requested by MKDEBUGKERNEL=yes | | 20 | # Default DEBUG to -g if kernel debug info is requested by MKDEBUGKERNEL=yes |
21 | .if ${MKDEBUGKERNEL:Uno} == "yes" || ${MKDEBUG:Uno} == "yes" | | 21 | .if ${MKDEBUGKERNEL:Uno} == "yes" || ${MKDEBUG:Uno} == "yes" |
22 | DEBUG?=-g | | 22 | DEBUG?=-g |
23 | .else | | 23 | .else |
24 | DEBUG?= | | 24 | DEBUG?= |
25 | .endif | | 25 | .endif |
26 | | | 26 | |
27 | ## | | 27 | ## |
28 | ## (0) toolchain settings for things that aren't part of the standard | | 28 | ## (0) toolchain settings for things that aren't part of the standard |
29 | ## toolchain | | 29 | ## toolchain |
30 | ## | | 30 | ## |
31 | HOST_SH?= sh | | 31 | HOST_SH?= sh |
32 | DBSYM?= dbsym | | 32 | DBSYM?= dbsym |
33 | MKDEP?= mkdep | | 33 | MKDEP?= mkdep |
34 | STRIP?= strip | | 34 | STRIP?= strip |
35 | OBJCOPY?= objcopy | | 35 | OBJCOPY?= objcopy |
36 | OBJDUMP?= objdump | | 36 | OBJDUMP?= objdump |
37 | CSCOPE?= cscope | | 37 | CSCOPE?= cscope |
38 | MKID?= mkid | | 38 | MKID?= mkid |
39 | UUDECODE?= ${TOOL_UUDECODE:Uuudecode} | | 39 | UUDECODE?= ${TOOL_UUDECODE:Uuudecode} |
40 | HEXDUMP?= ${TOOL_HEXDUMP:Uhexdump} | | 40 | HEXDUMP?= ${TOOL_HEXDUMP:Uhexdump} |
41 | GENASSYM?= ${TOOL_GENASSYM:Ugenassym} | | 41 | GENASSYM?= ${TOOL_GENASSYM:Ugenassym} |
42 | .MAKEOVERRIDES+=USETOOLS # make sure proper value is propagated | | 42 | .MAKEOVERRIDES+=USETOOLS # make sure proper value is propagated |
43 | | | 43 | |
44 | _MKMSG?= @\# | | 44 | _MKMSG?= @\# |
45 | _MKSHMSG?= echo | | 45 | _MKSHMSG?= echo |
46 | _MKSHECHO?= echo | | 46 | _MKSHECHO?= echo |
47 | _MKSHNOECHO= : | | 47 | _MKSHNOECHO= : |
48 | _MKMSG_CREATE?= : | | 48 | _MKMSG_CREATE?= : |
49 | _MKTARGET_COMPILE?= : | | 49 | _MKTARGET_COMPILE?= : |
50 | _MKTARGET_CREATE?= : | | 50 | _MKTARGET_CREATE?= : |
51 | | | 51 | |
52 | ## | | 52 | ## |
53 | ## (1) port independent source tree identification | | 53 | ## (1) port independent source tree identification |
54 | ## | | 54 | ## |
55 | # source tree is located via $S relative to the compilation directory | | 55 | # source tree is located via $S relative to the compilation directory |
56 | .ifndef S | | 56 | .ifndef S |
57 | S!= cd ../../../.. && pwd | | 57 | S!= cd ../../../.. && pwd |
58 | .endif | | 58 | .endif |
59 | | | 59 | |
60 | ## | | 60 | ## |
61 | ## (2) compile settings | | 61 | ## (2) compile settings |
62 | ## | | 62 | ## |
63 | ## CPPFLAGS, CFLAGS, and AFLAGS must be set in the port's Makefile | | 63 | ## CPPFLAGS, CFLAGS, and AFLAGS must be set in the port's Makefile |
64 | ## | | 64 | ## |
65 | INCLUDES?= -I. ${EXTRA_INCLUDES} -I${S}/../common/include -I$S/arch \ | | 65 | INCLUDES?= -I. ${EXTRA_INCLUDES} -I${S}/../common/include -I$S/arch \ |
66 | -I$S -nostdinc | | 66 | -I$S -nostdinc |
67 | CPPFLAGS+= ${INCLUDES} ${IDENT} -D_KERNEL -D_KERNEL_OPT | | 67 | CPPFLAGS+= ${INCLUDES} ${IDENT} -D_KERNEL -D_KERNEL_OPT |
68 | .if !defined(COVERITY_TOP_CONFIG) | | 68 | .if !defined(COVERITY_TOP_CONFIG) |
69 | CPPFLAGS+= -std=gnu99 | | 69 | CPPFLAGS+= -std=gnu99 |
70 | .endif | | 70 | .endif |
71 | .if ${KERNEL_DIR:Uno} == "yes" | | 71 | .if ${KERNEL_DIR:Uno} == "yes" |
72 | CPPFLAGS+= -DKERNEL_DIR | | 72 | CPPFLAGS+= -DKERNEL_DIR |
73 | .endif | | 73 | .endif |
74 | DEFCOPTS?= -O2 | | 74 | DEFCOPTS?= -O2 |
75 | COPTS?= ${DEFCOPTS} | | 75 | COPTS?= ${DEFCOPTS} |
76 | DBG= # might contain unwanted -Ofoo | | 76 | DBG= # might contain unwanted -Ofoo |
77 | CWARNFLAGS+= -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith | | 77 | CWARNFLAGS+= -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith |
78 | CWARNFLAGS+= -Wmissing-prototypes -Wstrict-prototypes | | 78 | CWARNFLAGS+= -Wmissing-prototypes -Wstrict-prototypes |
79 | CWARNFLAGS+= -Wold-style-definition | | 79 | CWARNFLAGS+= -Wold-style-definition |
80 | CWARNFLAGS+= -Wswitch -Wshadow | | 80 | CWARNFLAGS+= -Wswitch -Wshadow |
81 | CWARNFLAGS+= -Wcast-qual -Wwrite-strings | | 81 | CWARNFLAGS+= -Wcast-qual -Wwrite-strings |
82 | CWARNFLAGS+= -Wno-unreachable-code | | 82 | CWARNFLAGS+= -Wno-unreachable-code |
83 | #CWARNFLAGS+= -Wc++-compat -Wno-error=c++-compat | | 83 | #CWARNFLAGS+= -Wc++-compat -Wno-error=c++-compat |
84 | CWARNFLAGS+= -Wno-pointer-sign -Wno-attributes | | 84 | CWARNFLAGS+= -Wno-pointer-sign -Wno-attributes |
85 | CWARNFLAGS+= -Wno-type-limits | | 85 | CWARNFLAGS+= -Wno-type-limits |
86 | . if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64" || \ | | 86 | . if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64" || \ |
87 | ${MACHINE_ARCH} == "sparc64" || ${MACHINE} == "prep" | | 87 | ${MACHINE_ARCH} == "sparc64" || ${MACHINE} == "prep" |
88 | CWARNFLAGS+= -Wextra -Wno-unused-parameter | | 88 | CWARNFLAGS+= -Wextra -Wno-unused-parameter |
89 | . endif | | 89 | . endif |
90 | . if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64" | | 90 | . if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64" |
91 | CWARNFLAGS+= -Wold-style-definition | | 91 | CWARNFLAGS+= -Wold-style-definition |
92 | . endif | | 92 | . endif |
93 | # Add -Wno-sign-compare. -Wsign-compare is included in -Wall as of GCC 3.3, | | 93 | # Add -Wno-sign-compare. -Wsign-compare is included in -Wall as of GCC 3.3, |
94 | # but our sources aren't up for it yet. | | 94 | # but our sources aren't up for it yet. |
95 | CWARNFLAGS+= -Wno-sign-compare | | 95 | CWARNFLAGS+= -Wno-sign-compare |
96 | | | 96 | |
97 | CWARNFLAGS.clang+= -Wno-unknown-pragmas -Wno-conversion \ | | 97 | CWARNFLAGS.clang+= -Wno-unknown-pragmas -Wno-conversion \ |
98 | -Wno-self-assign \ | | 98 | -Wno-self-assign \ |
99 | -Wno-error=constant-conversion | | 99 | -Wno-error=constant-conversion |
100 | CWARNFLAGS+= ${CC_WNO_ADDRESS_OF_PACKED_MEMBER} | | 100 | CWARNFLAGS+= ${CC_WNO_ADDRESS_OF_PACKED_MEMBER} |
101 | | | 101 | |
102 | CWARNFLAGS.ah_regdomain.c= ${${ACTIVE_CC} == "clang":? \ | | 102 | CWARNFLAGS.ah_regdomain.c= ${${ACTIVE_CC} == "clang":? \ |
103 | -Wno-shift-count-negative -Wno-shift-count-overflow:} | | 103 | -Wno-shift-count-negative -Wno-shift-count-overflow:} |
104 | | | 104 | |
105 | CWARNFLAGS.ioconf.c= ${${ACTIVE_CC} == "clang":? -Wno-unused-const-variable :} | | 105 | CWARNFLAGS.ioconf.c= ${${ACTIVE_CC} == "clang":? -Wno-unused-const-variable :} |
106 | | | 106 | |
107 | CFLAGS+= -ffreestanding -fno-zero-initialized-in-bss | | 107 | CFLAGS+= -ffreestanding -fno-zero-initialized-in-bss |
108 | CFLAGS+= ${${ACTIVE_CC} == "gcc":? -fno-delete-null-pointer-checks :} | | 108 | CFLAGS+= ${${ACTIVE_CC} == "gcc":? -fno-delete-null-pointer-checks :} |
109 | CFLAGS+= ${DEBUG} ${COPTS} | | 109 | CFLAGS+= ${DEBUG} ${COPTS} |
110 | AFLAGS+= -D_LOCORE -Wa,--fatal-warnings | | 110 | AFLAGS+= -D_LOCORE -Wa,--fatal-warnings |
111 | | | 111 | |
112 | # example usage to find largest stack users in kernel compile directory: | | 112 | # example usage to find largest stack users in kernel compile directory: |
113 | # find . -name \*.su | xargs awk '{ printf "%6d %s\n", $2, $1 }' | sort -n | | 113 | # find . -name \*.su | xargs awk '{ printf "%6d %s\n", $2, $1 }' | sort -n |
114 | .if ${MACHINE} != "vax" | | 114 | .if ${MACHINE} != "vax" |
115 | # GCC/vax 8.4 does not support -fstack-usage. | | 115 | # GCC/vax 8.4 does not support -fstack-usage. |
116 | CFLAGS+= ${${ACTIVE_CC} == "gcc":? -fstack-usage -Wstack-usage=3584 :} | | 116 | CFLAGS+= ${${ACTIVE_CC} == "gcc":? -fstack-usage -Wstack-usage=3584 :} |
117 | .endif | | 117 | .endif |
118 | CWARNFLAGS+= -Walloca | | 118 | CWARNFLAGS+= -Walloca |
119 | | | 119 | |
120 | # XXX | | 120 | # XXX |
121 | .if defined(HAVE_GCC) || defined(HAVE_LLVM) | | 121 | .if defined(HAVE_GCC) || defined(HAVE_LLVM) |
122 | CFLAGS+= -fno-strict-aliasing | | 122 | CFLAGS+= -fno-strict-aliasing |
123 | CFLAGS+= -fno-common | | 123 | CFLAGS+= -fno-common |
124 | .endif | | 124 | .endif |
125 | | | 125 | |
126 | # Use the per-source COPTS variables to add -g to just those | | 126 | # Use the per-source COPTS variables to add -g to just those |
127 | # files that match the shell patterns given in ${DEBUGLIST} | | 127 | # files that match the shell patterns given in ${DEBUGLIST} |
128 | # | | 128 | # |
129 | .for i in ${DEBUGLIST} | | 129 | .for i in ${DEBUGLIST} |
130 | . for j in ${ALLFILES:M*.c:T:M$i.c} | | 130 | . for j in ${ALLFILES:M*.c:T:M$i.c} |
131 | COPTS.${j}+=-g | | 131 | COPTS.${j}+=-g |
132 | . endfor | | 132 | . endfor |
133 | .endfor | | 133 | .endfor |
134 | | | 134 | |
135 | # Always compile debugsyms.c with debug information. | | 135 | # Always compile debugsyms.c with debug information. |
136 | # This allows gdb to use type informations. | | 136 | # This allows gdb to use type informations. |
137 | # | | 137 | # |
138 | COPTS.debugsyms.c+= -g | | 138 | COPTS.debugsyms.c+= -g |
139 | | | 139 | |
140 | # Add CTF sections for DTrace | | 140 | # Add CTF sections for DTrace |
141 | .if defined(CTFCONVERT) | | 141 | .if defined(CTFCONVERT) |
142 | COMPILE_CTFCONVERT= ${_MKSHECHO}\ | | 142 | COMPILE_CTFCONVERT= ${_MKSHECHO}\ |
143 | ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ | | 143 | ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \ |
144 | ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} | | 144 | ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} |
145 | .else | | 145 | .else |
146 | COMPILE_CTFCONVERT= ${_MKSHNOECHO} | | 146 | COMPILE_CTFCONVERT= ${_MKSHNOECHO} |
147 | .endif | | 147 | .endif |
148 | | | 148 | |
149 | KCOMPILE.c= ${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} -c $< -o $@ | | 149 | KCOMPILE.c= ${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} -c $< -o $@ |
150 | KCOMPILE.s= ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} -c $< -o $@ | | 150 | KCOMPILE.s= ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} -c $< -o $@ |
151 | KLINK.o= ${LD} -r ${LINKFORMAT} -Map=${.TARGET}.map -o ${.TARGET} ${.ALLSRC} | | 151 | KLINK.o= ${LD} -r ${LINKFORMAT} -Map=${.TARGET}.map -o ${.TARGET} ${.ALLSRC} |
152 | | | 152 | |
153 | # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or | | 153 | # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or |
154 | # NOPROF and SUFFIX is the file suffix, capitalized (e.g. C for a .c file). | | 154 | # NOPROF and SUFFIX is the file suffix, capitalized (e.g. C for a .c file). |
155 | NORMAL_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \ | | 155 | NORMAL_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \ |
156 | ${_MKSHECHO} ${KCOMPILE.c} ${PROF} && \ | | 156 | ${_MKSHECHO} ${KCOMPILE.c} ${PROF} && \ |
157 | ${KCOMPILE.c} ${PROF} && \ | | 157 | ${KCOMPILE.c} ${PROF} && \ |
158 | ${COMPILE_CTFCONVERT} | | 158 | ${COMPILE_CTFCONVERT} |
159 | NOPROF_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \ | | 159 | NOPROF_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \ |
160 | ${_MKSHECHO} ${KCOMPILE.c} && \ | | 160 | ${_MKSHECHO} ${KCOMPILE.c} && \ |
161 | ${KCOMPILE.c} && \ | | 161 | ${KCOMPILE.c} && \ |
162 | ${COMPILE_CTFCONVERT} | | 162 | ${COMPILE_CTFCONVERT} |
163 | NORMAL_S?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \ | | 163 | NORMAL_S?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \ |
164 | ${_MKSHECHO} ${KCOMPILE.s} && \ | | 164 | ${_MKSHECHO} ${KCOMPILE.s} && \ |
165 | ${KCOMPILE.s} | | 165 | ${KCOMPILE.s} |
166 | | | 166 | |
167 | # link rules: | | 167 | # link rules: |
168 | LINK_O?= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}" && \ | | 168 | LINK_O?= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}" && \ |
169 | ${_MKSHECHO} ${KLINK.o} && \ | | 169 | ${_MKSHECHO} ${KLINK.o} && \ |
170 | ${KLINK.o} | | 170 | ${KLINK.o} |
171 | | | 171 | |
172 | ## | | 172 | ## |
173 | ## (3) libkern | | 173 | ## (3) libkern |
174 | ## | | 174 | ## |
175 | ## Set OPT_MODULAR in the port Makefile if module(7) is enabled, | | 175 | ## Set OPT_MODULAR in the port Makefile if module(7) is enabled, |
176 | ## as documented in $S/lib/libkern/Makefile.inc. | | 176 | ## as documented in $S/lib/libkern/Makefile.inc. |
177 | ## | | 177 | ## |
178 | | | 178 | |
179 | ### find out what to use for libkern | | 179 | ### find out what to use for libkern |
180 | .include "$S/lib/libkern/Makefile.inc" | | 180 | .include "$S/lib/libkern/Makefile.inc" |
181 | .ifndef PROF | | 181 | .ifndef PROF |
182 | LIBKERN?= ${KERNLIB} | | 182 | LIBKERN?= ${KERNLIB} |
183 | .else | | 183 | .else |
184 | LIBKERN?= ${KERNLIB_PROF} | | 184 | LIBKERN?= ${KERNLIB_PROF} |
185 | .endif | | 185 | .endif |
186 | | | 186 | |
187 | LIBKERNLN?= ${KERNLIBLN} | | 187 | LIBKERNLN?= ${KERNLIBLN} |
188 | | | 188 | |
189 | ## | | 189 | ## |
190 | ## (4) local objects, compile rules, and dependencies | | 190 | ## (4) local objects, compile rules, and dependencies |
191 | ## | | 191 | ## |
192 | ## Each port should have a corresponding section with settings for | | 192 | ## Each port should have a corresponding section with settings for |
193 | ## MD_CFILES, MD_SFILES, and MD_OBJS, along with build rules for same. | | 193 | ## MD_CFILES, MD_SFILES, and MD_OBJS, along with build rules for same. |
194 | ## | | 194 | ## |
195 | | | 195 | |
196 | .if !defined(___USE_SUFFIX_RULES___) | | 196 | .if !defined(___USE_SUFFIX_RULES___) |
197 | _MD_OBJS= ${MD_OBJS:T} | | 197 | _MD_OBJS= ${MD_OBJS:T} |
198 | .else | | 198 | .else |
199 | _MD_OBJS= ${MD_OBJS} | | 199 | _MD_OBJS= ${MD_OBJS} |
200 | .endif | | 200 | .endif |
201 | | | 201 | |
202 | ## | | 202 | ## |
203 | ## (5) link settings | | 203 | ## (5) link settings |
204 | ## | | 204 | ## |
205 | ## TEXTADDR (or LOADADDRESS), LINKFORMAT, LINKSCRIPT, and any EXTRA_LINKFLAGS | | 205 | ## TEXTADDR (or LOADADDRESS), LINKFORMAT, LINKSCRIPT, and any EXTRA_LINKFLAGS |
206 | ## must be set in the port's Makefile. The port specific definitions for | | 206 | ## must be set in the port's Makefile. The port specific definitions for |
207 | ## LINKFLAGS_NORMAL and LINKFLAGS_DEBUG will added to the LINKFLAGS | | 207 | ## LINKFLAGS_NORMAL and LINKFLAGS_DEBUG will added to the LINKFLAGS |
208 | ## depending on the value of DEBUG. | | 208 | ## depending on the value of DEBUG. |
209 | ## | | 209 | ## |
210 | # load lines for config "xxx" will be emitted as: | | 210 | # load lines for config "xxx" will be emitted as: |
211 | # xxx: ${SYSTEM_DEP} swapxxxx.o vers.o build_kernel | | 211 | # xxx: ${SYSTEM_DEP} swapxxxx.o vers.o build_kernel |
212 | | | 212 | |
213 | SYSTEM_LIB= ${MD_LIBS} ${LIBKERN} | | 213 | SYSTEM_LIB= ${MD_LIBS} ${LIBKERN} |
214 | SYSTEM_OBJ?= ${_MD_OBJS} ${OBJS} ${SYSTEM_LIB} | | 214 | SYSTEM_OBJ?= ${_MD_OBJS} ${OBJS} ${SYSTEM_LIB} |
215 | SYSTEM_DEP+= Makefile ${SYSTEM_OBJ:O} | | 215 | SYSTEM_DEP+= Makefile ${SYSTEM_OBJ:O} |
216 | .if defined(CTFMERGE) | | 216 | .if defined(CTFMERGE) |
217 | SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o | | 217 | SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o |
218 | .else | | 218 | .else |
219 | SYSTEM_CTFMERGE= ${_MKSHECHO} | | 219 | SYSTEM_CTFMERGE= ${_MKSHECHO} |
220 | .endif | | 220 | .endif |
221 | | | 221 | |
222 | REMOVE_SWAP= [@] | | 222 | REMOVE_SWAP= [@] |
223 | .for k in ${KERNELS} | | 223 | .for k in ${KERNELS} |
224 | REMOVE_SWAP:= ${REMOVE_SWAP}:Nswap${k}.o | | 224 | REMOVE_SWAP:= ${REMOVE_SWAP}:Nswap${k}.o |
225 | .endfor | | 225 | .endfor |
226 | | | 226 | |
227 | SYSTEM_LD_HEAD?=@rm -f $@ | | 227 | SYSTEM_LD_HEAD?=@rm -f $@ |
228 | SYSTEM_LD?= ${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}"; \ | | 228 | SYSTEM_LD?= ${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}"; \ |
229 | ${_MKSHECHO}\ | | 229 | ${_MKSHECHO}\ |
230 | ${LD} -Map ${.TARGET}.map --cref ${LINKFLAGS} -o ${.TARGET} \ | | 230 | ${LD} -Map ${.TARGET}.map --cref ${LINKFLAGS} -o ${.TARGET} \ |
231 | '$${SYSTEM_OBJ:${REMOVE_SWAP}}' '$${EXTRA_OBJ}' vers.o \ | | 231 | '$${SYSTEM_OBJ:${REMOVE_SWAP}}' '$${EXTRA_OBJ}' vers.o \ |
232 | ${OBJS:M*swap${.TARGET}.o}; \ | | 232 | ${OBJS:M*swap${.TARGET}.o}; \ |
233 | ${LD} -Map ${.TARGET}.map --cref ${LINKFLAGS} -o ${.TARGET} \ | | 233 | ${LD} -Map ${.TARGET}.map --cref ${LINKFLAGS} -o ${.TARGET} \ |
234 | ${SYSTEM_OBJ:${REMOVE_SWAP}} ${EXTRA_OBJ} vers.o \ | | 234 | ${SYSTEM_OBJ:${REMOVE_SWAP}} ${EXTRA_OBJ} vers.o \ |
235 | ${OBJS:M*swap${.TARGET}.o} | | 235 | ${OBJS:M*swap${.TARGET}.o} |
236 | | | 236 | |
237 | TEXTADDR?= ${LOADADDRESS} # backwards compatibility | | 237 | TEXTADDR?= ${LOADADDRESS} # backwards compatibility |
238 | LINKTEXT?= ${TEXTADDR:C/.+/-Ttext &/} | | 238 | LINKTEXT?= ${TEXTADDR:C/.+/-Ttext &/} |
239 | LINKDATA?= ${DATAADDR:C/.+/-Tdata &/} | | 239 | LINKDATA?= ${DATAADDR:C/.+/-Tdata &/} |
240 | ENTRYPOINT?= start | | 240 | ENTRYPOINT?= start |
241 | LINKENTRY?= ${ENTRYPOINT:C/.+/-e &/} | | 241 | LINKENTRY?= ${ENTRYPOINT:C/.+/-e &/} |
242 | LINKFLAGS?= ${LINKFORMAT} ${LINKSCRIPT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \ | | 242 | LINKFLAGS?= ${LINKFORMAT} ${LINKSCRIPT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \ |
243 | ${EXTRA_LINKFLAGS} | | 243 | ${EXTRA_LINKFLAGS} |
244 | | | 244 | |
245 | LINKFLAGS_DEBUG?= -X | | 245 | LINKFLAGS_DEBUG?= -X |
246 | KERNEL_CONFIG?= ${KERNEL_BUILD:T} | | 246 | KERNEL_CONFIG?= ${KERNEL_BUILD:T} |
247 | | | 247 | |
248 | SYSTEM_LD_TAIL?= @${_MKSHECHO} | | 248 | SYSTEM_LD_TAIL?= @${_MKSHECHO} |
249 | SYSTEM_LD_TAIL+= && ${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c && \ | | 249 | OBJCOPY_STRIPFLAGS?= -g |
250 | ${SIZE} $@ && ${SYSTEM_CTFMERGE} && chmod 755 $@ | | | |
251 | SYSTEM_LD_TAIL+= && runit() { echo $$@; $$@; } | | | |
252 | | | 250 | |
253 | OBJCOPY_STRIPFLAGS?= -g | | 251 | # Strip some architecture-defined symbols from kernel image, while |
| | | 252 | # keep them in netbsd.gdb. |
| | | 253 | .if defined(ARCH_STRIP_SYMBOLS) |
| | | 254 | .if empty(DEBUG:M-g*) |
| | | 255 | SYSTEM_LD_TAIL+= && ${OBJCOPY} -w ${ARCH_STRIP_SYMBOLS} $@ |
| | | 256 | .endif |
| | | 257 | OBJCOPY_STRIPFLAGS+= -w ${ARCH_STRIP_SYMBOLS} |
| | | 258 | .endif |
| | | 259 | |
| | | 260 | SYSTEM_LD_TAIL+= && ${TOOL_SED} \ |
| | | 261 | '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c && \ |
| | | 262 | ${SIZE} $@ && ${SYSTEM_CTFMERGE} && chmod 755 $@ && \ |
| | | 263 | runit() { echo $$@; $$@; } |
254 | | | 264 | |
255 | SYSTEM_LD_TAIL_DEBUG?=&& \ | | 265 | SYSTEM_LD_TAIL_DEBUG?=&& \ |
256 | runit mv -f $@ $@.gdb && \ | | 266 | runit mv -f $@ $@.gdb && \ |
257 | runit ${OBJCOPY} --only-keep-debug $@.gdb $@-${KERNEL_CONFIG}.debug && \ | | 267 | runit ${OBJCOPY} --only-keep-debug $@.gdb $@-${KERNEL_CONFIG}.debug && \ |
258 | runit ${OBJCOPY} ${OBJCOPY_STRIPFLAGS} -p -R .gnu_debuglink \ | | 268 | runit ${OBJCOPY} ${OBJCOPY_STRIPFLAGS} -p -R .gnu_debuglink \ |
259 | --add-gnu-debuglink=$@-${KERNEL_CONFIG}.debug $@.gdb $@ && \ | | 269 | --add-gnu-debuglink=$@-${KERNEL_CONFIG}.debug $@.gdb $@ && \ |
260 | runit chmod 755 $@ $@.gdb $@-${KERNEL_CONFIG}.debug | | 270 | runit chmod 755 $@ $@.gdb $@-${KERNEL_CONFIG}.debug |
261 | | | 271 | |
262 | LINKFLAGS_NORMAL?= -S | | 272 | LINKFLAGS_NORMAL?= -S |
263 | STRIPFLAGS?= -g | | 273 | STRIPFLAGS?= -g |
264 | | | 274 | |
265 | .if !empty(DEBUG:M-g*) | | 275 | .if !empty(DEBUG:M-g*) |
266 | SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_DEBUG} | | 276 | SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_DEBUG} |
267 | LINKFLAGS+= ${LINKFLAGS_DEBUG} | | 277 | LINKFLAGS+= ${LINKFLAGS_DEBUG} |
268 | EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.gdb@} | | 278 | EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.gdb@} |
269 | CTFFLAGS+= -g | | 279 | CTFFLAGS+= -g |
270 | TARGETSFX= .gdb | | 280 | TARGETSFX= .gdb |
271 | .elifndef PROF | | 281 | .elifndef PROF |
272 | LINKFLAGS+= ${LINKFLAGS_NORMAL} | | 282 | LINKFLAGS+= ${LINKFLAGS_NORMAL} |
273 | .endif | | 283 | .endif |
274 | | | 284 | |
275 | .if ${MKDEBUG:Uno} == "yes" | | 285 | .if ${MKDEBUG:Uno} == "yes" |
276 | # XXX: KERNEL_DIR? | | 286 | # XXX: KERNEL_DIR? |
277 | debuginstall: install-kernel-debug | | 287 | debuginstall: install-kernel-debug |
278 | .for k in ${KERNELS} | | 288 | .for k in ${KERNELS} |
279 | install-kernel-debug: ${DESTDIR}${DEBUGDIR}/${k}-${KERNEL_CONFIG}.debug | | 289 | install-kernel-debug: ${DESTDIR}${DEBUGDIR}/${k}-${KERNEL_CONFIG}.debug |
280 | | | 290 | |
281 | ${DESTDIR}${DEBUGDIR}/${k}-${KERNEL_CONFIG}.debug: ${k}-${KERNEL_CONFIG}.debug | | 291 | ${DESTDIR}${DEBUGDIR}/${k}-${KERNEL_CONFIG}.debug: ${k}-${KERNEL_CONFIG}.debug |
282 | ${_MKTARGET_INSTALL} | | 292 | ${_MKTARGET_INSTALL} |
283 | ${INSTALL_FILE} -o root -g bin -m 444 ${.ALLSRC} ${.TARGET} | | 293 | ${INSTALL_FILE} -o root -g bin -m 444 ${.ALLSRC} ${.TARGET} |
284 | .endfor | | 294 | .endfor |
285 | .else | | 295 | .else |
286 | debuginstall: | | 296 | debuginstall: |
287 | .endif | | 297 | .endif |
288 | | | 298 | |
289 | SYSTEM_LD_HEAD+= ${SYSTEM_LD_HEAD_EXTRA} | | 299 | SYSTEM_LD_HEAD+= ${SYSTEM_LD_HEAD_EXTRA} |
290 | SYSTEM_LD_TAIL_STAGE1= ${SYSTEM_LD_TAIL} | | 300 | SYSTEM_LD_TAIL_STAGE1= ${SYSTEM_LD_TAIL} |
291 | SYSTEM_LD_TAIL_STAGE2= ${SYSTEM_LD_TAIL} | | 301 | SYSTEM_LD_TAIL_STAGE2= ${SYSTEM_LD_TAIL} |
292 | .if defined(COPY_SYMTAB) | | 302 | .if defined(COPY_SYMTAB) |
293 | SYSTEM_LD_TAIL_STAGE2+= && runit ${DBSYM} $@ | | 303 | SYSTEM_LD_TAIL_STAGE2+= && runit ${DBSYM} $@ |
294 | .if !empty(DEBUG:M-g) | | 304 | .if !empty(DEBUG:M-g) |
295 | SYSTEM_LD_TAIL_STAGE2+= && runit ${DBSYM} $@.gdb | | 305 | SYSTEM_LD_TAIL_STAGE2+= && runit ${DBSYM} $@.gdb |
296 | .endif | | 306 | .endif |
297 | .endif | | 307 | .endif |
298 | SYSTEM_LD_TAIL_STAGE2+= ${SYSTEM_LD_TAIL_EXTRA} | | 308 | SYSTEM_LD_TAIL_STAGE2+= ${SYSTEM_LD_TAIL_EXTRA} |
299 | | | 309 | |
300 | ## | | 310 | ## |
301 | ## (6) port independent targets and dependencies: assym.h, vers.o | | 311 | ## (6) port independent targets and dependencies: assym.h, vers.o |
302 | ## | | 312 | ## |
303 | | | 313 | |
304 | .if !defined(___USE_SUFFIX_RULES___) | | 314 | .if !defined(___USE_SUFFIX_RULES___) |
305 | | | 315 | |
306 | # Generate list of *.o files to pass to ${LD}, preserving order. | | 316 | # Generate list of *.o files to pass to ${LD}, preserving order. |
307 | # x/y/z/a.[csS] -> a.[csS] | | 317 | # x/y/z/a.[csS] -> a.[csS] |
308 | # a.[csS] -> a.o | | 318 | # a.[csS] -> a.o |
309 | OBJS= ${ALLFILES:C|^.*/([^/]*\.[csS])$|\1|:C|^(.*)\.[csS]$|\1.o|} | | 319 | OBJS= ${ALLFILES:C|^.*/([^/]*\.[csS])$|\1|:C|^(.*)\.[csS]$|\1.o|} |
310 | | | 320 | |
311 | CFILES= ${ALLFILES:M*.c} | | 321 | CFILES= ${ALLFILES:M*.c} |
312 | SFILES= ${ALLFILES:M*.[sS]} | | 322 | SFILES= ${ALLFILES:M*.[sS]} |
313 | OFILES= ${ALLFILES:M*.o} | | 323 | OFILES= ${ALLFILES:M*.o} |
314 | # absolute, generated (build directory), relative (under $S) | | 324 | # absolute, generated (build directory), relative (under $S) |
315 | _CFILES=${CFILES:M/*} ${CFILES:N/*:N*/*} ${CFILES:N/*:M*/*:C|^|$S/|} | | 325 | _CFILES=${CFILES:M/*} ${CFILES:N/*:N*/*} ${CFILES:N/*:M*/*:C|^|$S/|} |
316 | _SFILES=${SFILES:M/*} ${SFILES:N/*:N*/*} ${SFILES:N/*:M*/*:C|^|$S/|} | | 326 | _SFILES=${SFILES:M/*} ${SFILES:N/*:N*/*} ${SFILES:N/*:M*/*:C|^|$S/|} |
317 | _MD_CFILES=${MD_CFILES} | | 327 | _MD_CFILES=${MD_CFILES} |
318 | _MD_SFILES=${MD_SFILES} | | 328 | _MD_SFILES=${MD_SFILES} |
319 | CSRCS= ${_MD_CFILES} ${_CFILES} | | 329 | CSRCS= ${_MD_CFILES} ${_CFILES} |
320 | SSRCS= ${_MD_SFILES} ${_SFILES} | | 330 | SSRCS= ${_MD_SFILES} ${_SFILES} |
321 | SRCS= ${CSRCS} ${SSRCS} | | 331 | SRCS= ${CSRCS} ${SSRCS} |
322 | | | 332 | |
323 | .else # ___USE_SUFFIX_RULES___ | | 333 | .else # ___USE_SUFFIX_RULES___ |
324 | OBJS= ${ALLFILES:C|\.[csS]$|.o|} | | 334 | OBJS= ${ALLFILES:C|\.[csS]$|.o|} |
325 | SRCS= ${ALLFILES:M*.[csS]} | | 335 | SRCS= ${ALLFILES:M*.[csS]} |
326 | .endif # ___USE_SUFFIX_RULES___ | | 336 | .endif # ___USE_SUFFIX_RULES___ |
327 | | | 337 | |
328 | .if !defined(___USE_SUFFIX_RULES___) | | 338 | .if !defined(___USE_SUFFIX_RULES___) |
329 | .for _s in ${_CFILES} | | 339 | .for _s in ${_CFILES} |
330 | .if !commands(${_s:T:R}.o) | | 340 | .if !commands(${_s:T:R}.o) |
331 | ${_s:T:R}.o: ${_s} | | 341 | ${_s:T:R}.o: ${_s} |
332 | ${NORMAL_C} | | 342 | ${NORMAL_C} |
333 | .endif | | 343 | .endif |
334 | .endfor | | 344 | .endfor |
335 | | | 345 | |
336 | .for _s in ${_SFILES} | | 346 | .for _s in ${_SFILES} |
337 | .if !commands(${_s:T:R}.o) | | 347 | .if !commands(${_s:T:R}.o) |
338 | ${_s:T:R}.o: ${_s} | | 348 | ${_s:T:R}.o: ${_s} |
339 | ${NORMAL_S} | | 349 | ${NORMAL_S} |
340 | .endif | | 350 | .endif |
341 | .endfor | | 351 | .endfor |
342 | .endif # !___USE_SUFFIX_RULES___ | | 352 | .endif # !___USE_SUFFIX_RULES___ |
343 | | | 353 | |
344 | .include "${S}/conf/ldscript.mk" | | 354 | .include "${S}/conf/ldscript.mk" |
345 | .include "${S}/conf/assym.mk" | | 355 | .include "${S}/conf/assym.mk" |
346 | .include "${S}/conf/newvers.mk" | | 356 | .include "${S}/conf/newvers.mk" |
347 | .include "${S}/dev/splash/splash.mk" | | 357 | .include "${S}/dev/splash/splash.mk" |
348 | .include "${S}/conf/mdroot.mk" | | 358 | .include "${S}/conf/mdroot.mk" |
349 | .include "${S}/conf/lint.mk" | | 359 | .include "${S}/conf/lint.mk" |
350 | .include "${S}/conf/cscope.mk" | | 360 | .include "${S}/conf/cscope.mk" |
351 | .include "${S}/conf/gdbinit.mk" | | 361 | .include "${S}/conf/gdbinit.mk" |
352 | .include "${S}/conf/ssp.mk" | | 362 | .include "${S}/conf/ssp.mk" |
353 | .if "${_SKIP_DTS}" != "yes" | | 363 | .if "${_SKIP_DTS}" != "yes" |
354 | .include "${S}/conf/dts.mk" | | 364 | .include "${S}/conf/dts.mk" |
355 | .endif | | 365 | .endif |
356 | .include "${S}/conf/copts.mk" | | 366 | .include "${S}/conf/copts.mk" |
357 | | | 367 | |
358 | ## | | 368 | ## |
359 | ## (7) misc targets: install, clean(dir), depend(all), lint, links, tags, | | 369 | ## (7) misc targets: install, clean(dir), depend(all), lint, links, tags, |
360 | ## cscope, mkid | | 370 | ## cscope, mkid |
361 | ## | | 371 | ## |
362 | ## Any ports that have other stuff to be cleaned up should fill in | | 372 | ## Any ports that have other stuff to be cleaned up should fill in |
363 | ## EXTRA_CLEAN. Some ports may want different settings for | | 373 | ## EXTRA_CLEAN. Some ports may want different settings for |
364 | ## KERNLINTFLAGS, MKDEP_CFLAGS, or MKDEP_AFLAGS. | | 374 | ## KERNLINTFLAGS, MKDEP_CFLAGS, or MKDEP_AFLAGS. |
365 | ## | | 375 | ## |
366 | | | 376 | |
367 | ## | | 377 | ## |
368 | ## clean | | 378 | ## clean |
369 | ## | | 379 | ## |
370 | | | 380 | |
371 | .if !target(__CLEANKERNEL) | | 381 | .if !target(__CLEANKERNEL) |
372 | __CLEANKERNEL: .USE | | 382 | __CLEANKERNEL: .USE |
373 | ${_MKMSG} "${.TARGET}ing the kernel objects" | | 383 | ${_MKMSG} "${.TARGET}ing the kernel objects" |
374 | rm -f ${KERNELS} *.map *.[io] *.ko *.ln [a-z]*.s *.su vers.c \ | | 384 | rm -f ${KERNELS} *.map *.[io] *.ko *.ln [a-z]*.s *.su vers.c \ |
375 | eddep tags [Ee]rrs linterrs makelinks assym.h.tmp assym.h \ | | 385 | eddep tags [Ee]rrs linterrs makelinks assym.h.tmp assym.h \ |
376 | ${EXTRA_KERNELS} ${EXTRA_CLEAN} | | 386 | ${EXTRA_KERNELS} ${EXTRA_CLEAN} |
377 | .endif | | 387 | .endif |
378 | | | 388 | |
379 | .if !target(kernelnames) | | 389 | .if !target(kernelnames) |
380 | kernelnames: | | 390 | kernelnames: |
381 | @echo "${KERNELS} ${EXTRA_KERNELS}" | | 391 | @echo "${KERNELS} ${EXTRA_KERNELS}" |
382 | .endif | | 392 | .endif |
383 | | | 393 | |
384 | .if !target(__CLEANDEPEND) | | 394 | .if !target(__CLEANDEPEND) |
385 | __CLEANDEPEND: .USE | | 395 | __CLEANDEPEND: .USE |
386 | echo .depend ${DEPS} | xargs rm -f -- | | 396 | echo .depend ${DEPS} | xargs rm -f -- |
387 | .endif | | 397 | .endif |
388 | | | 398 | |
389 | # do not !target these, the kern and compat Makefiles augment them | | 399 | # do not !target these, the kern and compat Makefiles augment them |
390 | cleandir distclean: __CLEANKERNEL __CLEANDEPEND | | 400 | cleandir distclean: __CLEANKERNEL __CLEANDEPEND |
391 | clean: __CLEANKERNEL | | 401 | clean: __CLEANKERNEL |
392 | depend: .depend | | 402 | depend: .depend |
393 | dependall: depend .WAIT all | | 403 | dependall: depend .WAIT all |
394 | | | 404 | |
395 | ## | | 405 | ## |
396 | ## depend | | 406 | ## depend |
397 | ## | | 407 | ## |
398 | | | 408 | |
399 | .if !target(.depend) | | 409 | .if !target(.depend) |
400 | MKDEP_AFLAGS?= ${AFLAGS} | | 410 | MKDEP_AFLAGS?= ${AFLAGS} |
401 | MKDEP_CFLAGS?= ${CFLAGS} | | 411 | MKDEP_CFLAGS?= ${CFLAGS} |
402 | .if !defined(___USE_SUFFIX_RULES___) | | 412 | .if !defined(___USE_SUFFIX_RULES___) |
403 | DEPS+= ${SRCS:T:R:S/$/.d/g} | | 413 | DEPS+= ${SRCS:T:R:S/$/.d/g} |
404 | .else | | 414 | .else |
405 | DEPS+= ${SRCS:R:S/$/.d/g} | | 415 | DEPS+= ${SRCS:R:S/$/.d/g} |
406 | .endif | | 416 | .endif |
407 | | | 417 | |
408 | .if !defined(___USE_SUFFIX_RULES___) | | 418 | .if !defined(___USE_SUFFIX_RULES___) |
409 | .for _s in ${SSRCS} | | 419 | .for _s in ${SSRCS} |
410 | .if !commands(${_s:T:R}.d) | | 420 | .if !commands(${_s:T:R}.d) |
411 | ${_s:T:R}.d: ${_s} | | 421 | ${_s:T:R}.d: ${_s} |
412 | ${_MKTARGET_CREATE} | | 422 | ${_MKTARGET_CREATE} |
413 | ${MKDEP} -f ${.TARGET}.tmp -- ${MKDEP_AFLAGS} \ | | 423 | ${MKDEP} -f ${.TARGET}.tmp -- ${MKDEP_AFLAGS} \ |
414 | ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s} | | 424 | ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s} |
415 | mv -f ${.TARGET}.tmp ${.TARGET} | | 425 | mv -f ${.TARGET}.tmp ${.TARGET} |
416 | .endif | | 426 | .endif |
417 | .endfor | | 427 | .endfor |
418 | | | 428 | |
419 | .for _s in ${CSRCS} | | 429 | .for _s in ${CSRCS} |
420 | .if !commands(${_s:T:R}.d) | | 430 | .if !commands(${_s:T:R}.d) |
421 | ${_s:T:R}.d: ${_s} | | 431 | ${_s:T:R}.d: ${_s} |
422 | ${_MKTARGET_CREATE} | | 432 | ${_MKTARGET_CREATE} |
423 | ${MKDEP} -f ${.TARGET}.tmp -- ${MKDEP_CFLAGS} \ | | 433 | ${MKDEP} -f ${.TARGET}.tmp -- ${MKDEP_CFLAGS} \ |
424 | ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s} | | 434 | ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s} |
425 | mv -f ${.TARGET}.tmp ${.TARGET} | | 435 | mv -f ${.TARGET}.tmp ${.TARGET} |
426 | .endif | | 436 | .endif |
427 | .endfor | | 437 | .endfor |
428 | .endif # !___USE_SUFFIX_RULES___ | | 438 | .endif # !___USE_SUFFIX_RULES___ |
429 | | | 439 | |
430 | .depend: ${DEPS:O} | | 440 | .depend: ${DEPS:O} |
431 | ${_MKTARGET_CREATE} | | 441 | ${_MKTARGET_CREATE} |
432 | echo "${.ALLSRC}" | ${MKDEP} -D | | 442 | echo "${.ALLSRC}" | ${MKDEP} -D |
433 | .endif | | 443 | .endif |
434 | | | 444 | |
435 | ## | | 445 | ## |
436 | ## install | | 446 | ## install |
437 | ## | | 447 | ## |
438 | | | 448 | |
439 | # List of kernel images that will be installed into the root file system. | | 449 | # List of kernel images that will be installed into the root file system. |
440 | # Some platforms may need to install more than one (e.g. a netbsd.aout file | | 450 | # Some platforms may need to install more than one (e.g. a netbsd.aout file |
441 | # to be loaded directly by the firmware), so this can be overridden by them. | | 451 | # to be loaded directly by the firmware), so this can be overridden by them. |
442 | KERNIMAGES?= netbsd | | 452 | KERNIMAGES?= netbsd |
443 | | | 453 | |
444 | .if !target(install) | | 454 | .if !target(install) |
445 | # The install target can be redefined by putting a | | 455 | # The install target can be redefined by putting a |
446 | # install-kernel-${MACHINE_NAME} target into /etc/mk.conf | | 456 | # install-kernel-${MACHINE_NAME} target into /etc/mk.conf |
447 | MACHINE_NAME!= uname -n | | 457 | MACHINE_NAME!= uname -n |
448 | install: install-kernel-${MACHINE_NAME} | | 458 | install: install-kernel-${MACHINE_NAME} |
449 | .if !target(install-kernel-${MACHINE_NAME}) | | 459 | .if !target(install-kernel-${MACHINE_NAME}) |
450 | install-kernel-${MACHINE_NAME}: | | 460 | install-kernel-${MACHINE_NAME}: |
451 | .for _K in ${KERNIMAGES} | | 461 | .for _K in ${KERNIMAGES} |
452 | .if ${KERNEL_DIR:Uno} == "yes" | | 462 | .if ${KERNEL_DIR:Uno} == "yes" |
453 | rm -fr ${DESTDIR}/o${_K} | | 463 | rm -fr ${DESTDIR}/o${_K} |
454 | mv ${DESTDIR}/${_K} ${DESTDIR}/o${_K} | | 464 | mv ${DESTDIR}/${_K} ${DESTDIR}/o${_K} |
455 | mkdir -p ${DESTDIR}/${_K} | | 465 | mkdir -p ${DESTDIR}/${_K} |
456 | cp ${_K} ${DESTDIR}/${_K}/kernel | | 466 | cp ${_K} ${DESTDIR}/${_K}/kernel |
457 | .else | | 467 | .else |
458 | rm -f ${DESTDIR}/o${_K} | | 468 | rm -f ${DESTDIR}/o${_K} |
459 | ln ${DESTDIR}/${_K} ${DESTDIR}/o${_K} | | 469 | ln ${DESTDIR}/${_K} ${DESTDIR}/o${_K} |
460 | cp ${_K} ${DESTDIR}/n${_K} | | 470 | cp ${_K} ${DESTDIR}/n${_K} |
461 | mv ${DESTDIR}/n${_K} ${DESTDIR}/${_K} | | 471 | mv ${DESTDIR}/n${_K} ${DESTDIR}/${_K} |
462 | .endif | | 472 | .endif |
463 | .endfor | | 473 | .endfor |
464 | .endif | | 474 | .endif |
465 | .endif | | 475 | .endif |
466 | | | 476 | |
467 | ## | | 477 | ## |
468 | ## the kernel | | 478 | ## the kernel |
469 | ## | | 479 | ## |
470 | | | 480 | |
471 | AFLAGS+= ${AOPTS.${.IMPSRC:T}} | | 481 | AFLAGS+= ${AOPTS.${.IMPSRC:T}} |
472 | CFLAGS+= ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} | | 482 | CFLAGS+= ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} |
473 | CPPFLAGS+= ${CPPFLAGS.${.IMPSRC:T}} | | 483 | CPPFLAGS+= ${CPPFLAGS.${.IMPSRC:T}} |
474 | CWARNFLAGS+= ${CWARNFLAGS.${.IMPSRC:T}} | | 484 | CWARNFLAGS+= ${CWARNFLAGS.${.IMPSRC:T}} |
475 | | | 485 | |
476 | .for _v in COPTS CPPFLAGS CWARNFLAGS | | 486 | .for _v in COPTS CPPFLAGS CWARNFLAGS |
477 | .for _c in ${CSRCS} | | 487 | .for _c in ${CSRCS} |
478 | ${_v}.${_c:T}+=${OPT.${_c:T}:@.o.@${${_v}.${.o.}}@} | | 488 | ${_v}.${_c:T}+=${OPT.${_c:T}:@.o.@${${_v}.${.o.}}@} |
479 | .endfor | | 489 | .endfor |
480 | .endfor | | 490 | .endfor |
481 | | | 491 | |
482 | .MAIN: all | | 492 | .MAIN: all |
483 | all: .gdbinit | | 493 | all: .gdbinit |
484 | .for k in ${KERNELS} | | 494 | .for k in ${KERNELS} |
485 | all: .WAIT ${k} | | 495 | all: .WAIT ${k} |
486 | ${k}: ${SYSTEM_DEP:O} swap${k}.o vers.o build_kernel #${MKLINT:Myes:%=lint} | | 496 | ${k}: ${SYSTEM_DEP:O} swap${k}.o vers.o build_kernel #${MKLINT:Myes:%=lint} |
487 | .endfor | | 497 | .endfor |
488 | | | 498 | |
489 | .if !defined(COPY_SYMTAB) | | 499 | .if !defined(COPY_SYMTAB) |
490 | build_kernel: .USE | | 500 | build_kernel: .USE |
491 | ${SYSTEM_LD_HEAD} | | 501 | ${SYSTEM_LD_HEAD} |
492 | ${SYSTEM_LD} | | 502 | ${SYSTEM_LD} |
493 | ${SYSTEM_LD_TAIL_STAGE2} | | 503 | ${SYSTEM_LD_TAIL_STAGE2} |
494 | .else | | 504 | .else |
495 | .for k in ${KERNELS} | | 505 | .for k in ${KERNELS} |
496 | ${k}: $S/kern/kern_ksyms_buf.c | | 506 | ${k}: $S/kern/kern_ksyms_buf.c |
497 | .endfor | | 507 | .endfor |
498 | build_kernel: .USE | | 508 | build_kernel: .USE |
499 | ${CC} ${CFLAGS} ${CPPFLAGS} \ | | 509 | ${CC} ${CFLAGS} ${CPPFLAGS} \ |
500 | -c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf.o | | 510 | -c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf.o |
501 | ${SYSTEM_LD_HEAD} | | 511 | ${SYSTEM_LD_HEAD} |
502 | ${SYSTEM_LD} kern_ksyms_buf.o | | 512 | ${SYSTEM_LD} kern_ksyms_buf.o |
503 | ${SYSTEM_LD_TAIL_STAGE1} | | 513 | ${SYSTEM_LD_TAIL_STAGE1} |
504 | ${CC} ${CFLAGS} ${CPPFLAGS} \ | | 514 | ${CC} ${CFLAGS} ${CPPFLAGS} \ |
505 | -DSYMTAB_SPACE=$$(${DBSYM} -P ${.TARGET}${TARGETSFX}) \ | | 515 | -DSYMTAB_SPACE=$$(${DBSYM} -P ${.TARGET}${TARGETSFX}) \ |
506 | -c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf_real.o | | 516 | -c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf_real.o |
507 | ${SYSTEM_LD_HEAD} | | 517 | ${SYSTEM_LD_HEAD} |
508 | ${SYSTEM_LD} kern_ksyms_buf_real.o | | 518 | ${SYSTEM_LD} kern_ksyms_buf_real.o |
509 | ${SYSTEM_LD_TAIL_STAGE2} | | 519 | ${SYSTEM_LD_TAIL_STAGE2} |
510 | .endif | | 520 | .endif |
511 | | | 521 | |
512 | .include <bsd.files.mk> | | 522 | .include <bsd.files.mk> |
513 | .include <bsd.clang-analyze.mk> | | 523 | .include <bsd.clang-analyze.mk> |
514 | | | 524 | |
515 | ## | | 525 | ## |
516 | ## suffix rules | | 526 | ## suffix rules |
517 | ## | | 527 | ## |
518 | | | 528 | |
519 | .if defined(___USE_SUFFIX_RULES___) | | 529 | .if defined(___USE_SUFFIX_RULES___) |
520 | .SUFFIXES: .s .d | | 530 | .SUFFIXES: .s .d |
521 | .s.d: | | 531 | .s.d: |
522 | ${_MKTARGET_CREATE} | | 532 | ${_MKTARGET_CREATE} |
523 | ${MKDEP} -f $@.tmp -- ${MKDEP_AFLAGS} ${CPPFLAGS} ${CPPFLAGS.${<:T}} $< | | 533 | ${MKDEP} -f $@.tmp -- ${MKDEP_AFLAGS} ${CPPFLAGS} ${CPPFLAGS.${<:T}} $< |
524 | mv -f $@.tmp $@ | | 534 | mv -f $@.tmp $@ |
525 | | | 535 | |
526 | .SUFFIXES: .S .d | | 536 | .SUFFIXES: .S .d |
527 | .S.d: | | 537 | .S.d: |
528 | ${_MKTARGET_CREATE} | | 538 | ${_MKTARGET_CREATE} |
529 | ${MKDEP} -f $@.tmp -- ${MKDEP_AFLAGS} ${CPPFLAGS} ${CPPFLAGS.${<:T}} $< | | 539 | ${MKDEP} -f $@.tmp -- ${MKDEP_AFLAGS} ${CPPFLAGS} ${CPPFLAGS.${<:T}} $< |
530 | mv -f $@.tmp $@ | | 540 | mv -f $@.tmp $@ |
531 | | | 541 | |
532 | .SUFFIXES: .c .d | | 542 | .SUFFIXES: .c .d |
533 | .c.d: | | 543 | .c.d: |
534 | ${_MKTARGET_CREATE} | | 544 | ${_MKTARGET_CREATE} |
535 | ${MKDEP} -f $@.tmp -- ${MKDEP_CFLAGS} ${CPPFLAGS} ${CPPFLAGS.${<:T}} $< | | 545 | ${MKDEP} -f $@.tmp -- ${MKDEP_CFLAGS} ${CPPFLAGS} ${CPPFLAGS.${<:T}} $< |
536 | mv -f $@.tmp $@ | | 546 | mv -f $@.tmp $@ |
537 | | | 547 | |
538 | .SUFFIXES: .c .o .go .po | | 548 | .SUFFIXES: .c .o .go .po |
539 | .c.o: | | 549 | .c.o: |
540 | @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" | | 550 | @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" |
541 | @${_MKSHECHO} ${KCOMPILE.c} | | 551 | @${_MKSHECHO} ${KCOMPILE.c} |
542 | @${KCOMPILE.c} | | 552 | @${KCOMPILE.c} |
543 | @${COMPILE_CTFCONVERT} | | 553 | @${COMPILE_CTFCONVERT} |
544 | .c.go: | | 554 | .c.go: |
545 | @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" | | 555 | @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" |
546 | @${_MKSHECHO} ${KCOMPILE.c} -g | | 556 | @${_MKSHECHO} ${KCOMPILE.c} -g |
547 | @${KCOMPILE.c} -g | | 557 | @${KCOMPILE.c} -g |
548 | @${COMPILE_CTFCONVERT} | | 558 | @${COMPILE_CTFCONVERT} |
549 | .c.po: | | 559 | .c.po: |
550 | @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" | | 560 | @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" |
551 | @${_MKSHECHO} ${KCOMPILE.c} -pg | | 561 | @${_MKSHECHO} ${KCOMPILE.c} -pg |
552 | @${KCOMPILE.c} -pg | | 562 | @${KCOMPILE.c} -pg |
553 | @${COMPILE_CTFCONVERT} | | 563 | @${COMPILE_CTFCONVERT} |
554 | | | 564 | |
555 | .SUFFIXES: .s .o .go .po | | 565 | .SUFFIXES: .s .o .go .po |
556 | .s.o: | | 566 | .s.o: |
557 | @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" | | 567 | @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" |
558 | @${_MKSHECHO} ${KCOMPILE.s} | | 568 | @${_MKSHECHO} ${KCOMPILE.s} |
559 | @${KCOMPILE.s} | | 569 | @${KCOMPILE.s} |
560 | .s.go: | | 570 | .s.go: |
561 | @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" | | 571 | @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" |
562 | @${_MKSHECHO} ${KCOMPILE.s} -g | | 572 | @${_MKSHECHO} ${KCOMPILE.s} -g |
563 | @${KCOMPILE.s} -g | | 573 | @${KCOMPILE.s} -g |
564 | .s.po: | | 574 | .s.po: |
565 | @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" | | 575 | @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" |
566 | @${_MKSHECHO} ${KCOMPILE.s} -pg | | 576 | @${_MKSHECHO} ${KCOMPILE.s} -pg |
567 | @${KCOMPILE.s} -pg | | 577 | @${KCOMPILE.s} -pg |
568 | | | 578 | |
569 | .S.o: | | 579 | .S.o: |
570 | @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" | | 580 | @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" |
571 | @${_MKSHECHO} ${KCOMPILE.s} | | 581 | @${_MKSHECHO} ${KCOMPILE.s} |
572 | @${KCOMPILE.s} | | 582 | @${KCOMPILE.s} |
573 | .S.go: | | 583 | .S.go: |
574 | @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" | | 584 | @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" |
575 | @${_MKSHECHO} ${KCOMPILE.s} -g | | 585 | @${_MKSHECHO} ${KCOMPILE.s} -g |
576 | @${KCOMPILE.s} -g | | 586 | @${KCOMPILE.s} -g |
577 | .S.po: | | 587 | .S.po: |
578 | @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" | | 588 | @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" |
579 | @${_MKSHECHO} ${KCOMPILE.s} -pg | | 589 | @${_MKSHECHO} ${KCOMPILE.s} -pg |
580 | @${KCOMPILE.s} -pg | | 590 | @${KCOMPILE.s} -pg |
581 | .endif # ___USE_SUFFIX_RULES___ | | 591 | .endif # ___USE_SUFFIX_RULES___ |
582 | | | 592 | |
583 | ## | | 593 | ## |
584 | ## the end | | 594 | ## the end |
585 | ## | | 595 | ## |