Makefile.landisk revision 1.57
1# $OpenBSD: Makefile.landisk,v 1.57 2016/10/15 13:45:08 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 13SIZE?= size 14STRIP?= strip 15 16# source tree is located via $S relative to the compilation directory 17.ifndef S 18S!= cd ../../../..; pwd 19.endif 20 21_machdir?= $S/arch/${_mach} 22_archdir?= $S/arch/${_arch} 23 24INCLUDES= -nostdinc -I$S -I${.OBJDIR} -I$S/arch 25CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D__${_mach}__ -MD -MP 26CWARNFLAGS= -Werror -Wall -Wimplicit-function-declaration \ 27 -Wno-main -Wno-uninitialized -Wno-pointer-sign \ 28 -Wframe-larger-than=2047 29 30CMACHFLAGS= -m4-nofpu 31CMACHFLAGS+= -fno-builtin-printf -fno-builtin-snprintf \ 32 -fno-builtin-vsnprintf -fno-builtin-log \ 33 -fno-builtin-log2 -fno-builtin-malloc ${NOPIE_FLAGS} 34.if ${IDENT:M-DNO_PROPOLICE} 35CMACHFLAGS+= -fno-stack-protector 36.endif 37 38COPTS?= -O2 39CFLAGS= ${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE} 40AFLAGS= -D_LOCORE -x assembler-with-cpp ${CWARNFLAGS} ${CMACHFLAGS} 41LINKFLAGS= -N -Ttext 0x8c002000 -e start --warn-common -nopie 42 43.if ${IDENT:M-DDDB_STRUCT} 44DB_STRUCTINFO= db_structinfo.h 45.else 46DB_STRUCTINFO= 47.endif 48 49HOSTCC?= ${CC} 50HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//} 51HOSTED_CFLAGS= ${CFLAGS} 52HOSTED_C= ${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $< 53 54NORMAL_C_NOP= ${CC} ${CFLAGS} ${CPPFLAGS} -c $< 55NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< 56NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $< 57 58%OBJS 59 60%CFILES 61 62%SFILES 63 64# load lines for config "xxx" will be emitted as: 65# xxx: ${SYSTEM_DEP} swapxxx.o 66# ${SYSTEM_LD_HEAD} 67# ${SYSTEM_LD} swapxxx.o 68# ${SYSTEM_LD_TAIL} 69SYSTEM_HEAD= locore.o param.o ioconf.o 70SYSTEM_OBJ= ${SYSTEM_HEAD} ${OBJS} 71SYSTEM_DEP= Makefile ${SYSTEM_OBJ} 72SYSTEM_LD_HEAD= @rm -f $@ 73SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \ 74 ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} vers.o ${OBJS} 75SYSTEM_LD_TAIL= @${SIZE} $@; chmod 755 $@ 76 77DEBUG?= 78.if ${DEBUG} == "-g" 79STRIPFLAGS= -S 80SYSTEM_LD_TAIL+=; \ 81 echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \ 82 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \ 83 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb 84.else 85LINKFLAGS+= -S 86.endif 87 88%LOAD 89 90# cc's -MD puts the source and output paths in the dependency file; 91# since those are temp files here we need to fix it up. It also 92# puts the file in /tmp, so we use -MF to put it in the current 93# directory as assym.P and then generate assym.d from it with a 94# good target name 95assym.h: $S/kern/genassym.sh Makefile \ 96 ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf 97 cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \ 98 sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp 99 sed '1s/.*/assym.h: \\/' assym.P > assym.d 100 sort -u assym.h.tmp > assym.h 101 102param.c: $S/conf/param.c 103 rm -f param.c 104 cp $S/conf/param.c . 105 106param.o: param.c Makefile 107 ${NORMAL_C} 108 109mcount.o: $S/lib/libkern/mcount.c Makefile 110 ${NORMAL_C_NOP} 111 112ioconf.o: ioconf.c 113 ${NORMAL_C} 114 115vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} 116 sh $S/conf/newvers.sh 117 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c 118 119clean:: 120 rm -f eddep *bsd *bsd.gdb tags *.[dio] [a-z]*.s \ 121 [Ee]rrs linterrs assym.* ${DB_STRUCTINFO} param.c 122 123cleandir: clean 124 rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c version 125 126lint: 127 @lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \ 128 ${CFILES} ioconf.c param.c | \ 129 grep -v 'static function .* unused' 130 131obj: 132 133depend: 134 @touch $@ 135 136tags: 137 @echo "see $S/kern/Makefile for tags" 138 139db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.pl 140 ${CC} ${CFLAGS} ${CPPFLAGS} -MT $@ -gstabs -c $S/ddb/db_structinfo.c 141 objdump -g db_structinfo.o | perl $S/ddb/parse_structinfo.pl > $@ 142 rm -f db_structinfo.o 143 144locore.o: ${_machdir}/${_mach}/locore.S assym.h 145locore_subr.o vectors.o in_cksum.o: assym.h 146 147# The install target can be redefined by putting a 148# install-kernel-${MACHINE_NAME} target into /etc/mk.conf 149MACHINE_NAME!= uname -n 150install: install-kernel-${MACHINE_NAME} 151.if !target(install-kernel-${MACHINE_NAME}}) 152install-kernel-${MACHINE_NAME}: 153 cmp -s bsd /bsd || ln -f /bsd /obsd 154 cp bsd /nbsd 155 mv /nbsd /bsd 156.endif 157 158# pull in the dependency information 159.if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) 160 ${SYSTEM_OBJ}: ${DB_STRUCTINFO} 161.endif 162.ifnmake clean 163. for o in ${SYSTEM_OBJ} assym.h ${DB_STRUCTINFO} 164. if exists(${o:R}.d) 165. include "${o:R}.d" 166. elif exists($o) 167 .PHONY: $o 168. endif 169. endfor 170.endif 171 172%RULES 173