1 # $NetBSD: Makefile.mips,v 1.18 2001/10/05 15:14:18 simonb 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 LINKFLAGS+= -Ttext ${TEXTADDR} -e start ${GP} -T ${MIPS}/conf/kern.ldscript 65 .if (${ENDIAN} == "-EB") 66 LINKFLAGS+= --oformat elf32-bigmips 67 .else 68 LINKFLAGS+= --oformat elf32-littlemips 69 .endif 70 STRIPFLAGS= -g -X -x 71 72 .-include "${THISMIPS}/conf/Makefile.${TARGET_MACHINE}.inc" 73 74 %INCLUDES 75 76 ### find out what to use for libkern 77 .include "$S/lib/libkern/Makefile.inc" 78 .ifndef PROF 79 LIBKERN= ${KERNLIB} 80 .else 81 LIBKERN= ${KERNLIB_PROF} 82 .endif 83 84 ### find out what to use for libcompat 85 .include "$S/compat/common/Makefile.inc" 86 .ifndef PROF 87 LIBCOMPAT= ${COMPATLIB} 88 .else 89 LIBCOMPAT= ${COMPATLIB_PROF} 90 .endif 91 92 # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or 93 # HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file). 94 95 NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< 96 NOPROF_C= ${CC} ${CFLAGS} ${CPPFLAGS} -c $< 97 NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $< 98 99 %OBJS 100 101 %CFILES 102 103 %SFILES 104 105 # load lines for config "xxx" will be emitted as: 106 # xxx: ${SYSTEM_DEP} swapxxx.o 107 # ${SYSTEM_LD_HEAD} 108 # ${SYSTEM_LD} swapxxx.o 109 # ${SYSTEM_LD_TAIL} 110 SYSTEM_OBJ= locore.o locore_machdep.o 111 .if !empty(IDENT:M-DMIPS1) 112 SYSTEM_OBJ+= locore_mips1.o 113 .endif 114 .if !empty(IDENT:M-DMIPS3) 115 SYSTEM_OBJ+= locore_mips3.o 116 .endif 117 .if empty(IDENT:M-DNOFPU) 118 SYSTEM_OBJ+= fp.o 119 .endif 120 SYSTEM_OBJ+= param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT} 121 SYSTEM_DEP= Makefile ${SYSTEM_OBJ} 122 SYSTEM_LD_HEAD?=@rm -f $@ 123 SYSTEM_LD?= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o ; \ 124 ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o 125 SYSTEM_LD_TAIL?= \ 126 @${SIZE} $@; chmod 755 $@ 127 128 DEBUG?= 129 .if ${DEBUG} == "-g" 130 LINKFLAGS+= -X 131 .ifdef DEBUG_SYSTEM_LD_TAIL 132 SYSTEM_LD_TAIL+=${DEBUG_SYSTEM_LD_TAIL} 133 .else 134 SYSTEM_LD_TAIL+=; \ 135 echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \ 136 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \ 137 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb 138 .endif 139 .else 140 LINKFLAGS+= -x 141 .endif 142 143 .ifdef POST_STRIP_SYSTEM_LD_TAIL 144 SYSTEM_LD_TAIL+=${POST_STRIP_SYSTEM_LD_TAIL} 145 .endif 146 147 %LOAD 148 149 assym.h: $S/kern/genassym.sh ${MIPS}/mips/genassym.cf 150 sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \ 151 < ${MIPS}/mips/genassym.cf > assym.h.tmp && \ 152 mv -f assym.h.tmp assym.h 153 154 155 param.c: $S/conf/param.c 156 rm -f param.c 157 cp $S/conf/param.c . 158 159 param.o: param.c Makefile 160 ${NORMAL_C} 161 162 ioconf.o: ioconf.c 163 ${NORMAL_C} 164 165 newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} 166 sh $S/conf/newvers.sh 167 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c 168 169 __CLEANKERNEL: .USE 170 @echo "${.TARGET}ing the kernel objects" 171 rm -f eddep *netbsd netbsd.ecoff netbsd.gdb tags *.[io] \ 172 [a-z]*.s [Ee]rrs linterrs makelinks assym.h.tmp assym.h 173 174 __CLEANDEPEND: .USE 175 rm -f .depend 176 177 clean: __CLEANKERNEL 178 179 cleandir distclean: __CLEANKERNEL __CLEANDEPEND 180 181 lint: 182 @lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \ 183 ${MIPS}/mips/Locore.c ${CFILES} \ 184 ioconf.c param.c | \ 185 grep -v 'static function .* unused' 186 187 tags: 188 @echo "see $S/kern/Makefile for tags" 189 190 links: 191 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 192 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 193 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 194 sort -u | comm -23 - dontlink | \ 195 sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks 196 sh makelinks && rm -f dontlink 197 198 .if !empty(IDENT:M-DMIPS1) 199 SFILES+=${MIPS}/mips/locore_mips1.S 200 .endif 201 .if !empty(IDENT:M-DMIPS3) 202 SFILES+=${MIPS}/mips/locore_mips3.S 203 .endif 204 .if empty(IDENT:M-DNOFPU) 205 SFILES+=${MIPS}/mips/fp.S 206 .endif 207 SFILES+=${MIPS}/mips/locore.S \ 208 ${THISMIPS}/${TARGET_MACHINE}/locore_machdep.S 209 SRCS= param.c ioconf.c ${CFILES} ${SFILES} 210 211 depend: .depend 212 .depend: ${SRCS} assym.h param.c 213 ${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES} 214 ${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES} 215 sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \ 216 ${CPPFLAGS} < ${MIPS}/mips/genassym.cf 217 @sed -e 's/.*\.o:.*\.c /assym.h: /' < assym.dep >> .depend 218 @rm -f assym.dep 219 220 dependall: depend all 221 222 223 # depend on root or device configuration 224 autoconf.o conf.o: Makefile 225 226 # depend on network or filesystem configuration 227 uipc_proto.o vfs_conf.o: Makefile 228 229 # depend on maxusers 230 machdep.o: Makefile 231 232 # depend on CPU configuration 233 machdep.o mainbus.o trap.o: Makefile 234 235 # depend on System V IPC/shmem options 236 mips_machdep.o pmap.o: Makefile 237 238 locore.o: ${MIPS}/mips/locore.S assym.h 239 ${NORMAL_S} 240 241 locore_mips1.o: ${MIPS}/mips/locore_mips1.S assym.h 242 ${NORMAL_S} 243 244 locore_mips3.o: ${MIPS}/mips/locore_mips3.S assym.h 245 ${NORMAL_S} 246 247 .if empty(IDENT:M-DNOFPU) 248 fp.o: ${MIPS}/mips/fp.S assym.h 249 ${NORMAL_S} 250 .endif 251 252 locore_machdep.o: ${THISMIPS}/${TARGET_MACHINE}/locore_machdep.S assym.h 253 ${NORMAL_S} 254 255 # The install target can be redefined by putting a 256 # install-kernel-${MACHINE_NAME} target into /etc/mk.conf 257 MACHINE_NAME!= uname -n 258 install: install-kernel-${MACHINE_NAME} 259 .if !target(install-kernel-${MACHINE_NAME}}) 260 install-kernel-${MACHINE_NAME}: 261 rm -f /onetbsd 262 ln /netbsd /onetbsd 263 cp netbsd /nnetbsd 264 mv /nnetbsd /netbsd 265 .endif 266 267 %RULES 268