[BACK]Return to Makefile.kern.inc CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / conf

Annotation of src/sys/conf/Makefile.kern.inc, Revision 1.4

1.4     ! atatat      1: #      $NetBSD: Makefile.kern.inc,v 1.3 2001/11/16 16:15:08 atatat Exp $
1.1       atatat      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}. There are
                      5: # many `MI' definitions that should end up in here, but they are not yet.
                      6: #
                      7: # Each target in this file should be protected with `if !target(target)'
                      8: # or `if !commands(target)' and each variable should only be conditionally
                      9: # assigned `VAR ?= VALUE', so that everything can be overriden.
                     10: #
                     11: # DEBUG is set to -g if debugging.
                     12: # PROF is set to -pg if profiling.
                     13: #
                     14: # To specify debugging, add the config line: makeoptions DEBUG="-g"
                     15: # A better way is to specify -g only for a few files.
                     16: #
                     17: #      makeoptions DEBUGLIST="uvm* trap if_*"
                     18: #
                     19: # all ports are expected to include bsd.own.mk for toolchain settings
                     20:
                     21: ##
1.3       atatat     22: ## (0) toolchain settings for things that aren't part of the standard
                     23: ## toolchain
                     24: ##
                     25: MKDEP?=                mkdep
                     26: STRIP?=                strip
                     27: OBJCOPY?=      objcopy
                     28: OBJDUMP?=      objdump
                     29:
                     30: ##
1.1       atatat     31: ## (1) port independent source tree identification
                     32: ##
                     33: # source tree is located via $S relative to the compilation directory
                     34: .ifndef S
                     35: S!=    cd ../../../..; pwd
                     36: .endif
                     37:
                     38: ##
                     39: ## (2) compile settings
                     40: ##
                     41: ## CPPFLAGS, CFLAGS, and AFLAGS must be set in the port's Makefile
                     42: ##
1.4     ! atatat     43: INCLUDES?=     -I. ${EXTRA_INCLUDES} -I$S/arch -I$S -nostdinc
        !            44: CPPFLAGS+=     ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT
        !            45: DEFCOPTS?=     -O2
        !            46: COPTS?=                ${DEFCOPTS}
        !            47: CWARNFLAGS+=   -Werror -Wall -Wmissing-prototypes -Wstrict-prototypes \
        !            48:                -Wpointer-arith -Wno-main
1.1       atatat     49: # XXX Delete -Wuninitialized for now, since the compiler doesn't
                     50: # XXX always get it right.  --thorpej
                     51: CWARNFLAGS+=   -Wno-uninitialized
1.4     ! atatat     52: CFLAGS+=       ${DEBUG} ${COPTS} ${CWARNFLAGS}
        !            53: AFLAGS+=       -D_LOCORE
