1 # $NetBSD: Makefile.mips,v 1.2 2000/12/03 04:52:38 matt 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 # N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE 16 # IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING 17 # 18 # -DTRACE compile in kernel tracing hooks 19 # -DQUOTA compile in file system quotas 20 21 # DEBUG is set to -g if debugging. 22 # PROF is set to -pg if profiling. 23 24 AR?= ar 25 AS?= as 26 CC?= cc 27 CPP?= cpp 28 LD?= ld 29 LORDER?= lorder 30 MKDEP?= mkdep 31 NM?= nm 32 RANLIB?= ranlib 33 SIZE?= size 34 STRIP?= strip 35 TSORT?= tsort -q 36 37 COPTS?= -O2 38 39 TEXTADDR?= ${DEFTEXTADDR} 40 41 # source tree is located via $S relative to the compilation directory 42 .ifndef S 43 S= ../../../.. 44 .endif 45 THISMIPS= $S/arch/${MACHINE} 46 MIPS= $S/arch/mips 47 48 HAVE_EGCS!= ${CC} --version | egrep "^(2\.[89]|egcs)" ; echo 49 INCLUDES= -I. -I$S/arch -I$S -nostdinc 50 CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D${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?= -G 0 60 CFLAGS= ${DEBUG} ${COPTS} ${CWARNFLAGS} ${GP} \ 61 -mno-abicalls -mno-half-pic ${ENDIAN} 62 AFLAGS= -x assembler-with-cpp -traditional-cpp -D_LOCORE ${ENDIAN} 63 LINKFLAGS+= -Ttext ${TEXTADDR} -e start ${GP} 64 .if (${ENDIAN} == "-EB") 65 LINKFLAGS+= -T ${MIPS}/conf/kern.ldscript.be 66 .else 67 LINKFLAGS+= -T ${MIPS}/conf/kern.ldscript.le 68 .endif 69 LD+= ${ENDIAN} 70 STRIPFLAGS= -g -X -x 71 72 .if exists(${THISMIPS}/conf/Makefile.${MACHINE}.inc) 73 .include "${THISMIPS}/conf/Makefile.${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 SYSTEM_OBJ+= fp.o param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT} 120 SYSTEM_DEP= Makefile ${SYSTEM_OBJ} 121 SYSTEM_LD_HEAD?=@rm -f $@ 122 SYSTEM_LD?= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o ; \ 123 ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o 124 SYSTEM_LD_TAIL?= \ 125 @${SIZE} $@; chmod 755 $@ 126 127 DEBUG?= 128 .if ${DEBUG} == "-g" 129 LINKFLAGS+= -X 130 .ifdef DEBUG_SYSTEM_LD_TAIL 131 SYSTEM_LD_TAIL+=${DEBUG_SYSTEM_LD_TAIL} 132 .else 133 SYSTEM_LD_TAIL+=; \ 134 echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \ 135 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \ 136 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb 137 .endif 138 .else 139 LINKFLAGS+= -x 140 .endif 141 142 .ifdef POST_STRIP_SYSTEM_LD_TAIL 143 SYSTEM_LD_TAIL+=${POST_STRIP_SYSTEM_LD_TAIL} 144 .endif 145 146 %LOAD 147 148 assym.h: $S/kern/genassym.sh ${MIPS}/mips/genassym.cf 149 sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \ 150 < ${MIPS}/mips/genassym.cf > assym.h.tmp && \ 151 mv -f assym.h.tmp assym.h 152 153 154 param.c: $S/conf/param.c 155 rm -f param.c 156 cp $S/conf/param.c . 157 158 param.o: param.c Makefile 159 ${NORMAL_C} 160 161 ioconf.o: ioconf.c 162 ${NORMAL_C} 163 164 newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} 165 sh $S/conf/newvers.sh 166 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c 167 168 __CLEANKERNEL: .USE 169 @echo "${.TARGET}ing the kernel objects" 170 rm -f eddep *netbsd netbsd.ecoff netbsd.gdb tags *.[io] \ 171 [a-z]*.s [Ee]rrs linterrs makelinks assym.h.tmp assym.h 172 173 __CLEANDEPEND: .USE 174 rm -f .depend 175 176 clean: __CLEANKERNEL 177 178 cleandir distclean: __CLEANKERNEL __CLEANDEPEND 179 180 lint: 181 @lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \ 182 ${MIPS}/mips/Locore.c ${CFILES} \ 183 ioconf.c param.c | \ 184 grep -v 'static function .* unused' 185 186 tags: 187 @echo "see $S/kern/Makefile for tags" 188 189 links: 190 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 191 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 192 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 193 sort -u | comm -23 - dontlink | \ 194 sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks 195 sh makelinks && rm -f dontlink 196 197 SRCS= ${MIPS}/mips/locore.S ${MIPS}/mips/fp.S \ 198 ${THISMIPS}/${MACHINE}/locore_machdep.S \ 199 param.c ioconf.c ${CFILES} ${SFILES} 200 depend: .depend 201 .depend: ${SRCS} assym.h param.c 202 ${MKDEP} ${AFLAGS} ${CPPFLAGS} ${MIPS}/mips/locore.S ${MIPS}/mips/fp.S 203 ${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${THISMIPS}/${MACHINE}/locore_machdep.S 204 ${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES} 205 .if (${SFILES} != "") 206 ${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES} 207 .endif 208 sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \ 209 ${CPPFLAGS} < ${MIPS}/mips/genassym.cf 210 @sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend 211 @rm -f assym.dep 212 213 dependall: depend all 214 215 216 # depend on root or device configuration 217 autoconf.o conf.o: Makefile 218 219 # depend on network or filesystem configuration 220 uipc_proto.o vfs_conf.o: Makefile 221 222 # depend on maxusers 223 machdep.o: Makefile 224 225 # depend on CPU configuration 226 machdep.o mainbus.o trap.o: Makefile 227 228 # depend on System V IPC/shmem options 229 mips_machdep.o pmap.o: Makefile 230 231 locore.o: ${MIPS}/mips/locore.S assym.h 232 ${NORMAL_S} 233 234 locore_mips1.o: ${MIPS}/mips/locore_mips1.S assym.h 235 ${NORMAL_S} 236 237 locore_mips3.o: ${MIPS}/mips/locore_mips3.S assym.h 238 ${NORMAL_S} 239 240 fp.o: ${MIPS}/mips/fp.S assym.h 241 ${NORMAL_S} 242 243 locore_machdep.o: ${THISMIPS}/${MACHINE}/locore_machdep.S assym.h 244 ${NORMAL_S} 245 246 # The install target can be redefined by putting a 247 # install-kernel-${MACHINE_NAME} target into /etc/mk.conf 248 MACHINE_NAME!= uname -n 249 install: install-kernel-${MACHINE_NAME} 250 .if !target(install-kernel-${MACHINE_NAME}}) 251 install-kernel-${MACHINE_NAME}: 252 rm -f /onetbsd 253 ln /netbsd /onetbsd 254 cp netbsd /nnetbsd 255 mv /nnetbsd /netbsd 256 .endif 257 258 %RULES 259