1 # $NetBSD: Makefile.news68k,v 1.10 2001/10/23 19:26:46 thorpej Exp $ 2 # 3 # Makefile for NetBSD 4 # 5 # This makefile is constructed from a machine description: 6 # config machineid 7 # Most changes should be made in the machine description 8 # /sys/arch/news68k/conf/``machineid'' 9 # after which you should do 10 # config machineid 11 # Machine generic makefile changes should be made in 12 # /sys/arch/news68k/conf/Makefile.news68k 13 # after which config should be rerun for all machines of that type. 14 15 MACHINE_ARCH=m68k 16 17 # DEBUG is set to -g if debugging. 18 # PROF is set to -pg if profiling. 19 20 AR?= ar 21 AS?= as 22 CC?= cc 23 CPP?= cpp 24 LD?= ld 25 LORDER?=lorder 26 MKDEP?= mkdep 27 NM?= nm 28 RANLIB?=ranlib 29 SIZE?= size 30 STRIP?= strip 31 TSORT?= tsort -q 32 33 COPTS?= -O2 34 35 # source tree is located via $S relative to the compilation directory 36 .ifndef S 37 #S!= cd ../../../..; pwd 38 S= ../../../.. 39 .endif 40 NEWS68K=$S/arch/news68k 41 42 HAVE_EGCS!= ${CC} --version | egrep "^(2\.[89]|egcs)" ; echo 43 INCLUDES= -I. -I$S/arch -I$S -nostdinc 44 CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT -Dnews68k 45 CWARNFLAGS?= -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \ 46 -Wall -Werror 47 # XXX Delete -Wuninitialized for now, since the compiler doesn't 48 # XXX always get it right. --thorpej 49 CWARNFLAGS+= -Wno-uninitialized 50 .if (${HAVE_EGCS} != "") 51 CWARNFLAGS+= -Wno-main 52 .endif 53 CFLAGS= ${DEBUG} ${COPTS} ${CWARNFLAGS} -msoft-float 54 AFLAGS= -x assembler-with-cpp -traditional-cpp -D_LOCORE 55 LINKFLAGS= -n -Ttext 0 -e start 56 STRIPFLAGS= -g 57 58 %INCLUDES 59 60 HOSTED_CC= ${CC} 61 HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//} 62 HOSTED_CFLAGS= ${CFLAGS} 63 64 ### find out what to use for libkern 65 KERN_AS= obj 66 .include "$S/lib/libkern/Makefile.inc" 67 .ifndef PROF 68 LIBKERN= ${KERNLIB} 69 .else 70 LIBKERN= ${KERNLIB_PROF} 71 .endif 72 73 ### find out what to use for libcompat 74 .include "$S/compat/common/Makefile.inc" 75 .ifndef PROF 76 LIBCOMPAT= ${COMPATLIB} 77 .else 78 LIBCOMPAT= ${COMPATLIB_PROF} 79 .endif 80 81 # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or 82 # HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file). 83 84 NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< 85 NOPROF_C= ${CC} ${CFLAGS} ${CPPFLAGS} -c $< 86 NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $< 87 88 HOSTED_C= ${HOSTED_CC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $< 89 90 %OBJS 91 92 %CFILES 93 94 %SFILES 95 96 # load lines for config "xxx" will be emitted as: 97 # xxx: ${SYSTEM_DEP} swapxxx.o 98 # ${SYSTEM_LD_HEAD} 99 # ${SYSTEM_LD} swapxxx.o 100 # ${SYSTEM_LD_TAIL} 101 SYSTEM_OBJ= locore.o ${FPSP} 102 SYSTEM_OBJ+= param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT} 103 SYSTEM_DEP= Makefile ${SYSTEM_OBJ} 104 SYSTEM_LD_HEAD= @rm -f $@ 105 SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o ; \ 106 ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o 107 SYSTEM_LD_TAIL= @${SIZE} $@; chmod 755 $@ 108 109 DEBUG?= 110 .if ${DEBUG} == "-g" 111 LINKFLAGS+= -X 112 SYSTEM_LD_TAIL+=; \ 113 echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \ 114 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \ 115 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb 116 .else 117 LINKFLAGS+= -S 118 .endif 119 120 %LOAD 121 122 assym.h: $S/kern/genassym.sh ${NEWS68K}/news68k/genassym.cf 123 sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \ 124 < ${NEWS68K}/news68k/genassym.cf > assym.h.tmp && \ 125 mv -f assym.h.tmp assym.h 126 127 128 param.c: $S/conf/param.c 129 rm -f param.c 130 cp $S/conf/param.c . 131 132 param.o: param.c Makefile 133 ${NORMAL_C} 134 135 ioconf.o: ioconf.c 136 ${NORMAL_C} 137 138 newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} 139 sh $S/conf/newvers.sh 140 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c 141 142 __CLEANKERNEL: .USE 143 @echo "${.TARGET}ing the kernel objects" 144 rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \ 145 [Ee]rrs linterrs makelinks assym.h.tmp assym.h 146 147 __CLEANDEPEND: .USE 148 rm -f .depend 149 150 clean: __CLEANKERNEL 151 152 cleandir distclean: __CLEANKERNEL __CLEANDEPEND 153 154 lint: 155 @lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \ 156 ${CFILES} ioconf.c param.c | \ 157 grep -v 'static function .* unused' 158 159 tags: 160 @echo "see $S/kern/Makefile for tags" 161 162 links: 163 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 164 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 165 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 166 sort -u | comm -23 - dontlink | \ 167 sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks 168 sh makelinks && rm -f dontlink 169 170 SRCS= ${NEWS68K}/news68k/locore.s \ 171 param.c ioconf.c ${CFILES} ${SFILES} 172 depend: .depend 173 .depend: ${SRCS} assym.h param.c 174 ${MKDEP} ${AFLAGS} ${CPPFLAGS} ${NEWS68K}/news68k/locore.s 175 ${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES} 176 .if ${SFILES} != "" 177 ${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES} 178 .endif 179 sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \ 180 ${CPPFLAGS} < ${NEWS68K}/news68k/genassym.cf 181 @sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend 182 @rm -f assym.dep 183 184 dependall: depend all 185 186 187 # depend on root or device configuration 188 autoconf.o conf.o: Makefile 189 190 # depend on network or filesystem configuration 191 uipc_proto.o vfs_conf.o: Makefile 192 193 # depend on maxusers 194 machdep.o: Makefile 195 196 # depend on CPU configuration 197 machdep.o mainbus.o trap.o: Makefile 198 199 200 locore.o: ${NEWS68K}/news68k/locore.s assym.h 201 ${NORMAL_S} 202 203 # The install target can be redefined by putting a 204 # install-kernel-${MACHINE_NAME} target into /etc/mk.conf 205 MACHINE_NAME!= uname -n 206 install: install-kernel-${MACHINE_NAME} 207 .if !target(install-kernel-${MACHINE_NAME}}) 208 install-kernel-${MACHINE_NAME}: 209 rm -f /onetbsd 210 ln /netbsd /onetbsd 211 cp netbsd /nnetbsd 212 mv /nnetbsd /netbsd 213 .endif 214 215 %RULES 216