Makefile.sun3 revision 1.91
11.91Slukem# $NetBSD: Makefile.sun3,v 1.91 2001/11/20 12:56:41 lukem Exp $
21.23Scgd
31.24Sgwr# Makefile for NetBSD
41.1Sglass#
51.1Sglass# This makefile is constructed from a machine description:
61.1Sglass#	config machineid
71.1Sglass# Most changes should be made in the machine description
81.35Sgwr#	/sys/arch/sun3/conf/``machineid''
91.1Sglass# after which you should do
101.38Smycroft#	config machineid
111.1Sglass# Machine generic makefile changes should be made in
121.35Sgwr#	/sys/arch/sun3/conf/Makefile.sun3
131.1Sglass# after which config should be rerun for all machines of that type.
141.1Sglass
151.88SthorpejMACHINE_ARCH=m68k
161.89SjmcUSETOOLS?=	no
171.89Sjmc
181.89Sjmc.include <bsd.own.mk>
191.88Sthorpej
201.38Smycroft# DEBUG is set to -g if debugging.
211.38Smycroft# PROF is set to -pg if profiling.
221.53Sgwr
231.66SthorpejAR?=	ar
241.53SgwrAS?=	as
251.42SmycroftCC?=	cc
261.53SgwrCPP?=	cpp
271.42SmycroftLD?=	ld
281.65SthorpejLORDER?=lorder
291.45SgwrMKDEP?=	mkdep
301.65SthorpejNM?=	nm
311.66SthorpejRANLIB?=ranlib
321.62SlukemSIZE?=	size
331.80StsutsuiSTRIP?=	strip
341.65SthorpejTSORT?=	tsort -q
351.66Sthorpej
361.58SgwrCOPTS?=	-O2 -fno-defer-pop
371.53Sgwr
381.1Sglass# source tree is located via $S relative to the compilation directory
391.50Smycroft.ifndef S
401.47SmycroftS!=	cd ../../../..; pwd
411.50Smycroft.endif
421.47SmycroftSUN3=	$S/arch/sun3
431.1Sglass
441.67Sgwr.if ${MACHTYPE} == "sun3x"
451.67SgwrTEXTADDR=F8004000
461.67Sgwr.else
471.67SgwrTEXTADDR=0E004000
481.67Sgwr.endif
491.67Sgwr
501.45Sgwr# Override CPP defaults entirely, so cross-compilation works.
511.53Sgwr# Keep -nostdinc before all -I flags, similar for -undef ...
521.91SlukemHAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo
531.53SgwrINCLUDES=	-nostdinc -I. -I$S/arch -I$S
541.86SchsXDEFS=		-undef -D__NetBSD__ -Dm68k -Dmc68000 -D__m68k__ -D__ELF__
551.87SmrgDEFINES=	-D_KERNEL -D_KERNEL_OPT -Dsun3
561.53SgwrCPPFLAGS=	${INCLUDES} ${XDEFS} ${DEFINES} ${IDENT} ${PARAM}
571.53Sgwr# Make it easy to override this on the command line...
581.73SaugustssCWARNFLAGS?= 	-Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \
591.73Saugustss		-Wpointer-arith
601.81Sthorpej# XXX Delete -Wuninitialized for now, since the compiler doesn't
611.91Slukem# XXX always get it right.  --thorpej
621.81SthorpejCWARNFLAGS+=	-Wno-uninitialized
631.81Sthorpej.if (${HAVE_EGCS} != "")
641.68StvCWARNFLAGS+=	-Wno-main
651.68Stv.endif
661.53SgwrCFLAGS= 	${DEBUG} ${COPTS} -msoft-float ${CWARNFLAGS}
671.86SchsAFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
681.67SgwrLINKFLAGS=	-N -Ttext ${TEXTADDR} -e start
691.77StsutsuiSTRIPFLAGS=	-g
701.75Smrg
711.75Smrg%INCLUDES
721.51Smycroft
731.47Smycroft### find out what to use for libkern
741.71SdrochnerKERN_AS=	obj
751.47Smycroft.include "$S/lib/libkern/Makefile.inc"
761.31Sgwr.ifndef PROF
771.47SmycroftLIBKERN=	${KERNLIB}
781.31Sgwr.else
791.47SmycroftLIBKERN=	${KERNLIB_PROF}
801.31Sgwr.endif
811.1Sglass
821.47Smycroft### find out what to use for libcompat
831.47Smycroft.include "$S/compat/common/Makefile.inc"
841.47Smycroft.ifndef PROF
851.47SmycroftLIBCOMPAT=	${COMPATLIB}
861.47Smycroft.else
871.47SmycroftLIBCOMPAT=	${COMPATLIB_PROF}
881.47Smycroft.endif
891.32Schristos
901.57Sgwr# compile rules: rules are named NORMAL_${SUFFIX} where SUFFIX is
911.57Sgwr# the file suffix, capitalized (e.g. C for a .c file).
921.1Sglass
931.38SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
941.69SthorpejNOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
951.86SchsNORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
961.53Sgwr
971.53Sgwr# These comments help identify sections in the generated Makefile.
981.53Sgwr# OBJS, CFILES, SFILES follow:
991.48Smycroft
1001.1Sglass%OBJS
1011.1Sglass
1021.1Sglass%CFILES
1031.1Sglass
1041.38Smycroft%SFILES
1051.38Smycroft
1061.53Sgwr# OBJS, CFILES, SFILES done.
1071.53Sgwr
1081.1Sglass# load lines for config "xxx" will be emitted as:
1091.1Sglass# xxx: ${SYSTEM_DEP} swapxxx.o
1101.1Sglass#	${SYSTEM_LD_HEAD}
1111.1Sglass#	${SYSTEM_LD} swapxxx.o
1121.1Sglass#	${SYSTEM_LD_TAIL}
1131.38SmycroftSYSTEM_OBJ=	locore.o \
1141.71Sdrochner		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
1151.38SmycroftSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1161.38SmycroftSYSTEM_LD_HEAD=	@rm -f $@
1171.38SmycroftSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1181.38Smycroft		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1191.62SlukemSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1201.38Smycroft
1211.38SmycroftDEBUG?=
1221.11Sderaadt.if ${DEBUG} == "-g"
1231.38SmycroftLINKFLAGS+=	-X
1241.38SmycroftSYSTEM_LD_TAIL+=; \
1251.76Scgd		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
1261.80Stsutsui		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
1271.80Stsutsui		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1281.11Sderaadt.else
1291.41SgwrLINKFLAGS+=	-S
1301.11Sderaadt.endif
1311.1Sglass
1321.53Sgwr# LOAD+
1331.53Sgwr
1341.1Sglass%LOAD
1351.1Sglass
1361.53Sgwr# LOAD-
1371.53Sgwr
1381.83Sjdolecekassym.h: $S/kern/genassym.sh ${SUN3}/${MACHTYPE}/genassym.cf
1391.83Sjdolecek	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1401.83Sjdolecek	    < ${SUN3}/${MACHTYPE}/genassym.cf > assym.h.tmp && \
1411.83Sjdolecek	mv -f assym.h.tmp assym.h
1421.1Sglass
1431.38Smycroftparam.c: $S/conf/param.c
1441.38Smycroft	rm -f param.c
1451.38Smycroft	cp $S/conf/param.c .
1461.17Sgwr
1471.38Smycroftparam.o: param.c Makefile
1481.49Smycroft	${NORMAL_C}
1491.21Sgwr
1501.38Smycroftioconf.o: ioconf.c
1511.38Smycroft	${NORMAL_C}
1521.1Sglass
1531.38Smycroftnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1541.38Smycroft	sh $S/conf/newvers.sh
1551.38Smycroft	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1561.38Smycroft
1571.61Schristos__CLEANKERNEL: .USE
1581.61Schristos	@echo "${.TARGET}ing the kernel objects"
1591.61Schristos	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1601.61Schristos	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1611.61Schristos
1621.61Schristos__CLEANDEPEND: .USE
1631.61Schristos	rm -f .depend
1641.38Smycroft
1651.61Schristosclean: __CLEANKERNEL
1661.61Schristos
1671.70Slukemcleandir distclean: __CLEANKERNEL __CLEANDEPEND
1681.1Sglass
1691.38Smycroftlint:
1701.54Sperry	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
1711.60Smycroft	    ${CFILES} ioconf.c param.c | \
1721.38Smycroft	    grep -v 'static function .* unused'
1731.1Sglass
1741.38Smycrofttags:
1751.38Smycroft	@echo "see $S/kern/Makefile for tags"
1761.1Sglass
1771.1Sglasslinks:
1781.1Sglass	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1791.1Sglass	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1801.1Sglass	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1811.1Sglass	  sort -u | comm -23 - dontlink | \
1821.38Smycroft	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1831.1Sglass	sh makelinks && rm -f dontlink
1841.1Sglass
1851.67SgwrSRCS=	${SUN3}/${MACHTYPE}/locore.s \
1861.43Scgd	param.c ioconf.c ${CFILES} ${SFILES}
1871.53Sgwr
1881.56Sgwrdepend: .depend
1891.47Smycroft.depend: ${SRCS} assym.h param.c
1901.53Sgwr	${MKDEP} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1911.83Sjdolecek	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
1921.83Sjdolecek	  ${CPPFLAGS} < ${SUN3}/${MACHTYPE}/genassym.cf
1931.83Sjdolecek	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
1941.83Sjdolecek	@rm -f assym.dep
1951.79Stron
1961.79Strondependall: depend all
1971.79Stron
1981.38Smycroft
1991.45Sgwr# XXX - see below
2001.67Sgwr#	${MKDEP} -a ${APPFLAGS} ${SUN3}/${MACHTYPE}/locore.s
2011.45Sgwr#	${MKDEP} -a ${APPFLAGS} ${SFILES}
2021.45Sgwr#
2031.45Sgwr# For cross-compilation, the "gcc -M" mkdep script is convenient,
2041.45Sgwr# but that does not correctly make rules from *.s files.  The
2051.59Sgwr# easiest work-around is to just list those dependencies here.
2061.59Sgwrlocore.o:   assym.h m68k/asm.h m68k/trap.h
2071.59Sgwrcopy.o:     assym.h m68k/asm.h $S/sys/errno.h
2081.59Sgwrbcopy.o:    assym.h m68k/asm.h
2091.59Sgwrcopypage.o: assym.h m68k/asm.h
2101.1Sglass
2111.38Smycroft# depend on root or device configuration
2121.59Sgwrconf.o: Makefile
2131.91Slukem
2141.91Slukem# depend on network or filesystem configuration
2151.91Slukemuipc_proto.o vfs_conf.o: Makefile
2161.1Sglass
2171.38Smycroft# depend on maxusers
2181.59Sgwrmachdep.o: Makefile
2191.1Sglass
2201.91Slukem# depend on CPU configuration
2211.38Smycroftdb_machdep.o dvma.o machdep.o pmap.o sun3_startup.o vm_machdep.o: Makefile
2221.64Sgwr
2231.64Sgwr# depends on DDB, etc.
2241.64Sgwrstub.o: Makefile
2251.1Sglass
2261.67Sgwrlocore.o: ${SUN3}/${MACHTYPE}/locore.s
2271.53Sgwr	${NORMAL_S}
2281.47Smycroft
2291.53Sgwr# Generated rules follow:
2301.82Shubertf
2311.82Shubertf# The install target can be redefined by putting a
2321.82Shubertf# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
2331.82ShubertfMACHINE_NAME!=  uname -n
2341.82Shubertfinstall: install-kernel-${MACHINE_NAME}
2351.82Shubertf.if !target(install-kernel-${MACHINE_NAME}})
2361.82Shubertfinstall-kernel-${MACHINE_NAME}:
2371.82Shubertf	rm -f /onetbsd
2381.82Shubertf	ln /netbsd /onetbsd
2391.82Shubertf	cp netbsd /nnetbsd
2401.82Shubertf	mv /nnetbsd /netbsd
2411.82Shubertf.endif
2421.1Sglass
2431.1Sglass%RULES
244