Makefile.landisk revision 1.38
1# $OpenBSD: Makefile.landisk,v 1.38 2010/12/02 04:35:02 deraadt Exp $ 2 3# For instructions on building kernels consult the config(8) and options(4) 4# manual pages. 5# 6# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE 7# IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING 8# DEBUG is set to -g by config if debugging is requested (config -g). 9# PROF is set to -pg by config if profiling is requested (config -p). 10 11.include <bsd.own.mk> 12 13MKDEP?= mkdep 14SIZE?= size 15STRIP?= strip 16 17# source tree is located via $S relative to the compilation directory 18.ifndef S 19S!= cd ../../../..; pwd 20.endif 21 22_machdir?= $S/arch/${_mach} 23_archdir?= $S/arch/${_arch} 24 25INCLUDES= -nostdinc -I. -I$S -I$S/arch 26CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D__${_mach}__ 27CWARNFLAGS= -Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \ 28 -Wno-main -Wno-uninitialized -Wno-format \ 29 -Wstack-larger-than-2047 30 31CMACHFLAGS= -m4-nofpu 32CMACHFLAGS+= -fno-builtin-printf -fno-builtin-snprintf \ 33 -fno-builtin-vsnprintf -fno-builtin-log \ 34 -fno-builtin-log2 -fno-builtin-malloc 35.if ${IDENT:M-DNO_PROPOLICE} 36CMACHFLAGS+= -fno-stack-protector 37.endif 38 39COPTS?= -O2 40CFLAGS= ${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE} 41AFLAGS= -D_LOCORE -x assembler-with-cpp ${CMACHFLAGS} 42LINKFLAGS= -N -Ttext 0x8c002000 -e start --warn-common 43 44.if ${IDENT:M-DDDB_STRUCT} 45DB_STRUCTINFO= db_structinfo.h 46.else 47DB_STRUCTINFO= 48.endif 49 50HOSTCC?= ${CC} 51HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//} 52HOSTED_CFLAGS= ${CFLAGS} 53HOSTED_C= ${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $< 54 55NORMAL_C_NOP= ${CC} ${CFLAGS} ${CPPFLAGS} -c $< 56NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< 57NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $< 58 59%OBJS 60 61%CFILES 62 63%SFILES 64 65# load lines for config "xxx" will be emitted as: 66# xxx: ${SYSTEM_DEP} swapxxx.o 67# ${SYSTEM_LD_HEAD} 68# ${SYSTEM_LD} swapxxx.o 69# ${SYSTEM_LD_TAIL} 70SYSTEM_OBJ= locore.o param.o ioconf.o vers.o ${OBJS} 71SYSTEM_DEP= Makefile ${SYSTEM_OBJ} 72SYSTEM_LD_HEAD= @rm -f $@ 73SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}'; \ 74 ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} 75SYSTEM_LD_TAIL= @${SIZE} $@; chmod 755 $@ 76 77DEBUG?= 78.if ${DEBUG} == "-g" 79LINKFLAGS+= -X 80STRIPFLAGS= -g -x 81SYSTEM_LD_TAIL+=; \ 82 echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \ 83 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \ 84 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb 85.else 86LINKFLAGS+= -S -x 87.endif 88 89%LOAD 90 91assym.h: $S/kern/genassym.sh Makefile \ 92 ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf 93 cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \ 94 sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} | \ 95 sort -u > assym.h.tmp && \ 96 mv -f assym.h.tmp assym.h 97 98param.c: $S/conf/param.c 99 rm -f param.c 100 cp $S/conf/param.c . 101 102param.o: param.c Makefile 103 ${NORMAL_C} 104 105mcount.o: $S/lib/libkern/mcount.c Makefile 106 ${NORMAL_C_NOP} 107 108ioconf.o: ioconf.c 109 ${NORMAL_C} 110 111vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} 112 sh $S/conf/newvers.sh 113 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c 114 115clean:: 116 rm -f eddep *bsd *bsd.gdb tags *.[io] [a-z]*.s \ 117 [Ee]rrs linterrs assym.h ${DB_STRUCTINFO} 118 119lint: 120 @lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \ 121 ${CFILES} ioconf.c param.c | \ 122 grep -v 'static function .* unused' 123 124tags: 125 @echo "see $S/kern/Makefile for tags" 126 127AFILES= ${_machdir}/${_mach}/locore.S 128depend:: .depend 129.depend: ${AFILES} param.c ioconf.c ${CFILES} ${SFILES} assym.h ${DB_STRUCTINFO} 130 ${MKDEP} ${AFLAGS} ${CPPFLAGS} ${AFILES} 131 ${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES} 132.if !empty(SFILES) 133 ${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES} 134.endif 135 cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \ 136 sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} ${CPPFLAGS} 137 @sed -e 's/.*\.o: /assym.h: /' -e 's/\/tmp\/genassym_c.[^ ]*//' \ 138 < assym.dep >> .depend 139 @rm -f assym.dep 140 141db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.awk 142 ${CC} ${CFLAGS} ${CPPFLAGS} -gstabs -c $S/ddb/db_structinfo.c 143 objdump -g db_structinfo.o | awk -f $S/ddb/parse_structinfo.awk > $@ 144 rm -f db_structinfo.o 145 146locore.o: ${_machdir}/${_mach}/locore.S assym.h 147locore_subr.o vectors.o in_cksum.o: assym.h 148 149# The install target can be redefined by putting a 150# install-kernel-${MACHINE_NAME} target into /etc/mk.conf 151MACHINE_NAME!= uname -n 152install: install-kernel-${MACHINE_NAME} 153.if !target(install-kernel-${MACHINE_NAME}}) 154install-kernel-${MACHINE_NAME}: 155 rm -f /obsd 156 ln /bsd /obsd 157 cp bsd /nbsd 158 mv /nbsd /bsd 159.endif 160 161%RULES 162