1# $OpenBSD: Makefile.landisk,v 1.70 2017/06/29 16:51:35 espie 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} 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 127gap.o: Makefile makegap.sh 128 sh makegap.sh 0xc3c3c3c3 129 130vers.o: ${SYSTEM_DEP:Ngap.o} 131 sh $S/conf/newvers.sh 132 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c 133 134clean: 135 rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* ${DB_STRUCTINFO} \ 136 gap.link ld.script lorder makegap.sh param.c 137 138cleandir: clean 139 rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c 140 141depend obj: 142 143db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.pl 144 ${CC} ${CFLAGS} ${CPPFLAGS} -MT $@ -gstabs -c $S/ddb/db_structinfo.c 145 objdump -g db_structinfo.o | perl $S/ddb/parse_structinfo.pl > $@ 146 rm -f db_structinfo.o 147 148locore.o: ${_machdir}/${_mach}/locore.S assym.h 149locore0.o: ${_machdir}/${_mach}/locore0.S assym.h 150locore_subr.o vectors.o in_cksum.o: assym.h 151 152newinstall: 153 cmp -s bsd /bsd || ln -f /bsd /obsd 154 umask 077 && cp bsd /nbsd && mv /nbsd /bsd && \ 155 sha256 -h /var/db/kernel.SHA256 /bsd 156 157install: update-link newinstall 158 159# pull in the dependency information 160.if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) 161 ${SYSTEM_OBJ}: ${DB_STRUCTINFO} 162.endif 163.ifnmake clean 164. for o in ${SYSTEM_OBJ} assym.h ${DB_STRUCTINFO} 165. if exists(${o:R}.d) 166. include "${o:R}.d" 167. elif exists($o) 168 .PHONY: $o 169. endif 170. endfor 171.endif 172 173%RULES 174