Home | History | Annotate | Line # | Download | only in conf
Makefile.mips revision 1.22
      1 #	$NetBSD: Makefile.mips,v 1.22 2001/10/23 20:40:02 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/<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 .if ${MACHINE_ARCH} == "mipsel"
     18 ENDIAN="-EL"
     19 .elif ${MACHINE_ARCH} == "mipseb"
     20 ENDIAN="-EB"
     21 .else
     22 .BEGIN:
     23 	@echo "MACHINE_ARCH ${MACHINE_ARCH} is invalid"
     24 	@false
     25 .endif
     26 
     27 # DEBUG is set to -g if debugging.
     28 # PROF is set to -pg if profiling.
     29 
     30 AR?=		${CROSSDIR}ar
     31 AS?=		${CROSSDIR}as
     32 CC?=		${CROSSDIR}cc
     33 CPP?=		cpp
     34 LD?=		${CROSSDIR}ld
     35 LORDER?=	lorder
     36 MKDEP?=		mkdep
     37 NM?=		${CROSSDIR}nm
     38 RANLIB?=	${CROSSDIR}ranlib
     39 SIZE?=		${CROSSDIR}size
     40 STRIP?=		${CROSSDIR}strip
     41 TSORT?=		${CROSSDIR}tsort -q
     42 OBJCOPY?=	${CROSSDIR}objcopy
     43 
     44 DEFCOPTS?=	-O2
     45 COPTS?=		${DEFCOPTS}
     46 
     47 DEFGP?=		-G 0
     48 TEXTADDR?=	${DEFTEXTADDR}
     49 
     50 # source tree is located via $S relative to the compilation directory
     51 .ifndef S
     52 S=	../../../..
     53 .endif
     54 THISMIPS=	$S/arch/${MACHINE}
     55 MIPS=		$S/arch/mips
     56 
     57 HAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo
     58 INCLUDES=	-I. -I$S/arch -I$S -nostdinc
     59 CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT \
     60 		-D${MACHINE}
     61 CWARNFLAGS?=	-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes \
     62 		-Wpointer-arith
     63 # XXX Delete -Wuninitialized for now, since the compiler doesn't
     64 # XXX always get it right.  --thorpej
     65 CWARNFLAGS+=	-Wno-uninitialized
     66 .if (${HAVE_EGCS} != "")
     67 CWARNFLAGS+=	-Wno-main
     68 .endif
     69 GP?=		${DEFGP}
     70 CFLAGS=		${ENDIAN} ${DEBUG} ${COPTS} ${CWARNFLAGS} ${GP} \
     71 		-mno-abicalls -mno-half-pic
     72 AFLAGS=		${ENDIAN} -x assembler-with-cpp -traditional-cpp -D_LOCORE
     73 LD+=		${ENDIAN}
     74 KERNLDSCRIPT?=	${MIPS}/conf/kern.ldscript
     75 LINKFLAGS+=	-Ttext ${TEXTADDR} -e start ${GP} -T ${KERNLDSCRIPT}
     76 .if (${ENDIAN} == "-EB")
     77 LINKFLAGS+=	--oformat elf32-bigmips
     78 .else
     79 LINKFLAGS+=	--oformat elf32-littlemips
     80 .endif
     81 STRIPFLAGS=	-g -X -x
     82 
     83 .-include "${THISMIPS}/conf/Makefile.${MACHINE}.inc"
     84 
     85 %INCLUDES
     86 
     87 ### find out what to use for libkern
     88 .include "$S/lib/libkern/Makefile.inc"
     89 .ifndef PROF
     90 LIBKERN=	${KERNLIB}
     91 .else
     92 LIBKERN=	${KERNLIB_PROF}
     93 .endif
     94 
     95 ### find out what to use for libcompat
     96 .include "$S/compat/common/Makefile.inc"
     97 .ifndef PROF
     98 LIBCOMPAT=	${COMPATLIB}
     99 .else
    100 LIBCOMPAT=	${COMPATLIB_PROF}
    101 .endif
    102 
    103 # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
    104 # HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
    105 
    106 NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
    107 NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
    108 NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
    109 
    110 %OBJS
    111 
    112 %CFILES
    113 
    114 %SFILES
    115 
    116 # load lines for config "xxx" will be emitted as:
    117 # xxx: ${SYSTEM_DEP} swapxxx.o
    118 #	${SYSTEM_LD_HEAD}
    119 #	${SYSTEM_LD} swapxxx.o
    120 #	${SYSTEM_LD_TAIL}
    121 SYSTEM_OBJ=	locore.o locore_machdep.o
    122 .if !empty(IDENT:M-DMIPS1)
    123 SYSTEM_OBJ+=	locore_mips1.o
    124 .endif
    125 .if !empty(IDENT:M-DMIPS3)
    126 SYSTEM_OBJ+=	locore_mips3.o
    127 .endif
    128 .if !empty(IDENT:M-DMIPS3_5900)
    129 SYSTEM_OBJ+=	locore_r5900.o r5900_machdep.o
    130 .endif
    131 .if empty(IDENT:M-DNOFPU)
    132 SYSTEM_OBJ+=	fp.o
    133 .endif
    134 SYSTEM_OBJ+=	param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
    135 SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
    136 SYSTEM_LD_HEAD?=@rm -f $@
    137 SYSTEM_LD?=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o ; \
    138 		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
    139 SYSTEM_LD_TAIL?= \
    140 		@${SIZE} $@; chmod 755 $@
    141 
    142 DEBUG?=
    143 .if ${DEBUG} == "-g"
    144 LINKFLAGS+=	-X
    145 .ifdef DEBUG_SYSTEM_LD_TAIL
    146 SYSTEM_LD_TAIL+=${DEBUG_SYSTEM_LD_TAIL}
    147 .else
    148 SYSTEM_LD_TAIL+=; \
    149 		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
    150 		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
    151 		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
    152 .endif
    153 .else
    154 LINKFLAGS+=	-x
    155 .endif
    156 
    157 .ifdef POST_STRIP_SYSTEM_LD_TAIL
    158 SYSTEM_LD_TAIL+=${POST_STRIP_SYSTEM_LD_TAIL}
    159 .endif
    160 
    161 %LOAD
    162 
    163 assym.h: $S/kern/genassym.sh ${MIPS}/mips/genassym.cf
    164 	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
    165 	  < ${MIPS}/mips/genassym.cf > assym.h.tmp && \
    166 	mv -f assym.h.tmp assym.h
    167 
    168 
    169 param.c: $S/conf/param.c
    170 	rm -f param.c
    171 	cp $S/conf/param.c .
    172 
    173 param.o: param.c Makefile
    174 	${NORMAL_C}
    175 
    176 ioconf.o: ioconf.c
    177 	${NORMAL_C}
    178 
    179 newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
    180 	sh $S/conf/newvers.sh
    181 	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
    182 
    183 __CLEANKERNEL: .USE
    184 	@echo "${.TARGET}ing the kernel objects"
    185 	rm -f eddep *netbsd netbsd.ecoff netbsd.gdb tags *.[io] \
    186 	  [a-z]*.s [Ee]rrs linterrs makelinks assym.h.tmp assym.h
    187 
    188 __CLEANDEPEND: .USE
    189 	rm -f .depend
    190 
    191 clean: __CLEANKERNEL
    192 
    193 cleandir distclean: __CLEANKERNEL __CLEANDEPEND
    194 
    195 lint:
    196 	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
    197 	  ${MIPS}/mips/Locore.c ${CFILES} \
    198 	  ioconf.c param.c | \
    199 	  grep -v 'static function .* unused'
    200 
    201 tags:
    202 	@echo "see $S/kern/Makefile for tags"
    203 
    204 links:
    205 	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
    206 	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
    207 	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
    208 	  sort -u | comm -23 - dontlink | \
    209 	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
    210 	sh makelinks && rm -f dontlink
    211 
    212 .if !empty(IDENT:M-DMIPS1)
    213 SFILES+=${MIPS}/mips/locore_mips1.S
    214 .endif
    215 .if !empty(IDENT:M-DMIPS3)
    216 SFILES+=${MIPS}/mips/locore_mips3.S
    217 .endif
    218 .if !empty(IDENT:M-DMIPS3_5900)
    219 SRCS+=	${MIPS}/mips/r5900/locore_r5900.S ${MIPS}/mips/r5900/r5900_machdep.c
    220 .endif
    221 .if empty(IDENT:M-DNOFPU)
    222 SFILES+=${MIPS}/mips/fp.S
    223 .endif
    224 SFILES+=${MIPS}/mips/locore.S \
    225 	${THISMIPS}/${MACHINE}/locore_machdep.S
    226 SRCS=	param.c ioconf.c ${CFILES} ${SFILES}
    227 
    228 depend: .depend
    229 .depend: ${SRCS} assym.h param.c
    230 	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
    231 	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
    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 locore_r5900.o: ${MIPS}/mips/r5900/locore_r5900.S assym.h
    265 	${NORMAL_S}
    266 
    267 r5900_machdep.o: ${MIPS}/mips/r5900/r5900_machdep.c
    268 	${NORMAL_C}
    269 
    270 .if empty(IDENT:M-DNOFPU)
    271 fp.o: ${MIPS}/mips/fp.S assym.h
    272 	${NORMAL_S}
    273 .endif
    274 
    275 locore_machdep.o: ${THISMIPS}/${MACHINE}/locore_machdep.S assym.h
    276 	${NORMAL_S}
    277 
    278 # The install target can be redefined by putting a
    279 # install-kernel-${MACHINE_NAME} target into /etc/mk.conf
    280 MACHINE_NAME!=  uname -n
    281 install: install-kernel-${MACHINE_NAME}
    282 .if !target(install-kernel-${MACHINE_NAME}})
    283 install-kernel-${MACHINE_NAME}:
    284 	rm -f /onetbsd
    285 	ln /netbsd /onetbsd
    286 	cp netbsd /nnetbsd
    287 	mv /nnetbsd /netbsd
    288 .endif
    289 
    290 %RULES
    291