Makefile.sun3 revision 1.55
11.55Sperry#	$NetBSD: Makefile.sun3,v 1.55 1997/02/04 05:08:50 perry 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.1Sglass# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
161.1Sglass#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
171.1Sglass#
181.1Sglass# -DTRACE	compile in kernel tracing hooks
191.1Sglass# -DQUOTA	compile in file system quotas
201.1Sglass
211.38Smycroft# DEBUG is set to -g if debugging.
221.38Smycroft# PROF is set to -pg if profiling.
231.38Smycroft
241.53Sgwr# XXX - Make cross-build work...
251.53SgwrMACHINE_ARCH=m68k
261.53SgwrMACHINE=sun3
271.53Sgwr
281.53SgwrAS?=	as
291.42SmycroftCC?=	cc
301.53SgwrCPP?=	cpp
311.42SmycroftLD?=	ld
321.45SgwrMKDEP?=	mkdep
331.51SmycroftSTRIP?=	strip
341.53SgwrCOPTS?=	-O2
351.53Sgwr
361.53Sgwr# Need to override this for cross compilation.
371.53SgwrHOSTED_CC?=	${CC}
381.1Sglass
391.1Sglass# source tree is located via $S relative to the compilation directory
401.50Smycroft.ifndef S
411.47SmycroftS!=	cd ../../../..; pwd
421.50Smycroft.endif
431.47SmycroftSUN3=	$S/arch/sun3
441.1Sglass
451.45Sgwr# Override CPP defaults entirely, so cross-compilation works.
461.53Sgwr# Keep -nostdinc before all -I flags, similar for -undef ...
471.53SgwrINCLUDES=	-nostdinc -I. -I$S/arch -I$S
481.47SmycroftXDEFS=		-undef -D__NetBSD__ -Dm68k -Dmc68000
491.53SgwrDEFINES=	-D_KERNEL -Dmc68020 -Dsun3
501.53SgwrCPPFLAGS=	${INCLUDES} ${XDEFS} ${DEFINES} ${IDENT} ${PARAM}
511.53Sgwr# Make it easy to override this on the command line...
521.53SgwrCWARNFLAGS= 	-Werror -Wall -Wstrict-prototypes # -Wmissing-prototypes
531.53SgwrCFLAGS= 	${DEBUG} ${COPTS} -msoft-float ${CWARNFLAGS}
541.53Sgwr# No, we may NOT assume that the compiler does -x whatever...
551.53SgwrAPPFLAGS=	-P -traditional ${CPPFLAGS} -D_LOCORE
561.38SmycroftLINKFLAGS=	-N -Ttext 0E004000 -e start
571.51SmycroftSTRIPFLAGS=	-d
581.51Smycroft
591.47Smycroft### find out what to use for libkern
601.47Smycroft.include "$S/lib/libkern/Makefile.inc"
611.31Sgwr.ifndef PROF
621.47SmycroftLIBKERN=	${KERNLIB}
631.31Sgwr.else
641.47SmycroftLIBKERN=	${KERNLIB_PROF}
651.31Sgwr.endif
661.1Sglass
671.47Smycroft### find out what to use for libcompat
681.47Smycroft.include "$S/compat/common/Makefile.inc"
691.47Smycroft.ifndef PROF
701.47SmycroftLIBCOMPAT=	${COMPATLIB}
711.47Smycroft.else
721.47SmycroftLIBCOMPAT=	${COMPATLIB_PROF}
731.47Smycroft.endif
741.32Schristos
751.49Smycroft# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
761.49Smycroft# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
771.1Sglass
781.38SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
791.1Sglass
801.53Sgwr# Do NOT assume the compiler does "-x funny_format" (gcc-specific)
811.53Sgwr# This needs an intermediate file.  The original file is always
821.53Sgwr# safe in some far away directory, so just use the base name.
831.53SgwrNORMAL_S=	${CPP} ${APPFLAGS} $< > $*.s ;\
841.53Sgwr		${AS} -o $@ $*.s ; rm $*.s
851.53Sgwr
861.53Sgwr# These comments help identify sections in the generated Makefile.
871.53Sgwr# OBJS, CFILES, SFILES follow:
881.48Smycroft
891.1Sglass%OBJS
901.1Sglass
911.1Sglass%CFILES
921.1Sglass
931.38Smycroft%SFILES
941.38Smycroft
951.53Sgwr# OBJS, CFILES, SFILES done.
961.53Sgwr
971.1Sglass# load lines for config "xxx" will be emitted as:
981.1Sglass# xxx: ${SYSTEM_DEP} swapxxx.o
991.1Sglass#	${SYSTEM_LD_HEAD}
1001.1Sglass#	${SYSTEM_LD} swapxxx.o
1011.1Sglass#	${SYSTEM_LD_TAIL}
1021.38SmycroftSYSTEM_OBJ=	locore.o \
1031.43Scgd		param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
1041.38SmycroftSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1051.38SmycroftSYSTEM_LD_HEAD=	@rm -f $@
1061.38SmycroftSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1071.38Smycroft		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1081.53SgwrSYSTEM_LD_TAIL=	size $@; chmod 755 $@
1091.38Smycroft
1101.38SmycroftDEBUG?=
1111.11Sderaadt.if ${DEBUG} == "-g"
1121.38SmycroftLINKFLAGS+=	-X
1131.38SmycroftSYSTEM_LD_TAIL+=; \
1141.53Sgwr		mv -f $@ $@.gdb; cp -p $@.gdb $@; \
1151.53Sgwr		${STRIP} ${STRIPFLAGS} $@
1161.11Sderaadt.else
1171.41SgwrLINKFLAGS+=	-S
1181.11Sderaadt.endif
1191.1Sglass
1201.53Sgwr# LOAD+
1211.53Sgwr
1221.1Sglass%LOAD
1231.1Sglass
1241.53Sgwr# LOAD-
1251.53Sgwr
1261.38Smycroftassym.h: genassym
1271.38Smycroft	./genassym >assym.h
1281.1Sglass
1291.53Sgwr# Doing a cross-build of this is very tricky, and very dependent
1301.53Sgwr# on compatibility of things like structure member alignment in
1311.53Sgwr# the compiler used as HOSTED_CC (must match the native compiler).
1321.53Sgwr# Often this is not possible at all, and you just have to build
1331.53Sgwr# the assym.h file by hand on some other machine. -gwr
1341.53Sgwrgenassym: ${SUN3}/sun3/genassym.c
1351.53Sgwr	${CC} ${CPPFLAGS} -E $< > $@.i
1361.53Sgwr	${HOSTED_CC} -o $@ $@.i
1371.1Sglass
1381.38Smycroftparam.c: $S/conf/param.c
1391.38Smycroft	rm -f param.c
1401.38Smycroft	cp $S/conf/param.c .
1411.17Sgwr
1421.38Smycroftparam.o: param.c Makefile
1431.49Smycroft	${NORMAL_C}
1441.21Sgwr
1451.38Smycroftioconf.o: ioconf.c
1461.38Smycroft	${NORMAL_C}
1471.1Sglass
1481.38Smycroftnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1491.38Smycroft	sh $S/conf/newvers.sh
1501.38Smycroft	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1511.38Smycroft
1521.38Smycroft
1531.38Smycroftclean::
1541.43Scgd	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1551.38Smycroft	    [Ee]rrs linterrs makelinks genassym genassym.o assym.h
1561.1Sglass
1571.38Smycroftlint:
1581.54Sperry	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
1591.55Sperry	    ${SUN3}/sun3/Locore.c ${CFILES} \
1601.38Smycroft	    ioconf.c param.c | \
1611.38Smycroft	    grep -v 'static function .* unused'
1621.1Sglass
1631.38Smycrofttags:
1641.38Smycroft	@echo "see $S/kern/Makefile for tags"
1651.1Sglass
1661.1Sglasslinks:
1671.1Sglass	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1681.1Sglass	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1691.1Sglass	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1701.1Sglass	  sort -u | comm -23 - dontlink | \
1711.38Smycroft	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1721.1Sglass	sh makelinks && rm -f dontlink
1731.1Sglass
1741.38SmycroftSRCS=	${SUN3}/sun3/locore.s \
1751.43Scgd	param.c ioconf.c ${CFILES} ${SFILES}
1761.53Sgwr
1771.44Smycroftdepend:: .depend
1781.47Smycroft.depend: ${SRCS} assym.h param.c
1791.53Sgwr	${MKDEP} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1801.53Sgwr	${MKDEP} -a ${CPPFLAGS} ${SUN3}/sun3/genassym.c
1811.38Smycroft
1821.45Sgwr# XXX - see below
1831.45Sgwr#	${MKDEP} -a ${APPFLAGS} ${SUN3}/sun3/locore.s
1841.45Sgwr#	${MKDEP} -a ${APPFLAGS} ${SFILES}
1851.45Sgwr#
1861.45Sgwr# For cross-compilation, the "gcc -M" mkdep script is convenient,
1871.45Sgwr# but that does not correctly make rules from *.s files.  The
1881.45Sgwr# easiest compromise is to just list those dependencies here.
1891.45Sgwrlocore.o: assym.h machine/trap.h m68k/trap.h
1901.45Sgwrcopy.o:   assym.h $S/sys/errno.h
1911.1Sglass
1921.38Smycroft# depend on root or device configuration
1931.38Smycroftautoconf.o conf.o: Makefile
1941.38Smycroft 
1951.38Smycroft# depend on network or filesystem configuration 
1961.38Smycroftuipc_proto.o vfs_conf.o: Makefile 
1971.1Sglass
1981.38Smycroft# depend on maxusers
1991.38Smycroftgenassym.o machdep.o: Makefile
2001.1Sglass
2011.38Smycroft# depend on CPU configuration 
2021.38Smycroftdb_machdep.o dvma.o machdep.o pmap.o sun3_startup.o vm_machdep.o: Makefile
2031.1Sglass
2041.53Sgwrlocore.o: ${SUN3}/sun3/locore.s
2051.53Sgwr	${NORMAL_S}
2061.47Smycroft
2071.53Sgwr# Generated rules follow:
2081.1Sglass
2091.1Sglass%RULES
210