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