Makefile.sun3 revision 1.83
11.83Sjdolecek# $NetBSD: Makefile.sun3,v 1.83 2000/12/07 17:51:06 jdolecek 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.66SthorpejAR?=	ar
291.53SgwrAS?=	as
301.42SmycroftCC?=	cc
311.53SgwrCPP?=	cpp
321.42SmycroftLD?=	ld
331.65SthorpejLORDER?=lorder
341.45SgwrMKDEP?=	mkdep
351.65SthorpejNM?=	nm
361.66SthorpejRANLIB?=ranlib
371.62SlukemSIZE?=	size
381.80StsutsuiSTRIP?=	strip
391.65SthorpejTSORT?=	tsort -q
401.66Sthorpej
411.58SgwrCOPTS?=	-O2 -fno-defer-pop
421.53Sgwr
431.1Sglass# source tree is located via $S relative to the compilation directory
441.50Smycroft.ifndef S
451.47SmycroftS!=	cd ../../../..; pwd
461.50Smycroft.endif
471.47SmycroftSUN3=	$S/arch/sun3
481.1Sglass
491.67Sgwr.if ${MACHTYPE} == "sun3x"
501.67SgwrTEXTADDR=F8004000
511.67Sgwr.else
521.67SgwrTEXTADDR=0E004000
531.67Sgwr.endif
541.67Sgwr
551.45Sgwr# Override CPP defaults entirely, so cross-compilation works.
561.53Sgwr# Keep -nostdinc before all -I flags, similar for -undef ...
571.81SthorpejHAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo 
581.53SgwrINCLUDES=	-nostdinc -I. -I$S/arch -I$S
591.47SmycroftXDEFS=		-undef -D__NetBSD__ -Dm68k -Dmc68000
601.74SthorpejDEFINES=	-D_KERNEL -Dsun3
611.53SgwrCPPFLAGS=	${INCLUDES} ${XDEFS} ${DEFINES} ${IDENT} ${PARAM}
621.53Sgwr# Make it easy to override this on the command line...
631.73SaugustssCWARNFLAGS?= 	-Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \
641.73Saugustss		-Wpointer-arith
651.81Sthorpej# XXX Delete -Wuninitialized for now, since the compiler doesn't
661.81Sthorpej# XXX always get it right.  --thorpej 
671.81SthorpejCWARNFLAGS+=	-Wno-uninitialized
681.81Sthorpej.if (${HAVE_EGCS} != "")
691.68StvCWARNFLAGS+=	-Wno-main
701.68Stv.endif
711.53SgwrCFLAGS= 	${DEBUG} ${COPTS} -msoft-float ${CWARNFLAGS}
721.53Sgwr# No, we may NOT assume that the compiler does -x whatever...
731.53SgwrAPPFLAGS=	-P -traditional ${CPPFLAGS} -D_LOCORE
741.67SgwrAFLAGS=
751.67SgwrLINKFLAGS=	-N -Ttext ${TEXTADDR} -e start
761.77StsutsuiSTRIPFLAGS=	-g
771.75Smrg
781.75Smrg%INCLUDES
791.51Smycroft
801.47Smycroft### find out what to use for libkern
811.71SdrochnerKERN_AS=	obj
821.47Smycroft.include "$S/lib/libkern/Makefile.inc"
831.31Sgwr.ifndef PROF
841.47SmycroftLIBKERN=	${KERNLIB}
851.31Sgwr.else
861.47SmycroftLIBKERN=	${KERNLIB_PROF}
871.31Sgwr.endif
881.1Sglass
891.47Smycroft### find out what to use for libcompat
901.47Smycroft.include "$S/compat/common/Makefile.inc"
911.47Smycroft.ifndef PROF
921.47SmycroftLIBCOMPAT=	${COMPATLIB}
931.47Smycroft.else
941.47SmycroftLIBCOMPAT=	${COMPATLIB_PROF}
951.47Smycroft.endif
961.32Schristos
971.57Sgwr# compile rules: rules are named NORMAL_${SUFFIX} where SUFFIX is
981.57Sgwr# the file suffix, capitalized (e.g. C for a .c file).
991.1Sglass
1001.38SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
1011.69SthorpejNOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
1021.1Sglass
1031.53Sgwr# Do NOT assume the compiler does "-x funny_format" (gcc-specific)
1041.53Sgwr# This needs an intermediate file.  The original file is always
1051.53Sgwr# safe in some far away directory, so just use the base name.
1061.53SgwrNORMAL_S=	${CPP} ${APPFLAGS} $< > $*.s ;\
1071.58Sgwr		${AS} ${AFLAGS} -o $@ $*.s ; rm $*.s
1081.53Sgwr
1091.53Sgwr# These comments help identify sections in the generated Makefile.
1101.53Sgwr# OBJS, CFILES, SFILES follow:
1111.48Smycroft
1121.1Sglass%OBJS
1131.1Sglass
1141.1Sglass%CFILES
1151.1Sglass
1161.38Smycroft%SFILES
1171.38Smycroft
1181.53Sgwr# OBJS, CFILES, SFILES done.
1191.53Sgwr
1201.1Sglass# load lines for config "xxx" will be emitted as:
1211.1Sglass# xxx: ${SYSTEM_DEP} swapxxx.o
1221.1Sglass#	${SYSTEM_LD_HEAD}
1231.1Sglass#	${SYSTEM_LD} swapxxx.o
1241.1Sglass#	${SYSTEM_LD_TAIL}
1251.38SmycroftSYSTEM_OBJ=	locore.o \
1261.71Sdrochner		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
1271.38SmycroftSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1281.38SmycroftSYSTEM_LD_HEAD=	@rm -f $@
1291.38SmycroftSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1301.38Smycroft		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1311.62SlukemSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1321.38Smycroft
1331.38SmycroftDEBUG?=
1341.11Sderaadt.if ${DEBUG} == "-g"
1351.38SmycroftLINKFLAGS+=	-X
1361.38SmycroftSYSTEM_LD_TAIL+=; \
1371.76Scgd		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
1381.80Stsutsui		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
1391.80Stsutsui		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1401.11Sderaadt.else
1411.41SgwrLINKFLAGS+=	-S
1421.11Sderaadt.endif
1431.1Sglass
1441.53Sgwr# LOAD+
1451.53Sgwr
1461.1Sglass%LOAD
1471.1Sglass
1481.53Sgwr# LOAD-
1491.53Sgwr
1501.83Sjdolecekassym.h: $S/kern/genassym.sh ${SUN3}/${MACHTYPE}/genassym.cf
1511.83Sjdolecek	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1521.83Sjdolecek	    < ${SUN3}/${MACHTYPE}/genassym.cf > assym.h.tmp && \
1531.83Sjdolecek	mv -f assym.h.tmp assym.h
1541.1Sglass
1551.38Smycroftparam.c: $S/conf/param.c
1561.38Smycroft	rm -f param.c
1571.38Smycroft	cp $S/conf/param.c .
1581.17Sgwr
1591.38Smycroftparam.o: param.c Makefile
1601.49Smycroft	${NORMAL_C}
1611.21Sgwr
1621.38Smycroftioconf.o: ioconf.c
1631.38Smycroft	${NORMAL_C}
1641.1Sglass
1651.38Smycroftnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1661.38Smycroft	sh $S/conf/newvers.sh
1671.38Smycroft	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1681.38Smycroft
1691.61Schristos__CLEANKERNEL: .USE
1701.61Schristos	@echo "${.TARGET}ing the kernel objects"
1711.61Schristos	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1721.61Schristos	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1731.61Schristos
1741.61Schristos__CLEANDEPEND: .USE
1751.61Schristos	rm -f .depend
1761.38Smycroft
1771.61Schristosclean: __CLEANKERNEL
1781.61Schristos
1791.70Slukemcleandir distclean: __CLEANKERNEL __CLEANDEPEND
1801.1Sglass
1811.38Smycroftlint:
1821.54Sperry	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
1831.60Smycroft	    ${CFILES} ioconf.c param.c | \
1841.38Smycroft	    grep -v 'static function .* unused'
1851.1Sglass
1861.38Smycrofttags:
1871.38Smycroft	@echo "see $S/kern/Makefile for tags"
1881.1Sglass
1891.1Sglasslinks:
1901.1Sglass	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1911.1Sglass	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1921.1Sglass	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1931.1Sglass	  sort -u | comm -23 - dontlink | \
1941.38Smycroft	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1951.1Sglass	sh makelinks && rm -f dontlink
1961.1Sglass
1971.67SgwrSRCS=	${SUN3}/${MACHTYPE}/locore.s \
1981.43Scgd	param.c ioconf.c ${CFILES} ${SFILES}
1991.53Sgwr
2001.56Sgwrdepend: .depend
2011.47Smycroft.depend: ${SRCS} assym.h param.c
2021.53Sgwr	${MKDEP} ${CPPFLAGS} param.c ioconf.c ${CFILES}
2031.83Sjdolecek	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
2041.83Sjdolecek	  ${CPPFLAGS} < ${SUN3}/${MACHTYPE}/genassym.cf
2051.83Sjdolecek	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
2061.83Sjdolecek	@rm -f assym.dep
2071.79Stron
2081.79Strondependall: depend all
2091.79Stron
2101.38Smycroft
2111.45Sgwr# XXX - see below
2121.67Sgwr#	${MKDEP} -a ${APPFLAGS} ${SUN3}/${MACHTYPE}/locore.s
2131.45Sgwr#	${MKDEP} -a ${APPFLAGS} ${SFILES}
2141.45Sgwr#
2151.45Sgwr# For cross-compilation, the "gcc -M" mkdep script is convenient,
2161.45Sgwr# but that does not correctly make rules from *.s files.  The
2171.59Sgwr# easiest work-around is to just list those dependencies here.
2181.59Sgwrlocore.o:   assym.h m68k/asm.h m68k/trap.h
2191.59Sgwrcopy.o:     assym.h m68k/asm.h $S/sys/errno.h
2201.59Sgwrbcopy.o:    assym.h m68k/asm.h
2211.59Sgwrcopypage.o: assym.h m68k/asm.h
2221.1Sglass
2231.38Smycroft# depend on root or device configuration
2241.59Sgwrconf.o: Makefile
2251.38Smycroft 
2261.38Smycroft# depend on network or filesystem configuration 
2271.38Smycroftuipc_proto.o vfs_conf.o: Makefile 
2281.1Sglass
2291.38Smycroft# depend on maxusers
2301.59Sgwrmachdep.o: Makefile
2311.1Sglass
2321.38Smycroft# depend on CPU configuration 
2331.38Smycroftdb_machdep.o dvma.o machdep.o pmap.o sun3_startup.o vm_machdep.o: Makefile
2341.58Sgwr
2351.58Sgwr# depends on KGDBDEV, KGDBRATE
2361.58Sgwrkgdb_stub.o: Makefile
2371.64Sgwr
2381.64Sgwr# depends on DDB, etc.
2391.64Sgwrstub.o: Makefile
2401.1Sglass
2411.67Sgwrlocore.o: ${SUN3}/${MACHTYPE}/locore.s
2421.53Sgwr	${NORMAL_S}
2431.47Smycroft
2441.53Sgwr# Generated rules follow:
2451.82Shubertf
2461.82Shubertf# The install target can be redefined by putting a
2471.82Shubertf# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
2481.82ShubertfMACHINE_NAME!=  uname -n
2491.82Shubertfinstall: install-kernel-${MACHINE_NAME}
2501.82Shubertf.if !target(install-kernel-${MACHINE_NAME}})
2511.82Shubertfinstall-kernel-${MACHINE_NAME}:
2521.82Shubertf	rm -f /onetbsd
2531.82Shubertf	ln /netbsd /onetbsd
2541.82Shubertf	cp netbsd /nnetbsd
2551.82Shubertf	mv /nnetbsd /netbsd
2561.82Shubertf.endif
2571.1Sglass
2581.1Sglass%RULES
259