Makefile.landisk revision 1.62
1# $OpenBSD: Makefile.landisk,v 1.62 2017/06/03 22:21:33 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 38DEBUG?= -g 39COPTS?= -O2 40CFLAGS= ${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE} 41AFLAGS= -D_LOCORE -x assembler-with-cpp ${CWARNFLAGS} ${CMACHFLAGS} 42LINKFLAGS= -N -Ttext 0x8c002000 -e start --warn-common -nopie 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_HEAD= locore.o param.o ioconf.o 71SYSTEM_OBJ= ${SYSTEM_HEAD} ${OBJS} 72SYSTEM_DEP= Makefile ${SYSTEM_OBJ} 73SYSTEM_LD_HEAD= @rm -f $@ 74SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \ 75 umask 007; \ 76 ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} vers.o ${OBJS} 77SYSTEM_LD_TAIL= @${SIZE} $@ 78 79.if ${DEBUG} == "-g" 80STRIPFLAGS= -S 81SYSTEM_LD_TAIL+=; umask 007; \ 82 echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \ 83 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \ 84 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb 85.else 86LINKFLAGS+= -S 87.endif 88 89%LOAD 90 91# cc's -MD puts the source and output paths in the dependency file; 92# since those are temp files here we need to fix it up. It also 93# puts the file in /tmp, so we use -MF to put it in the current 94# directory as assym.P and then generate assym.d from it with a 95# good target name 96assym.h: $S/kern/genassym.sh Makefile \ 97 ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf 98 cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \ 99 sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp 100 sed '1s/.*/assym.h: \\/' assym.P > assym.d 101 sort -u assym.h.tmp > assym.h 102 103param.c: $S/conf/param.c 104 rm -f param.c 105 cp $S/conf/param.c . 106 107param.o: param.c Makefile 108 ${NORMAL_C} 109 110mcount.o: $S/lib/libkern/mcount.c Makefile 111 ${NORMAL_C_NOP} 112 113ioconf.o: ioconf.c 114 ${NORMAL_C} 115 116vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} 117 sh $S/conf/newvers.sh 118 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c 119 120clean: 121 rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* ${DB_STRUCTINFO} param.c 122 123cleandir: clean 124 rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c 125 126depend obj: 127 128db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.pl 129 ${CC} ${CFLAGS} ${CPPFLAGS} -MT $@ -gstabs -c $S/ddb/db_structinfo.c 130 objdump -g db_structinfo.o | perl $S/ddb/parse_structinfo.pl > $@ 131 rm -f db_structinfo.o 132 133locore.o: ${_machdir}/${_mach}/locore.S assym.h 134locore_subr.o vectors.o in_cksum.o: assym.h 135 136# The install target can be redefined by putting a 137# install-kernel-${MACHINE_NAME} target into /etc/mk.conf 138MACHINE_NAME!= uname -n 139install: install-kernel-${MACHINE_NAME} 140.if !target(install-kernel-${MACHINE_NAME}}) 141install-kernel-${MACHINE_NAME}: 142 cmp -s bsd /bsd || ln -f /bsd /obsd 143 cp -p bsd /nbsd 144 mv /nbsd /bsd 145.endif 146 147# pull in the dependency information 148.if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) 149 ${SYSTEM_OBJ}: ${DB_STRUCTINFO} 150.endif 151.ifnmake clean 152. for o in ${SYSTEM_OBJ} assym.h ${DB_STRUCTINFO} 153. if exists(${o:R}.d) 154. include "${o:R}.d" 155. elif exists($o) 156 .PHONY: $o 157. endif 158. endfor 159.endif 160 161%RULES 162