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