1# $OpenBSD: Makefile.alpha,v 1.76 2011/07/07 22:28:18 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 13MKDEP?= mkdep 14SIZE?= size 15STRIP?= strip 16 17# source tree is located via $S relative to the compilation directory 18.ifndef S 19S!= cd ../../../..; pwd 20.endif 21 22_machdir?= $S/arch/${_mach} 23_archdir?= $S/arch/${_arch} 24 25INCLUDES= -nostdinc -I. -I$S -I$S/arch 26CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -MD -MP 27CWARNFLAGS= -Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \ 28 -Wno-main -Wno-uninitialized -Wno-format \ 29 -Wstack-larger-than-2047 30 31CMACHFLAGS= -mno-fp-regs -Wa,-mev56 32CMACHFLAGS+= -fno-builtin-printf -fno-builtin-snprintf \ 33 -fno-builtin-vsnprintf -fno-builtin-log \ 34 -fno-builtin-log2 -fno-builtin-malloc 35.if ${IDENT:M-DNO_PROPOLICE} 36CMACHFLAGS+= -fno-stack-protector 37.endif 38 39COPTS?= -O2 40CFLAGS= ${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE} 41AFLAGS= -D_LOCORE -x assembler-with-cpp -traditional-cpp ${CMACHFLAGS} 42LINKFLAGS= -T ${_machdir}/conf/ld.script -X -N -G 4 --warn-common 43 44.if ${IDENT:M-DDDB_STRUCT} 45DB_STRUCTINFO= db_structinfo.h 46.else 47DB_STRUCTINFO= 48.endif 49 50HOSTCC?= ${CC} 51HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//} 52HOSTED_CFLAGS= ${CFLAGS} 53HOSTED_C= ${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $< 54 55NORMAL_C_NOP= ${CC} ${CFLAGS} ${CPPFLAGS} -c $< 56NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< 57NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $< 58 59%OBJS 60 61%CFILES 62 63%SFILES 64 65# load lines for config "xxx" will be emitted as: 66# xxx: ${SYSTEM_DEP} swapxxx.o 67# ${SYSTEM_LD_HEAD} 68# ${SYSTEM_LD} swapxxx.o 69# ${SYSTEM_LD_TAIL} 70SYSTEM_HEAD= locore.o param.o ioconf.o 71SYSTEM_OBJ= ${SYSTEM_HEAD} ${OBJS} 72SYSTEM_DEP= Makefile ${SYSTEM_OBJ} 73SYSTEM_LD_HEAD= @rm -f $@ 74SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \ 75 ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} vers.o ${OBJS} 76SYSTEM_LD_TAIL= @${SIZE} $@; chmod 755 $@ 77 78DEBUG?= 79.if ${DEBUG} == "-g" 80LINKFLAGS+= -X 81STRIPFLAGS= -g -x 82SYSTEM_LD_TAIL+=; \ 83 echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \ 84 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \ 85 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb 86.else 87LINKFLAGS+= -S -x 88.endif 89 90%LOAD 91 92# cc's -MD puts the source and output paths in the dependency file; 93# since those are temp files here we need to fix it up. It also 94# puts the file in /tmp, so we use -MF to put it in the current 95# directory as assym.P and then generate assym.d from it with a 96# good target name 97assym.h: $S/kern/genassym.sh Makefile \ 98 ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf 99 cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \ 100 sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp 101 sed '1s/.*/assym.h: \\/' assym.P > assym.d 102 sort -u assym.h.tmp > assym.h 103 104param.c: $S/conf/param.c 105 rm -f param.c 106 cp $S/conf/param.c . 107 108param.o: param.c Makefile 109 ${NORMAL_C} 110 111mcount.o: $S/lib/libkern/mcount.c Makefile 112 ${NORMAL_C_NOP} 113 114ioconf.o: ioconf.c 115 ${NORMAL_C} 116 117vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} 118 sh $S/conf/newvers.sh 119 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c 120 121clean:: 122 rm -f eddep *bsd *bsd.gdb tags *.[dio] [a-z]*.s \ 123 [Ee]rrs linterrs assym.h ${DB_STRUCTINFO} 124 125lint: 126 @lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \ 127 ${CFILES} ioconf.c param.c | \ 128 grep -v 'static function .* unused' 129 130depend: 131 @touch $@ 132 133tags: 134 @echo "see $S/kern/Makefile for tags" 135 136db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.awk 137 ${CC} ${CFLAGS} ${CPPFLAGS} -MT $@ -gstabs -c $S/ddb/db_structinfo.c 138 objdump -g db_structinfo.o | awk -f $S/ddb/parse_structinfo.awk > $@ 139 rm -f db_structinfo.o 140 141locore.o: ${_machdir}/${_mach}/locore.s 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