Makefile.mvme68k revision 1.53
11.53Sjmc#	$NetBSD: Makefile.mvme68k,v 1.53 2001/10/26 06:45:38 jmc Exp $
21.1Schuck
31.1Schuck# Makefile for NetBSD
41.1Schuck#
51.1Schuck# This makefile is constructed from a machine description:
61.1Schuck#	config machineid
71.1Schuck# Most changes should be made in the machine description
81.1Schuck#	/sys/arch/mvme68k/conf/``machineid''
91.1Schuck# after which you should do
101.6Smycroft#	config machineid
111.1Schuck# Machine generic makefile changes should be made in
121.1Schuck#	/sys/arch/mvme68k/conf/Makefile.mvme68k
131.1Schuck# after which config should be rerun for all machines of that type.
141.52Sthorpej
151.52SthorpejMACHINE_ARCH=m68k
161.53SjmcUSETOOLS?=	no
171.53Sjmc
181.53Sjmc.include <bsd.own.mk>
191.1Schuck
201.6Smycroft# DEBUG is set to -g if debugging.
211.6Smycroft# PROF is set to -pg if profiling.
221.1Schuck
231.32SthorpejAR?=	ar
241.32SthorpejAS?=	as
251.9SmycroftCC?=	cc
261.32SthorpejCPP?=	cpp
271.9SmycroftLD?=	ld
281.31SthorpejLORDER?=lorder
291.12SmycroftMKDEP?=	mkdep
301.31SthorpejNM?=	nm
311.32SthorpejRANLIB?=ranlib
321.30SlukemSIZE?=	size
331.45StsutsuiSTRIP?=	strip
341.31SthorpejTSORT?=	tsort -q
351.32Sthorpej
361.30SlukemCOPTS?=	-O2
371.1Schuck
381.1Schuck# source tree is located via $S relative to the compilation directory
391.15Smycroft.ifndef S
401.12SmycroftS!=	cd ../../../..; pwd
411.15Smycroft.endif
421.12SmycroftMVME68K=$S/arch/mvme68k
431.1Schuck
441.23Sgwr# Override CPP defaults entirely, so cross-compilation works.
451.23Sgwr# Keep -nostdinc before all -I flags, similar for -undef ...
461.47SthorpejHAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo 
471.23SgwrINCLUDES=	-nostdinc -I. -I$S/arch -I$S
481.51SmrgCPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT -Dmvme68k
491.49Sscw.if empty(IDENT:M-DMVME172) && empty(IDENT:M-DMVME177)
501.49Sscw.if empty(IDENT:M-DMVME147)
511.49SscwCMACHFLAGS=	-m68040
521.49Sscw.else
531.49SscwCMACHFLAGS=	-m68030
541.49Sscw.endif
551.49Sscw.else
561.49Sscw.if empty(IDENT:M-DMVME147) && empty(IDENT:M-DMVME162) && empty(IDENT:M-DMVME167)
571.49SscwCMACHFLAGS=	-m68060 -Wa,-m68030 -Wa,-m68851
581.49Sscw.else
591.49SscwCMACHFLAGS=	-m68020-60 -Wa,-m68030 -Wa,-m68851
601.49Sscw.endif
611.49Sscw.endif
621.46SscwCWARNFLAGS?=	-Werror -Wall -Wmissing-prototypes -Wstrict-prototypes \
631.46Sscw		-Wpointer-arith
641.47Sthorpej# XXX Delete -Wuninitialized for now, since the compiler doesn't
651.47Sthorpej# XXX always get it right.  --thorpej 
661.47SthorpejCWARNFLAGS+=	-Wno-uninitialized
671.47Sthorpej.if (${HAVE_EGCS} != "")
681.33StvCWARNFLAGS+=	-Wno-main
691.33Stv.endif
701.49SscwCFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS} ${CMACHFLAGS} -msoft-float
711.25SthorpejAFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
721.6SmycroftLINKFLAGS=	-n -Ttext 8000 -e start
731.42StsutsuiSTRIPFLAGS=	-g
741.40Smrg
751.40Smrg%INCLUDES
761.16Smycroft
771.25SthorpejHOSTED_CC=	${CC}
781.25SthorpejHOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
791.25SthorpejHOSTED_CFLAGS=	${CFLAGS}
801.25Sthorpej
811.1Schuck### find out what to use for libkern
821.36SdrochnerKERN_AS=	obj
831.1Schuck.include "$S/lib/libkern/Makefile.inc"
841.1Schuck.ifndef PROF
851.1SchuckLIBKERN=	${KERNLIB}
861.1Schuck.else
871.1SchuckLIBKERN=	${KERNLIB_PROF}
881.1Schuck.endif
891.1Schuck
901.1Schuck### find out what to use for libcompat
911.1Schuck.include "$S/compat/common/Makefile.inc"
921.1Schuck.ifndef PROF
931.23SgwrLIBCOMPAT=	${COMPATLIB}
941.1Schuck.else
951.23SgwrLIBCOMPAT=	${COMPATLIB_PROF}
961.1Schuck.endif
971.1Schuck
981.1Schuck### for the Motorola 68040 Floating Point Software Product
991.1Schuck.include "$S/arch/m68k/fpsp/Makefile.inc"
1001.49Sscw
1011.49Sscw### for the Motorola 68060 Software Support Package
1021.49Sscw.include "$S/arch/m68k/060sp/Makefile.inc"
1031.1Schuck
1041.25Sthorpej# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
1051.25Sthorpej# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
1061.1Schuck
1071.6SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
1081.34SthorpejNOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
1091.25SthorpejNORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
1101.1Schuck
1111.25SthorpejHOSTED_C=	${HOSTED_CC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
1121.13Smycroft
1131.1Schuck%OBJS
1141.1Schuck
1151.1Schuck%CFILES
1161.1Schuck
1171.6Smycroft%SFILES
1181.6Smycroft
1191.1Schuck# load lines for config "xxx" will be emitted as:
1201.1Schuck# xxx: ${SYSTEM_DEP} swapxxx.o
1211.1Schuck#	${SYSTEM_LD_HEAD}
1221.1Schuck#	${SYSTEM_LD} swapxxx.o
1231.1Schuck#	${SYSTEM_LD_TAIL}
1241.6SmycroftSYSTEM_OBJ=	locore.o ${FPSP} \
1251.36Sdrochner		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
1261.6SmycroftSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1271.6SmycroftSYSTEM_LD_HEAD=	@rm -f $@
1281.6SmycroftSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1291.6Smycroft		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1301.30SlukemSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1311.6Smycroft
1321.1SchuckDEBUG?=
1331.1Schuck.if ${DEBUG} == "-g"
1341.6SmycroftLINKFLAGS+=	-X
1351.6SmycroftSYSTEM_LD_TAIL+=; \
1361.41Scgd		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
1371.45Stsutsui		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
1381.45Stsutsui		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1391.1Schuck.else
1401.12SmycroftLINKFLAGS+=	-S
1411.1Schuck.endif
1421.1Schuck
1431.1Schuck%LOAD
1441.1Schuck
1451.22Smycroftassym.h: $S/kern/genassym.sh ${MVME68K}/mvme68k/genassym.cf
1461.22Smycroft	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1471.22Smycroft	    < ${MVME68K}/mvme68k/genassym.cf > assym.h.tmp && \
1481.22Smycroft	mv -f assym.h.tmp assym.h
1491.6Smycroft
1501.6Smycroftparam.c: $S/conf/param.c
1511.6Smycroft	rm -f param.c
1521.6Smycroft	cp $S/conf/param.c .
1531.6Smycroft
1541.6Smycroftparam.o: param.c Makefile
1551.14Smycroft	${NORMAL_C}
1561.6Smycroft
1571.6Smycroftioconf.o: ioconf.c
1581.6Smycroft	${NORMAL_C}
1591.1Schuck
1601.6Smycroftnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1611.1Schuck	sh $S/conf/newvers.sh
1621.6Smycroft	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1631.6Smycroft
1641.29Schristos__CLEANKERNEL: .USE
1651.29Schristos	@echo "${.TARGET}ing the kernel objects"
1661.10Scgd	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1671.22Smycroft	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1681.29Schristos
1691.29Schristos__CLEANDEPEND: .USE
1701.29Schristos	rm -f .depend
1711.29Schristos
1721.29Schristosclean: __CLEANKERNEL
1731.29Schristos
1741.35Slukemcleandir distclean: __CLEANKERNEL __CLEANDEPEND
1751.1Schuck
1761.6Smycroftlint:
1771.18Sperry	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
1781.27Smycroft	    ${CFILES} ioconf.c param.c | \
1791.6Smycroft	    grep -v 'static function .* unused'
1801.1Schuck
1811.6Smycrofttags:
1821.6Smycroft	@echo "see $S/kern/Makefile for tags"
1831.1Schuck
1841.1Schucklinks:
1851.1Schuck	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1861.1Schuck	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1871.1Schuck	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1881.1Schuck	  sort -u | comm -23 - dontlink | \
1891.6Smycroft	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1901.1Schuck	sh makelinks && rm -f dontlink
1911.1Schuck
1921.6SmycroftSRCS=	${MVME68K}/mvme68k/locore.s \
1931.10Scgd	param.c ioconf.c ${CFILES} ${SFILES}
1941.20Schuckdepend: .depend
1951.10Scgd.depend: ${SRCS} assym.h param.c
1961.25Sthorpej	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${MVME68K}/mvme68k/locore.s
1971.25Sthorpej	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1981.25Sthorpej	-if test -n "${SFILES}"; then \
1991.25Sthorpej		${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}; \
2001.25Sthorpej	fi
2011.26Sleo	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
2021.26Sleo	  ${CPPFLAGS} < ${MVME68K}/mvme68k/genassym.cf
2031.26Sleo	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
2041.26Sleo	@rm -f assym.dep
2051.44Stron
2061.44Strondependall: depend all
2071.6Smycroft
2081.6Smycroft
2091.6Smycroft# depend on root or device configuration
2101.6Smycroftautoconf.o conf.o: Makefile
2111.6Smycroft 
2121.6Smycroft# depend on network or filesystem configuration 
2131.6Smycroftuipc_proto.o vfs_conf.o: Makefile 
2141.1Schuck
2151.6Smycroft# depend on maxusers
2161.22Smycroftmachdep.o: Makefile
2171.1Schuck
2181.6Smycroft# depend on CPU configuration 
2191.6Smycroftlocore.o pmap.o sys_machdep.o trap.o: Makefile
2201.1Schuck
2211.1Schuck
2221.6Smycroftlocore.o: ${MVME68K}/mvme68k/locore.s assym.h
2231.6Smycroft	${NORMAL_S}
2241.48Shubertf
2251.48Shubertf# The install target can be redefined by putting a
2261.48Shubertf# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
2271.48ShubertfMACHINE_NAME!=  uname -n
2281.48Shubertfinstall: install-kernel-${MACHINE_NAME}
2291.48Shubertf.if !target(install-kernel-${MACHINE_NAME}})
2301.48Shubertfinstall-kernel-${MACHINE_NAME}:
2311.48Shubertf	rm -f /onetbsd
2321.48Shubertf	ln /netbsd /onetbsd
2331.48Shubertf	cp netbsd /nnetbsd
2341.48Shubertf	mv /nnetbsd /netbsd
2351.48Shubertf.endif
2361.1Schuck
2371.1Schuck%RULES
238