Home | History | Annotate | Line # | Download | only in conf
Makefile.sh3 revision 1.7
      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 
     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 
     33 COPTS?=	-O2
     34 
     35 # source tree is located via $S relative to the compilation directory
     36 .ifndef S
     37 S!=	cd ../../../..; pwd
     38 .endif
     39 SH3=	$S/arch/sh3
     40 
     41 HAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo
     42 INCLUDES=	-I. -I$S/arch -I$S -nostdinc
     43 CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -Dsh3
     44 CWARNFLAGS=	-Werror -Wall -Wmissing-prototypes -Wstrict-prototypes
     45 CWARNFLAGS+=	-Wpointer-arith -Wno-parentheses
     46 # XXX Delete -Wuninitialized for now, since the compiler doesn't
     47 # XXX always get it right.  --thorpej 
     48 CWARNFLAGS+=	-Wno-uninitialized
     49 .if (${HAVE_EGCS} != "")
     50 CWARNFLAGS+=	-Wno-main
     51 .endif
     52 CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS}
     53 AFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
     54 LINKFLAGS=	-e start -T ../../conf/sh.x
     55 STRIPFLAGS=	--strip-debug
     56 MACHINE=sh3
     57 MACHINE_ARCH=sh3
     58 
     59 ### find out what to use for libkern
     60 .include "$S/lib/libkern/Makefile.inc"
     61 .ifndef PROF
     62 LIBKERN=	${KERNLIB}
     63 .else
     64 LIBKERN=	${KERNLIB_PROF}
     65 .endif
     66 
     67 ### find out what to use for libcompat
     68 .include "$S/compat/common/Makefile.inc"
     69 .ifndef PROF
     70 LIBCOMPAT=	${COMPATLIB}
     71 .else
     72 LIBCOMPAT=	${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 
     78 NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
     79 NORMAL_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}
     92 SYSTEM_OBJ=	locore.o \
     93 		param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
     94 SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
     95 SYSTEM_LD_HEAD=	rm -f $@
     96 SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
     97 		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
     98 SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
     99 
    100 DEBUG?=
    101 .if ${DEBUG} == "-g"
    102 LINKFLAGS+=	-X
    103 SYSTEM_LD_TAIL+=; \
    104 		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
    105 		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
    106 		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
    107 .else
    108 LINKFLAGS+=
    109 .endif
    110 
    111 %LOAD
    112 
    113 assym.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 
    118 param.c: $S/conf/param.c
    119 	rm -f param.c
    120 	cp $S/conf/param.c .
    121 
    122 param.o: param.c Makefile
    123 	${NORMAL_C}
    124 
    125 ioconf.o: ioconf.c
    126 	${NORMAL_C}
    127 
    128 newvers: ${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 
    141 clean: __CLEANKERNEL
    142 
    143 cleandir: __CLEANKERNEL __CLEANDEPEND
    144 
    145 lint:
    146 	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
    147 	    ${SH3}/sh3/Locore.c ${CFILES} \
    148 	    ioconf.c param.c | \
    149 	    grep -v 'static function .* unused'
    150 
    151 tags:
    152 	@echo "see $S/kern/Makefile for tags"
    153 
    154 links:
    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 
    162 SRCS=	${SH3}/sh3/locore.s \
    163 	param.c ioconf.c ${CFILES} ${SFILES}
    164 depend: .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 
    176 dependall: depend all
    177 
    178 
    179 # depend on root or device configuration
    180 autoconf.o conf.o: Makefile
    181 
    182 # depend on network or filesystem configuration
    183 uipc_proto.o vfs_conf.o: Makefile
    184 
    185 # depend on maxusers
    186 machdep.o: Makefile
    187 
    188 # depend on CPU configuration
    189 locore.o machdep.o: Makefile
    190 
    191 locore.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
    200 MACHINE_NAME!=  uname -n
    201 install: install-kernel-${MACHINE_NAME}
    202 .if !target(install-kernel-${MACHINE_NAME}})
    203 install-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