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