1 # $NetBSD: Makefile.sh3,v 1.8 2001/01/03 18:14:47 itojun 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/sh3/conf/``machineid'' 9 # after which you should do 10 # config machineid 11 # Machine generic makefile changes should be made in 12 # /sys/arch/sh3/conf/Makefile.sh3 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?= ar 21 AS?= as 22 CC?= cc 23 CPP?= cpp 24 LD?= ld 25 LORDER?=lorder 26 MKDEP?= mkdep 27 NM?= nm 28 RANLIB?=ranlib 29 SIZE?= size 30 STRIP?= strip 31 TSORT?= tsort -q 32 OBJCOPY?=objcopy 33 34 COPTS?= -O2 35 36 # source tree is located via $S relative to the compilation directory 37 .ifndef S 38 S!= cd ../../../..; pwd 39 .endif 40 THISSH3=$S/arch/${TARGET_MACHINE} 41 SH3= $S/arch/sh3 42 43 HAVE_EGCS!= ${CC} --version | egrep "^(2\.[89]|egcs)" ; echo 44 INCLUDES= -I. -I$S/arch -I$S -nostdinc 45 CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -Dsh3 46 CWARNFLAGS= -Werror -Wall -Wmissing-prototypes -Wstrict-prototypes 47 CWARNFLAGS+= -Wpointer-arith -Wno-parentheses 48 # XXX Delete -Wuninitialized for now, since the compiler doesn't 49 # XXX always get it right. --thorpej 50 CWARNFLAGS+= -Wno-uninitialized 51 .if (${HAVE_EGCS} != "") 52 CWARNFLAGS+= -Wno-main 53 .endif 54 CFLAGS= ${DEBUG} ${COPTS} ${CWARNFLAGS} 55 AFLAGS= -x assembler-with-cpp -traditional-cpp -D_LOCORE 56 LINKFLAGS?= -e start -T ../../conf/${LDSCRIPTBASE} 57 STRIPFLAGS= --strip-debug 58 59 .if exists(${THISSH3}/conf/Makefile.${TARGET_MACHINE}.inc) 60 .include "${THISSH3}/conf/Makefile.${TARGET_MACHINE}.inc" 61 .endif 62 63 %INCLUDES 64 65 ### find out what to use for libkern 66 .include "$S/lib/libkern/Makefile.inc" 67 .ifndef PROF 68 LIBKERN= ${KERNLIB} 69 .else 70 LIBKERN= ${KERNLIB_PROF} 71 .endif 72 73 ### find out what to use for libcompat 74 .include "$S/compat/common/Makefile.inc" 75 .ifndef PROF 76 LIBCOMPAT= ${COMPATLIB} 77 .else 78 LIBCOMPAT= ${COMPATLIB_PROF} 79 .endif 80 81 # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or 82 # HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file). 83 84 NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< 85 NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $< 86 87 %OBJS 88 89 %CFILES 90 91 %SFILES 92 93 # load lines for config "xxx" will be emitted as: 94 # xxx: ${SYSTEM_DEP} swapxxx.o 95 # ${SYSTEM_LD_HEAD} 96 # ${SYSTEM_LD} swapxxx.o 97 # ${SYSTEM_LD_TAIL} 98 SYSTEM_OBJ= locore.o \ 99 param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT} 100 SYSTEM_DEP= Makefile ${SYSTEM_OBJ} 101 SYSTEM_LD_HEAD= rm -f $@ 102 SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \ 103 ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o 104 SYSTEM_LD_TAIL= @${SIZE} $@; chmod 755 $@ 105 106 DEBUG?= 107 .if ${DEBUG} == "-g" 108 LINKFLAGS+= -X 109 SYSTEM_LD_TAIL+=; \ 110 echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \ 111 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \ 112 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb 113 .else 114 LINKFLAGS+= 115 .endif 116 117 %LOAD 118 119 assym.h: $S/kern/genassym.sh ${THISSH3}/${TARGET_MACHINE}/genassym.cf 120 sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \ 121 < ${THISSH3}/${TARGET_MACHINE}/genassym.cf > assym.h.tmp && \ 122 mv -f assym.h.tmp assym.h 123 124 param.c: $S/conf/param.c 125 rm -f param.c 126 cp $S/conf/param.c . 127 128 param.o: param.c Makefile 129 ${NORMAL_C} 130 131 ioconf.o: ioconf.c 132 ${NORMAL_C} 133 134 newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} 135 sh $S/conf/newvers.sh 136 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c 137 138 139 __CLEANKERNEL: .USE 140 @echo "${.TARGET}ing the kernel objects" 141 rm -f eddep *netbsd netbsd netbsd.gdb tags *.[io] [a-z]*.s \ 142 [Ee]rrs linterrs makelinks assym.h.tmp assym.h 143 144 __CLEANDEPEND: .USE 145 rm -f .depend 146 147 clean: __CLEANKERNEL 148 149 cleandir: __CLEANKERNEL __CLEANDEPEND 150 151 lint: 152 @lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \ 153 ${SH3}/sh3/Locore.c ${CFILES} \ 154 ioconf.c param.c | \ 155 grep -v 'static function .* unused' 156 157 tags: 158 @echo "see $S/kern/Makefile for tags" 159 160 links: 161 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 162 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 163 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 164 sort -u | comm -23 - dontlink | \ 165 sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks 166 sh makelinks && rm -f dontlink 167 168 # ${SH3}/sh3/locore.s ? 169 SRCS= ${THISSH3}/${TARGET_MACHINE}/locore.s \ 170 param.c ioconf.c ${CFILES} ${SFILES} 171 depend: .depend 172 .depend: ${SRCS} assym.h param.c 173 ${MKDEP} ${AFLAGS} ${CPPFLAGS} ${THISSH3}/${TARGET_MACHINE}/locore.s 174 ${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES} 175 .if ${SFILES} != "" 176 ${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES} 177 .endif 178 sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \ 179 ${CPPFLAGS} < ${THISSH3}/${TARGET_MACHINE}/genassym.cf 180 @sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend 181 @rm -f assym.dep 182 183 dependall: depend all 184 185 186 # depend on root or device configuration 187 autoconf.o conf.o: Makefile 188 189 # depend on network or filesystem configuration 190 uipc_proto.o vfs_conf.o: Makefile 191 192 # depend on maxusers 193 machdep.o: Makefile 194 195 # depend on CPU configuration 196 locore.o machdep.o: Makefile 197 198 locore.o: ${THISSH3}/${TARGET_MACHINE}/locore.s assym.h 199 ${NORMAL_S} 200 201 # XXX compile ffs_inode.c always with -O0 to avoid egcs-1.1.2 bug. 202 #ffs_inode.o: $S/ufs/ffs/ffs_inode.c 203 # ${CC} ${CFLAGS} -O0 ${CPPFLAGS} ${PROF} -c $< 204 205 # The install target can be redefined by putting a 206 # install-kernel-${MACHINE_NAME} target into /etc/mk.conf 207 MACHINE_NAME!= uname -n 208 install: install-kernel-${MACHINE_NAME} 209 .if !target(install-kernel-${MACHINE_NAME}}) 210 install-kernel-${MACHINE_NAME}: 211 rm -f /onetbsd 212 ln /netbsd /onetbsd 213 cp netbsd /nnetbsd 214 mv /nnetbsd /netbsd 215 .endif 216 217 %RULES 218