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