Makefile.landisk revision 1.73
1# $OpenBSD: Makefile.landisk,v 1.73 2017/08/12 20:26:11 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?= ctfstrip 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} 34SORTR= sort -R 35.if ${IDENT:M-DNO_PROPOLICE} 36CMACHFLAGS+= -fno-stack-protector 37.endif 38.if ${IDENT:M-DSMALL_KERNEL} 39SORTR= cat 40.endif 41 42DEBUG?= -g 43COPTS?= -O2 44CFLAGS= ${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE} 45AFLAGS= -D_LOCORE -x assembler-with-cpp ${CWARNFLAGS} ${CMACHFLAGS} 46LINKFLAGS= -N -Ttext 0x8c002000 -e start --warn-common -nopie 47 48.if ${IDENT:M-DDDB_STRUCT} 49DB_STRUCTINFO= db_structinfo.h 50.else 51DB_STRUCTINFO= 52.endif 53 54HOSTCC?= ${CC} 55HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//} 56HOSTED_CFLAGS= ${CFLAGS} 57HOSTED_C= ${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $< 58 59NORMAL_C_NOP= ${CC} ${CFLAGS} ${CPPFLAGS} -c $< 60NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< 61NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $< 62 63%OBJS 64 65%CFILES 66 67%SFILES 68 69# load lines for config "xxx" will be emitted as: 70# xxx: ${SYSTEM_DEP} swapxxx.o 71# ${SYSTEM_LD_HEAD} 72# ${SYSTEM_LD} swapxxx.o 73# ${SYSTEM_LD_TAIL} 74SYSTEM_HEAD= locore0.o gap.o 75SYSTEM_OBJ= ${SYSTEM_HEAD} ${OBJS} param.o ioconf.o 76SYSTEM_DEP= Makefile ${SYSTEM_OBJ} ld.script 77SYSTEM_LD_HEAD= @rm -f $@ 78SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \ 79 umask 007; \ 80 echo ${OBJS} param.o ioconf.o vers.o | tr " " "\n" | ${SORTR} > lorder; \ 81 ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} `cat lorder` 82SYSTEM_LD_TAIL= @${SIZE} $@ 83 84.if ${DEBUG} == "-g" 85STRIPFLAGS= -S 86SYSTEM_LD_TAIL+=; umask 007; \ 87 echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \ 88 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \ 89 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb 90.else 91LINKFLAGS+= -S 92.endif 93 94%LOAD 95 96# cc's -MD puts the source and output paths in the dependency file; 97# since those are temp files here we need to fix it up. It also 98# puts the file in /tmp, so we use -MF to put it in the current 99# directory as assym.P and then generate assym.d from it with a 100# good target name 101assym.h: $S/kern/genassym.sh Makefile \ 102 ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf 103 cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \ 104 sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp 105 sed '1s/.*/assym.h: \\/' assym.P > assym.d 106 sort -u assym.h.tmp > assym.h 107 108param.c: $S/conf/param.c 109 rm -f param.c 110 cp $S/conf/param.c . 111 112param.o: param.c Makefile 113 ${NORMAL_C} 114 115mcount.o: $S/lib/libkern/mcount.c Makefile 116 ${NORMAL_C_NOP} 117 118ioconf.o: ioconf.c 119 ${NORMAL_C} 120 121ld.script: ${_machdir}/conf/ld.script 122 cp ${_machdir}/conf/ld.script $@ 123 124makegap.sh: 125 cp $S/conf/makegap.sh $@ 126 127MAKE_GAP = LD="${LD}" sh makegap.sh 0xc3c3c3c3 128 129gap.o: Makefile makegap.sh vers.o 130 ${MAKE_GAP} 131 132vers.o: ${SYSTEM_DEP:Ngap.o} 133 sh $S/conf/newvers.sh 134 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c 135 136clean: 137 rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* ${DB_STRUCTINFO} \ 138 gap.link ld.script lorder makegap.sh param.c 139 140cleandir: clean 141 rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c 142 143depend obj: 144 145db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.pl 146 ${CC} ${CFLAGS} ${CPPFLAGS} -MT $@ -gstabs -c $S/ddb/db_structinfo.c 147 objdump -g db_structinfo.o | perl $S/ddb/parse_structinfo.pl > $@ 148 rm -f db_structinfo.o 149 150locore.o: ${_machdir}/${_mach}/locore.S assym.h 151locore0.o: ${_machdir}/${_mach}/locore0.S assym.h 152locore_subr.o vectors.o in_cksum.o: assym.h 153 154newinstall: 155 cmp -s bsd /bsd || ln -f /bsd /obsd 156 umask 077 && cp bsd /nbsd && mv /nbsd /bsd && \ 157 sha256 -h /var/db/kernel.SHA256 /bsd 158 159install: update-link newinstall 160 161# pull in the dependency information 162.if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) 163 ${SYSTEM_OBJ}: ${DB_STRUCTINFO} 164.endif 165.ifnmake clean 166. for o in ${SYSTEM_OBJ:Ngap.o} assym.h ${DB_STRUCTINFO} 167. if exists(${o:R}.d) 168. include "${o:R}.d" 169. elif exists($o) 170 .PHONY: $o 171. endif 172. endfor 173.endif 174 175%RULES 176