Home | History | Annotate | Line # | Download | only in conf
Makefile.mips revision 1.12
      1 #	$NetBSD: Makefile.mips,v 1.12 2001/03/28 17:03:48 tsutsui 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/<machine>/conf/``machineid''
      9 # after which you should do
     10 #	config machineid
     11 # Machine generic makefile changes should be made in
     12 #	/sys/arch/mips/conf/Makefile.mips
     13 # after which config should be rerun for all machines of that type.
     14 
     15 # DEBUG is set to -g if debugging.
     16 # PROF is set to -pg if profiling.
     17 
     18 AR?=		${CROSSDIR}ar
     19 AS?=		${CROSSDIR}as
     20 CC?=		${CROSSDIR}cc
     21 CPP?=		cpp
     22 LD?=		${CROSSDIR}ld
     23 LORDER?=	lorder
     24 MKDEP?=		mkdep
     25 NM?=		${CROSSDIR}nm
     26 RANLIB?=	${CROSSDIR}ranlib
     27 SIZE?=		${CROSSDIR}size
     28 STRIP?=		${CROSSDIR}strip
     29 TSORT?=		${CROSSDIR}tsort -q
     30 OBJCOPY?=	${CROSSDIR}objcopy
     31 
     32 DEFCOPTS?=	-O2
     33 COPTS?=		${DEFCOPTS}
     34 
     35 DEFGP?=		-G 0
     36 TEXTADDR?=	${DEFTEXTADDR}
     37 
     38 # source tree is located via $S relative to the compilation directory
     39 .ifndef S
     40 S=	../../../..
     41 .endif
     42 THISMIPS=	$S/arch/${TARGET_MACHINE}
     43 MIPS=		$S/arch/mips
     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${TARGET_MACHINE}
     48 CWARNFLAGS?=	-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes \
     49 		-Wpointer-arith
     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 GP?=		${DEFGP}
     57 CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS} ${GP} \
     58 		-mno-abicalls -mno-half-pic
     59 AFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
     60 LINKFLAGS+=	-Ttext ${TEXTADDR} -e start ${GP}
     61 .if (${ENDIAN} == "-EB")
     62 LINKFLAGS+=	-T ${MIPS}/conf/kern.ldscript.be
     63 CFLAGS+=	-EB
     64 AFLAGS+=	-EB
     65 LD+=		-EB
     66 .else
     67 LINKFLAGS+=	-T ${MIPS}/conf/kern.ldscript.le
     68 CFLAGS+=	-EL
     69 AFLAGS+=	-EL
     70 LD+=		-EL
     71 .endif
     72 STRIPFLAGS=	-g -X -x
     73 
     74 .if exists(${THISMIPS}/conf/Makefile.${TARGET_MACHINE}.inc)
     75 .include "${THISMIPS}/conf/Makefile.${TARGET_MACHINE}.inc"
     76 .endif
     77 
     78 %INCLUDES
     79 
     80 ### find out what to use for libkern
     81 .include "$S/lib/libkern/Makefile.inc"
     82 .ifndef PROF
     83 LIBKERN=	${KERNLIB}
     84 .else
     85 LIBKERN=	${KERNLIB_PROF}
     86 .endif
     87 
     88 ### find out what to use for libcompat
     89 .include "$S/compat/common/Makefile.inc"
     90 .ifndef PROF
     91 LIBCOMPAT=	${COMPATLIB}
     92 .else
     93 LIBCOMPAT=	${COMPATLIB_PROF}
     94 .endif
     95 
     96 # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
     97 # HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
     98 
     99 NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
    100 NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
    101 NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
    102 
    103 %OBJS
    104 
    105 %CFILES
    106 
    107 %SFILES
    108 
    109 # load lines for config "xxx" will be emitted as:
    110 # xxx: ${SYSTEM_DEP} swapxxx.o
    111 #	${SYSTEM_LD_HEAD}
    112 #	${SYSTEM_LD} swapxxx.o
    113 #	${SYSTEM_LD_TAIL}
    114 SYSTEM_OBJ=	locore.o locore_machdep.o
    115 .if !empty(IDENT:M-DMIPS1)
    116 SYSTEM_OBJ+=	locore_mips1.o
    117 .endif
    118 .if !empty(IDENT:M-DMIPS3)
    119 SYSTEM_OBJ+=	locore_mips3.o
    120 .endif
    121 .if empty(IDENT:M-DNOFPU)
    122 SYSTEM_OBJ+=	fp.o
    123 .endif
    124 SYSTEM_OBJ+=	param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
    125 SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
    126 SYSTEM_LD_HEAD?=@rm -f $@
    127 SYSTEM_LD?=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o ; \
    128 		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
    129 SYSTEM_LD_TAIL?= \
    130 		@${SIZE} $@; chmod 755 $@
    131 
    132 DEBUG?=
    133 .if ${DEBUG} == "-g"
    134 LINKFLAGS+=	-X
    135 .ifdef DEBUG_SYSTEM_LD_TAIL
    136 SYSTEM_LD_TAIL+=${DEBUG_SYSTEM_LD_TAIL}
    137 .else
    138 SYSTEM_LD_TAIL+=; \
    139 		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
    140 		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
    141 		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
    142 .endif
    143 .else
    144 LINKFLAGS+=	-x
    145 .endif
    146 
    147 .ifdef POST_STRIP_SYSTEM_LD_TAIL
    148 SYSTEM_LD_TAIL+=${POST_STRIP_SYSTEM_LD_TAIL}
    149 .endif
    150 
    151 %LOAD
    152 
    153 assym.h: $S/kern/genassym.sh ${MIPS}/mips/genassym.cf
    154 	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
    155 	  < ${MIPS}/mips/genassym.cf > assym.h.tmp && \
    156 	mv -f assym.h.tmp assym.h
    157 
    158 
    159 param.c: $S/conf/param.c
    160 	rm -f param.c
    161 	cp $S/conf/param.c .
    162 
    163 param.o: param.c Makefile
    164 	${NORMAL_C}
    165 
    166 ioconf.o: ioconf.c
    167 	${NORMAL_C}
    168 
    169 newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
    170 	sh $S/conf/newvers.sh
    171 	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
    172 
    173 __CLEANKERNEL: .USE
    174 	@echo "${.TARGET}ing the kernel objects"
    175 	rm -f eddep *netbsd netbsd.ecoff netbsd.gdb tags *.[io] \
    176 	  [a-z]*.s [Ee]rrs linterrs makelinks assym.h.tmp assym.h
    177 
    178 __CLEANDEPEND: .USE
    179 	rm -f .depend
    180 
    181 clean: __CLEANKERNEL
    182 
    183 cleandir distclean: __CLEANKERNEL __CLEANDEPEND
    184 
    185 lint:
    186 	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
    187 	  ${MIPS}/mips/Locore.c ${CFILES} \
    188 	  ioconf.c param.c | \
    189 	  grep -v 'static function .* unused'
    190 
    191 tags:
    192 	@echo "see $S/kern/Makefile for tags"
    193 
    194 links:
    195 	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
    196 	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
    197 	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
    198 	  sort -u | comm -23 - dontlink | \
    199 	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
    200 	sh makelinks && rm -f dontlink
    201 
    202 SRCS=	${MIPS}/mips/locore.S \
    203 	${THISMIPS}/${TARGET_MACHINE}/locore_machdep.S \
    204 	param.c ioconf.c ${CFILES} ${SFILES}
    205 .if !empty(IDENT:M-DMIPS1)
    206 SRCS+=	${MIPS}/mips/locore_mips1.S
    207 .endif
    208 .if !empty(IDENT:M-DMIPS3)
    209 SRCS+=	${MIPS}/mips/locore_mips3.S
    210 .endif
    211 .if empty(IDENT:M-DNOFPU)
    212 SRCS+=	${MIPS}/mips/fp.S
    213 .endif
    214 
    215 depend: .depend
    216 .depend: ${SRCS} assym.h param.c
    217 	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${MIPS}/mips/locore.S
    218 .if !empty(IDENT:M-DMIPS1)
    219 	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${MIPS}/mips/locore_mips1.S
    220 .endif
    221 .if !empty(IDENT:M-DMIPS3)
    222 	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${MIPS}/mips/locore_mips3.S
    223 .endif
    224 .if empty(IDENT:M-DNOFPU)
    225 	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${MIPS}/mips/fp.S
    226 .endif
    227 	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${THISMIPS}/${TARGET_MACHINE}/locore_machdep.S
    228 	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
    229 .if (${SFILES} != "")
    230 	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
    231 .endif
    232 	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
    233 	  ${CPPFLAGS} < ${MIPS}/mips/genassym.cf
    234 	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
    235 	@rm -f assym.dep
    236 
    237 dependall: depend all
    238 
    239 
    240 # depend on root or device configuration
    241 autoconf.o conf.o: Makefile
    242 
    243 # depend on network or filesystem configuration
    244 uipc_proto.o vfs_conf.o: Makefile
    245 
    246 # depend on maxusers
    247 machdep.o: Makefile
    248 
    249 # depend on CPU configuration
    250 machdep.o mainbus.o trap.o: Makefile
    251 
    252 # depend on System V IPC/shmem options
    253 mips_machdep.o pmap.o: Makefile
    254 
    255 locore.o: ${MIPS}/mips/locore.S assym.h
    256 	${NORMAL_S}
    257 
    258 locore_mips1.o: ${MIPS}/mips/locore_mips1.S assym.h
    259 	${NORMAL_S}
    260 
    261 locore_mips3.o: ${MIPS}/mips/locore_mips3.S assym.h
    262 	${NORMAL_S}
    263 
    264 fp.o: ${MIPS}/mips/fp.S assym.h
    265 	${NORMAL_S}
    266 
    267 locore_machdep.o: ${THISMIPS}/${TARGET_MACHINE}/locore_machdep.S assym.h
    268 	${NORMAL_S}
    269 
    270 # The install target can be redefined by putting a
    271 # install-kernel-${MACHINE_NAME} target into /etc/mk.conf
    272 MACHINE_NAME!=  uname -n
    273 install: install-kernel-${MACHINE_NAME}
    274 .if !target(install-kernel-${MACHINE_NAME}})
    275 install-kernel-${MACHINE_NAME}:
    276 	rm -f /onetbsd
    277 	ln /netbsd /onetbsd
    278 	cp netbsd /nnetbsd
    279 	mv /nnetbsd /netbsd
    280 .endif
    281 
    282 %RULES
    283