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