Home | History | Annotate | Line # | Download | only in conf
Makefile.mips revision 1.3
      1 #	$NetBSD: Makefile.mips,v 1.3 2000/12/03 05:30:31 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 SYSTEM_OBJ+=	fp.o param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
    125 SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
    126 SYSTEM_LD_HEAD?=@rm -f $@
    127 SYSTEM_LD?=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o ; \
    128 		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
    129 SYSTEM_LD_TAIL?= \
    130 		@${SIZE} $@; chmod 755 $@
    131 
    132 DEBUG?=
    133 .if ${DEBUG} == "-g"
    134 LINKFLAGS+=	-X
    135 .ifdef DEBUG_SYSTEM_LD_TAIL
    136 SYSTEM_LD_TAIL+=${DEBUG_SYSTEM_LD_TAIL}
    137 .else
    138 SYSTEM_LD_TAIL+=; \
    139 		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
    140 		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
    141 		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
    142 .endif
    143 .else
    144 LINKFLAGS+=	-x
    145 .endif
    146 
    147 .ifdef POST_STRIP_SYSTEM_LD_TAIL
    148 SYSTEM_LD_TAIL+=${POST_STRIP_SYSTEM_LD_TAIL}
    149 .endif
    150 
    151 %LOAD
    152 
    153 assym.h: $S/kern/genassym.sh ${MIPS}/mips/genassym.cf
    154 	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
    155 	  < ${MIPS}/mips/genassym.cf > assym.h.tmp && \
    156 	mv -f assym.h.tmp assym.h
    157 
    158 
    159 param.c: $S/conf/param.c
    160 	rm -f param.c
    161 	cp $S/conf/param.c .
    162 
    163 param.o: param.c Makefile
    164 	${NORMAL_C}
    165 
    166 ioconf.o: ioconf.c
    167 	${NORMAL_C}
    168 
    169 newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
    170 	sh $S/conf/newvers.sh
    171 	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
    172 
    173 __CLEANKERNEL: .USE
    174 	@echo "${.TARGET}ing the kernel objects"
    175 	rm -f eddep *netbsd netbsd.ecoff netbsd.gdb tags *.[io] \
    176 	  [a-z]*.s [Ee]rrs linterrs makelinks assym.h.tmp assym.h
    177 
    178 __CLEANDEPEND: .USE
    179 	rm -f .depend
    180 
    181 clean: __CLEANKERNEL
    182 
    183 cleandir distclean: __CLEANKERNEL __CLEANDEPEND
    184 
    185 lint:
    186 	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
    187 	  ${MIPS}/mips/Locore.c ${CFILES} \
    188 	  ioconf.c param.c | \
    189 	  grep -v 'static function .* unused'
    190 
    191 tags:
    192 	@echo "see $S/kern/Makefile for tags"
    193 
    194 links:
    195 	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
    196 	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
    197 	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
    198 	  sort -u | comm -23 - dontlink | \
    199 	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
    200 	sh makelinks && rm -f dontlink
    201 
    202 SRCS=	${MIPS}/mips/locore.S ${MIPS}/mips/fp.S \
    203 	${THISMIPS}/${MACHINE}/locore_machdep.S \
    204 	param.c ioconf.c ${CFILES} ${SFILES}
    205 depend: .depend
    206 .depend: ${SRCS} assym.h param.c
    207 	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${MIPS}/mips/locore.S ${MIPS}/mips/fp.S
    208 	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${THISMIPS}/${MACHINE}/locore_machdep.S
    209 	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
    210 .if (${SFILES} != "")
    211 	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
    212 .endif
    213 	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
    214 	  ${CPPFLAGS} < ${MIPS}/mips/genassym.cf
    215 	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
    216 	@rm -f assym.dep
    217 
    218 dependall: depend all
    219 
    220 
    221 # depend on root or device configuration
    222 autoconf.o conf.o: Makefile
    223 
    224 # depend on network or filesystem configuration
    225 uipc_proto.o vfs_conf.o: Makefile
    226 
    227 # depend on maxusers
    228 machdep.o: Makefile
    229 
    230 # depend on CPU configuration
    231 machdep.o mainbus.o trap.o: Makefile
    232 
    233 # depend on System V IPC/shmem options
    234 mips_machdep.o pmap.o: Makefile
    235 
    236 locore.o: ${MIPS}/mips/locore.S assym.h
    237 	${NORMAL_S}
    238 
    239 locore_mips1.o: ${MIPS}/mips/locore_mips1.S assym.h
    240 	${NORMAL_S}
    241 
    242 locore_mips3.o: ${MIPS}/mips/locore_mips3.S assym.h
    243 	${NORMAL_S}
    244 
    245 fp.o: ${MIPS}/mips/fp.S assym.h
    246 	${NORMAL_S}
    247 
    248 locore_machdep.o: ${THISMIPS}/${MACHINE}/locore_machdep.S assym.h
    249 	${NORMAL_S}
    250 
    251 # The install target can be redefined by putting a
    252 # install-kernel-${MACHINE_NAME} target into /etc/mk.conf
    253 MACHINE_NAME!=  uname -n
    254 install: install-kernel-${MACHINE_NAME}
    255 .if !target(install-kernel-${MACHINE_NAME}})
    256 install-kernel-${MACHINE_NAME}:
    257 	rm -f /onetbsd
    258 	ln /netbsd /onetbsd
    259 	cp netbsd /nnetbsd
    260 	mv /nnetbsd /netbsd
    261 .endif
    262 
    263 %RULES
    264