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