Makefile.sun3 revision 1.64
11.64Sgwr#	$NetBSD: Makefile.sun3,v 1.64 1997/10/23 01:39:20 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.62SlukemSIZE?=	size
341.51SmycroftSTRIP?=	strip
351.58SgwrCOPTS?=	-O2 -fno-defer-pop
361.53Sgwr
371.1Sglass# source tree is located via $S relative to the compilation directory
381.50Smycroft.ifndef S
391.47SmycroftS!=	cd ../../../..; pwd
401.50Smycroft.endif
411.47SmycroftSUN3=	$S/arch/sun3
421.1Sglass
431.45Sgwr# Override CPP defaults entirely, so cross-compilation works.
441.53Sgwr# Keep -nostdinc before all -I flags, similar for -undef ...
451.53SgwrINCLUDES=	-nostdinc -I. -I$S/arch -I$S
461.47SmycroftXDEFS=		-undef -D__NetBSD__ -Dm68k -Dmc68000
471.53SgwrDEFINES=	-D_KERNEL -Dmc68020 -Dsun3
481.53SgwrCPPFLAGS=	${INCLUDES} ${XDEFS} ${DEFINES} ${IDENT} ${PARAM}
491.53Sgwr# Make it easy to override this on the command line...
501.58SgwrCWARNFLAGS= 	-Wall -Wstrict-prototypes # -Wmissing-prototypes -Werror
511.53SgwrCFLAGS= 	${DEBUG} ${COPTS} -msoft-float ${CWARNFLAGS}
521.53Sgwr# No, we may NOT assume that the compiler does -x whatever...
531.53SgwrAPPFLAGS=	-P -traditional ${CPPFLAGS} -D_LOCORE
541.58SgwrAFLAGS= 	-m68020
551.38SmycroftLINKFLAGS=	-N -Ttext 0E004000 -e start
561.51SmycroftSTRIPFLAGS=	-d
571.51Smycroft
581.47Smycroft### find out what to use for libkern
591.47Smycroft.include "$S/lib/libkern/Makefile.inc"
601.31Sgwr.ifndef PROF
611.47SmycroftLIBKERN=	${KERNLIB}
621.31Sgwr.else
631.47SmycroftLIBKERN=	${KERNLIB_PROF}
641.31Sgwr.endif
651.1Sglass
661.47Smycroft### find out what to use for libcompat
671.47Smycroft.include "$S/compat/common/Makefile.inc"
681.47Smycroft.ifndef PROF
691.47SmycroftLIBCOMPAT=	${COMPATLIB}
701.47Smycroft.else
711.47SmycroftLIBCOMPAT=	${COMPATLIB_PROF}
721.47Smycroft.endif
731.32Schristos
741.57Sgwr# compile rules: rules are named NORMAL_${SUFFIX} where SUFFIX is
751.57Sgwr# the file suffix, capitalized (e.g. C for a .c file).
761.1Sglass
771.38SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
781.1Sglass
791.53Sgwr# Do NOT assume the compiler does "-x funny_format" (gcc-specific)
801.53Sgwr# This needs an intermediate file.  The original file is always
811.53Sgwr# safe in some far away directory, so just use the base name.
821.53SgwrNORMAL_S=	${CPP} ${APPFLAGS} $< > $*.s ;\
831.58Sgwr		${AS} ${AFLAGS} -o $@ $*.s ; rm $*.s
841.53Sgwr
851.53Sgwr# These comments help identify sections in the generated Makefile.
861.53Sgwr# OBJS, CFILES, SFILES follow:
871.48Smycroft
881.1Sglass%OBJS
891.1Sglass
901.1Sglass%CFILES
911.1Sglass
921.38Smycroft%SFILES
931.38Smycroft
941.53Sgwr# OBJS, CFILES, SFILES done.
951.53Sgwr
961.1Sglass# load lines for config "xxx" will be emitted as:
971.1Sglass# xxx: ${SYSTEM_DEP} swapxxx.o
981.1Sglass#	${SYSTEM_LD_HEAD}
991.1Sglass#	${SYSTEM_LD} swapxxx.o
1001.1Sglass#	${SYSTEM_LD_TAIL}
1011.38SmycroftSYSTEM_OBJ=	locore.o \
1021.43Scgd		param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
1031.38SmycroftSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1041.38SmycroftSYSTEM_LD_HEAD=	@rm -f $@
1051.38SmycroftSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1061.38Smycroft		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1071.62SlukemSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1081.38Smycroft
1091.38SmycroftDEBUG?=
1101.11Sderaadt.if ${DEBUG} == "-g"
1111.38SmycroftLINKFLAGS+=	-X
1121.38SmycroftSYSTEM_LD_TAIL+=; \
1131.53Sgwr		mv -f $@ $@.gdb; cp -p $@.gdb $@; \
1141.53Sgwr		${STRIP} ${STRIPFLAGS} $@
1151.11Sderaadt.else
1161.41SgwrLINKFLAGS+=	-S
1171.11Sderaadt.endif
1181.1Sglass
1191.53Sgwr# LOAD+
1201.53Sgwr
1211.1Sglass%LOAD
1221.1Sglass
1231.53Sgwr# LOAD-
1241.53Sgwr
1251.57Sgwr# Use awk to cross-build assym.h from the genassym.s file.
1261.63Sgwrassym.h: genassym.o $S/kern/genassym.awk
1271.64Sgwr	awk -f $S/kern/genassym.awk < genassym.s > assym.h.tmp
1281.64Sgwr	mv -f assym.h.tmp $@
1291.57Sgwr
1301.57Sgwr# The above rule lists genassym.o as a prerequisite so that the
1311.58Sgwr# generated .depend rule is effective, even though we actually
1321.58Sgwr# use genassym.s instead.   This always creates both.
1331.58Sgwrgenassym.o: ${SUN3}/sun3/genassym.c
1341.58Sgwr	${CC} ${CPPFLAGS} -S $<
1351.57Sgwr	${CC} -c $*.s
1361.1Sglass
1371.38Smycroftparam.c: $S/conf/param.c
1381.38Smycroft	rm -f param.c
1391.38Smycroft	cp $S/conf/param.c .
1401.17Sgwr
1411.38Smycroftparam.o: param.c Makefile
1421.49Smycroft	${NORMAL_C}
1431.21Sgwr
1441.38Smycroftioconf.o: ioconf.c
1451.38Smycroft	${NORMAL_C}
1461.1Sglass
1471.38Smycroftnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1481.38Smycroft	sh $S/conf/newvers.sh
1491.38Smycroft	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1501.38Smycroft
1511.61Schristos__CLEANKERNEL: .USE
1521.61Schristos	@echo "${.TARGET}ing the kernel objects"
1531.61Schristos	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1541.61Schristos	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1551.61Schristos
1561.61Schristos__CLEANDEPEND: .USE
1571.61Schristos	rm -f .depend
1581.38Smycroft
1591.61Schristosclean: __CLEANKERNEL
1601.61Schristos
1611.61Schristoscleandir: __CLEANKERNEL __CLEANDEPEND
1621.1Sglass
1631.38Smycroftlint:
1641.54Sperry	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
1651.60Smycroft	    ${CFILES} ioconf.c param.c | \
1661.38Smycroft	    grep -v 'static function .* unused'
1671.1Sglass
1681.38Smycrofttags:
1691.38Smycroft	@echo "see $S/kern/Makefile for tags"
1701.1Sglass
1711.1Sglasslinks:
1721.1Sglass	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1731.1Sglass	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1741.1Sglass	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1751.1Sglass	  sort -u | comm -23 - dontlink | \
1761.38Smycroft	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1771.1Sglass	sh makelinks && rm -f dontlink
1781.1Sglass
1791.38SmycroftSRCS=	${SUN3}/sun3/locore.s \
1801.43Scgd	param.c ioconf.c ${CFILES} ${SFILES}
1811.53Sgwr
1821.56Sgwrdepend: .depend
1831.47Smycroft.depend: ${SRCS} assym.h param.c
1841.53Sgwr	${MKDEP} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1851.53Sgwr	${MKDEP} -a ${CPPFLAGS} ${SUN3}/sun3/genassym.c
1861.38Smycroft
1871.45Sgwr# XXX - see below
1881.45Sgwr#	${MKDEP} -a ${APPFLAGS} ${SUN3}/sun3/locore.s
1891.45Sgwr#	${MKDEP} -a ${APPFLAGS} ${SFILES}
1901.45Sgwr#
1911.45Sgwr# For cross-compilation, the "gcc -M" mkdep script is convenient,
1921.45Sgwr# but that does not correctly make rules from *.s files.  The
1931.59Sgwr# easiest work-around is to just list those dependencies here.
1941.59Sgwrlocore.o:   assym.h m68k/asm.h m68k/trap.h
1951.59Sgwrcopy.o:     assym.h m68k/asm.h $S/sys/errno.h
1961.59Sgwrbcopy.o:    assym.h m68k/asm.h
1971.59Sgwrcopypage.o: assym.h m68k/asm.h
1981.1Sglass
1991.38Smycroft# depend on root or device configuration
2001.59Sgwrconf.o: Makefile
2011.38Smycroft 
2021.38Smycroft# depend on network or filesystem configuration 
2031.38Smycroftuipc_proto.o vfs_conf.o: Makefile 
2041.1Sglass
2051.38Smycroft# depend on maxusers
2061.59Sgwrmachdep.o: Makefile
2071.1Sglass
2081.38Smycroft# depend on CPU configuration 
2091.38Smycroftdb_machdep.o dvma.o machdep.o pmap.o sun3_startup.o vm_machdep.o: Makefile
2101.58Sgwr
2111.58Sgwr# depends on KGDBDEV, KGDBRATE
2121.58Sgwrkgdb_stub.o: Makefile
2131.64Sgwr
2141.64Sgwr# depends on DDB, etc.
2151.64Sgwrstub.o: Makefile
2161.1Sglass
2171.53Sgwrlocore.o: ${SUN3}/sun3/locore.s
2181.53Sgwr	${NORMAL_S}
2191.47Smycroft
2201.53Sgwr# Generated rules follow:
2211.1Sglass
2221.1Sglass%RULES
223