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