1.1       atatat     54:
                     55: # Define a set of xxx_G variables that will add -g to just those
                     56: # files that match the shell patterns given in ${DEBUGLIST}
                     57: #
                     58: .for i in ${DEBUGLIST}
                     59: .for j in ${CFILES:T:M$i.c}
                     60: ${j:R}_G?= -g
                     61: .endfor
                     62: .endfor
                     63:
                     64: # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
                     65: # NOPROF and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
                     66: NORMAL_C?=     ${CC} ${CFLAGS} ${CPPFLAGS} ${${<:T:R}_G} ${PROF} -c $<
                     67: NOPROF_C?=     ${CC} ${CFLAGS} ${CPPFLAGS} ${${<:T:R}_G} -c $<
                     68: NORMAL_S?=     ${CC} ${AFLAGS} ${CPPFLAGS} -c $<
                     69:
                     70: ##
                     71: ## (3) libkern and compat
                     72: ##
                     73: ## Set KERN_AS in the port Makefile to "obj" or "library".  The
                     74: ## default is "library", as documented in $S/lib/libkern/Makefile.inc.
                     75: ##
                     76:
                     77: ### find out what to use for libkern
                     78: .include "$S/lib/libkern/Makefile.inc"
                     79: .ifndef PROF
                     80: LIBKERN?=      ${KERNLIB}
                     81: .else
                     82: LIBKERN?=      ${KERNLIB_PROF}
                     83: .endif
                     84:
                     85: ### find out what to use for libcompat
                     86: .include "$S/compat/common/Makefile.inc"
                     87: .ifndef PROF
                     88: LIBCOMPAT?=    ${COMPATLIB}
                     89: .else
                     90: LIBCOMPAT?=    ${COMPATLIB_PROF}
                     91: .endif
                     92:
                     93: ##
                     94: ## (4) local objects, compile rules, and dependencies
                     95: ##
                     96: ## Each port should have a corresponding section with settings for
                     97: ## MD_CFILES, MD_SFILES, and MD_OBJS, along with build rules for same.
                     98: ##
                     99: MI_CFILES=ioconf.c param.c
                    100: # the need for a MI_SFILES variable is dubitable at best
                    101: MI_OBJS=${MI_CFILES:S/.c/.o/}
                    102:
                    103: param.c: $S/conf/param.c
                    104:        rm -f param.c
                    105:        cp $S/conf/param.c .
                    106:
                    107: param.o: Makefile
                    108:
                    109: .for _cfile in ${MI_CFILES}
                    110: ${_cfile:T:R}.o: ${_cfile}
                    111:        ${NORMAL_C}
                    112: .endfor
                    113:
                    114: ##
                    115: ## (5) link settings
                    116: ##
                    117: ## TEXTADDR (or LOADADDRESS), LINKFORMAT, and any EXTRA_LINKFLAGS must
                    118: ## be set in the port's Makefile.  The port specific definitions for
                    119: ## LINKFLAGS_NORMAL and LINKFLAGS_DEBUG will added to the LINKFLAGS
                    120: ## depending on the value of DEBUG.
                    121: ##
                    122: # load lines for config "xxx" will be emitted as:
                    123: # xxx: ${SYSTEM_DEP} swapxxx.o
                    124: #      ${SYSTEM_LD_HEAD}
                    125: #      ${SYSTEM_LD} swapxxx.o
                    126: #      ${SYSTEM_LD_TAIL}
                    127: SYSTEM_OBJ?=   ${MD_OBJS} ${MI_OBJS} ${OBJS} ${LIBCOMPAT} ${LIBKERN}
                    128: SYSTEM_DEP?=   Makefile ${SYSTEM_OBJ}
                    129: SYSTEM_LD_HEAD?=       @rm -f $@
                    130: SYSTEM_LD?=    @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
                    131:                ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
                    132: SYSTEM_LD_TAIL?=       @${SIZE} $@; chmod 755 $@
                    133:
                    134: TEXTADDR?=     ${LOADADDRESS}                  # backwards compatibility
                    135: LINKTEXT?=     -Ttext ${TEXTADDR}
                    136: LINKDATA?=     ${DATAADDR:D-Tdata ${DATAADDR}}
                    137: ENTRYPOINT?=   start
                    138: LINKENTRY?=    -e ${ENTRYPOINT}
                    139: LINKFLAGS?=    ${LINKFORMAT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \
                    140:                ${EXTRA_LINKFLAGS}
                    141:
1.4     ! atatat    142: LINKFLAGS_DEBUG?=      -X
1.1       atatat    143: SYSTEM_LD_TAIL_DEBUG?=; \
                    144:                echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
                    145:                echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
                    146:                ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1.4     ! atatat    147: LINKFLAGS_NORMAL?=     -S
1.1       atatat    148: STRIPFLAGS?=   -g
                    149:
                    150: DEBUG?=
                    151: .if ${DEBUG} == "-g"
                    152: SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_DEBUG}
                    153: LINKFLAGS+=    ${LINKFLAGS_DEBUG}
                    154: .else
                    155: LINKFLAGS+=    ${LINKFLAGS_NORMAL}
                    156: .endif
                    157:
                    158: ##
                    159: ## (6) port independent targets and dependencies: assym.h, newvers
                    160: ##
                    161: .if !target(assym.h)
                    162: assym.h: $S/kern/genassym.sh ${GENASSYM}
                    163:        sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
                    164:            < ${GENASSYM} > assym.h.tmp && \
                    165:        mv -f assym.h.tmp assym.h
                    166: .endif
                    167:
                    168: .if !target(newvers)
                    169: newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
                    170:        sh $S/conf/newvers.sh
                    171:        ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
                    172: .endif
                    173:
                    174: # depend on root or device configuration
                    175: autoconf.o conf.o: Makefile
                    176:
                    177: # depend on network or filesystem configuration
                    178: uipc_proto.o vfs_conf.o: Makefile
                    179:
                    180: # depend on maxusers and CPU configuration
                    181: assym.h machdep.o: Makefile
                    182:
                    183: ##
                    184: ## (7) misc targets: install, clean(dir), depend(all), lint, links, tags
                    185: ##
                    186: ## Any ports that have other stuff to be cleaned up should fill in
                    187: ## EXTRA_CLEAN.  Some ports may want different settings for
                    188: ## KERNLINTFLAGS, MKDEP_CFLAGS, or MKDEP_AFLAGS.
                    189: ##
                    190: .if !target(__CLEANKERNEL)
                    191: __CLEANKERNEL: .USE
                    192:        @echo "${.TARGET}ing the kernel objects"
                    193:        rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
                    194:            [Ee]rrs linterrs makelinks assym.h.tmp assym.h \
                    195:            ${EXTRA_CLEAN}
                    196: .endif
                    197:
                    198: .if !target(__CLEANDEPEND)
                    199: __CLEANDEPEND: .USE
                    200:        rm -f .depend
                    201: .endif
                    202:
                    203: # do not !target these, the kern and compat Makefiles augment them
                    204: cleandir distclean: __CLEANKERNEL __CLEANDEPEND
                    205: clean: __CLEANKERNEL
                    206: depend: .depend
                    207:
                    208: .if !target(.depend)
                    209: SRCS?=         ${MD_SFILES} ${MD_CFILES} ${MI_CFILES} ${CFILES} ${SFILES}
                    210: MKDEP_AFLAGS?= ${AFLAGS}
                    211: MKDEP_CFLAGS?= ${CFLAGS}
                    212: .depend: ${SRCS} assym.h
                    213:        ${MKDEP} ${MKDEP_AFLAGS} ${CPPFLAGS} ${MD_SFILES} ${SFILES}
                    214:        ${MKDEP} -a ${MKDEP_CFLAGS} ${CPPFLAGS} ${MD_CFILES} ${MI_CFILES} \
                    215:            ${CFILES}
                    216:        sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
                    217:            ${CPPFLAGS} < ${GENASSYM}
                    218:        @sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
                    219:        @rm -f assym.dep
                    220: .endif
                    221:
                    222: .if !target(dependall)
                    223: dependall: depend all
                    224: .endif
                    225:
                    226: .if !target(lint)
                    227: ALLSFILES?=    ${MD_SFILES} ${SFILES}
                    228: LINTSTUBS?=    ${ALLSFILES:T:R:C/^.*$/LintStub_&.c/g}
                    229: KERNLINTFLAGS?=        -hbxncez -Dvolatile=
                    230: .for _sfile in ${ALLSFILES}
                    231: LintStub_${_sfile:T:R}.c: ${_sfile} assym.h
                    232:        ${CC} -E -C ${AFLAGS} ${CPPFLAGS} ${_sfile} | \
                    233:              awk -f $S/kern/genlintstub.awk >${.TARGET}
                    234: .endfor
                    235: lint: ${CFILES} ${KERNLINTSTUBS} ${MI_CFILES} ${MD_CFILES}
                    236:        @${LINT} ${KERNLINTFLAGS} ${CPPFLAGS} -UKGDB \
                    237:            ${CFILES} ${LINTSTUBS} ${MI_CFILES} ${MD_CFILES} | \
                    238:            grep -v 'static function .* unused'
                    239: .endif
                    240:
                    241: .if !target(install)
                    242: # The install target can be redefined by putting a
                    243: # install-kernel-${MACHINE_NAME} target into /etc/mk.conf
                    244: MACHINE_NAME!=  uname -n
                    245: install: install-kernel-${MACHINE_NAME}
                    246: .if !target(install-kernel-${MACHINE_NAME}})
                    247: install-kernel-${MACHINE_NAME}:
                    248:        rm -f /onetbsd
                    249:        ln /netbsd /onetbsd
                    250:        cp netbsd /nnetbsd
                    251:        mv /nnetbsd /netbsd
                    252: .endif
                    253: .endif
                    254:
                    255: .if !target(tags)
                    256: tags:
                    257:        @echo "see $S/kern/Makefile for tags"
                    258: .endif
                    259:
                    260: ##
                    261: ## the end
                    262: ##

CVSweb <webmaster@jp.NetBSD.org>