1# $OpenBSD: Makefile.sparc64,v 1.67 2013/10/15 19:23:31 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?= 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. -I$S/arch 25CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -MD -MP 26CWARNFLAGS= -Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \ 27 -Wno-main -Wno-uninitialized -Wno-format \ 28 -Wstack-larger-than-2047 29 30CMACHFLAGS= -Wa,-Av9b, -mno-fpu 31CMACHFLAGS+= -fno-builtin-printf -fno-builtin-snprintf \ 32 -fno-builtin-vsnprintf -fno-builtin-log \ 33 -fno-builtin-log2 -fno-builtin-malloc ${NOPIE_FLAGS} 34.if ${IDENT:M-DNO_PROPOLICE} 35CMACHFLAGS+= -fno-stack-protector 36.endif 37 38COPTS?= -O2 39CFLAGS= ${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE} 40AFLAGS= -D_LOCORE -x assembler-with-cpp ${CWARNFLAGS} ${CMACHFLAGS} 41LINKFLAGS= -n -T ${_machdir}/conf/ld.script --warn-common -nopie 42 43.if ${IDENT:M-DDDB_STRUCT} 44DB_STRUCTINFO= db_structinfo.h 45.else 46DB_STRUCTINFO= 47.endif 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} -c $< 57 58%OBJS 59 60%CFILES 61 62%SFILES 63 64# load lines for config "xxx" will be emitted as: 65# xxx: ${SYSTEM_DEP} swapxxx.o 66# ${SYSTEM_LD_HEAD} 67# ${SYSTEM_LD} swapxxx.o 68# ${SYSTEM_LD_TAIL} 69SYSTEM_HEAD= locore.o param.o ioconf.o 70SYSTEM_OBJ= ${SYSTEM_HEAD} ${OBJS} 71SYSTEM_DEP= Makefile ${SYSTEM_OBJ} 72SYSTEM_LD_HEAD= @rm -f $@ 73SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \ 74 ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} vers.o ${OBJS} 75SYSTEM_LD_TAIL= @${SIZE} $@; chmod 755 $@ 76 77DEBUG?= 78.if ${DEBUG} == "-g" 79LINKFLAGS+= -X 80STRIPFLAGS= -g -x 81SYSTEM_LD_TAIL+=; \ 82 echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \ 83 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \ 84 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb 85.else 86LINKFLAGS+= -S -x 87.endif 88 89%LOAD 90 91# cc's -MD puts the source and output paths in the dependency file; 92# since those are temp files here we need to fix it up. It also 93# puts the file in /tmp, so we use -MF to put it in the current 94# directory as assym.P and then generate assym.d from it with a 95# good target name 96assym.h: $S/kern/genassym.sh Makefile \ 97 ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf 98 cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \ 99 sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp 100 sed '1s/.*/assym.h: \\/' assym.P > assym.d 101 sort -u assym.h.tmp > assym.h 102 103param.c: $S/conf/param.c 104 rm -f param.c 105 cp $S/conf/param.c . 106 107param.o: param.c Makefile 108 ${NORMAL_C} 109 110mcount.o: $S/lib/libkern/mcount.c Makefile 111 ${NORMAL_C_NOP} 112 113ioconf.o: ioconf.c 114 ${NORMAL_C} 115 116vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} 117 sh $S/conf/newvers.sh 118 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c 119 120clean:: 121 rm -f eddep *bsd *bsd.gdb tags *.[dio] [a-z]*.s \ 122 [Ee]rrs linterrs assym.h ${DB_STRUCTINFO} 123 124lint: 125 @lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \ 126 ${CFILES} ioconf.c param.c | \ 127 grep -v 'static function .* unused' 128 129depend: 130 @touch $@ 131 132tags: 133 @echo "see $S/kern/Makefile for tags" 134 135db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.pl 136 ${CC} ${CFLAGS} ${CPPFLAGS} -MT $@ -gstabs -c $S/ddb/db_structinfo.c 137 objdump -g db_structinfo.o | perl $S/ddb/parse_structinfo.pl > $@ 138 rm -f db_structinfo.o 139 140locore.o: ${_machdir}/${_mach}/locore.s assym.h 141hvcall.o in_cksum.o mutex.o: assym.h 142 143# The install target can be redefined by putting a 144# install-kernel-${MACHINE_NAME} target into /etc/mk.conf 145MACHINE_NAME!= uname -n 146install: install-kernel-${MACHINE_NAME} 147.if !target(install-kernel-${MACHINE_NAME}}) 148install-kernel-${MACHINE_NAME}: 149 rm -f /obsd 150 ln /bsd /obsd 151 cp bsd /nbsd 152 mv /nbsd /bsd 153.endif 154 155# pull in the dependency information 156.if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO}) 157 ${SYSTEM_OBJ}: ${DB_STRUCTINFO} 158.endif 159.ifnmake clean 160. for o in ${SYSTEM_OBJ} assym.h ${DB_STRUCTINFO} 161. if exists(${o:R}.d) 162. include "${o:R}.d" 163. elif exists($o) 164 .PHONY: $o 165. endif 166. endfor 167.endif 168 169%RULES 170