Annotation of src/sys/conf/Makefile.kern.inc, Revision 1.73.8.3
1.73.8.3! yamt 1: # $NetBSD: Makefile.kern.inc,v 1.73.8.2 2006/05/24 10:57:35 yamt Exp $
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:
20: ##
1.3 atatat 21: ## (0) toolchain settings for things that aren't part of the standard
22: ## toolchain
23: ##
1.45 lukem 24: HOST_SH?= sh
1.15 tv 25: DBSYM?= dbsym
1.3 atatat 26: MKDEP?= mkdep
27: STRIP?= strip
28: OBJCOPY?= objcopy
29: OBJDUMP?= objdump
1.16 wrstuden 30: CSCOPE?= cscope
31: MKID?= mkid
1.55 atatat 32: UUDECODE?= ${TOOL_UUDECODE:Uuudecode}
1.63 christos 33: HEXDUMP?= ${TOOL_HEXDUMP:Uhexdump}
34: GENASSYM?= ${TOOL_GENASSYM:Ugenassym}
1.12 tv 35: .MAKEOVERRIDES+=USETOOLS # make sure proper value is propagated
1.46 lukem 36:
37: _MKMSG?= @\#
1.49 pk 38: _MKSHMSG?= echo
39: _MKSHECHO?= echo
1.46 lukem 40: _MKMSG_CREATE?= :
41: _MKTARGET_COMPILE?= :
42: _MKTARGET_CREATE?= :
1.3 atatat 43:
44: ##
1.1 atatat 45: ## (1) port independent source tree identification
46: ##
47: # source tree is located via $S relative to the compilation directory
48: .ifndef S
49: S!= cd ../../../..; pwd
50: .endif
51:
52: ##
53: ## (2) compile settings
54: ##
55: ## CPPFLAGS, CFLAGS, and AFLAGS must be set in the port's Makefile
56: ##
1.73.8.2 yamt 57: INCLUDES?= -I. ${EXTRA_INCLUDES} -I${S}/../common/include -I$S/arch \
58: -I$S -nostdinc
1.4 atatat 59: CPPFLAGS+= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT
60: DEFCOPTS?= -O2
1.25 fvdl 61: COPTS?= ${DEFCOPTS}
1.7 atatat 62: DBG= # might contain unwanted -Ofoo
63: DEFWARNINGS?= yes
64: .if (${DEFWARNINGS} == "yes")
1.37 matt 65: .if !defined(NOGCCERROR)
66: CWARNFLAGS+= -Werror
67: .endif
68: CWARNFLAGS+= -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith
1.7 atatat 69: CWARNFLAGS+= -Wmissing-prototypes -Wstrict-prototypes
1.68 martin 70: CWARNFLAGS+= -Wswitch -Wshadow
1.62 christos 71: CWARNFLAGS+= -Wcast-qual -Wwrite-strings
1.30 thorpej 72: # Add -Wno-sign-compare. -Wsign-compare is included in -Wall as of GCC 3.3,
73: # but our sources aren't up for it yet.
74: CWARNFLAGS+= -Wno-sign-compare
1.73.8.2 yamt 75: . if ${HAVE_GCC} > 3
76: CWARNFLAGS+= -Wno-pointer-sign -Wno-attributes
77: . endif
1.7 atatat 78: .endif
1.42 jdolecek 79:
1.73.8.3! yamt 80: CFLAGS+= -ffreestanding -fno-zero-initialized-in-bss
1.53 matt 81: CFLAGS+= ${CPUFLAGS} ${DEBUG} ${COPTS} ${CWARNFLAGS}
82: AFLAGS+= ${CPUFLAGS} -D_LOCORE
83:
1.73.8.2 yamt 84: # XXX
85: .if ${HAVE_GCC} > 3
86: CFLAGS+= -fno-strict-aliasing
87: .endif
88:
1.45 lukem 89: # Use the per-source COPTS variables to add -g to just those
1.1 atatat 90: # files that match the shell patterns given in ${DEBUGLIST}
91: #
92: .for i in ${DEBUGLIST}
93: .for j in ${CFILES:T:M$i.c}
1.45 lukem 94: COPTS.${j}+=-g
1.1 atatat 95: .endfor
96: .endfor
97:
98: # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
99: # NOPROF and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
1.51 lukem 100: NORMAL_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}"; \
1.45 lukem 101: ${_MKSHECHO}\
102: ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<; \
103: ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
1.51 lukem 104: NOPROF_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}"; \
1.45 lukem 105: ${_MKSHECHO}\
106: ${CC} ${CFLAGS} ${CPPFLAGS} -c $<; \
107: ${CC} ${CFLAGS} ${CPPFLAGS} -c $<
1.51 lukem 108: NORMAL_S?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}"; \
1.45 lukem 109: ${_MKSHECHO}\
110: ${CC} ${AFLAGS} ${CPPFLAGS} -c $<; \
111: ${CC} ${AFLAGS} ${CPPFLAGS} -c $<
1.1 atatat 112:
113: ##
1.59 perry 114: ## (3) libkern and compat
1.1 atatat 115: ##
116: ## Set KERN_AS in the port Makefile to "obj" or "library". The
117: ## default is "library", as documented in $S/lib/libkern/Makefile.inc.
118: ##
119:
120: ### find out what to use for libkern
121: .include "$S/lib/libkern/Makefile.inc"
122: .ifndef PROF
123: LIBKERN?= ${KERNLIB}
124: .else
125: LIBKERN?= ${KERNLIB_PROF}
126: .endif
127:
1.27 perry 128: LIBKERNLN?= ${KERNLIBLN}
129:
1.1 atatat 130: ### find out what to use for libcompat
131: .include "$S/compat/common/Makefile.inc"
132: .ifndef PROF
1.56 lukem 133: SYSLIBCOMPAT?= ${COMPATLIB}
1.1 atatat 134: .else
1.56 lukem 135: SYSLIBCOMPAT?= ${COMPATLIB_PROF}
1.1 atatat 136: .endif
137:
1.56 lukem 138: SYSLIBCOMPATLN?= ${COMPATLIBLN}
1.27 perry 139:
1.1 atatat 140: ##
141: ## (4) local objects, compile rules, and dependencies
142: ##
143: ## Each port should have a corresponding section with settings for
144: ## MD_CFILES, MD_SFILES, and MD_OBJS, along with build rules for same.
145: ##
1.22 gehenna 146: MI_CFILES=devsw.c ioconf.c param.c
1.1 atatat 147: # the need for a MI_SFILES variable is dubitable at best
148: MI_OBJS=${MI_CFILES:S/.c/.o/}
149:
150: param.c: $S/conf/param.c
1.45 lukem 151: ${_MKTARGET_CREATE}
1.1 atatat 152: rm -f param.c
153: cp $S/conf/param.c .
154:
155: param.o: Makefile
156:
157: .for _cfile in ${MI_CFILES}
158: ${_cfile:T:R}.o: ${_cfile}
159: ${NORMAL_C}
160: .endfor
161:
162: ##
163: ## (5) link settings
164: ##
165: ## TEXTADDR (or LOADADDRESS), LINKFORMAT, and any EXTRA_LINKFLAGS must
166: ## be set in the port's Makefile. The port specific definitions for
167: ## LINKFLAGS_NORMAL and LINKFLAGS_DEBUG will added to the LINKFLAGS
168: ## depending on the value of DEBUG.
169: ##
170: # load lines for config "xxx" will be emitted as:
171: # xxx: ${SYSTEM_DEP} swapxxx.o
172: # ${SYSTEM_LD_HEAD}
173: # ${SYSTEM_LD} swapxxx.o
174: # ${SYSTEM_LD_TAIL}
1.56 lukem 175: SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS} ${SYSLIBCOMPAT} ${LIBKERN}
1.73.8.2 yamt 176: SYSTEM_DEP?= Makefile ${SYSTEM_OBJ:O} .gdbinit
1.45 lukem 177: SYSTEM_LD_HEAD?=@rm -f $@
1.50 lukem 178: SYSTEM_LD?= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}"; \
1.45 lukem 179: ${_MKSHECHO}\
1.47 pk 180: ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o; \
1.32 matt 181: ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o
1.45 lukem 182: SYSTEM_LD_TAIL?=@${SIZE} $@; chmod 755 $@
1.1 atatat 183:
184: TEXTADDR?= ${LOADADDRESS} # backwards compatibility
1.5 atatat 185: LINKTEXT?= ${TEXTADDR:C/.+/-Ttext &/}
186: LINKDATA?= ${DATAADDR:C/.+/-Tdata &/}
1.1 atatat 187: ENTRYPOINT?= start
1.6 atatat 188: LINKENTRY?= ${ENTRYPOINT:C/.+/-e &/}
1.1 atatat 189: LINKFLAGS?= ${LINKFORMAT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \
190: ${EXTRA_LINKFLAGS}
191:
1.4 atatat 192: LINKFLAGS_DEBUG?= -X
1.1 atatat 193: SYSTEM_LD_TAIL_DEBUG?=; \
194: echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
195: echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
196: ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1.4 atatat 197: LINKFLAGS_NORMAL?= -S
1.1 atatat 198: STRIPFLAGS?= -g
199:
200: DEBUG?=
1.60 dbj 201: .if !empty(DEBUG:M-g*)
1.1 atatat 202: SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_DEBUG}
203: LINKFLAGS+= ${LINKFLAGS_DEBUG}
1.7 atatat 204: EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.gdb@}
1.9 chs 205: .elifndef PROF
1.1 atatat 206: LINKFLAGS+= ${LINKFLAGS_NORMAL}
207: .endif
208:
1.70 dbj 209: SYSTEM_LD_TAIL+=; \
210: if grep -q '^\#define.*SYMTAB_SPACE' opt_ddbparam.h; then \
211: echo "${DBSYM} $@"; \
212: ${DBSYM} $@; \
213: fi
214:
1.57 chs 215: SYSTEM_LD_HEAD+=${SYSTEM_LD_HEAD_EXTRA}
1.5 atatat 216: SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_EXTRA}
217:
1.1 atatat 218: ##
1.8 atatat 219: ## (6) port independent targets and dependencies: assym.h, vers.o
1.1 atatat 220: ##
221: .if !target(assym.h)
1.63 christos 222: assym.h: ${GENASSYM_CONF} ${GENASSYM_EXTRAS}
1.45 lukem 223: ${_MKTARGET_CREATE}
1.63 christos 224: cat ${GENASSYM_CONF} ${GENASSYM_EXTRAS} | \
225: ${GENASSYM} -- ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1.5 atatat 226: > assym.h.tmp && \
1.1 atatat 227: mv -f assym.h.tmp assym.h
1.11 mrg 228: ${MD_SFILES:C/\.[Ss]/.o/} ${SFILES:C/\.[Ss]/.o/}: assym.h
1.1 atatat 229: .endif
230:
1.8 atatat 231: .if !target(vers.o)
232: newvers: vers.o
1.20 lukem 233: vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} $S/conf/newvers.sh $S/conf/osrelease.sh
1.45 lukem 234: ${_MKMSG_CREATE} vers.c
235: ${HOST_SH} $S/conf/newvers.sh
236: ${_MKTARGET_COMPILE}
1.1 atatat 237: ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1.29 atatat 238: .endif
239:
240: .if !target(config_time.h)
241: EXTRA_CLEAN+= config_time.h
242: config_time.h: Makefile
1.45 lukem 243: ${_MKTARGET_CREATE}
1.29 atatat 244: cp config_time.src config_time.h
1.1 atatat 245: .endif
1.33 thorpej 246:
247: .if defined(MEMORY_DISK_IMAGE)
248: md_root_image.h: ${MEMORY_DISK_IMAGE}
1.45 lukem 249: ${_MKTARGET_CREATE}
1.35 lukem 250: ${TOOL_HEXDUMP} -v -e '"\t" 8/1 "0x%02x, " "\n"' ${.ALLSRC} > ${.TARGET}
1.33 thorpej 251:
252: # XXX This is only needed when building md_root.o
253: CPPFLAGS+= -DMEMORY_DISK_IMAGE
254: md_root.o: md_root_image.h
255: .endif
256:
257: # depend on MEMORY_DISK_IMAGE configuration
258: md_root.o: Makefile
1.1 atatat 259:
260: # depend on root or device configuration
261: autoconf.o conf.o: Makefile
262:
263: # depend on network or filesystem configuration
264: uipc_proto.o vfs_conf.o: Makefile
265:
266: # depend on maxusers and CPU configuration
267: assym.h machdep.o: Makefile
268:
269: ##
1.16 wrstuden 270: ## (7) misc targets: install, clean(dir), depend(all), lint, links, tags,
271: ## cscope, mkid
1.1 atatat 272: ##
273: ## Any ports that have other stuff to be cleaned up should fill in
274: ## EXTRA_CLEAN. Some ports may want different settings for
275: ## KERNLINTFLAGS, MKDEP_CFLAGS, or MKDEP_AFLAGS.
276: ##
277: .if !target(__CLEANKERNEL)
278: __CLEANKERNEL: .USE
1.45 lukem 279: ${_MKMSG} "${.TARGET}ing the kernel objects"
1.27 perry 280: rm -f ${KERNELS} eddep tags *.[io] *.ln [a-z]*.s vers.c \
1.1 atatat 281: [Ee]rrs linterrs makelinks assym.h.tmp assym.h \
1.7 atatat 282: ${EXTRA_KERNELS} ${EXTRA_CLEAN}
283: .endif
284:
285: .if !target(kernelnames)
286: kernelnames:
287: @echo "${KERNELS} ${EXTRA_KERNELS}"
1.1 atatat 288: .endif
289:
290: .if !target(__CLEANDEPEND)
291: __CLEANDEPEND: .USE
1.73 dsl 292: echo .depend ${DEPS} | xargs rm -f --
1.1 atatat 293: .endif
294:
295: # do not !target these, the kern and compat Makefiles augment them
296: cleandir distclean: __CLEANKERNEL __CLEANDEPEND
297: clean: __CLEANKERNEL
298: depend: .depend
1.44 dsl 299: dependall: depend all
1.1 atatat 300:
301: .if !target(.depend)
302: MKDEP_AFLAGS?= ${AFLAGS}
303: MKDEP_CFLAGS?= ${CFLAGS}
1.71 yamt 304: SSRCS=${MD_SFILES} ${SFILES}
305: CSRCS=${MD_CFILES} ${MI_CFILES} ${CFILES}
306: SRCS=${SSRCS} ${CSRCS}
1.73.8.2 yamt 307: DEPS= ${SRCS:T:O:u:R:S/$/.d/g}
1.71 yamt 308:
309: .for _s in ${SSRCS}
310: ${_s:T:R}.d: ${_s} assym.h config_time.h
1.73 dsl 311: ${_MKTARGET_CREATE}
312: ${MKDEP} -f ${.TARGET} -- ${MKDEP_AFLAGS} \
313: ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s}
1.71 yamt 314: .endfor
315: .for _s in ${CSRCS}
316: ${_s:T:R}.d: ${_s} config_time.h
1.73 dsl 317: ${_MKTARGET_CREATE}
318: ${MKDEP} -f ${.TARGET} -- ${MKDEP_CFLAGS} \
319: ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s}
1.71 yamt 320: .endfor
321:
1.73 dsl 322: assym.d: assym.h config_time.h
1.45 lukem 323: ${_MKTARGET_CREATE}
1.63 christos 324: cat ${GENASSYM_CONF} ${GENASSYM_EXTRAS} | \
325: ${GENASSYM} -- ${MKDEP} -f assym.dep -- \
1.43 enami 326: ${CFLAGS} ${CPPFLAGS}
1.73 dsl 327: sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >${.TARGET}
328: rm -f assym.dep
329:
330: .depend: ${DEPS} assym.d
331: ${_MKTARGET_CREATE}
332: echo "${.ALLSRC}" | ${MKDEP} -D
1.1 atatat 333: .endif
334:
335: .if !target(lint)
336: ALLSFILES?= ${MD_SFILES} ${SFILES}
337: LINTSTUBS?= ${ALLSFILES:T:R:C/^.*$/LintStub_&.c/g}
1.27 perry 338: KERNLINTFLAGS?= -bcehnxzFS
339: NORMAL_LN?= ${LINT} ${KERNLINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i $<
340:
341: _lsrc=${CFILES} ${LINTSTUBS} ${MI_CFILES} ${MD_CFILES}
1.56 lukem 342: LOBJS?= ${_lsrc:T:S/.c$/.ln/g} ${LIBKERNLN} ${SYSLIBCOMPATLN}
1.27 perry 343:
1.1 atatat 344: .for _sfile in ${ALLSFILES}
345: LintStub_${_sfile:T:R}.c: ${_sfile} assym.h
1.45 lukem 346: ${_MKTARGET_COMPILE}
1.1 atatat 347: ${CC} -E -C ${AFLAGS} ${CPPFLAGS} ${_sfile} | \
348: awk -f $S/kern/genlintstub.awk >${.TARGET}
349: .endfor
1.27 perry 350:
351: .for _cfile in ${CFILES} ${LINTSTUBS} ${MI_CFILES} ${MD_CFILES}
352: ${_cfile:T:R}.ln: ${_cfile}
1.45 lukem 353: ${_MKTARGET_COMPILE}
1.27 perry 354: ${NORMAL_LN}
355: .endfor
356:
357: lint: ${LOBJS}
358: ${LINT} ${KERNLINTFLAGS} ${CPPFLAGS:M-[IDU]*} ${LOBJS}
1.1 atatat 359: .endif
360:
361: .if !target(install)
362: # The install target can be redefined by putting a
363: # install-kernel-${MACHINE_NAME} target into /etc/mk.conf
364: MACHINE_NAME!= uname -n
365: install: install-kernel-${MACHINE_NAME}
1.28 chris 366: .if !target(install-kernel-${MACHINE_NAME})
1.1 atatat 367: install-kernel-${MACHINE_NAME}:
1.7 atatat 368: rm -f ${DESTDIR}/onetbsd
369: ln ${DESTDIR}/netbsd ${DESTDIR}/onetbsd
370: cp netbsd ${DESTDIR}/nnetbsd
371: mv ${DESTDIR}/nnetbsd ${DESTDIR}/netbsd
1.1 atatat 372: .endif
373: .endif
374:
375: .if !target(tags)
376: tags:
377: @echo "see $S/kern/Makefile for tags"
1.16 wrstuden 378: .endif
379:
1.58 heas 380: EXTRA_CLEAN+= cscope.out cscope.tmp
1.16 wrstuden 381: .if !target(cscope.out)
1.19 wrstuden 382: cscope.out: Makefile depend
1.45 lukem 383: ${_MKTARGET_CREATE}
1.58 heas 384: @sed 's/[^:]*://;s/^ *//;s/ *\\ *$$//;' lib/kern/.depend | \
385: tr -s ' ' '\n' | sed 's|^\([^.\\]\)|lib/kern/\1|;s|^../../||;' > \
386: cscope.tmp
387: @sed 's/[^:]*://;s/^ *//;s/ *\\ *$$//;' lib/compat/.depend | \
388: tr -s ' ' '\n' | sed 's|^\([^.\\]\)|lib/compat/\1|;s|^../../||;' >> \
389: cscope.tmp
390: @echo ${SRCS} | cat - cscope.tmp | tr -s ' ' '\n' | sort -u | \
391: ${CSCOPE} -k -i - -b `echo ${INCLUDES} | sed s/-nostdinc//`
1.16 wrstuden 392: # cscope doesn't write cscope.out if it's uptodate, so ensure
393: # make doesn't keep calling cscope when not needed.
1.58 heas 394: @rm -f cscope.tmp; touch cscope.out
1.16 wrstuden 395: .endif
396:
397: .if !target(cscope)
398: cscope: cscope.out
399: @${CSCOPE} -d
400: .endif
401:
402: EXTRA_CLEAN+= ID
403: .if !target(mkid)
404: .PHONY: mkid
405: mkid: ID
406:
1.17 wrstuden 407: ID: Makefile depend
1.45 lukem 408: ${_MKTARGET_CREATE}
1.18 wrstuden 409: @${MKID} `sed 's/[^:]*://;s/^ *//;s/ *\\\\ *$$//;' lib/kern/.depend \
410: lib/compat/.depend | tr ' ' '\n' | sed "s|^../../||" | sort -u` \
411: `sed 's/[^:]*://;s/^ *//;s/ *\\\\ *$$//;' .depend | tr ' ' '\n' \
412: | sort -u`
413:
1.21 thorpej 414: .endif
415:
416: .include "${S}/gdbscripts/Makefile.inc"
417:
418: EXTRA_CLEAN+= .gdbinit
419: .gdbinit: Makefile ${S}/gdbscripts/Makefile.inc
1.45 lukem 420: ${_MKTARGET_CREATE}
1.21 thorpej 421: rm -f .gdbinit
422: .for __gdbinit in ${SYS_GDBINIT}
423: echo "source ${S}/gdbscripts/${__gdbinit}" >> .gdbinit
424: .endfor
425: .if defined(GDBINIT) && !empty(GDBINIT)
426: .for __gdbinit in ${GDBINIT}
427: echo "source ${__gdbinit}" >> .gdbinit
428: .endfor
1.1 atatat 429: .endif
430:
1.64 yamt 431: CFLAGS+= ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}}
432: CPPFLAGS+= ${CPPFLAGS.${.IMPSRC:T}}
1.65 uwe 433: CWARNFLAGS+= ${CWARNFLAGS.${.IMPSRC:T}}
1.64 yamt 434:
1.1 atatat 435: ##
436: ## the end
437: ##
CVSweb <webmaster@jp.NetBSD.org>