1 # $NetBSD: Makefile.mips,v 1.23 2001/10/26 06:45:37 jmc 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/<machine>/conf/``machineid'' 9 # after which you should do 10 # config machineid 11 # Machine generic makefile changes should be made in 12 # /sys/arch/mips/conf/Makefile.mips 13 # after which config should be rerun for all machines of that type. 14 15 USETOOLS?= no 16 17 .include <bsd.own.mk> 18 19 .if ${MACHINE_ARCH} == "mipsel" 20 ENDIAN="-EL" 21 .elif ${MACHINE_ARCH} == "mipseb" 22 ENDIAN="-EB" 23 .else 24 .BEGIN: 25 @echo "MACHINE_ARCH ${MACHINE_ARCH} is invalid" 26 @false 27 .endif 28 29 # DEBUG is set to -g if debugging. 30 # PROF is set to -pg if profiling. 31 32 AR?= ${CROSSDIR}ar 33 AS?= ${CROSSDIR}as 34 CC?= ${CROSSDIR}cc 35 CPP?= cpp 36 LD?= ${CROSSDIR}ld 37 LORDER?= lorder 38 MKDEP?= mkdep 39 NM?= ${CROSSDIR}nm 40 RANLIB?= ${CROSSDIR}ranlib 41 SIZE?= ${CROSSDIR}size 42 STRIP?= ${CROSSDIR}strip 43 TSORT?= ${CROSSDIR}tsort -q 44 OBJCOPY?= ${CROSSDIR}objcopy 45 46 DEFCOPTS?= -O2 47 COPTS?= ${DEFCOPTS} 48 49 DEFGP?= -G 0 50 TEXTADDR?= ${DEFTEXTADDR} 51 52 # source tree is located via $S relative to the compilation directory 53 .ifndef S 54 S= ../../../.. 55 .endif 56 THISMIPS= $S/arch/${MACHINE} 57 MIPS= $S/arch/mips 58 59 HAVE_EGCS!= ${CC} --version | egrep "^(2\.[89]|egcs)" ; echo 60 INCLUDES= -I. -I$S/arch -I$S -nostdinc 61 CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT \ 62 -D${MACHINE} 63 CWARNFLAGS?= -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes \ 64 -Wpointer-arith 65 # XXX Delete -Wuninitialized for now, since the compiler doesn't 66 # XXX always get it right. --thorpej 67 CWARNFLAGS+= -Wno-uninitialized 68 .if (${HAVE_EGCS} != "") 69 CWARNFLAGS+= -Wno-main 70 .endif 71 GP?= ${DEFGP} 72 CFLAGS= ${ENDIAN} ${DEBUG} ${COPTS} ${CWARNFLAGS} ${GP} \ 73 -mno-abicalls -mno-half-pic 74 AFLAGS= ${ENDIAN} -x assembler-with-cpp -traditional-cpp -D_LOCORE 75 LD+= ${ENDIAN} 76 KERNLDSCRIPT?= ${MIPS}/conf/kern.ldscript 77 LINKFLAGS+= -Ttext ${TEXTADDR} -e start ${GP} -T ${KERNLDSCRIPT} 78 .if (${ENDIAN} == "-EB") 79 LINKFLAGS+= --oformat elf32-bigmips 80 .else 81 LINKFLAGS+= --oformat elf32-littlemips 82 .endif 83 STRIPFLAGS= -g -X -x 84 85 .-include "${THISMIPS}/conf/Makefile.${MACHINE}.inc" 86 87 %INCLUDES 88 89 ### find out what to use for libkern 90 .include "$S/lib/libkern/Makefile.inc" 91 .ifndef PROF 92 LIBKERN= ${KERNLIB} 93 .else 94 LIBKERN= ${KERNLIB_PROF} 95 .endif 96 97 ### find out what to use for libcompat 98 .include "$S/compat/common/Makefile.inc" 99 .ifndef PROF 100 LIBCOMPAT= ${COMPATLIB} 101 .else 102 LIBCOMPAT= ${COMPATLIB_PROF} 103 .endif 104 105 # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or 106 # HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file). 107 108 NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< 109 NOPROF_C= ${CC} ${CFLAGS} ${CPPFLAGS} -c $< 110 NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $< 111 112 %OBJS 113 114 %CFILES 115 116 %SFILES 117 118 # load lines for config "xxx" will be emitted as: 119 # xxx: ${SYSTEM_DEP} swapxxx.o 120 # ${SYSTEM_LD_HEAD} 121 # ${SYSTEM_LD} swapxxx.o 122 # ${SYSTEM_LD_TAIL} 123 SYSTEM_OBJ= locore.o locore_machdep.o 124 .if !empty(IDENT:M-DMIPS1) 125 SYSTEM_OBJ+= locore_mips1.o 126 .endif 127 .if !empty(IDENT:M-DMIPS3) 128 SYSTEM_OBJ+= locore_mips3.o 129 .endif 130 .if !empty(IDENT:M-DMIPS3_5900) 131 SYSTEM_OBJ+= locore_r5900.o r5900_machdep.o 132 .endif 133 .if empty(IDENT:M-DNOFPU) 134 SYSTEM_OBJ+= fp.o 135 .endif 136 SYSTEM_OBJ+= param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT} 137 SYSTEM_DEP= Makefile ${SYSTEM_OBJ} 138 SYSTEM_LD_HEAD?=@rm -f $@ 139 SYSTEM_LD?= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o ; \ 140 ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o 141 SYSTEM_LD_TAIL?= \ 142 @${SIZE} $@; chmod 755 $@ 143 144 DEBUG?= 145 .if ${DEBUG} == "-g" 146 LINKFLAGS+= -X 147 .ifdef DEBUG_SYSTEM_LD_TAIL 148 SYSTEM_LD_TAIL+=${DEBUG_SYSTEM_LD_TAIL} 149 .else 150 SYSTEM_LD_TAIL+=; \ 151 echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \ 152 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \ 153 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb 154 .endif 155 .else 156 LINKFLAGS+= -x 157 .endif 158 159 .ifdef POST_STRIP_SYSTEM_LD_TAIL 160 SYSTEM_LD_TAIL+=${POST_STRIP_SYSTEM_LD_TAIL} 161 .endif 162 163 %LOAD 164 165 assym.h: $S/kern/genassym.sh ${MIPS}/mips/genassym.cf 166 sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \ 167 < ${MIPS}/mips/genassym.cf > assym.h.tmp && \ 168 mv -f assym.h.tmp assym.h 169 170 171 param.c: $S/conf/param.c 172 rm -f param.c 173 cp $S/conf/param.c . 174 175 param.o: param.c Makefile 176 ${NORMAL_C} 177 178 ioconf.o: ioconf.c 179 ${NORMAL_C} 180 181 newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} 182 sh $S/conf/newvers.sh 183 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c 184 185 __CLEANKERNEL: .USE 186 @echo "${.TARGET}ing the kernel objects" 187 rm -f eddep *netbsd netbsd.ecoff netbsd.gdb tags *.[io] \ 188 [a-z]*.s [Ee]rrs linterrs makelinks assym.h.tmp assym.h 189 190 __CLEANDEPEND: .USE 191 rm -f .depend 192 193 clean: __CLEANKERNEL 194 195 cleandir distclean: __CLEANKERNEL __CLEANDEPEND 196 197 lint: 198 @lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \ 199 ${MIPS}/mips/Locore.c ${CFILES} \ 200 ioconf.c param.c | \ 201 grep -v 'static function .* unused' 202 203 tags: 204 @echo "see $S/kern/Makefile for tags" 205 206 links: 207 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 208 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 209 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 210 sort -u | comm -23 - dontlink | \ 211 sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks 212 sh makelinks && rm -f dontlink 213 214 .if !empty(IDENT:M-DMIPS1) 215 SFILES+=${MIPS}/mips/locore_mips1.S 216 .endif 217 .if !empty(IDENT:M-DMIPS3) 218 SFILES+=${MIPS}/mips/locore_mips3.S 219 .endif 220 .if !empty(IDENT:M-DMIPS3_5900) 221 SRCS+= ${MIPS}/mips/r5900/locore_r5900.S ${MIPS}/mips/r5900/r5900_machdep.c 222 .endif 223 .if empty(IDENT:M-DNOFPU) 224 SFILES+=${MIPS}/mips/fp.S 225 .endif 226 SFILES+=${MIPS}/mips/locore.S \ 227 ${THISMIPS}/${MACHINE}/locore_machdep.S 228 SRCS= param.c ioconf.c ${CFILES} ${SFILES} 229 230 depend: .depend 231 .depend: ${SRCS} assym.h param.c 232 ${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES} 233 ${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES} 234 sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \ 235 ${CPPFLAGS} < ${MIPS}/mips/genassym.cf 236 @sed -e 's/.*\.o:.*\.c /assym.h: /' < assym.dep >> .depend 237 @rm -f assym.dep 238 239 dependall: depend all 240 241 242 # depend on root or device configuration 243 autoconf.o conf.o: Makefile 244 245 # depend on network or filesystem configuration 246 uipc_proto.o vfs_conf.o: Makefile 247 248 # depend on maxusers 249 machdep.o: Makefile 250 251 # depend on CPU configuration 252 machdep.o mainbus.o trap.o: Makefile 253 254 # depend on System V IPC/shmem options 255 mips_machdep.o pmap.o: Makefile 256 257 locore.o: ${MIPS}/mips/locore.S assym.h 258 ${NORMAL_S} 259 260 locore_mips1.o: ${MIPS}/mips/locore_mips1.S assym.h 261 ${NORMAL_S} 262 263 locore_mips3.o: ${MIPS}/mips/locore_mips3.S assym.h 264 ${NORMAL_S} 265 266 locore_r5900.o: ${MIPS}/mips/r5900/locore_r5900.S assym.h 267 ${NORMAL_S} 268 269 r5900_machdep.o: ${MIPS}/mips/r5900/r5900_machdep.c 270 ${NORMAL_C} 271 272 .if empty(IDENT:M-DNOFPU) 273 fp.o: ${MIPS}/mips/fp.S assym.h 274 ${NORMAL_S} 275 .endif 276 277 locore_machdep.o: ${THISMIPS}/${MACHINE}/locore_machdep.S assym.h 278 ${NORMAL_S} 279 280 # The install target can be redefined by putting a 281 # install-kernel-${MACHINE_NAME} target into /etc/mk.conf 282 MACHINE_NAME!= uname -n 283 install: install-kernel-${MACHINE_NAME} 284 .if !target(install-kernel-${MACHINE_NAME}}) 285 install-kernel-${MACHINE_NAME}: 286 rm -f /onetbsd 287 ln /netbsd /onetbsd 288 cp netbsd /nnetbsd 289 mv /nnetbsd /netbsd 290 .endif 291 292 %RULES 293