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