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