Home | History | Annotate | Line # | Download | only in conf
Makefile.mips revision 1.19
      1 #	$NetBSD: Makefile.mips,v 1.19 2001/10/08 10:14:20 simonb 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_KERNEL_OPT \
     50 		-D${TARGET_MACHINE}
     51 CWARNFLAGS?=	-Wall -Werror -Wstrict-prototypes -Wmissing-prototypes \
     52 		-Wpointer-arith
     53 # XXX Delete -Wuninitialized for now, since the compiler doesn't
     54 # XXX always get it right.  --thorpej
     55 CWARNFLAGS+=	-Wno-uninitialized
     56 .if (${HAVE_EGCS} != "")
     57 CWARNFLAGS+=	-Wno-main
     58 .endif
     59 GP?=		${DEFGP}
     60 CFLAGS=		${ENDIAN} ${DEBUG} ${COPTS} ${CWARNFLAGS} ${GP} \
     61 		-mno-abicalls -mno-half-pic
     62 AFLAGS=		${ENDIAN} -x assembler-with-cpp -traditional-cpp -D_LOCORE
     63 LD+=		${ENDIAN}
     64 KERNLDSCRIPT?=	${MIPS}/conf/kern.ldscript
     65 LINKFLAGS+=	-Ttext ${TEXTADDR} -e start ${GP} -T ${KERNLDSCRIPT}
     66 .if (${ENDIAN} == "-EB")
     67 LINKFLAGS+=	--oformat elf32-bigmips
     68 .else
     69 LINKFLAGS+=	--oformat elf32-littlemips
     70 .endif
     71 STRIPFLAGS=	-g -X -x
     72 
     73 .-include "${THISMIPS}/conf/Makefile.${TARGET_MACHINE}.inc"
     74 
     75 %INCLUDES
     76 
     77 ### find out what to use for libkern
     78 .include "$S/lib/libkern/Makefile.inc"
     79 .ifndef PROF
     80 LIBKERN=	${KERNLIB}
     81 .else
     82 LIBKERN=	${KERNLIB_PROF}
     83 .endif
     84 
     85 ### find out what to use for libcompat
     86 .include "$S/compat/common/Makefile.inc"
     87 .ifndef PROF
     88 LIBCOMPAT=	${COMPATLIB}
     89 .else
     90 LIBCOMPAT=	${COMPATLIB_PROF}
     91 .endif
     92 
     93 # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
     94 # HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
     95 
     96 NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
     97 NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
     98 NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
     99 
    100 %OBJS
    101 
    102 %CFILES
    103 
    104 %SFILES
    105 
    106 # load lines for config "xxx" will be emitted as:
    107 # xxx: ${SYSTEM_DEP} swapxxx.o
    108 #	${SYSTEM_LD_HEAD}
    109 #	${SYSTEM_LD} swapxxx.o
    110 #	${SYSTEM_LD_TAIL}
    111 SYSTEM_OBJ=	locore.o locore_machdep.o
    112 .if !empty(IDENT:M-DMIPS1)
    113 SYSTEM_OBJ+=	locore_mips1.o
    114 .endif
    115 .if !empty(IDENT:M-DMIPS3)
    116 SYSTEM_OBJ+=	locore_mips3.o
    117 .endif
    118 .if empty(IDENT:M-DNOFPU)
    119 SYSTEM_OBJ+=	fp.o
    120 .endif
    121 SYSTEM_OBJ+=	param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
    122 SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
    123 SYSTEM_LD_HEAD?=@rm -f $@
    124 SYSTEM_LD?=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o ; \
    125 		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
    126 SYSTEM_LD_TAIL?= \
    127 		@${SIZE} $@; chmod 755 $@
    128 
    129 DEBUG?=
    130 .if ${DEBUG} == "-g"
    131 LINKFLAGS+=	-X
    132 .ifdef DEBUG_SYSTEM_LD_TAIL
    133 SYSTEM_LD_TAIL+=${DEBUG_SYSTEM_LD_TAIL}
    134 .else
    135 SYSTEM_LD_TAIL+=; \
    136 		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
    137 		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
    138 		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
    139 .endif
    140 .else
    141 LINKFLAGS+=	-x
    142 .endif
    143 
    144 .ifdef POST_STRIP_SYSTEM_LD_TAIL
    145 SYSTEM_LD_TAIL+=${POST_STRIP_SYSTEM_LD_TAIL}
    146 .endif
    147 
    148 %LOAD
    149 
    150 assym.h: $S/kern/genassym.sh ${MIPS}/mips/genassym.cf
    151 	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
    152 	  < ${MIPS}/mips/genassym.cf > assym.h.tmp && \
    153 	mv -f assym.h.tmp assym.h
    154 
    155 
    156 param.c: $S/conf/param.c
    157 	rm -f param.c
    158 	cp $S/conf/param.c .
    159 
    160 param.o: param.c Makefile
    161 	${NORMAL_C}
    162 
    163 ioconf.o: ioconf.c
    164 	${NORMAL_C}
    165 
    166 newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
    167 	sh $S/conf/newvers.sh
    168 	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
    169 
    170 __CLEANKERNEL: .USE
    171 	@echo "${.TARGET}ing the kernel objects"
    172 	rm -f eddep *netbsd netbsd.ecoff netbsd.gdb tags *.[io] \
    173 	  [a-z]*.s [Ee]rrs linterrs makelinks assym.h.tmp assym.h
    174 
    175 __CLEANDEPEND: .USE
    176 	rm -f .depend
    177 
    178 clean: __CLEANKERNEL
    179 
    180 cleandir distclean: __CLEANKERNEL __CLEANDEPEND
    181 
    182 lint:
    183 	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
    184 	  ${MIPS}/mips/Locore.c ${CFILES} \
    185 	  ioconf.c param.c | \
    186 	  grep -v 'static function .* unused'
    187 
    188 tags:
    189 	@echo "see $S/kern/Makefile for tags"
    190 
    191 links:
    192 	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
    193 	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
    194 	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
    195 	  sort -u | comm -23 - dontlink | \
    196 	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
    197 	sh makelinks && rm -f dontlink
    198 
    199 .if !empty(IDENT:M-DMIPS1)
    200 SFILES+=${MIPS}/mips/locore_mips1.S
    201 .endif
    202 .if !empty(IDENT:M-DMIPS3)
    203 SFILES+=${MIPS}/mips/locore_mips3.S
    204 .endif
    205 .if empty(IDENT:M-DNOFPU)
    206 SFILES+=${MIPS}/mips/fp.S
    207 .endif
    208 SFILES+=${MIPS}/mips/locore.S \
    209 	${THISMIPS}/${TARGET_MACHINE}/locore_machdep.S
    210 SRCS=	param.c ioconf.c ${CFILES} ${SFILES}
    211 
    212 depend: .depend
    213 .depend: ${SRCS} assym.h param.c
    214 	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
    215 	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
    216 	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
    217 	  ${CPPFLAGS} < ${MIPS}/mips/genassym.cf
    218 	@sed -e 's/.*\.o:.*\.c /assym.h: /' < assym.dep >> .depend
    219 	@rm -f assym.dep
    220 
    221 dependall: depend all
    222 
    223 
    224 # depend on root or device configuration
    225 autoconf.o conf.o: Makefile
    226 
    227 # depend on network or filesystem configuration
    228 uipc_proto.o vfs_conf.o: Makefile
    229 
    230 # depend on maxusers
    231 machdep.o: Makefile
    232 
    233 # depend on CPU configuration
    234 machdep.o mainbus.o trap.o: Makefile
    235 
    236 # depend on System V IPC/shmem options
    237 mips_machdep.o pmap.o: Makefile
    238 
    239 locore.o: ${MIPS}/mips/locore.S assym.h
    240 	${NORMAL_S}
    241 
    242 locore_mips1.o: ${MIPS}/mips/locore_mips1.S assym.h
    243 	${NORMAL_S}
    244 
    245 locore_mips3.o: ${MIPS}/mips/locore_mips3.S assym.h
    246 	${NORMAL_S}
    247 
    248 .if empty(IDENT:M-DNOFPU)
    249 fp.o: ${MIPS}/mips/fp.S assym.h
    250 	${NORMAL_S}
    251 .endif
    252 
    253 locore_machdep.o: ${THISMIPS}/${TARGET_MACHINE}/locore_machdep.S assym.h
    254 	${NORMAL_S}
    255 
    256 # The install target can be redefined by putting a
    257 # install-kernel-${MACHINE_NAME} target into /etc/mk.conf
    258 MACHINE_NAME!=  uname -n
    259 install: install-kernel-${MACHINE_NAME}
    260 .if !target(install-kernel-${MACHINE_NAME}})
    261 install-kernel-${MACHINE_NAME}:
    262 	rm -f /onetbsd
    263 	ln /netbsd /onetbsd
    264 	cp netbsd /nnetbsd
    265 	mv /nnetbsd /netbsd
    266 .endif
    267 
    268 %RULES
    269