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