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