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