1# $OpenBSD: Makefile.luna88k,v 1.27 2010/04/28 15:31:33 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 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_mach?= luna88k 23_arch?= m88k 24_machdir?= $S/arch/${_mach} 25_archdir?= $S/arch/${_arch} 26 27INCLUDES= -nostdinc -I. -I$S -I$S/arch 28CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D${_mach} -Dm88k 29CWARNFLAGS= -Wall -Werror -Wmissing-prototypes \ 30 -Wno-uninitialized -Wno-format -Wno-main -Wstrict-prototypes \ 31 -Wstack-larger-than-2047 -Wvariable-decl 32CMACHFLAGS= -mno-check-zero-division -mmemcpy \ 33 -fno-builtin-printf -fno-builtin-log 34.if ${IDENT:M-DNO_PROPOLICE} 35CMACHFLAGS+= -fno-stack-protector 36.endif 37COPTS?= -O2 38CFLAGS= ${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE} 39AFLAGS= -x assembler-with-cpp -traditional-cpp -D_LOCORE ${CMACHFLAGS} 40LINKFLAGS= -N -Ttext 0x20000 -e start 41STRIPFLAGS= -d 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} 52 53# compile rules: rules are named ${TYPE}_${SUFFIX}${CONFIG_DEP} 54# where TYPE is NORMAL, or PROFILE}; SUFFIX is the file suffix, 55# capitalized (e.g. C for a .c file), and CONFIG_DEP is _C if the file 56# is marked as config-dependent. 57 58NORMAL_C_NOP= ${CC} ${CFLAGS} ${CPPFLAGS} -c $< 59NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< 60NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $< 61 62HOSTED_C= ${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $< 63 64PROFILE_C= ${CC} -S -c ${CFLAGS} ${CPPFLAGS} $<; \ 65 sed -e s/_mcount/mcount/ -e s/subrmcount/subr_mcount/ <$*.s | \ 66 ${AS} -o $@; \ 67 rm -f $*.s 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_OBJ= locore.o param.o ioconf.o ${OBJS} 81SYSTEM_DEP= Makefile ${SYSTEM_OBJ} 82SYSTEM_LD_HEAD= @rm -f $@ 83SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \ 84 ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o 85SYSTEM_LD_TAIL= @${SIZE} $@; chmod 755 $@ 86 87DEBUG?= 88.if ${DEBUG} == "-g" 89LINKFLAGS+= -X 90SYSTEM_LD_TAIL+=; \ 91 echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \ 92 echo ${STRIP} ${STRIPFLAGS} $@; ${STRIP} ${STRIPFLAGS} $@ 93.else 94LINKFLAGS+= -x 95.endif 96 97%LOAD 98 99assym.h: $S/kern/genassym.sh Makefile \ 100 ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf 101 cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \ 102 sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PARAM} | \ 103 sort -u > assym.h.tmp && \ 104 mv -f assym.h.tmp assym.h 105 106param.c: $S/conf/param.c 107 rm -f param.c 108 cp $S/conf/param.c . 109 110param.o: param.c Makefile 111 ${NORMAL_C} 112 113mcount.o: $S/lib/libkern/mcount.c Makefile 114 ${NORMAL_C_NOP} 115 116ioconf.o: ioconf.c 117 ${NORMAL_C} 118 119vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} 120 sh $S/conf/newvers.sh 121 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c 122 123clean:: 124 rm -f eddep *bsd bsd.gdb tags *.[io] [a-z]*.s \ 125 [Ee]rrs linterrs makelinks assym.h ${DB_STRUCTINFO} 126 127lint: 128 @lint -hbxncez -DGENERIC -Dvolatile= ${CPPFLAGS} ${PARAM} -UKGDB \ 129 ${CFILES} ioconf.c param.c | \ 130 grep -v 'struct/union .* never defined' | \ 131 grep -v 'possible pointer alignment problem' 132 133tags: 134 @echo "see $S/kern/Makefile for tags" 135 136links: 137 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 138 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 139 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 140 sort -u | comm -23 - dontlink | \ 141 sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks 142 sh makelinks && rm -f dontlink makelinks 143 144SRCS= \ 145 param.c ioconf.c ${CFILES} ${SFILES} 146 147depend:: .depend 148.depend: ${SRCS} assym.h param.c ${DB_STRUCTINFO} 149 ${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES} 150.if !empty(SFILES) 151 ${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES} 152.endif 153 cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \ 154 sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} ${CPPFLAGS} 155 @sed -e 's/.*\.o: /assym.h: /' -e 's/\/tmp\/genassym_c.[^ ]*//' \ 156 < assym.dep >> .depend 157 @rm -f assym.dep 158 159db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.awk 160 ${CC} ${CFLAGS} ${CPPFLAGS} -gstabs -c $S/ddb/db_structinfo.c 161 objdump -g db_structinfo.o | awk -f $S/ddb/parse_structinfo.awk > $@ 162 rm -f db_structinfo.o 163 164locore.o: ${_machdir}/${_mach}/locore.S assym.h 165 ${NORMAL_S} 166 167# The install target can be redefined by putting a 168# install-kernel-${MACHINE_NAME} target into /etc/mk.conf 169MACHINE_NAME!= uname -n 170install: install-kernel-${MACHINE_NAME} 171.if !target(install-kernel-${MACHINE_NAME}}) 172install-kernel-${MACHINE_NAME}: 173 rm -f /obsd 174 ln /bsd /obsd 175 cp bsd /nbsd 176 mv /nbsd /bsd 177.endif 178 179%RULES 180