Makefile.sun3 revision 1.88
11.88Sthorpej# $NetBSD: Makefile.sun3,v 1.88 2001/10/23 19:26:47 thorpej 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.88SthorpejMACHINE_ARCH=m68k
161.88Sthorpej
171.38Smycroft# DEBUG is set to -g if debugging.
181.38Smycroft# PROF is set to -pg if profiling.
191.53Sgwr
201.66SthorpejAR?=	ar
211.53SgwrAS?=	as
221.42SmycroftCC?=	cc
231.53SgwrCPP?=	cpp
241.42SmycroftLD?=	ld
251.65SthorpejLORDER?=lorder
261.45SgwrMKDEP?=	mkdep
271.65SthorpejNM?=	nm
281.66SthorpejRANLIB?=ranlib
291.62SlukemSIZE?=	size
301.80StsutsuiSTRIP?=	strip
311.65SthorpejTSORT?=	tsort -q
321.66Sthorpej
331.58SgwrCOPTS?=	-O2 -fno-defer-pop
341.53Sgwr
351.1Sglass# source tree is located via $S relative to the compilation directory
361.50Smycroft.ifndef S
371.47SmycroftS!=	cd ../../../..; pwd
381.50Smycroft.endif
391.47SmycroftSUN3=	$S/arch/sun3
401.1Sglass
411.67Sgwr.if ${MACHTYPE} == "sun3x"
421.67SgwrTEXTADDR=F8004000
431.67Sgwr.else
441.67SgwrTEXTADDR=0E004000
451.67Sgwr.endif
461.67Sgwr
471.45Sgwr# Override CPP defaults entirely, so cross-compilation works.
481.53Sgwr# Keep -nostdinc before all -I flags, similar for -undef ...
491.81SthorpejHAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo 
501.53SgwrINCLUDES=	-nostdinc -I. -I$S/arch -I$S
511.86SchsXDEFS=		-undef -D__NetBSD__ -Dm68k -Dmc68000 -D__m68k__ -D__ELF__
521.87SmrgDEFINES=	-D_KERNEL -D_KERNEL_OPT -Dsun3
531.53SgwrCPPFLAGS=	${INCLUDES} ${XDEFS} ${DEFINES} ${IDENT} ${PARAM}
541.53Sgwr# Make it easy to override this on the command line...
551.73SaugustssCWARNFLAGS?= 	-Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \
561.73Saugustss		-Wpointer-arith
571.81Sthorpej# XXX Delete -Wuninitialized for now, since the compiler doesn't
581.81Sthorpej# XXX always get it right.  --thorpej 
591.81SthorpejCWARNFLAGS+=	-Wno-uninitialized
601.81Sthorpej.if (${HAVE_EGCS} != "")
611.68StvCWARNFLAGS+=	-Wno-main
621.68Stv.endif
631.53SgwrCFLAGS= 	${DEBUG} ${COPTS} -msoft-float ${CWARNFLAGS}
641.86SchsAFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
651.67SgwrLINKFLAGS=	-N -Ttext ${TEXTADDR} -e start
661.77StsutsuiSTRIPFLAGS=	-g
671.75Smrg
681.75Smrg%INCLUDES
691.51Smycroft
701.47Smycroft### find out what to use for libkern
711.71SdrochnerKERN_AS=	obj
721.47Smycroft.include "$S/lib/libkern/Makefile.inc"
731.31Sgwr.ifndef PROF
741.47SmycroftLIBKERN=	${KERNLIB}
751.31Sgwr.else
761.47SmycroftLIBKERN=	${KERNLIB_PROF}
771.31Sgwr.endif
781.1Sglass
791.47Smycroft### find out what to use for libcompat
801.47Smycroft.include "$S/compat/common/Makefile.inc"
811.47Smycroft.ifndef PROF
821.47SmycroftLIBCOMPAT=	${COMPATLIB}
831.47Smycroft.else
841.47SmycroftLIBCOMPAT=	${COMPATLIB_PROF}
851.47Smycroft.endif
861.32Schristos
871.57Sgwr# compile rules: rules are named NORMAL_${SUFFIX} where SUFFIX is
881.57Sgwr# the file suffix, capitalized (e.g. C for a .c file).
891.1Sglass
901.38SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
911.69SthorpejNOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
921.86SchsNORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
931.53Sgwr
941.53Sgwr# These comments help identify sections in the generated Makefile.
951.53Sgwr# OBJS, CFILES, SFILES follow:
961.48Smycroft
971.1Sglass%OBJS
981.1Sglass
991.1Sglass%CFILES
1001.1Sglass
1011.38Smycroft%SFILES
1021.38Smycroft
1031.53Sgwr# OBJS, CFILES, SFILES done.
1041.53Sgwr
1051.1Sglass# load lines for config "xxx" will be emitted as:
1061.1Sglass# xxx: ${SYSTEM_DEP} swapxxx.o
1071.1Sglass#	${SYSTEM_LD_HEAD}
1081.1Sglass#	${SYSTEM_LD} swapxxx.o
1091.1Sglass#	${SYSTEM_LD_TAIL}
1101.38SmycroftSYSTEM_OBJ=	locore.o \
1111.71Sdrochner		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
1121.38SmycroftSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1131.38SmycroftSYSTEM_LD_HEAD=	@rm -f $@
1141.38SmycroftSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1151.38Smycroft		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1161.62SlukemSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1171.38Smycroft
1181.38SmycroftDEBUG?=
1191.11Sderaadt.if ${DEBUG} == "-g"
1201.38SmycroftLINKFLAGS+=	-X
1211.38SmycroftSYSTEM_LD_TAIL+=; \
1221.76Scgd		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
1231.80Stsutsui		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
1241.80Stsutsui		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1251.11Sderaadt.else
1261.41SgwrLINKFLAGS+=	-S
1271.11Sderaadt.endif
1281.1Sglass
1291.53Sgwr# LOAD+
1301.53Sgwr
1311.1Sglass%LOAD
1321.1Sglass
1331.53Sgwr# LOAD-
1341.53Sgwr
1351.83Sjdolecekassym.h: $S/kern/genassym.sh ${SUN3}/${MACHTYPE}/genassym.cf
1361.83Sjdolecek	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1371.83Sjdolecek	    < ${SUN3}/${MACHTYPE}/genassym.cf > assym.h.tmp && \
1381.83Sjdolecek	mv -f assym.h.tmp assym.h
1391.1Sglass
1401.38Smycroftparam.c: $S/conf/param.c
1411.38Smycroft	rm -f param.c
1421.38Smycroft	cp $S/conf/param.c .
1431.17Sgwr
1441.38Smycroftparam.o: param.c Makefile
1451.49Smycroft	${NORMAL_C}
1461.21Sgwr
1471.38Smycroftioconf.o: ioconf.c
1481.38Smycroft	${NORMAL_C}
1491.1Sglass
1501.38Smycroftnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1511.38Smycroft	sh $S/conf/newvers.sh
1521.38Smycroft	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1531.38Smycroft
1541.61Schristos__CLEANKERNEL: .USE
1551.61Schristos	@echo "${.TARGET}ing the kernel objects"
1561.61Schristos	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1571.61Schristos	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1581.61Schristos
1591.61Schristos__CLEANDEPEND: .USE
1601.61Schristos	rm -f .depend
1611.38Smycroft
1621.61Schristosclean: __CLEANKERNEL
1631.61Schristos
1641.70Slukemcleandir distclean: __CLEANKERNEL __CLEANDEPEND
1651.1Sglass
1661.38Smycroftlint:
1671.54Sperry	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
1681.60Smycroft	    ${CFILES} ioconf.c param.c | \
1691.38Smycroft	    grep -v 'static function .* unused'
1701.1Sglass
1711.38Smycrofttags:
1721.38Smycroft	@echo "see $S/kern/Makefile for tags"
1731.1Sglass
1741.1Sglasslinks:
1751.1Sglass	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
1761.1Sglass	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
1771.1Sglass	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
1781.1Sglass	  sort -u | comm -23 - dontlink | \
1791.38Smycroft	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
1801.1Sglass	sh makelinks && rm -f dontlink
1811.1Sglass
1821.67SgwrSRCS=	${SUN3}/${MACHTYPE}/locore.s \
1831.43Scgd	param.c ioconf.c ${CFILES} ${SFILES}
1841.53Sgwr
1851.56Sgwrdepend: .depend
1861.47Smycroft.depend: ${SRCS} assym.h param.c
1871.53Sgwr	${MKDEP} ${CPPFLAGS} param.c ioconf.c ${CFILES}
1881.83Sjdolecek	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
1891.83Sjdolecek	  ${CPPFLAGS} < ${SUN3}/${MACHTYPE}/genassym.cf
1901.83Sjdolecek	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
1911.83Sjdolecek	@rm -f assym.dep
1921.79Stron
1931.79Strondependall: depend all
1941.79Stron
1951.38Smycroft
1961.45Sgwr# XXX - see below
1971.67Sgwr#	${MKDEP} -a ${APPFLAGS} ${SUN3}/${MACHTYPE}/locore.s
1981.45Sgwr#	${MKDEP} -a ${APPFLAGS} ${SFILES}
1991.45Sgwr#
2001.45Sgwr# For cross-compilation, the "gcc -M" mkdep script is convenient,
2011.45Sgwr# but that does not correctly make rules from *.s files.  The
2021.59Sgwr# easiest work-around is to just list those dependencies here.
2031.59Sgwrlocore.o:   assym.h m68k/asm.h m68k/trap.h
2041.59Sgwrcopy.o:     assym.h m68k/asm.h $S/sys/errno.h
2051.59Sgwrbcopy.o:    assym.h m68k/asm.h
2061.59Sgwrcopypage.o: assym.h m68k/asm.h
2071.1Sglass
2081.38Smycroft# depend on root or device configuration
2091.59Sgwrconf.o: Makefile
2101.38Smycroft 
2111.38Smycroft# depend on network or filesystem configuration 
2121.38Smycroftuipc_proto.o vfs_conf.o: Makefile 
2131.1Sglass
2141.38Smycroft# depend on maxusers
2151.59Sgwrmachdep.o: Makefile
2161.1Sglass
2171.38Smycroft# depend on CPU configuration 
2181.38Smycroftdb_machdep.o dvma.o machdep.o pmap.o sun3_startup.o vm_machdep.o: Makefile
2191.58Sgwr
2201.58Sgwr# depends on KGDBDEV, KGDBRATE
2211.58Sgwrkgdb_stub.o: Makefile
2221.64Sgwr
2231.64Sgwr# depends on DDB, etc.
2241.64Sgwrstub.o: Makefile
2251.1Sglass
2261.67Sgwrlocore.o: ${SUN3}/${MACHTYPE}/locore.s
2271.53Sgwr	${NORMAL_S}
2281.47Smycroft
2291.53Sgwr# Generated rules follow:
2301.82Shubertf
2311.82Shubertf# The install target can be redefined by putting a
2321.82Shubertf# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
2331.82ShubertfMACHINE_NAME!=  uname -n
2341.82Shubertfinstall: install-kernel-${MACHINE_NAME}
2351.82Shubertf.if !target(install-kernel-${MACHINE_NAME}})
2361.82Shubertfinstall-kernel-${MACHINE_NAME}:
2371.82Shubertf	rm -f /onetbsd
2381.82Shubertf	ln /netbsd /onetbsd
2391.82Shubertf	cp netbsd /nnetbsd
2401.82Shubertf	mv /nnetbsd /netbsd
2411.82Shubertf.endif
2421.1Sglass
2431.1Sglass%RULES
244