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