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