Makefile.kern.inc revision 1.203 1 # $NetBSD: Makefile.kern.inc,v 1.203 2015/08/29 14:07:45 uebayasi Exp $
2 #
3 # This file contains common `MI' targets and definitions and it is included
4 # at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}.
5 #
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
8 # assigned `VAR ?= VALUE', so that everything can be overriden.
9 #
10 # DEBUG is set to -g if debugging.
11 # PROF is set to -pg if profiling.
12 #
13 # To specify debugging, add the config line: makeoptions DEBUG="-g"
14 # A better way is to specify -g only for a few files.
15 #
16 # makeoptions DEBUGLIST="uvm* trap if_*"
17 #
18 # all ports are expected to include bsd.own.mk for toolchain settings
19
20 # Default DEBUG to -g if kernel debug info is requested by MKKDEBUG=yes
21 .if defined(MKKDEBUG) && ${MKKDEBUG} == "yes"
22 DEBUG?=-g
23 .endif
24
25 ##
26 ## (0) toolchain settings for things that aren't part of the standard
27 ## toolchain
28 ##
29 HOST_SH?= sh
30 DBSYM?= dbsym
31 MKDEP?= mkdep
32 STRIP?= strip
33 OBJCOPY?= objcopy
34 OBJDUMP?= objdump
35 CSCOPE?= cscope
36 MKID?= mkid
37 UUDECODE?= ${TOOL_UUDECODE:Uuudecode}
38 HEXDUMP?= ${TOOL_HEXDUMP:Uhexdump}
39 GENASSYM?= ${TOOL_GENASSYM:Ugenassym}
40 .MAKEOVERRIDES+=USETOOLS # make sure proper value is propagated
41
42 _MKMSG?= @\#
43 _MKSHMSG?= echo
44 _MKSHECHO?= echo
45 _MKSHNOECHO= :
46 _MKMSG_CREATE?= :
47 _MKTARGET_COMPILE?= :
48 _MKTARGET_CREATE?= :
49
50 ##
51 ## (1) port independent source tree identification
52 ##
53 # source tree is located via $S relative to the compilation directory
54 .ifndef S
55 S!= cd ../../../..; pwd
56 .endif
57
58 ##
59 ## (2) compile settings
60 ##
61 ## CPPFLAGS, CFLAGS, and AFLAGS must be set in the port's Makefile
62 ##
63 INCLUDES?= -I. ${EXTRA_INCLUDES} -I${S}/../common/include -I$S/arch \
64 -I$S -nostdinc
65 CPPFLAGS+= ${INCLUDES} ${IDENT} -D_KERNEL -D_KERNEL_OPT
66 CPPFLAGS+= -std=gnu99
67 DEFCOPTS?= -O2
68 COPTS?= ${DEFCOPTS}
69 DBG= # might contain unwanted -Ofoo
70 DEFWARNINGS?= yes
71 .if (${DEFWARNINGS} == "yes")
72 CWARNFLAGS+= -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith
73 CWARNFLAGS+= -Wmissing-prototypes -Wstrict-prototypes
74 CWARNFLAGS+= -Wold-style-definition
75 CWARNFLAGS+= -Wswitch -Wshadow
76 CWARNFLAGS+= -Wcast-qual -Wwrite-strings
77 CWARNFLAGS+= -Wno-unreachable-code
78 #CWARNFLAGS+= -Wc++-compat -Wno-error=c++-compat
79 CWARNFLAGS+= -Wno-pointer-sign -Wno-attributes
80 . if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64" || \
81 ${MACHINE_ARCH} == "sparc64" || ${MACHINE} == "prep"
82 CWARNFLAGS+= -Wextra -Wno-unused-parameter
83 . endif
84 . if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64"
85 CWARNFLAGS+= -Wold-style-definition
86 . endif
87 # Add -Wno-sign-compare. -Wsign-compare is included in -Wall as of GCC 3.3,
88 # but our sources aren't up for it yet.
89 CWARNFLAGS+= -Wno-sign-compare
90 .endif
91
92 CWARNFLAGS.clang+= -Wno-unknown-pragmas -Wno-conversion \
93 -Wno-self-assign
94
95 CWARNFLAGS.ah_regdomain.c= ${${ACTIVE_CC} == "clang":? \
96 -Wno-shift-count-negative -Wno-shift-count-overflow:}
97
98 CWARNFLAGS.ioconf.c= ${${ACTIVE_CC} == "clang":? -Wno-unused-const-variable :}
99
100 CFLAGS+= -ffreestanding -fno-zero-initialized-in-bss
101 CFLAGS+= ${DEBUG} ${COPTS}
102 AFLAGS+= -D_LOCORE -Wa,--fatal-warnings
103
104 # XXX
105 .if defined(HAVE_GCC) || defined(HAVE_LLVM)
106 CFLAGS+= -fno-strict-aliasing
107 CFLAGS+= -fno-common
108 .endif
109
110 .if ${USE_SSP:Uno} == "yes"
111 COPTS.kern_ssp.c+= -fno-stack-protector -D__SSP__
112 .endif
113
114 # for multi-cpu machines, cpu_hatch() straddles the init of
115 # __stack_chk_guard, so ensure stack protection is disabled
116 .if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64"
117 COPTS.cpu.c+= -fno-stack-protector
118 .endif
119
120 # Use the per-source COPTS variables to add -g to just those
121 # files that match the shell patterns given in ${DEBUGLIST}
122 #
123 .for i in ${DEBUGLIST}
124 . for j in ${CFILES:T:M$i.c}
125 COPTS.${j}+=-g
126 . endfor
127 .endfor
128
129 # Always compile debugsyms.c with debug information.
130 # This allows gdb to use type informations.
131 #
132 COPTS.debugsyms.c+= -g
133
134 # Add CTF sections for DTrace
135 .if defined(CTFCONVERT)
136 COMPILE_CTFCONVERT= ${_MKSHECHO}\
137 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \
138 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
139 .else
140 COMPILE_CTFCONVERT= ${_MKSHNOECHO}
141 .endif
142
143 # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
144 # NOPROF and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
145 NORMAL_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \
146 ${_MKSHECHO}\
147 ${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< -o $@ && \
148 ${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< -o $@ && \
149 ${COMPILE_CTFCONVERT}
150 NOPROF_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \
151 ${_MKSHECHO}\
152 ${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} -c $< -o $@ && \
153 ${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} -c $< -o $@ && \
154 ${COMPILE_CTFCONVERT}
155 NORMAL_S?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \
156 ${_MKSHECHO}\
157 ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} -c $< -o $@ && \
158 ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} -c $< -o $@
159
160 # link rules:
161 LINK_O?= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}" && \
162 ${_MKSHECHO}\
163 ${LD} -r ${LINKFORMAT} -Map=${.TARGET}.map -o ${.TARGET} ${.ALLSRC} && \
164 ${LD} -r ${LINKFORMAT} -Map=${.TARGET}.map -o ${.TARGET} ${.ALLSRC}
165
166 ##
167 ## (3) libkern and compat
168 ##
169 ## Set KERN_AS in the port Makefile to "obj" or "library". The
170 ## default is "library", as documented in $S/lib/libkern/Makefile.inc.
171 ##
172
173 ### find out what to use for libkern
174 .include "$S/lib/libkern/Makefile.inc"
175 .ifndef PROF
176 LIBKERN?= ${KERNLIB}
177 .else
178 LIBKERN?= ${KERNLIB_PROF}
179 .endif
180
181 LIBKERNLN?= ${KERNLIBLN}
182
183 ### find out what to use for libcompat
184 .include "$S/compat/common/Makefile.inc"
185 .ifndef PROF
186 SYSLIBCOMPAT?= ${COMPATLIB}
187 .else
188 SYSLIBCOMPAT?= ${COMPATLIB_PROF}
189 .endif
190
191 SYSLIBCOMPATLN?= ${COMPATLIBLN}
192
193 ##
194 ## (4) local objects, compile rules, and dependencies
195 ##
196 ## Each port should have a corresponding section with settings for
197 ## MD_CFILES, MD_SFILES, and MD_OBJS, along with build rules for same.
198 ##
199 MI_CFILES=devsw.c ioconf.c param.c
200 # the need for a MI_SFILES variable is dubitable at best
201 MI_OBJS=${MI_CFILES:S/.c/.o/}
202
203 param.c: $S/conf/param.c
204 ${_MKTARGET_CREATE}
205 rm -f param.c
206 cp $S/conf/param.c .
207
208 param.o: Makefile
209
210 .for _cfile in ${MI_CFILES}
211 ${_cfile:T:R}.o: ${_cfile}
212 ${NORMAL_C}
213 .endfor
214
215 ##
216 ## (5) link settings
217 ##
218 ## TEXTADDR (or LOADADDRESS), LINKFORMAT, LINKSCRIPT, and any EXTRA_LINKFLAGS
219 ## must be set in the port's Makefile. The port specific definitions for
220 ## LINKFLAGS_NORMAL and LINKFLAGS_DEBUG will added to the LINKFLAGS
221 ## depending on the value of DEBUG.
222 ##
223 # load lines for config "xxx" will be emitted as:
224 # xxx: ${SYSTEM_DEP} swapxxxx.o vers.o build_kernel
225
226 .if !empty(OBJS:Mnetbsd.ko)
227 SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS} ${SYSLIBCOMPAT} ${LIBKERN}
228 .else
229 SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS:O} ${SYSLIBCOMPAT} ${LIBKERN}
230 .endif
231 SYSTEM_DEP+= Makefile ${SYSTEM_OBJ} .gdbinit
232 .if defined(CTFMERGE)
233 SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o
234 .else
235 SYSTEM_CTFMERGE= ${_MKSHECHO}
236 .endif
237 SYSTEM_LD_HEAD?=@rm -f $@
238 SYSTEM_LD?= @do_system_ld() { \
239 target=$$1; shift; \
240 ${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}"; \
241 ${_MKSHECHO}\
242 ${LD} -Map $${target}.map --cref ${LINKFLAGS} -o $${target} '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o $$@; \
243 ${LD} -Map $${target}.map --cref ${LINKFLAGS} -o $${target} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o $$@; \
244 }; \
245 do_system_ld
246
247 # Give MD generated ldscript dependency on ${SYSTEM_OBJ}
248 .if defined(KERNLDSCRIPT)
249 .if target(${KERNLDSCRIPT})
250 ${KERNLDSCRIPT}: ${SYSTEM_OBJ}
251 .endif
252 .endif
253
254 .if defined(KERNLDSCRIPT)
255 .for k in ${KERNELS}
256 EXTRA_CLEAN+= ${k}.ldscript
257 ${k}: ${k}.ldscript
258 ${k}.ldscript: ${KERNLDSCRIPT} assym.h
259 ${_MKTARGET_CREATE}
260 ${CPP} -I. ${KERNLDSCRIPT} | grep -v '^#' | grep -v '^$$' >$@
261 .endfor
262 LINKSCRIPT= -T ${.TARGET}.ldscript
263 .endif
264
265 TEXTADDR?= ${LOADADDRESS} # backwards compatibility
266 LINKTEXT?= ${TEXTADDR:C/.+/-Ttext &/}
267 LINKDATA?= ${DATAADDR:C/.+/-Tdata &/}
268 ENTRYPOINT?= start
269 LINKENTRY?= ${ENTRYPOINT:C/.+/-e &/}
270 LINKFLAGS?= ${LINKFORMAT} ${LINKSCRIPT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \
271 ${EXTRA_LINKFLAGS}
272
273 LINKFLAGS_DEBUG?= -X
274
275 SYSTEM_LD_TAIL?=@${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c; \
276 ${SIZE} $@; chmod 755 $@; \
277 ${SYSTEM_CTFMERGE}
278 SYSTEM_LD_TAIL_DEBUG?=; \
279 echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
280 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
281 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
282 LINKFLAGS_NORMAL?= -S
283 STRIPFLAGS?= -g
284
285 DEBUG?=
286 .if !empty(DEBUG:M-g*)
287 SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_DEBUG}
288 LINKFLAGS+= ${LINKFLAGS_DEBUG}
289 EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.gdb@}
290 CTFFLAGS+= -g
291 TARGETSFX= .gdb
292 .elifndef PROF
293 LINKFLAGS+= ${LINKFLAGS_NORMAL}
294 .endif
295
296 SYSTEM_LD_HEAD+=${SYSTEM_LD_HEAD_EXTRA}
297 SYSTEM_LD_TAIL_STAGE1= ${SYSTEM_LD_TAIL}
298 SYSTEM_LD_TAIL_STAGE2= ${SYSTEM_LD_TAIL}
299 .if defined(COPY_SYMTAB)
300 SYSTEM_LD_TAIL_STAGE2+= ; echo ${DBSYM} $@; ${DBSYM} $@
301 .if !empty(DEBUG:M-g)
302 SYSTEM_LD_TAIL_STAGE2+= ; echo ${DBSYM} $@.gdb; ${DBSYM} $@.gdb
303 .endif
304 .endif
305 SYSTEM_LD_TAIL_STAGE2+= ${SYSTEM_LD_TAIL_EXTRA}
306
307 ##
308 ## (6) port independent targets and dependencies: assym.h, vers.o
309 ##
310
311 .SUFFIXES: .genassym .assym.h
312 .genassym.assym.h:
313 ${_MKTARGET_CREATE}
314 cat $< | \
315 ${GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${PROF} \
316 ${GENASSYM_CPPFLAGS} > $@.tmp && \
317 mv -f $@.tmp $@
318
319 assym.h: ${GENASSYM_CONF} ${GENASSYM_EXTRAS} $S/conf/genassym.cf
320 ${_MKTARGET_CREATE}
321 cat ${GENASSYM_CONF} ${GENASSYM_EXTRAS} $S/conf/genassym.cf | \
322 ${GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${PROF} \
323 ${GENASSYM_CPPFLAGS} > assym.h.tmp && \
324 mv -f assym.h.tmp assym.h
325 ${MD_SFILES:C/\.[Ss]/.o/} ${SFILES:C/\.[Ss]/.o/}: assym.h
326
327 MKREPRO?=no
328
329 .if ${MKREPRO} == "yes"
330 _NVFLAGS=${NVFLAGS} -r
331 .else
332 _NVFLAGS=${NVFLAGS}
333 .endif
334
335 .if !target(vers.o)
336 newvers: vers.o
337 vers.o: ${SYSTEM_OBJ} Makefile $S/conf/newvers.sh \
338 $S/conf/osrelease.sh ${_NETBSD_VERSION_DEPENDS}
339 ${_MKMSG_CREATE} vers.c
340 ${HOST_SH} $S/conf/newvers.sh ${_NVFLAGS}
341 ${_MKTARGET_COMPILE}
342 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
343 ${COMPILE_CTFCONVERT}
344 .endif
345
346 # Option for embedding a splashscreen image.
347 .if defined(SPLASHSCREEN_IMAGE)
348 .include "${S}/dev/splash/splash.mk"
349 init_main.o: splash_image.o
350 .endif
351
352 .if defined(MEMORY_DISK_IMAGE)
353 md_root_image.h: ${MEMORY_DISK_IMAGE}
354 ${_MKTARGET_CREATE}
355 ${TOOL_HEXDUMP} -v -e '"\t" 8/1 "0x%02x, " "\n"' ${.ALLSRC} > ${.TARGET}
356
357 # XXX This is only needed when building md_root.o
358 CPPFLAGS+= -DMEMORY_DISK_IMAGE
359 md_root.o: md_root_image.h
360 .endif
361
362 # depend on MEMORY_DISK_IMAGE configuration
363 md_root.o: Makefile
364
365 # depend on root or device configuration
366 autoconf.o conf.o: Makefile
367
368 # depend on network or filesystem configuration
369 uipc_proto.o vfs_conf.o: Makefile
370
371 # depend on maxusers and CPU configuration
372 assym.h machdep.o: Makefile
373
374 ##
375 ## (7) misc targets: install, clean(dir), depend(all), lint, links, tags,
376 ## cscope, mkid
377 ##
378 ## Any ports that have other stuff to be cleaned up should fill in
379 ## EXTRA_CLEAN. Some ports may want different settings for
380 ## KERNLINTFLAGS, MKDEP_CFLAGS, or MKDEP_AFLAGS.
381 ##
382
383 ##
384 ## clean
385 ##
386
387 .if !target(__CLEANKERNEL)
388 __CLEANKERNEL: .USE
389 ${_MKMSG} "${.TARGET}ing the kernel objects"
390 rm -f ${KERNELS} *.map eddep tags *.[io] *.ko *.ln [a-z]*.s vers.c \
391 [Ee]rrs linterrs makelinks assym.h.tmp assym.h \
392 ${EXTRA_KERNELS} ${EXTRA_CLEAN}
393 .endif
394
395 .if !target(kernelnames)
396 kernelnames:
397 @echo "${KERNELS} ${EXTRA_KERNELS}"
398 .endif
399
400 .if !target(__CLEANDEPEND)
401 __CLEANDEPEND: .USE
402 echo .depend ${DEPS} | xargs rm -f --
403 .endif
404
405 # do not !target these, the kern and compat Makefiles augment them
406 cleandir distclean: __CLEANKERNEL __CLEANDEPEND
407 clean: __CLEANKERNEL
408 depend: .depend
409 dependall: depend .WAIT all
410
411 ##
412 ## depend
413 ##
414
415 .if !target(.depend)
416 MKDEP_AFLAGS?= ${AFLAGS}
417 MKDEP_CFLAGS?= ${CFLAGS}
418 SSRCS=${MD_SFILES} ${SFILES}
419 CSRCS=${MD_CFILES} ${MI_CFILES} ${CFILES}
420 SRCS=${SSRCS} ${CSRCS}
421 DEPS= ${SRCS:T:u:R:S/$/.d/g}
422
423 .SUFFIXES: .S .d
424 .S.d:
425 ${_MKTARGET_CREATE}
426 ${MKDEP} -f ${.TARGET} -- ${MKDEP_AFLAGS} \
427 ${CPPFLAGS} ${CPPFLAGS.${_s:T}} $<
428
429 .for _s in ${SSRCS}
430 .if !target(${_s:T:R}.d)
431 ${_s:T:R}.d: ${_s} assym.h
432 ${_MKTARGET_CREATE}
433 ${MKDEP} -f ${.TARGET} -- ${MKDEP_AFLAGS} \
434 ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s}
435 .endif
436 .endfor
437
438 .SUFFIXES: .c .d
439 .c.d:
440 ${_MKTARGET_CREATE}
441 ${MKDEP} -f ${.TARGET} -- ${MKDEP_CFLAGS} \
442 ${CPPFLAGS} ${CPPFLAGS.${_s:T}} $<
443
444 .for _s in ${CSRCS}
445 .if !target(${_s:T:R}.d)
446 ${_s:T:R}.d: ${_s}
447 ${_MKTARGET_CREATE}
448 ${MKDEP} -f ${.TARGET} -- ${MKDEP_CFLAGS} \
449 ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s}
450 .endif
451 .endfor
452
453 assym.d: assym.h
454 ${_MKTARGET_CREATE}
455 cat ${GENASSYM_CONF} ${GENASSYM_EXTRAS} | \
456 ${GENASSYM} -- ${MKDEP} -f assym.dep -- \
457 ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${GENASSYM_CPPFLAGS}
458 ${TOOL_SED} -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >${.TARGET}
459 rm -f assym.dep
460
461 DEPS+= assym.d
462
463 .depend: ${DEPS}
464 ${_MKTARGET_CREATE}
465 echo "${.ALLSRC}" | ${MKDEP} -D
466 .endif
467
468 ##
469 ## lint
470 ##
471
472 .if !target(lint)
473 ALLSFILES?= ${MD_SFILES} ${SFILES}
474 LINTSTUBS?= ${ALLSFILES:T:R:C/^.*$/LintStub_&.c/g}
475 KERNLINTFLAGS?= -bcehnxzFS
476 NORMAL_LN?= ${LINT} ${KERNLINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i $< -o $@
477
478 _lsrc=${CFILES} ${LINTSTUBS} ${MI_CFILES} ${MD_CFILES}
479 LOBJS?= ${_lsrc:T:S/.c$/.ln/g} ${LIBKERNLN} ${SYSLIBCOMPATLN}
480
481 .for _sfile in ${ALLSFILES}
482 LintStub_${_sfile:T:R}.c: ${_sfile} assym.h
483 ${_MKTARGET_COMPILE}
484 ${CC} -E -C ${AFLAGS} ${CPPFLAGS} ${_sfile} | \
485 ${TOOL_AWK} -f $S/kern/genlintstub.awk >${.TARGET}
486 .endfor
487
488 .for _cfile in ${CFILES} ${LINTSTUBS} ${MI_CFILES} ${MD_CFILES}
489 ${_cfile:T:R}.ln: ${_cfile}
490 ${_MKTARGET_COMPILE}
491 ${NORMAL_LN}
492 .endfor
493
494 lint: ${LOBJS}
495 ${LINT} ${KERNLINTFLAGS} ${CPPFLAGS:M-[IDU]*} ${LOBJS}
496 .endif
497
498 # Attempt to do a syntax-only compile of the entire kernel as one entity.
499 # Alas, bugs in the GCC C frontend prevent this from completely effective
500 # but information can be gleaned from the output.
501 syntax-only: ${CFILES} ${MD_CFILES}
502 ${CC} -fsyntax-only -combine ${CFLAGS} ${CPPFLAGS} \
503 ${CFILES} ${MD_CFILES}
504
505 # List of kernel images that will be installed into the root file system.
506 # Some platforms may need to install more than one (e.g. a netbsd.aout file
507 # to be loaded directly by the firmware), so this can be overriden by them.
508 KERNIMAGES?= netbsd
509
510 ##
511 ## install
512 ##
513
514 .if !target(install)
515 # The install target can be redefined by putting a
516 # install-kernel-${MACHINE_NAME} target into /etc/mk.conf
517 MACHINE_NAME!= uname -n
518 install: install-kernel-${MACHINE_NAME}
519 .if !target(install-kernel-${MACHINE_NAME})
520 install-kernel-${MACHINE_NAME}:
521 .for _K in ${KERNIMAGES}
522 rm -f ${DESTDIR}/o${_K}
523 ln ${DESTDIR}/${_K} ${DESTDIR}/o${_K}
524 cp ${_K} ${DESTDIR}/n${_K}
525 mv ${DESTDIR}/n${_K} ${DESTDIR}/${_K}
526 .endfor
527 .endif
528 .endif
529
530 ##
531 ## tags
532 ##
533
534 .if !target(tags)
535 tags:
536 @echo "see $S/kern/Makefile for tags"
537 .endif
538
539 ##
540 ## cscope
541 ##
542
543 EXTRA_CLEAN+= cscope.out cscope.tmp
544 .if !target(cscope.out)
545 cscope.out: Makefile depend
546 ${_MKTARGET_CREATE}
547 @${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\ *$$//;' lib/kern/.depend \
548 | tr -s ' ' '\n' \
549 | ${TOOL_SED} ';s|^../../||;' \
550 > cscope.tmp
551 @${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\ *$$//;' lib/compat/.depend \
552 | tr -s ' ' '\n' \
553 | ${TOOL_SED} 's|^../../||;' \
554 >> cscope.tmp
555 @echo ${SRCS} | cat - cscope.tmp | tr -s ' ' '\n' | sort -u | \
556 ${CSCOPE} -k -i - -b `echo ${INCLUDES} | ${TOOL_SED} s/-nostdinc//`
557 # cscope doesn't write cscope.out if it's uptodate, so ensure
558 # make doesn't keep calling cscope when not needed.
559 @rm -f cscope.tmp; touch cscope.out
560 .endif
561
562 .if !target(cscope)
563 cscope: cscope.out
564 @${CSCOPE} -d
565 .endif
566
567 EXTRA_CLEAN+= ID
568 .if !target(mkid)
569 .PHONY: mkid
570 mkid: ID
571
572 ID: Makefile depend
573 ${_MKTARGET_CREATE}
574 @${MKID} \
575 `${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\\\ *$$//;' \
576 lib/kern/.depend lib/compat/.depend \
577 | tr ' ' '\n' \
578 | ${TOOL_SED} "s|^../../||" \
579 | sort -u` \
580 `${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\\\ *$$//;' \
581 .depend \
582 | tr ' ' '\n' \
583 | sort -u`
584
585 .endif
586
587 ##
588 ## .gdbinit
589 ##
590
591 .include "${S}/gdbscripts/Makefile.inc"
592
593 EXTRA_CLEAN+= .gdbinit
594 .gdbinit: Makefile ${S}/gdbscripts/Makefile.inc
595 ${_MKTARGET_CREATE}
596 rm -f .gdbinit
597 .for __gdbinit in ${SYS_GDBINIT}
598 echo "source ${S}/gdbscripts/${__gdbinit}" >> .gdbinit
599 .endfor
600 .if defined(GDBINIT) && !empty(GDBINIT)
601 .for __gdbinit in ${GDBINIT}
602 echo "source ${__gdbinit}" >> .gdbinit
603 .endfor
604 .endif
605
606 ##
607 ## the kernel
608 ##
609
610 # The following files use alloca(3) or variable array allocations.
611 # Their full name is noted as documentation.
612 VARSTACK=kern/uipc_socket.c miscfs/genfs/genfs_vnops.c \
613 nfs/nfs_bio.c uvm/uvm_bio.c \
614 uvm/uvm_pager.c dev/ic/aic7xxx.c dev/ic/aic79xx.c arch/xen/i386/gdt.c \
615 dev/ofw/ofw_subr.c
616
617 .for __varstack in ${VARSTACK}
618 COPTS.${__varstack:T} += -Wno-stack-protector
619 .endfor
620
621 AFLAGS+= ${AOPTS.${.IMPSRC:T}}
622 CFLAGS+= ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}}
623 CPPFLAGS+= ${CPPFLAGS.${.IMPSRC:T}}
624 CWARNFLAGS+= ${CWARNFLAGS.${.IMPSRC:T}}
625
626 locore.o machdep.o kern_ksyms.o: Makefile
627
628 .if defined(COPY_SYMTAB)
629 CPPFLAGS.locore.S+= -DCOPY_SYMTAB
630 CPPFLAGS.machdep.c+= -DCOPY_SYMTAB
631 CPPFLAGS.kern_ksyms.c+= -DCOPY_SYMTAB
632 CPPFLAGS.kern_ksyms_buf.c+= -DCOPY_SYMTAB
633 .endif
634
635 .if !defined(COPY_SYMTAB)
636 build_kernel: .USE
637 ${SYSTEM_LD_HEAD}
638 ${SYSTEM_LD} ${.TARGET} swap${.TARGET}.o
639 ${SYSTEM_LD_TAIL_STAGE2}
640 .else
641 .for k in ${KERNELS}
642 ${k}: $S/kern/kern_ksyms_buf.c
643 .endfor
644 build_kernel: .USE
645 ${CC} ${CFLAGS} ${CPPFLAGS} -DCOPY_SYMTAB \
646 -c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf.o
647 ${SYSTEM_LD_HEAD}
648 ${SYSTEM_LD} ${.TARGET} swap${.TARGET}.o kern_ksyms_buf.o
649 ${SYSTEM_LD_TAIL_STAGE1}
650 ${CC} ${CFLAGS} ${CPPFLAGS} -DCOPY_SYMTAB \
651 -DSYMTAB_SPACE=$$(${DBSYM} -P ${.TARGET}${TARGETSFX}) \
652 -c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf_real.o
653 ${SYSTEM_LD_HEAD}
654 ${SYSTEM_LD} ${.TARGET} swap${.TARGET}.o kern_ksyms_buf_real.o
655 ${SYSTEM_LD_TAIL_STAGE2}
656 .endif
657
658 .include <bsd.files.mk>
659 .include <bsd.clang-analyze.mk>
660
661 ##
662 ## the end
663 ##
664