Makefile.landisk revision 1.54
1# $OpenBSD: Makefile.landisk,v 1.54 2016/04/29 12:44:52 mpi 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. -I$S/arch 25CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D__${_mach}__ -MD -MP 26CWARNFLAGS= -Werror -Wall -Wimplicit-function-declaration \ 27 -Wno-main -Wno-uninitialized \ 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.h ${DB_STRUCTINFO} 122 123lint: 124 @lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \ 125 ${CFILES} ioconf.c param.c | \ 126 grep -v 'static function .* unused' 127 128depend: 129 @touch $@ 130 131tags: 132 @echo "see $S/kern/Makefile for tags" 133 134db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.pl 135 ${CC} ${CFLAGS} ${CPPFLAGS} -MT $@ -gstabs -c $S/ddb/db_structinfo.c 136 objdump -g db_structinfo.o | perl $S/ddb/parse_structinfo.pl > $@ 137 rm -f db_structinfo.o 138 139locore.o: ${_machdir}/${_mach}/locore.S assym.h 140locore_subr.o vectors.o in_cksum.o: assym.h 141 142# The install target can be redefined by putting a 143# install-kernel-${MACHINE_NAME} target into /etc/mk.conf 144MACHINE_NAME!= uname -n 145install: install-kernel-${MACHINE_NAME} 146.if !target(install-kernel-${MACHINE_NAME}}) 147install-kernel-${MACHINE_NAME}: 148 cmp -s bsd /bsd || ln -f /bsd /obsd 149 cp bsd /nbsd 150 mv /nbsd /bsd 151.endif 152 153# pull in the dependency information 154.if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) 155 ${SYSTEM_OBJ}: ${DB_STRUCTINFO} 156.endif 157.ifnmake clean 158. for o in ${SYSTEM_OBJ} assym.h ${DB_STRUCTINFO} 159. if exists(${o:R}.d) 160. include "${o:R}.d" 161. elif exists($o) 162 .PHONY: $o 163. endif 164. endfor 165.endif 166 167%RULES 168