Makefile.sun3 revision 1.50
11.50Smycroft#	$NetBSD: Makefile.sun3,v 1.50 1996/08/31 21:41:51 mycroft 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.42SmycroftCC?=	cc
251.42SmycroftLD?=	ld
261.45SgwrMKDEP?=	mkdep
271.42SmycroftSTRIP?=	strip -d
281.42SmycroftTOUCH?=	touch -f -c
291.1Sglass
301.1Sglass# source tree is located via $S relative to the compilation directory
311.50Smycroft.ifndef S
321.47SmycroftS!=	cd ../../../..; pwd
331.50Smycroft.endif
341.47SmycroftSUN3=	$S/arch/sun3
351.1Sglass
361.45Sgwr# Override CPP defaults entirely, so cross-compilation works.
371.48SmycroftINCLUDES=	-I. -I$S/arch -I$S -nostdinc
381.47SmycroftXDEFS=		-undef -D__NetBSD__ -Dm68k -Dmc68000
391.49SmycroftCPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL \
401.49Smycroft		-Dmc68020 -Dsun3 ${XDEFS}
411.47SmycroftCWARNFLAGS= 	-Werror # -Wall -Wstrict-prototypes -Wmissing-prototypes
421.47SmycroftCFLAGS= 	${DEBUG} ${CWARNFLAGS} -O2 -msoft-float
431.47SmycroftAFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
441.38SmycroftLINKFLAGS=	-N -Ttext 0E004000 -e start
451.31Sgwr
461.47Smycroft### find out what to use for libkern
471.47Smycroft.include "$S/lib/libkern/Makefile.inc"
481.31Sgwr.ifndef PROF
491.47SmycroftLIBKERN=	${KERNLIB}
501.31Sgwr.else
511.47SmycroftLIBKERN=	${KERNLIB_PROF}
521.31Sgwr.endif
531.1Sglass
541.47Smycroft### find out what to use for libcompat
551.47Smycroft.include "$S/compat/common/Makefile.inc"
561.47Smycroft.ifndef PROF
571.47SmycroftLIBCOMPAT=	${COMPATLIB}
581.47Smycroft.else
591.47SmycroftLIBCOMPAT=	${COMPATLIB_PROF}
601.47Smycroft.endif
611.32Schristos
621.49Smycroft# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
631.49Smycroft# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
641.1Sglass
651.38SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
661.47SmycroftNORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
671.1Sglass
681.49SmycroftHOSTED_C=	${NORMAL_C:S/^-pg$//:S/^-p$//:S/^-nostdinc$//}
691.48Smycroft
701.1Sglass%OBJS
711.1Sglass
721.1Sglass%CFILES
731.1Sglass
741.38Smycroft%SFILES
751.38Smycroft
761.1Sglass# load lines for config "xxx" will be emitted as:
771.1Sglass# xxx: ${SYSTEM_DEP} swapxxx.o
781.1Sglass#	${SYSTEM_LD_HEAD}
791.1Sglass#	${SYSTEM_LD} swapxxx.o
801.1Sglass#	${SYSTEM_LD_TAIL}
811.38SmycroftSYSTEM_OBJ=	locore.o \
821.43Scgd		param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT}
831.38SmycroftSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
841.38SmycroftSYSTEM_LD_HEAD=	@rm -f $@
851.38SmycroftSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
861.38Smycroft		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
871.38SmycroftSYSTEM_LD_TAIL=	@size $@; chmod 755 $@
881.38Smycroft
891.38SmycroftDEBUG?=
901.11Sderaadt.if ${DEBUG} == "-g"
911.38SmycroftLINKFLAGS+=	-X
921.38SmycroftSYSTEM_LD_TAIL+=; \
931.38Smycroft		echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \
941.38Smycroft		echo ${STRIP} $@; ${STRIP} $@
951.11Sderaadt.else
961.41SgwrLINKFLAGS+=	-S
971.11Sderaadt.endif
981.1Sglass
991.1Sglass%LOAD
1001.1Sglass
1011.38Smycroftassym.h: genassym
1021.38Smycroft	./genassym >assym.h
1031.1Sglass
1041.38Smycroftgenassym: genassym.o
1051.38Smycroft	${CC} -o $@ genassym.o
1061.1Sglass
1071.38Smycroftgenassym.o: ${SUN3}/sun3/genassym.c
1081.49Smycroft	${HOSTED_C}
1091.1Sglass
1101.38Smycroftparam.c: $S/conf/param.c
1111.38Smycroft	rm -f param.c
1121.38Smycroft	cp $S/conf/param.c .
1131.17Sgwr
1141.38Smycroftparam.o: param.c Makefile
1151.49Smycroft	${NORMAL_C}
1161.21Sgwr
1171.38Smycroftioconf.o: ioconf.c
1181.38Smycroft	${NORMAL_C}
1191.1Sglass
1201.38Smycroftnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1211.38Smycroft	sh $S/conf/newvers.sh
1221.38Smycroft	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1231.38Smycroft
1241.38Smycroft
1251.38Smycroftclean::
1261.43Scgd	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1271.38Smycroft	    [Ee]rrs linterrs makelinks genassym genassym.o assym.h
1281.1Sglass
1291.38Smycroftlint:
1301.49Smycroft	@lint -hbxncez -DGENERIC -Dvolatile= ${CPPFLAGS} -UKGDB \
1311.38Smycroft	    ${SUN3}/sun3/Locore.c ${CFILES} ${SUN3}/sun3/swapgeneric.c \
1321.38Smycroft	    ioconf.c param.c | \
1331.38Smycroft	    grep -v 'static function .* unused'
1341.1Sglass
1351.38Smycrofttags:
1361.38Smycroft	@echo "see $S/kern/Makefile for tags"
1371.1Sglass
1381.1Sglasslinks:
1391.1Sglass	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1401.1Sglass	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1411.1Sglass	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1421.1Sglass	  sort -u | comm -23 - dontlink | \
1431.38Smycroft	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1441.1Sglass	sh makelinks && rm -f dontlink
1451.1Sglass
1461.38SmycroftSRCS=	${SUN3}/sun3/locore.s \
1471.43Scgd	param.c ioconf.c ${CFILES} ${SFILES}
1481.44Smycroftdepend:: .depend
1491.47Smycroft.depend: ${SRCS} assym.h param.c
1501.47Smycroft	${MKDEP} ${AFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1511.49Smycroft	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} ${SUN3}/sun3/genassym.c
1521.38Smycroft
1531.45Sgwr# XXX - see below
1541.45Sgwr#	${MKDEP} -a ${APPFLAGS} ${SUN3}/sun3/locore.s
1551.45Sgwr#	${MKDEP} -a ${APPFLAGS} ${SFILES}
1561.45Sgwr#
1571.45Sgwr# For cross-compilation, the "gcc -M" mkdep script is convenient,
1581.45Sgwr# but that does not correctly make rules from *.s files.  The
1591.45Sgwr# easiest compromise is to just list those dependencies here.
1601.45Sgwrlocore.o: assym.h machine/trap.h m68k/trap.h
1611.45Sgwrcopy.o:   assym.h $S/sys/errno.h
1621.1Sglass
1631.47Smycroft
1641.38Smycroft# depend on root or device configuration
1651.38Smycroftautoconf.o conf.o: Makefile
1661.38Smycroft 
1671.38Smycroft# depend on network or filesystem configuration 
1681.38Smycroftuipc_proto.o vfs_conf.o: Makefile 
1691.1Sglass
1701.38Smycroft# depend on maxusers
1711.38Smycroftgenassym.o machdep.o: Makefile
1721.1Sglass
1731.38Smycroft# depend on CPU configuration 
1741.38Smycroftdb_machdep.o dvma.o machdep.o pmap.o sun3_startup.o vm_machdep.o: Makefile
1751.1Sglass
1761.47Smycroft
1771.47Smycroftlocore.o: ${SUN3}/sun3/locore.s assym.h
1781.45Sgwr	${NORMAL_S}
1791.1Sglass
1801.1Sglass%RULES
181