Makefile.sun3 revision 1.86
11.86Schs# $NetBSD: Makefile.sun3,v 1.86 2001/02/22 07:11:08 chs 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.38Smycroft# DEBUG is set to -g if debugging.
161.38Smycroft# PROF is set to -pg if profiling.
171.38Smycroft
181.53Sgwr# XXX - Make cross-build work...
191.53SgwrMACHINE_ARCH=m68k
201.53SgwrMACHINE=sun3
211.53Sgwr
221.66SthorpejAR?=	ar
231.53SgwrAS?=	as
241.42SmycroftCC?=	cc
251.53SgwrCPP?=	cpp
261.42SmycroftLD?=	ld
271.65SthorpejLORDER?=lorder
281.45SgwrMKDEP?=	mkdep
291.65SthorpejNM?=	nm
301.66SthorpejRANLIB?=ranlib
311.62SlukemSIZE?=	size
321.80StsutsuiSTRIP?=	strip
331.65SthorpejTSORT?=	tsort -q
341.66Sthorpej
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.67Sgwr.if ${MACHTYPE} == "sun3x"
441.67SgwrTEXTADDR=F8004000
451.67Sgwr.else
461.67SgwrTEXTADDR=0E004000
471.67Sgwr.endif
481.67Sgwr
491.45Sgwr# Override CPP defaults entirely, so cross-compilation works.
501.53Sgwr# Keep -nostdinc before all -I flags, similar for -undef ...
511.81SthorpejHAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo 
521.53SgwrINCLUDES=	-nostdinc -I. -I$S/arch -I$S
531.86SchsXDEFS=		-undef -D__NetBSD__ -Dm68k -Dmc68000 -D__m68k__ -D__ELF__
541.74SthorpejDEFINES=	-D_KERNEL -Dsun3
551.53SgwrCPPFLAGS=	${INCLUDES} ${XDEFS} ${DEFINES} ${IDENT} ${PARAM}
561.53Sgwr# Make it easy to override this on the command line...
571.73SaugustssCWARNFLAGS?= 	-Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \
581.73Saugustss		-Wpointer-arith
591.81Sthorpej# XXX Delete -Wuninitialized for now, since the compiler doesn't
601.81Sthorpej# XXX always get it right.  --thorpej 
611.81SthorpejCWARNFLAGS+=	-Wno-uninitialized
621.81Sthorpej.if (${HAVE_EGCS} != "")
631.68StvCWARNFLAGS+=	-Wno-main
641.68Stv.endif
651.53SgwrCFLAGS= 	${DEBUG} ${COPTS} -msoft-float ${CWARNFLAGS}
661.86SchsAFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
671.67SgwrLINKFLAGS=	-N -Ttext ${TEXTADDR} -e start
681.77StsutsuiSTRIPFLAGS=	-g
691.75Smrg
701.75Smrg%INCLUDES
711.51Smycroft
721.47Smycroft### find out what to use for libkern
731.71SdrochnerKERN_AS=	obj
741.47Smycroft.include "$S/lib/libkern/Makefile.inc"
751.31Sgwr.ifndef PROF
761.47SmycroftLIBKERN=	${KERNLIB}
771.31Sgwr.else
781.47SmycroftLIBKERN=	${KERNLIB_PROF}
791.31Sgwr.endif
801.1Sglass
811.47Smycroft### find out what to use for libcompat
821.47Smycroft.include "$S/compat/common/Makefile.inc"
831.47Smycroft.ifndef PROF
841.47SmycroftLIBCOMPAT=	${COMPATLIB}
851.47Smycroft.else
861.47SmycroftLIBCOMPAT=	${COMPATLIB_PROF}
871.47Smycroft.endif
881.32Schristos
891.57Sgwr# compile rules: rules are named NORMAL_${SUFFIX} where SUFFIX is
901.57Sgwr# the file suffix, capitalized (e.g. C for a .c file).
911.1Sglass
921.38SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
931.69SthorpejNOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
941.86SchsNORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
951.53Sgwr
961.53Sgwr# These comments help identify sections in the generated Makefile.
971.53Sgwr# OBJS, CFILES, SFILES follow:
981.48Smycroft
991.1Sglass%OBJS
1001.1Sglass
1011.1Sglass%CFILES
1021.1Sglass
1031.38Smycroft%SFILES
1041.38Smycroft
1051.53Sgwr# OBJS, CFILES, SFILES done.
1061.53Sgwr
1071.1Sglass# load lines for config "xxx" will be emitted as:
1081.1Sglass# xxx: ${SYSTEM_DEP} swapxxx.o
1091.1Sglass#	${SYSTEM_LD_HEAD}
1101.1Sglass#	${SYSTEM_LD} swapxxx.o
1111.1Sglass#	${SYSTEM_LD_TAIL}
1121.38SmycroftSYSTEM_OBJ=	locore.o \
1131.71Sdrochner		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
1141.38SmycroftSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1151.38SmycroftSYSTEM_LD_HEAD=	@rm -f $@
1161.38SmycroftSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1171.38Smycroft		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1181.62SlukemSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1191.38Smycroft
1201.38SmycroftDEBUG?=
1211.11Sderaadt.if ${DEBUG} == "-g"
1221.38SmycroftLINKFLAGS+=	-X
1231.38SmycroftSYSTEM_LD_TAIL+=; \
1241.76Scgd		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
1251.80Stsutsui		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
1261.80Stsutsui		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1271.11Sderaadt.else
1281.41SgwrLINKFLAGS+=	-S
1291.11Sderaadt.endif
1301.1Sglass
1311.53Sgwr# LOAD+
1321.53Sgwr
1331.1Sglass%LOAD
1341.1Sglass
1351.53Sgwr# LOAD-
1361.53Sgwr
1371.83Sjdolecekassym.h: $S/kern/genassym.sh ${SUN3}/${MACHTYPE}/genassym.cf
1381.83Sjdolecek	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1391.83Sjdolecek	    < ${SUN3}/${MACHTYPE}/genassym.cf > assym.h.tmp && \
1401.83Sjdolecek	mv -f assym.h.tmp assym.h
1411.1Sglass
1421.38Smycroftparam.c: $S/conf/param.c
1431.38Smycroft	rm -f param.c
1441.38Smycroft	cp $S/conf/param.c .
1451.17Sgwr
1461.38Smycroftparam.o: param.c Makefile
1471.49Smycroft	${NORMAL_C}
1481.21Sgwr
1491.38Smycroftioconf.o: ioconf.c
1501.38Smycroft	${NORMAL_C}
1511.1Sglass
1521.38Smycroftnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1531.38Smycroft	sh $S/conf/newvers.sh
1541.38Smycroft	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1551.38Smycroft
1561.61Schristos__CLEANKERNEL: .USE
1571.61Schristos	@echo "${.TARGET}ing the kernel objects"
1581.61Schristos	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1591.61Schristos	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1601.61Schristos
1611.61Schristos__CLEANDEPEND: .USE
1621.61Schristos	rm -f .depend
1631.38Smycroft
1641.61Schristosclean: __CLEANKERNEL
1651.61Schristos
1661.70Slukemcleandir distclean: __CLEANKERNEL __CLEANDEPEND
1671.1Sglass
1681.38Smycroftlint:
1691.54Sperry	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
1701.60Smycroft	    ${CFILES} ioconf.c param.c | \
1711.38Smycroft	    grep -v 'static function .* unused'
1721.1Sglass
1731.38Smycrofttags:
1741.38Smycroft	@echo "see $S/kern/Makefile for tags"
1751.1Sglass
1761.1Sglasslinks:
1771.1Sglass	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1781.1Sglass	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1791.1Sglass	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1801.1Sglass	  sort -u | comm -23 - dontlink | \
1811.38Smycroft	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1821.1Sglass	sh makelinks && rm -f dontlink
1831.1Sglass
1841.67SgwrSRCS=	${SUN3}/${MACHTYPE}/locore.s \
1851.43Scgd	param.c ioconf.c ${CFILES} ${SFILES}
1861.53Sgwr
1871.56Sgwrdepend: .depend
1881.47Smycroft.depend: ${SRCS} assym.h param.c
1891.53Sgwr	${MKDEP} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1901.83Sjdolecek	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
1911.83Sjdolecek	  ${CPPFLAGS} < ${SUN3}/${MACHTYPE}/genassym.cf
1921.83Sjdolecek	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
1931.83Sjdolecek	@rm -f assym.dep
1941.79Stron
1951.79Strondependall: depend all
1961.79Stron
1971.38Smycroft
1981.45Sgwr# XXX - see below
1991.67Sgwr#	${MKDEP} -a ${APPFLAGS} ${SUN3}/${MACHTYPE}/locore.s
2001.45Sgwr#	${MKDEP} -a ${APPFLAGS} ${SFILES}
2011.45Sgwr#
2021.45Sgwr# For cross-compilation, the "gcc -M" mkdep script is convenient,
2031.45Sgwr# but that does not correctly make rules from *.s files.  The
2041.59Sgwr# easiest work-around is to just list those dependencies here.
2051.59Sgwrlocore.o:   assym.h m68k/asm.h m68k/trap.h
2061.59Sgwrcopy.o:     assym.h m68k/asm.h $S/sys/errno.h
2071.59Sgwrbcopy.o:    assym.h m68k/asm.h
2081.59Sgwrcopypage.o: assym.h m68k/asm.h
2091.1Sglass
2101.38Smycroft# depend on root or device configuration
2111.59Sgwrconf.o: Makefile
2121.38Smycroft 
2131.38Smycroft# depend on network or filesystem configuration 
2141.38Smycroftuipc_proto.o vfs_conf.o: Makefile 
2151.1Sglass
2161.38Smycroft# depend on maxusers
2171.59Sgwrmachdep.o: Makefile
2181.1Sglass
2191.38Smycroft# depend on CPU configuration 
2201.38Smycroftdb_machdep.o dvma.o machdep.o pmap.o sun3_startup.o vm_machdep.o: Makefile
2211.58Sgwr
2221.58Sgwr# depends on KGDBDEV, KGDBRATE
2231.58Sgwrkgdb_stub.o: Makefile
2241.64Sgwr
2251.64Sgwr# depends on DDB, etc.
2261.64Sgwrstub.o: Makefile
2271.1Sglass
2281.67Sgwrlocore.o: ${SUN3}/${MACHTYPE}/locore.s
2291.53Sgwr	${NORMAL_S}
2301.47Smycroft
2311.53Sgwr# Generated rules follow:
2321.82Shubertf
2331.82Shubertf# The install target can be redefined by putting a
2341.82Shubertf# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
2351.82ShubertfMACHINE_NAME!=  uname -n
2361.82Shubertfinstall: install-kernel-${MACHINE_NAME}
2371.82Shubertf.if !target(install-kernel-${MACHINE_NAME}})
2381.82Shubertfinstall-kernel-${MACHINE_NAME}:
2391.82Shubertf	rm -f /onetbsd
2401.82Shubertf	ln /netbsd /onetbsd
2411.82Shubertf	cp netbsd /nnetbsd
2421.82Shubertf	mv /nnetbsd /netbsd
2431.82Shubertf.endif
2441.1Sglass
2451.1Sglass%RULES
246