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