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