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