1# $OpenBSD: Makefile.octeon,v 1.56 2019/11/07 20:42:28 guenther 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 15AS?= as 16CC?= cc 17LD?= ld ${ENDIAN} 18 19AS+=${ENDIAN} 20CC+=${ENDIAN} 21LD+=${ENDIAN} 22 23# source tree is located via $S relative to the compilation directory 24.ifndef S 25S!= cd ../../../..; pwd 26.endif 27 28_machdir?= $S/arch/${_mach} 29_archdir?= $S/arch/${_arch} 30 31INCLUDES= -nostdinc -I$S -I${.OBJDIR} -I$S/arch 32CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D__${_mach}__ -MD -MP 33CWARNFLAGS= -Werror -Wall -Wimplicit-function-declaration \ 34 -Wno-uninitialized -Wno-pointer-sign \ 35 -Wframe-larger-than=2047 36 37CMACHFLAGS= -mno-abicalls ${ABI} -msoft-float -G 0 38CMACHFLAGS+= -ffreestanding ${NOPIE_FLAGS} 39SORTR= sort -R 40.if ${IDENT:M-DNO_PROPOLICE} 41CMACHFLAGS+= -fno-stack-protector 42.endif 43.if ${IDENT:M-DSMALL_KERNEL} 44SORTR= cat 45COPTS?= -Oz 46.endif 47.if ${COMPILER_VERSION:Mclang} 48NO_INTEGR_AS= -no-integrated-as 49CMACHFLAGS+= -fomit-frame-pointer 50CWARNFLAGS+= -Wno-address-of-packed-member -Wno-constant-conversion 51.endif 52 53DEBUG?= -g 54COPTS?= -O2 55CFLAGS= ${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE} 56AFLAGS= -D_LOCORE -x assembler-with-cpp ${CWARNFLAGS} ${CMACHFLAGS} 57LINKFLAGS= -e start -T ld.script -Ttext=${LINK_ADDRESS} --warn-common -nopie 58 59HOSTCC?= ${CC} 60HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//} 61HOSTED_CFLAGS= ${CFLAGS} 62HOSTED_C= ${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $< 63 64NORMAL_C_NOP= ${CC} ${CFLAGS} ${CPPFLAGS} -fno-ret-protector -c $< 65NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< 66NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} ${PROF} -c $< 67 68%OBJS 69 70%CFILES 71 72%SFILES 73 74# load lines for config "xxx" will be emitted as: 75# xxx: ${SYSTEM_DEP} swapxxx.o 76# ${SYSTEM_LD_HEAD} 77# ${SYSTEM_LD} swapxxx.o 78# ${SYSTEM_LD_TAIL} 79SYSTEM_HEAD= locore0.o gap.o 80SYSTEM_OBJ= ${SYSTEM_HEAD} ${OBJS} param.o ioconf.o 81SYSTEM_DEP= Makefile ${SYSTEM_OBJ} ld.script 82SYSTEM_LD_HEAD= @rm -f $@ 83SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \ 84 umask 007; \ 85 echo ${OBJS} param.o ioconf.o vers.o | tr " " "\n" | ${SORTR} > lorder; \ 86 ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} `cat lorder` 87SYSTEM_LD_TAIL= @${SIZE} $@ 88 89.if ${DEBUG} == "-g" 90STRIPFLAGS= -S 91SYSTEM_LD_TAIL+=; umask 007; \ 92 echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \ 93 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \ 94 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb 95.else 96LINKFLAGS+= -S 97.endif 98 99%LOAD 100 101# cc's -MD puts the source and output paths in the dependency file; 102# since those are temp files here we need to fix it up. It also 103# puts the file in /tmp, so we use -MF to put it in the current 104# directory as assym.P and then generate assym.d from it with a 105# good target name 106assym.h: $S/kern/genassym.sh Makefile \ 107 ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf 108 cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \ 109 sh $S/kern/genassym.sh ${CC} ${NO_INTEGR_AS} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp 110 sed '1s/.*/assym.h: \\/' assym.P > assym.d 111 sort -u assym.h.tmp > assym.h 112 113param.c: $S/conf/param.c 114 rm -f param.c 115 cp $S/conf/param.c . 116 117param.o: param.c Makefile 118 ${NORMAL_C} 119 120mcount.o: $S/lib/libkern/mcount.c Makefile 121 ${NORMAL_C_NOP} 122 123ioconf.o: ioconf.c 124 ${NORMAL_C} 125 126ld.script: ${_machdir}/conf/ld.script 127 cp ${_machdir}/conf/ld.script $@ 128 129gapdummy.o: 130 echo '__asm(".section .rodata,\"a\"");' > gapdummy.c 131 ${CC} -c ${CFLAGS} ${CPPFLAGS} gapdummy.c -o $@ 132 133makegap.sh: 134 cp $S/conf/makegap.sh $@ 135 136MAKE_GAP = LD="${LD}" sh makegap.sh 0xefefefef gapdummy.o 137 138gap.o: Makefile makegap.sh gapdummy.o vers.o 139 ${MAKE_GAP} 140 141vers.o: ${SYSTEM_DEP:Ngap.o} 142 sh $S/conf/newvers.sh 143 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c 144 145clean: 146 rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* \ 147 gap.link gapdummy.c ld.script lorder makegap.sh param.c 148 149cleandir: clean 150 rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c 151 152depend obj: 153 154locore0.o: ${_machdir}/${_mach}/locore0.S assym.h 155context.o cp0access.o exception.o locore.o: assym.h 156lcore_access.o lcore_ddb.o lcore_float.o tlbhandler.o: assym.h 157mips64r2.o: assym.h 158 159hardlink-obsd: 160 [[ ! -f /bsd ]] || cmp -s bsd /bsd || ln -f /bsd /obsd 161 162newinstall: 163 install -F -m 700 bsd /bsd && sha256 -h /var/db/kernel.SHA256 /bsd 164 165install: update-link hardlink-obsd newinstall 166 167# pull in the dependency information 168.ifnmake clean 169. for o in ${SYSTEM_OBJ:Ngap.o} assym.h 170. if exists(${o:R}.d) 171. include "${o:R}.d" 172. elif exists($o) 173 .PHONY: $o 174. endif 175. endfor 176.endif 177 178%RULES 179