1# $OpenBSD: Makefile.luna88k,v 1.84 2021/01/28 17:39:03 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?= 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 \ 28 -Wframe-larger-than=2047 29 30CMACHFLAGS= -mno-check-zero-division -mmemcpy 31CMACHFLAGS+= -fno-builtin-printf -fno-builtin-snprintf \ 32 -fno-builtin-vsnprintf -fno-builtin-log \ 33 -fno-builtin-log2 -fno-builtin-malloc 34SORTR= sort -R 35.if ${IDENT:M-DNO_PROPOLICE} 36CMACHFLAGS+= -fno-stack-protector 37.endif 38.if ${IDENT:M-DSMALL_KERNEL} 39SORTR= cat 40COPTIMIZE?= -Oz 41.endif 42 43DEBUG?= -g 44COPTIMIZE?= -O2 45CFLAGS= ${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTIMIZE} ${COPTS} ${PIPE} 46AFLAGS= -D_LOCORE -x assembler-with-cpp ${CWARNFLAGS} ${CMACHFLAGS} 47LINKFLAGS= -T ld.script -Ttext 0x80000 -e __start -X -N --warn-common -nopie 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} ${PROF} -c $< 57PROFILE_C= ${CC} -S -c ${CFLAGS} ${CPPFLAGS} $<; \ 58 sed -e s/_mcount/mcount/ -e s/subrmcount/subr_mcount/ <$*.s | \ 59 ${AS} -o $@; \ 60 rm -f $*.s 61 62%OBJS 63 64%CFILES 65 66%SFILES 67 68# load lines for config "xxx" will be emitted as: 69# xxx: ${SYSTEM_DEP} swapxxx.o 70# ${SYSTEM_LD_HEAD} 71# ${SYSTEM_LD} swapxxx.o 72# ${SYSTEM_LD_TAIL} 73SYSTEM_HEAD= locore0.o gap.o 74SYSTEM_OBJ= ${SYSTEM_HEAD} ${OBJS} param.o ioconf.o 75SYSTEM_DEP= Makefile ${SYSTEM_OBJ} ld.script 76SYSTEM_LD_HEAD= @rm -f $@ 77SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \ 78 umask 007; \ 79 echo ${OBJS} param.o ioconf.o vers.o | tr " " "\n" | ${SORTR} > lorder; \ 80 ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} `cat lorder` 81SYSTEM_LD_TAIL= @${SIZE} $@ 82 83.if ${DEBUG} == "-g" 84STRIPFLAGS= -S 85SYSTEM_LD_TAIL+=; umask 007; \ 86 echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \ 87 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \ 88 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb 89.else 90LINKFLAGS+= -S 91.endif 92 93%LOAD 94 95# cc's -MD puts the source and output paths in the dependency file; 96# since those are temp files here we need to fix it up. It also 97# puts the file in /tmp, so we use -MF to put it in the current 98# directory as assym.P and then generate assym.d from it with a 99# good target name 100assym.h: $S/kern/genassym.sh Makefile \ 101 ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf 102 cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \ 103 sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp 104 sed '1s/.*/assym.h: \\/' assym.P > assym.d 105 sort -u assym.h.tmp > assym.h 106 107param.c: $S/conf/param.c 108 rm -f param.c 109 cp $S/conf/param.c . 110 111param.o: param.c Makefile 112 ${NORMAL_C} 113 114mcount.o: $S/lib/libkern/mcount.c Makefile 115 ${NORMAL_C_NOP} 116 117ioconf.o: ioconf.c 118 ${NORMAL_C} 119 120ld.script: ${_machdir}/conf/ld.script 121 cp ${_machdir}/conf/ld.script $@ 122 123makegap.sh: 124 cp $S/conf/makegap.sh $@ 125 126MAKE_GAP = LD="${LD}" sh makegap.sh 0x00000000 127 128gap.o: Makefile makegap.sh vers.o 129 ${MAKE_GAP} 130 131vers.o: ${SYSTEM_DEP:Ngap.o} 132 sh $S/conf/newvers.sh 133 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c 134 135clean: 136 rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* \ 137 gap.link ld.script lorder makegap.sh param.c 138 139cleandir: clean 140 rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c 141 142depend obj: 143 144locore0.o: ${_machdir}/${_mach}/locore0.S assym.h 145locore.o eh.o mutex.o process.o subr.o: assym.h 146 147hardlink-obsd: 148 [[ ! -f /bsd ]] || cmp -s bsd /bsd || ln -f /bsd /obsd 149 150newinstall: 151 install -F -m 700 bsd /bsd && sha256 -h /var/db/kernel.SHA256 /bsd 152 153install: update-link hardlink-obsd newinstall 154 155# pull in the dependency information 156.ifnmake clean 157. for o in ${SYSTEM_OBJ:Ngap.o} assym.h 158. if exists(${o:R}.d) 159. include "${o:R}.d" 160. elif exists($o) 161 .PHONY: $o 162. endif 163. endfor 164.endif 165 166%RULES 167