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