Annotation of src/sys/conf/Makefile.kern.inc, Revision 1.206
1.190 uebayasi 1: # $NetBSD$
1.1 atatat 2: #
3: # This file contains common `MI' targets and definitions and it is included
1.31 atatat 4: # at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}.
1.1 atatat 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: #
1.59 perry 13: # To specify debugging, add the config line: makeoptions DEBUG="-g"
1.1 atatat 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:
1.168 martin 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:
1.1 atatat 25: ##
1.3 atatat 26: ## (0) toolchain settings for things that aren't part of the standard
27: ## toolchain
28: ##
1.45 lukem 29: HOST_SH?= sh
1.15 tv 30: DBSYM?= dbsym
1.3 atatat 31: MKDEP?= mkdep
32: STRIP?= strip
33: OBJCOPY?= objcopy
34: OBJDUMP?= objdump
1.16 wrstuden 35: CSCOPE?= cscope
36: MKID?= mkid
1.55 atatat 37: UUDECODE?= ${TOOL_UUDECODE:Uuudecode}
1.63 christos 38: HEXDUMP?= ${TOOL_HEXDUMP:Uhexdump}
39: GENASSYM?= ${TOOL_GENASSYM:Ugenassym}
1.12 tv 40: .MAKEOVERRIDES+=USETOOLS # make sure proper value is propagated
1.46 lukem 41:
42: _MKMSG?= @\#
1.49 pk 43: _MKSHMSG?= echo
44: _MKSHECHO?= echo
1.156 martin 45: _MKSHNOECHO= :
1.46 lukem 46: _MKMSG_CREATE?= :
47: _MKTARGET_COMPILE?= :
48: _MKTARGET_CREATE?= :
1.3 atatat 49:
50: ##
1.1 atatat 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: ##
1.77 thorpej 63: INCLUDES?= -I. ${EXTRA_INCLUDES} -I${S}/../common/include -I$S/arch \
1.164 mbalmer 64: -I$S -nostdinc
1.203 uebayasi 65: CPPFLAGS+= ${INCLUDES} ${IDENT} -D_KERNEL -D_KERNEL_OPT
1.128 matt 66: CPPFLAGS+= -std=gnu99
1.4 atatat 67: DEFCOPTS?= -O2
1.25 fvdl 68: COPTS?= ${DEFCOPTS}
1.7 atatat 69: DBG= # might contain unwanted -Ofoo
70: DEFWARNINGS?= yes
71: .if (${DEFWARNINGS} == "yes")
1.37 matt 72: CWARNFLAGS+= -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith
1.7 atatat 73: CWARNFLAGS+= -Wmissing-prototypes -Wstrict-prototypes
1.152 matt 74: CWARNFLAGS+= -Wold-style-definition
1.68 martin 75: CWARNFLAGS+= -Wswitch -Wshadow
1.62 christos 76: CWARNFLAGS+= -Wcast-qual -Wwrite-strings
1.113 gmcgarry 77: CWARNFLAGS+= -Wno-unreachable-code
1.173 matt 78: #CWARNFLAGS+= -Wc++-compat -Wno-error=c++-compat
1.81 christos 79: CWARNFLAGS+= -Wno-pointer-sign -Wno-attributes
1.116 tron 80: . if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64" || \
81: ${MACHINE_ARCH} == "sparc64" || ${MACHINE} == "prep"
1.89 martin 82: CWARNFLAGS+= -Wextra -Wno-unused-parameter
1.87 christos 83: . endif
1.151 christos 84: . if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64"
85: CWARNFLAGS+= -Wold-style-definition
86: . endif
1.136 joerg 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
1.7 atatat 90: .endif
1.42 jdolecek 91:
1.137 joerg 92: CWARNFLAGS.clang+= -Wno-unknown-pragmas -Wno-conversion \
1.144 joerg 93: -Wno-self-assign
1.137 joerg 94:
1.150 joerg 95: CWARNFLAGS.ah_regdomain.c= ${${ACTIVE_CC} == "clang":? \
96: -Wno-shift-count-negative -Wno-shift-count-overflow:}
97:
1.162 joerg 98: CWARNFLAGS.ioconf.c= ${${ACTIVE_CC} == "clang":? -Wno-unused-const-variable :}
99:
1.82 mrg 100: CFLAGS+= -ffreestanding -fno-zero-initialized-in-bss
1.115 tron 101: CFLAGS+= ${DEBUG} ${COPTS}
1.134 joerg 102: AFLAGS+= -D_LOCORE -Wa,--fatal-warnings
1.53 matt 103:
1.78 mrg 104: # XXX
1.158 joerg 105: .if defined(HAVE_GCC) || defined(HAVE_LLVM)
1.78 mrg 106: CFLAGS+= -fno-strict-aliasing
1.157 matt 107: CFLAGS+= -fno-common
1.78 mrg 108: .endif
109:
1.103 tls 110: .if ${USE_SSP:Uno} == "yes"
1.121 christos 111: COPTS.kern_ssp.c+= -fno-stack-protector -D__SSP__
1.92 christos 112: .endif
113:
1.148 plunky 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:
1.45 lukem 120: # Use the per-source COPTS variables to add -g to just those
1.1 atatat 121: # files that match the shell patterns given in ${DEBUGLIST}
122: #
123: .for i in ${DEBUGLIST}
1.87 christos 124: . for j in ${CFILES:T:M$i.c}
1.45 lukem 125: COPTS.${j}+=-g
1.87 christos 126: . endfor
1.1 atatat 127: .endfor
128:
1.131 plunky 129: # Always compile debugsyms.c with debug information.
1.107 joerg 130: # This allows gdb to use type informations.
131: #
132: COPTS.debugsyms.c+= -g
133:
1.126 darran 134: # Add CTF sections for DTrace
135: .if defined(CTFCONVERT)
136: COMPILE_CTFCONVERT= ${_MKSHECHO}\
1.127 njoly 137: ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \
1.126 darran 138: ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
139: .else
1.156 martin 140: COMPILE_CTFCONVERT= ${_MKSHNOECHO}
1.126 darran 141: .endif
142:
1.1 atatat 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).
1.127 njoly 145: NORMAL_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \
1.45 lukem 146: ${_MKSHECHO}\
1.197 uebayasi 147: ${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< -o $@ && \
148: ${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< -o $@ && \
1.126 darran 149: ${COMPILE_CTFCONVERT}
1.127 njoly 150: NOPROF_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \
1.45 lukem 151: ${_MKSHECHO}\
1.197 uebayasi 152: ${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} -c $< -o $@ && \
153: ${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} -c $< -o $@ && \
1.126 darran 154: ${COMPILE_CTFCONVERT}
1.127 njoly 155: NORMAL_S?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \
1.45 lukem 156: ${_MKSHECHO}\
1.197 uebayasi 157: ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} -c $< -o $@ && \
158: ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} -c $< -o $@
1.175 uebayasi 159:
160: # link rules:
1.176 uebayasi 161: LINK_O?= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}" && \
1.175 uebayasi 162: ${_MKSHECHO}\
1.180 uebayasi 163: ${LD} -r ${LINKFORMAT} -Map=${.TARGET}.map -o ${.TARGET} ${.ALLSRC} && \
164: ${LD} -r ${LINKFORMAT} -Map=${.TARGET}.map -o ${.TARGET} ${.ALLSRC}
1.1 atatat 165:
166: ##
1.59 perry 167: ## (3) libkern and compat
1.1 atatat 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:
1.27 perry 181: LIBKERNLN?= ${KERNLIBLN}
182:
1.1 atatat 183: ### find out what to use for libcompat
184: .include "$S/compat/common/Makefile.inc"
185: .ifndef PROF
1.56 lukem 186: SYSLIBCOMPAT?= ${COMPATLIB}
1.1 atatat 187: .else
1.56 lukem 188: SYSLIBCOMPAT?= ${COMPATLIB_PROF}
1.1 atatat 189: .endif
190:
1.56 lukem 191: SYSLIBCOMPATLN?= ${COMPATLIBLN}
1.27 perry 192:
1.1 atatat 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: ##
1.22 gehenna 199: MI_CFILES=devsw.c ioconf.c param.c
1.1 atatat 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
1.45 lukem 204: ${_MKTARGET_CREATE}
1.1 atatat 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: ##
1.181 uebayasi 218: ## TEXTADDR (or LOADADDRESS), LINKFORMAT, LINKSCRIPT, and any EXTRA_LINKFLAGS
219: ## must be set in the port's Makefile. The port specific definitions for
1.1 atatat 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:
1.170 joerg 224: # xxx: ${SYSTEM_DEP} swapxxxx.o vers.o build_kernel
225:
1.182 uebayasi 226: .if !empty(OBJS:Mnetbsd.ko)
227: SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS} ${SYSLIBCOMPAT} ${LIBKERN}
228: .else
1.119 matt 229: SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS:O} ${SYSLIBCOMPAT} ${LIBKERN}
1.182 uebayasi 230: .endif
1.183 uebayasi 231: SYSTEM_DEP+= Makefile ${SYSTEM_OBJ} .gdbinit
1.126 darran 232: .if defined(CTFMERGE)
1.166 ozaki-r 233: SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o
1.126 darran 234: .else
235: SYSTEM_CTFMERGE= ${_MKSHECHO}
236: .endif
1.45 lukem 237: SYSTEM_LD_HEAD?=@rm -f $@
1.194 uebayasi 238: SYSTEM_LD?= @do_system_ld() { \
239: target=$$1; shift; \
240: ${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}"; \
1.45 lukem 241: ${_MKSHECHO}\
1.195 uebayasi 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 $$@; \
1.194 uebayasi 244: }; \
245: do_system_ld
1.153 bsh 246:
1.185 uebayasi 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:
1.188 uebayasi 254: .if defined(KERNLDSCRIPT)
255: .for k in ${KERNELS}
256: EXTRA_CLEAN+= ${k}.ldscript
1.190 uebayasi 257: ${k}: ${k}.ldscript
1.191 uebayasi 258: ${k}.ldscript: ${KERNLDSCRIPT} assym.h
1.190 uebayasi 259: ${_MKTARGET_CREATE}
1.191 uebayasi 260: ${CPP} -I. ${KERNLDSCRIPT} | grep -v '^#' | grep -v '^$$' >$@
1.188 uebayasi 261: .endfor
262: LINKSCRIPT= -T ${.TARGET}.ldscript
263: .endif
264:
1.1 atatat 265: TEXTADDR?= ${LOADADDRESS} # backwards compatibility
1.5 atatat 266: LINKTEXT?= ${TEXTADDR:C/.+/-Ttext &/}
267: LINKDATA?= ${DATAADDR:C/.+/-Tdata &/}
1.1 atatat 268: ENTRYPOINT?= start
1.6 atatat 269: LINKENTRY?= ${ENTRYPOINT:C/.+/-e &/}
1.181 uebayasi 270: LINKFLAGS?= ${LINKFORMAT} ${LINKSCRIPT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \
1.1 atatat 271: ${EXTRA_LINKFLAGS}
272:
1.4 atatat 273: LINKFLAGS_DEBUG?= -X
1.161 skrll 274:
1.179 nakayama 275: SYSTEM_LD_TAIL?=@${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c; \
1.161 skrll 276: ${SIZE} $@; chmod 755 $@; \
277: ${SYSTEM_CTFMERGE}
1.1 atatat 278: SYSTEM_LD_TAIL_DEBUG?=; \
279: echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
280: echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
281: ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1.4 atatat 282: LINKFLAGS_NORMAL?= -S
1.1 atatat 283: STRIPFLAGS?= -g
284:
285: DEBUG?=
1.60 dbj 286: .if !empty(DEBUG:M-g*)
1.1 atatat 287: SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_DEBUG}
288: LINKFLAGS+= ${LINKFLAGS_DEBUG}
1.7 atatat 289: EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.gdb@}
1.126 darran 290: CTFFLAGS+= -g
1.174 matt 291: TARGETSFX= .gdb
1.9 chs 292: .elifndef PROF
1.1 atatat 293: LINKFLAGS+= ${LINKFLAGS_NORMAL}
294: .endif
295:
1.57 chs 296: SYSTEM_LD_HEAD+=${SYSTEM_LD_HEAD_EXTRA}
1.170 joerg 297: SYSTEM_LD_TAIL_STAGE1= ${SYSTEM_LD_TAIL}
298: SYSTEM_LD_TAIL_STAGE2= ${SYSTEM_LD_TAIL}
1.171 joerg 299: .if defined(COPY_SYMTAB)
1.170 joerg 300: SYSTEM_LD_TAIL_STAGE2+= ; echo ${DBSYM} $@; ${DBSYM} $@
1.174 matt 301: .if !empty(DEBUG:M-g)
302: SYSTEM_LD_TAIL_STAGE2+= ; echo ${DBSYM} $@.gdb; ${DBSYM} $@.gdb
303: .endif
1.161 skrll 304: .endif
1.170 joerg 305: SYSTEM_LD_TAIL_STAGE2+= ${SYSTEM_LD_TAIL_EXTRA}
1.5 atatat 306:
1.1 atatat 307: ##
1.8 atatat 308: ## (6) port independent targets and dependencies: assym.h, vers.o
1.1 atatat 309: ##
1.199 uebayasi 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:
1.193 uebayasi 319: assym.h: ${GENASSYM_CONF} ${GENASSYM_EXTRAS} $S/conf/genassym.cf
1.45 lukem 320: ${_MKTARGET_CREATE}
1.193 uebayasi 321: cat ${GENASSYM_CONF} ${GENASSYM_EXTRAS} $S/conf/genassym.cf | \
1.155 joerg 322: ${GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${PROF} \
1.165 joerg 323: ${GENASSYM_CPPFLAGS} > assym.h.tmp && \
1.1 atatat 324: mv -f assym.h.tmp assym.h
1.11 mrg 325: ${MD_SFILES:C/\.[Ss]/.o/} ${SFILES:C/\.[Ss]/.o/}: assym.h
1.1 atatat 326:
1.123 perry 327: MKREPRO?=no
328:
329: .if ${MKREPRO} == "yes"
1.145 jmcneill 330: _NVFLAGS=${NVFLAGS} -r
1.123 perry 331: .else
1.145 jmcneill 332: _NVFLAGS=${NVFLAGS}
1.123 perry 333: .endif
334:
1.8 atatat 335: .if !target(vers.o)
336: newvers: vers.o
1.187 uebayasi 337: vers.o: ${SYSTEM_OBJ} Makefile $S/conf/newvers.sh \
1.159 apb 338: $S/conf/osrelease.sh ${_NETBSD_VERSION_DEPENDS}
1.45 lukem 339: ${_MKMSG_CREATE} vers.c
1.123 perry 340: ${HOST_SH} $S/conf/newvers.sh ${_NVFLAGS}
1.45 lukem 341: ${_MKTARGET_COMPILE}
1.1 atatat 342: ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1.167 ozaki-r 343: ${COMPILE_CTFCONVERT}
1.29 atatat 344: .endif
345:
1.184 nat 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:
1.33 thorpej 352: .if defined(MEMORY_DISK_IMAGE)
353: md_root_image.h: ${MEMORY_DISK_IMAGE}
1.45 lukem 354: ${_MKTARGET_CREATE}
1.35 lukem 355: ${TOOL_HEXDUMP} -v -e '"\t" 8/1 "0x%02x, " "\n"' ${.ALLSRC} > ${.TARGET}
1.33 thorpej 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
1.1 atatat 364:
365: ##
1.16 wrstuden 366: ## (7) misc targets: install, clean(dir), depend(all), lint, links, tags,
367: ## cscope, mkid
1.1 atatat 368: ##
369: ## Any ports that have other stuff to be cleaned up should fill in
370: ## EXTRA_CLEAN. Some ports may want different settings for
371: ## KERNLINTFLAGS, MKDEP_CFLAGS, or MKDEP_AFLAGS.
372: ##
1.200 uebayasi 373:
374: ##
375: ## clean
376: ##
377:
1.1 atatat 378: .if !target(__CLEANKERNEL)
379: __CLEANKERNEL: .USE
1.45 lukem 380: ${_MKMSG} "${.TARGET}ing the kernel objects"
1.177 uebayasi 381: rm -f ${KERNELS} *.map eddep tags *.[io] *.ko *.ln [a-z]*.s vers.c \
1.1 atatat 382: [Ee]rrs linterrs makelinks assym.h.tmp assym.h \
1.7 atatat 383: ${EXTRA_KERNELS} ${EXTRA_CLEAN}
384: .endif
385:
386: .if !target(kernelnames)
387: kernelnames:
388: @echo "${KERNELS} ${EXTRA_KERNELS}"
1.1 atatat 389: .endif
390:
391: .if !target(__CLEANDEPEND)
392: __CLEANDEPEND: .USE
1.73 dsl 393: echo .depend ${DEPS} | xargs rm -f --
1.1 atatat 394: .endif
395:
396: # do not !target these, the kern and compat Makefiles augment them
397: cleandir distclean: __CLEANKERNEL __CLEANDEPEND
398: clean: __CLEANKERNEL
399: depend: .depend
1.90 thorpej 400: dependall: depend .WAIT all
1.1 atatat 401:
1.200 uebayasi 402: ##
403: ## depend
404: ##
405:
1.1 atatat 406: .if !target(.depend)
407: MKDEP_AFLAGS?= ${AFLAGS}
408: MKDEP_CFLAGS?= ${CFLAGS}
1.71 yamt 409: SSRCS=${MD_SFILES} ${SFILES}
410: CSRCS=${MD_CFILES} ${MI_CFILES} ${CFILES}
411: SRCS=${SSRCS} ${CSRCS}
1.183 uebayasi 412: DEPS= ${SRCS:T:u:R:S/$/.d/g}
1.71 yamt 413:
1.199 uebayasi 414: .SUFFIXES: .S .d
415: .S.d:
416: ${_MKTARGET_CREATE}
417: ${MKDEP} -f ${.TARGET} -- ${MKDEP_AFLAGS} \
418: ${CPPFLAGS} ${CPPFLAGS.${_s:T}} $<
419:
1.71 yamt 420: .for _s in ${SSRCS}
1.147 jmcneill 421: .if !target(${_s:T:R}.d)
1.106 lukem 422: ${_s:T:R}.d: ${_s} assym.h
1.73 dsl 423: ${_MKTARGET_CREATE}
424: ${MKDEP} -f ${.TARGET} -- ${MKDEP_AFLAGS} \
425: ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s}
1.147 jmcneill 426: .endif
1.71 yamt 427: .endfor
1.199 uebayasi 428:
429: .SUFFIXES: .c .d
430: .c.d:
431: ${_MKTARGET_CREATE}
432: ${MKDEP} -f ${.TARGET} -- ${MKDEP_CFLAGS} \
433: ${CPPFLAGS} ${CPPFLAGS.${_s:T}} $<
434:
1.71 yamt 435: .for _s in ${CSRCS}
1.147 jmcneill 436: .if !target(${_s:T:R}.d)
1.106 lukem 437: ${_s:T:R}.d: ${_s}
1.73 dsl 438: ${_MKTARGET_CREATE}
439: ${MKDEP} -f ${.TARGET} -- ${MKDEP_CFLAGS} \
440: ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s}
1.147 jmcneill 441: .endif
1.71 yamt 442: .endfor
443:
1.106 lukem 444: assym.d: assym.h
1.45 lukem 445: ${_MKTARGET_CREATE}
1.63 christos 446: cat ${GENASSYM_CONF} ${GENASSYM_EXTRAS} | \
447: ${GENASSYM} -- ${MKDEP} -f assym.dep -- \
1.165 joerg 448: ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${GENASSYM_CPPFLAGS}
1.118 apb 449: ${TOOL_SED} -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >${.TARGET}
1.73 dsl 450: rm -f assym.dep
451:
1.109 matt 452: DEPS+= assym.d
453:
454: .depend: ${DEPS}
1.73 dsl 455: ${_MKTARGET_CREATE}
456: echo "${.ALLSRC}" | ${MKDEP} -D
1.1 atatat 457: .endif
458:
1.200 uebayasi 459: ##
460: ## lint
461: ##
462:
1.1 atatat 463: .if !target(lint)
464: ALLSFILES?= ${MD_SFILES} ${SFILES}
465: LINTSTUBS?= ${ALLSFILES:T:R:C/^.*$/LintStub_&.c/g}
1.27 perry 466: KERNLINTFLAGS?= -bcehnxzFS
1.198 uebayasi 467: NORMAL_LN?= ${LINT} ${KERNLINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i $< -o $@
1.27 perry 468:
469: _lsrc=${CFILES} ${LINTSTUBS} ${MI_CFILES} ${MD_CFILES}
1.56 lukem 470: LOBJS?= ${_lsrc:T:S/.c$/.ln/g} ${LIBKERNLN} ${SYSLIBCOMPATLN}
1.27 perry 471:
1.1 atatat 472: .for _sfile in ${ALLSFILES}
473: LintStub_${_sfile:T:R}.c: ${_sfile} assym.h
1.45 lukem 474: ${_MKTARGET_COMPILE}
1.1 atatat 475: ${CC} -E -C ${AFLAGS} ${CPPFLAGS} ${_sfile} | \
1.117 apb 476: ${TOOL_AWK} -f $S/kern/genlintstub.awk >${.TARGET}
1.1 atatat 477: .endfor
1.27 perry 478:
479: .for _cfile in ${CFILES} ${LINTSTUBS} ${MI_CFILES} ${MD_CFILES}
480: ${_cfile:T:R}.ln: ${_cfile}
1.45 lukem 481: ${_MKTARGET_COMPILE}
1.27 perry 482: ${NORMAL_LN}
483: .endfor
484:
485: lint: ${LOBJS}
486: ${LINT} ${KERNLINTFLAGS} ${CPPFLAGS:M-[IDU]*} ${LOBJS}
1.1 atatat 487: .endif
488:
1.108 matt 489: # Attempt to do a syntax-only compile of the entire kernel as one entity.
490: # Alas, bugs in the GCC C frontend prevent this from completely effective
491: # but information can be gleaned from the output.
492: syntax-only: ${CFILES} ${MD_CFILES}
493: ${CC} -fsyntax-only -combine ${CFLAGS} ${CPPFLAGS} \
494: ${CFILES} ${MD_CFILES}
495:
1.100 jmmv 496: # List of kernel images that will be installed into the root file system.
497: # Some platforms may need to install more than one (e.g. a netbsd.aout file
498: # to be loaded directly by the firmware), so this can be overriden by them.
499: KERNIMAGES?= netbsd
500:
1.200 uebayasi 501: ##
502: ## install
503: ##
504:
1.1 atatat 505: .if !target(install)
506: # The install target can be redefined by putting a
507: # install-kernel-${MACHINE_NAME} target into /etc/mk.conf
508: MACHINE_NAME!= uname -n
509: install: install-kernel-${MACHINE_NAME}
1.28 chris 510: .if !target(install-kernel-${MACHINE_NAME})
1.1 atatat 511: install-kernel-${MACHINE_NAME}:
1.100 jmmv 512: .for _K in ${KERNIMAGES}
513: rm -f ${DESTDIR}/o${_K}
514: ln ${DESTDIR}/${_K} ${DESTDIR}/o${_K}
515: cp ${_K} ${DESTDIR}/n${_K}
516: mv ${DESTDIR}/n${_K} ${DESTDIR}/${_K}
517: .endfor
1.1 atatat 518: .endif
519: .endif
520:
1.200 uebayasi 521: ##
522: ## tags
523: ##
524:
1.1 atatat 525: .if !target(tags)
526: tags:
527: @echo "see $S/kern/Makefile for tags"
1.16 wrstuden 528: .endif
529:
1.200 uebayasi 530: ##
531: ## cscope
532: ##
533:
1.58 heas 534: EXTRA_CLEAN+= cscope.out cscope.tmp
1.16 wrstuden 535: .if !target(cscope.out)
1.19 wrstuden 536: cscope.out: Makefile depend
1.45 lukem 537: ${_MKTARGET_CREATE}
1.118 apb 538: @${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\ *$$//;' lib/kern/.depend \
539: | tr -s ' ' '\n' \
1.122 pooka 540: | ${TOOL_SED} ';s|^../../||;' \
1.118 apb 541: > cscope.tmp
542: @${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\ *$$//;' lib/compat/.depend \
543: | tr -s ' ' '\n' \
1.122 pooka 544: | ${TOOL_SED} 's|^../../||;' \
1.118 apb 545: >> cscope.tmp
1.58 heas 546: @echo ${SRCS} | cat - cscope.tmp | tr -s ' ' '\n' | sort -u | \
1.118 apb 547: ${CSCOPE} -k -i - -b `echo ${INCLUDES} | ${TOOL_SED} s/-nostdinc//`
1.16 wrstuden 548: # cscope doesn't write cscope.out if it's uptodate, so ensure
549: # make doesn't keep calling cscope when not needed.
1.58 heas 550: @rm -f cscope.tmp; touch cscope.out
1.16 wrstuden 551: .endif
552:
553: .if !target(cscope)
554: cscope: cscope.out
555: @${CSCOPE} -d
556: .endif
557:
558: EXTRA_CLEAN+= ID
559: .if !target(mkid)
560: .PHONY: mkid
561: mkid: ID
562:
1.17 wrstuden 563: ID: Makefile depend
1.45 lukem 564: ${_MKTARGET_CREATE}
1.118 apb 565: @${MKID} \
566: `${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\\\ *$$//;' \
567: lib/kern/.depend lib/compat/.depend \
568: | tr ' ' '\n' \
569: | ${TOOL_SED} "s|^../../||" \
570: | sort -u` \
571: `${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\\\ *$$//;' \
572: .depend \
573: | tr ' ' '\n' \
574: | sort -u`
1.18 wrstuden 575:
1.21 thorpej 576: .endif
577:
1.200 uebayasi 578: ##
579: ## .gdbinit
580: ##
581:
1.21 thorpej 582: .include "${S}/gdbscripts/Makefile.inc"
583:
584: EXTRA_CLEAN+= .gdbinit
585: .gdbinit: Makefile ${S}/gdbscripts/Makefile.inc
1.45 lukem 586: ${_MKTARGET_CREATE}
1.21 thorpej 587: rm -f .gdbinit
588: .for __gdbinit in ${SYS_GDBINIT}
589: echo "source ${S}/gdbscripts/${__gdbinit}" >> .gdbinit
590: .endfor
591: .if defined(GDBINIT) && !empty(GDBINIT)
592: .for __gdbinit in ${GDBINIT}
593: echo "source ${__gdbinit}" >> .gdbinit
594: .endfor
1.1 atatat 595: .endif
596:
1.200 uebayasi 597: ##
598: ## the kernel
599: ##
600:
1.99 christos 601: # The following files use alloca(3) or variable array allocations.
1.92 christos 602: # Their full name is noted as documentation.
1.125 tron 603: VARSTACK=kern/uipc_socket.c miscfs/genfs/genfs_vnops.c \
1.102 pooka 604: nfs/nfs_bio.c uvm/uvm_bio.c \
1.104 jnemeth 605: uvm/uvm_pager.c dev/ic/aic7xxx.c dev/ic/aic79xx.c arch/xen/i386/gdt.c \
606: dev/ofw/ofw_subr.c
1.92 christos 607:
608: .for __varstack in ${VARSTACK}
609: COPTS.${__varstack:T} += -Wno-stack-protector
610: .endfor
611:
1.86 matt 612: AFLAGS+= ${AOPTS.${.IMPSRC:T}}
1.64 yamt 613: CFLAGS+= ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}}
614: CPPFLAGS+= ${CPPFLAGS.${.IMPSRC:T}}
1.65 uwe 615: CWARNFLAGS+= ${CWARNFLAGS.${.IMPSRC:T}}
1.64 yamt 616:
1.170 joerg 617: locore.o machdep.o kern_ksyms.o: Makefile
618:
1.172 skrll 619: .if defined(COPY_SYMTAB)
1.170 joerg 620: CPPFLAGS.locore.S+= -DCOPY_SYMTAB
621: CPPFLAGS.machdep.c+= -DCOPY_SYMTAB
622: CPPFLAGS.kern_ksyms.c+= -DCOPY_SYMTAB
623: CPPFLAGS.kern_ksyms_buf.c+= -DCOPY_SYMTAB
624: .endif
625:
626: .if !defined(COPY_SYMTAB)
627: build_kernel: .USE
628: ${SYSTEM_LD_HEAD}
1.194 uebayasi 629: ${SYSTEM_LD} ${.TARGET} swap${.TARGET}.o
1.170 joerg 630: ${SYSTEM_LD_TAIL_STAGE2}
631: .else
1.196 uebayasi 632: .for k in ${KERNELS}
633: ${k}: $S/kern/kern_ksyms_buf.c
634: .endfor
1.170 joerg 635: build_kernel: .USE
636: ${CC} ${CFLAGS} ${CPPFLAGS} -DCOPY_SYMTAB \
637: -c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf.o
638: ${SYSTEM_LD_HEAD}
1.194 uebayasi 639: ${SYSTEM_LD} ${.TARGET} swap${.TARGET}.o kern_ksyms_buf.o
1.170 joerg 640: ${SYSTEM_LD_TAIL_STAGE1}
641: ${CC} ${CFLAGS} ${CPPFLAGS} -DCOPY_SYMTAB \
1.174 matt 642: -DSYMTAB_SPACE=$$(${DBSYM} -P ${.TARGET}${TARGETSFX}) \
1.170 joerg 643: -c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf_real.o
644: ${SYSTEM_LD_HEAD}
1.194 uebayasi 645: ${SYSTEM_LD} ${.TARGET} swap${.TARGET}.o kern_ksyms_buf_real.o
1.170 joerg 646: ${SYSTEM_LD_TAIL_STAGE2}
647: .endif
648:
1.105 lukem 649: .include <bsd.files.mk>
1.149 joerg 650: .include <bsd.clang-analyze.mk>
1.105 lukem 651:
1.1 atatat 652: ##
653: ## the end
654: ##
CVSweb <webmaster@jp.NetBSD.org>