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