Makefile.sun3 revision 1.57
11.57Sgwr#	$NetBSD: Makefile.sun3,v 1.57 1997/02/07 22:55:44 gwr 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.1Sglass# source tree is located via $S relative to the compilation directory
371.50Smycroft.ifndef S
381.47SmycroftS!=	cd ../../../..; pwd
391.50Smycroft.endif
401.47SmycroftSUN3=	$S/arch/sun3
411.1Sglass
421.45Sgwr# Override CPP defaults entirely, so cross-compilation works.
431.53Sgwr# Keep -nostdinc before all -I flags, similar for -undef ...
441.53SgwrINCLUDES=	-nostdinc -I. -I$S/arch -I$S
451.47SmycroftXDEFS=		-undef -D__NetBSD__ -Dm68k -Dmc68000
461.53SgwrDEFINES=	-D_KERNEL -Dmc68020 -Dsun3
471.53SgwrCPPFLAGS=	${INCLUDES} ${XDEFS} ${DEFINES} ${IDENT} ${PARAM}
481.53Sgwr# Make it easy to override this on the command line...
491.53SgwrCWARNFLAGS= 	-Werror -Wall -Wstrict-prototypes # -Wmissing-prototypes
501.53SgwrCFLAGS= 	${DEBUG} ${COPTS} -msoft-float ${CWARNFLAGS}
511.53Sgwr# No, we may NOT assume that the compiler does -x whatever...
521.53SgwrAPPFLAGS=	-P -traditional ${CPPFLAGS} -D_LOCORE
531.38SmycroftLINKFLAGS=	-N -Ttext 0E004000 -e start
541.51SmycroftSTRIPFLAGS=	-d
551.51Smycroft
561.47Smycroft### find out what to use for libkern
571.47Smycroft.include "$S/lib/libkern/Makefile.inc"
581.31Sgwr.ifndef PROF
591.47SmycroftLIBKERN=	${KERNLIB}
601.31Sgwr.else
611.47SmycroftLIBKERN=	${KERNLIB_PROF}
621.31Sgwr.endif
631.1Sglass
641.47Smycroft### find out what to use for libcompat
651.47Smycroft.include "$S/compat/common/Makefile.inc"
661.47Smycroft.ifndef PROF
671.47SmycroftLIBCOMPAT=	${COMPATLIB}
681.47Smycroft.else
691.47SmycroftLIBCOMPAT=	${COMPATLIB_PROF}
701.47Smycroft.endif
711.32Schristos
721.57Sgwr# compile rules: rules are named NORMAL_${SUFFIX} where SUFFIX is
731.57Sgwr# the file suffix, capitalized (e.g. C for a .c file).
741.1Sglass
751.38SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
761.1Sglass
771.53Sgwr# Do NOT assume the compiler does "-x funny_format" (gcc-specific)
781.53Sgwr# This needs an intermediate file.  The original file is always
791.53Sgwr# safe in some far away directory, so just use the base name.
801.53SgwrNORMAL_S=	${CPP} ${APPFLAGS} $< > $*.s ;\
811.53Sgwr		${AS} -o $@ $*.s ; rm $*.s
821.53Sgwr
831.53Sgwr# These comments help identify sections in the generated Makefile.
841.53Sgwr# OBJS, CFILES, SFILES follow:
851.48Smycroft
861.1Sglass%OBJS
871.1Sglass
881.1Sglass%CFILES
891.1Sglass
901.38Smycroft%SFILES
911.38Smycroft
921.53Sgwr# OBJS, CFILES, SFILES done.
931.53Sgwr
941.1Sglass# load lines for config "xxx" will be emitted as:
951.1Sglass# xxx: ${SYSTEM_DEP} swapxxx.o
961.1Sglass#	${SYSTEM_LD_HEAD}
971.1Sglass#	${SYSTEM_LD} swapxxx.o
981.1Sglass#	${SYSTEM_LD_TAIL}
991.38SmycroftSYSTEM_OBJ=	locore.o \
1001.43Scgd		param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
1011.38SmycroftSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1021.38SmycroftSYSTEM_LD_HEAD=	@rm -f $@
1031.38SmycroftSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1041.38Smycroft		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1051.53SgwrSYSTEM_LD_TAIL=	size $@; chmod 755 $@
1061.38Smycroft
1071.38SmycroftDEBUG?=
1081.11Sderaadt.if ${DEBUG} == "-g"
1091.38SmycroftLINKFLAGS+=	-X
1101.38SmycroftSYSTEM_LD_TAIL+=; \
1111.53Sgwr		mv -f $@ $@.gdb; cp -p $@.gdb $@; \
1121.53Sgwr		${STRIP} ${STRIPFLAGS} $@
1131.11Sderaadt.else
1141.41SgwrLINKFLAGS+=	-S
1151.11Sderaadt.endif
1161.1Sglass
1171.53Sgwr# LOAD+
1181.53Sgwr
1191.1Sglass%LOAD
1201.1Sglass
1211.53Sgwr# LOAD-
1221.53Sgwr
1231.57Sgwr# Use awk to cross-build assym.h from the genassym.s file.
1241.57Sgwrassym.h: genassym.o genassym.s ${SUN3}/sun3/genassym.awk
1251.57Sgwr	awk -f ${SUN3}/sun3/genassym.awk < genassym.s > $@
1261.57Sgwr
1271.57Sgwr# The above rule lists genassym.o as a prerequisite so that the
1281.57Sgwr# generated .depend rule is effective, even though we really use
1291.57Sgwr# the genassym.s file.   This always creates both.  Also create
1301.57Sgwr# the .i file so it can be examined (or compiled elsewhere).
1311.57Sgwrgenassym.o genassym.s : genassym.i
1321.57Sgwr	${CC} ${COPTS} -S $*.i
1331.57Sgwr	${CC} -c $*.s
1341.1Sglass
1351.57Sgwrgenassym.i: ${SUN3}/sun3/genassym.c
1361.57Sgwr	${CC} ${CPPFLAGS} -E $< > $*.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.56Sgwrclean:
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.56Sgwrdepend: .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