Makefile.sparc64 revision 1.37
11.37Smrg# 	$NetBSD: Makefile.sparc64,v 1.37 2001/05/29 02:20:26 mrg Exp $
21.1Seeh
31.1Seeh# Makefile for NetBSD
41.1Seeh#
51.1Seeh# This makefile is constructed from a machine description:
61.1Seeh#	config machineid
71.1Seeh# Most changes should be made in the machine description
81.1Seeh#	/sys/arch/sparc64/conf/``machineid''
91.1Seeh# after which you should do
101.1Seeh#	config machineid
111.1Seeh# Machine generic makefile changes should be made in
121.1Seeh#	/sys/arch/sparc64/conf/Makefile.sparc64
131.1Seeh# after which config should be rerun for all machines of that type.
141.1Seeh
151.1Seeh# DEBUG is set to -g if debugging.
161.1Seeh# PROF is set to -pg if profiling.
171.1Seeh
181.22Seeh.if defined(MAKECONF) && exists(${MAKECONF})
191.22Seeh.include "${MAKECONF}"
201.22Seeh.elif exists(/etc/mk.conf)
211.5Seeh.include "/etc/mk.conf"
221.22Seeh.endif
231.5Seeh
241.1SeehCC?=	cc
251.9Smrg.if exists(/usr/ccs/bin/ld)
261.1SeehLD?=	/usr/ccs/bin/ld #Need to use Solaris ld to use the solaris loader
271.9Smrg.endif
281.1SeehMKDEP?=	mkdep
291.18SeehSTRIP?=strip
301.2SmrgSIZE?=	size
311.1SeehCOPTS?= 	-O2
321.5Seeh#### Stuff for cross compiling
331.5SeehNM?=nm
341.5SeehLORDER?=lorder
351.5SeehTSORT?=tsort
361.5Seeh
371.1Seeh
381.4Smrg# deal with Solaris vs. NetBSD build environments for now ..
391.4SmrgOS!=uname -s
401.4Smrg.if (${OS} == "NetBSD")
411.4SmrgUSE_GENASSYM?=	no
421.4Smrg.else
431.11SeehUSE_GENASSYM?=	no
441.11SeehAWK=nawk
451.9Smrg.endif
461.9Smrg
471.9Smrg.if exists(/usr/ccs/bin/ld)
481.4SmrgSVR4=-U__SVR4 -U__svr4__ -D__NetBSD__
491.9Smrg.else
501.9SmrgSVR4=
511.4Smrg.endif
521.4Smrg
531.1Seeh# source tree is located via $S relative to the compilation directory
541.1Seeh.ifndef S
551.1SeehS!=	cd ../../../..; pwd
561.1Seeh.endif
571.1SeehSPARC64=	$S/arch/sparc64
581.1Seeh
591.1SeehINCLUDES=	-I. -I$S/arch -I$S -nostdinc
601.37SmrgCPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT -Dsparc64 ${SVR4}
611.32Sfvdl#CWARNFLAGS=	-Wimplicit -Wunused -Wswitch -Wcomment -Wtrigraphs -Wchar-subscripts -Wparentheses -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-main -Werror
621.1Seeh#CWARNFLAGS=	-Werror -Wall -Wstrict-prototypes -Wmissing-prototypes
631.32SfvdlCWARNFLAGS=	-Werror -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-main
641.32SfvdlCWARNFLAGS+=	-Wno-uninitialized
651.27SmycroftCFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS} -Wa,-Av9a -mno-fpu
661.30Seeh.if defined(PROF)
671.30Seeh# We need to run the compiler in medlow memory model.
681.30SeehCFLAGS += -mcmodel=medlow
691.30Seeh.endif
701.27SmycroftAFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE -Wa,-Av9a
711.31Seeh
721.31Seeh#
731.31Seeh# Gotta find a way to make kernel base tuneable.
741.31Seeh#
751.31Seeh
761.31SeehLINKFLAGS=	-Ttext 01000000 -Tdata 01400000 -e start
771.34Smrg#LINKFLAGS=	-Ttext f1000000 -Tdata f1400000 -e start
781.34Smrg
791.34SmrgLINKFLAGS+=	-n -T ${SPARC64}/conf/${KERN_LDSCRIPT}
801.35Smrg.if ${MACHINE_ARCH} == "sparc64"
811.34SmrgKERN_LDSCRIPT?= kern.ldscript
821.35Smrg.else
831.35SmrgKERN_LDSCRIPT?= kern32.ldscript
841.35Smrg.endif
851.31Seeh
861.15StsutsuiSTRIPFLAGS=	-g
871.10Smrg
881.10Smrg%INCLUDES
891.1Seeh
901.1Seeh### find out what to use for libkern
911.14Seeh# KERN_AS=	obj	# bcopy, bzero, memcpy, memset, etc. are in locore.s
921.1Seeh.include "$S/lib/libkern/Makefile.inc"
931.1Seeh.ifndef PROF
941.1SeehLIBKERN=	${KERNLIB}
951.1Seeh.else
961.1SeehLIBKERN=	${KERNLIB_PROF}
971.1Seeh.endif
981.1Seeh
991.1Seeh### find out what to use for libcompat
1001.1Seeh.include "$S/compat/common/Makefile.inc"
1011.1Seeh.ifndef PROF
1021.1SeehLIBCOMPAT=	${COMPATLIB}
1031.1Seeh.else
1041.1SeehLIBCOMPAT=	${COMPATLIB_PROF}
1051.1Seeh.endif
1061.1Seeh
1071.1Seeh# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
1081.1Seeh# HOSTED, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
1091.1Seeh
1101.27SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
1111.27SmycroftNOOPT_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -O0 -c $<
1121.1SeehNORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
1131.1Seeh
1141.1Seeh%OBJS
1151.1Seeh
1161.1Seeh%CFILES
1171.1Seeh
1181.1Seeh%SFILES
1191.1Seeh
1201.1Seeh# load lines for config "xxx" will be emitted as:
1211.1Seeh# xxx: ${SYSTEM_DEP} swapxxx.o
1221.1Seeh#	${SYSTEM_LD_HEAD}
1231.1Seeh#	${SYSTEM_LD} swapxxx.o
1241.1Seeh#	${SYSTEM_LD_TAIL}
1251.1SeehSYSTEM_OBJ=	locore.o \
1261.6Sdrochner		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
1271.1SeehSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1281.27SmycroftSYSTEM_LD_HEAD=	rm -f $@
1291.1SeehSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1301.1Seeh		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1311.2SmrgSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1321.1Seeh
1331.1SeehDEBUG?=
1341.1Seeh.if ${DEBUG} == "-g"
1351.1SeehLINKFLAGS+=	-X
1361.1SeehSYSTEM_LD_TAIL+=; \
1371.12Scgd		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
1381.19Seeh		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
1391.19Seeh		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1401.1Seeh.else
1411.1SeehLINKFLAGS+=	-S
1421.1Seeh.endif
1431.1Seeh
1441.1Seeh%LOAD
1451.2Smrg
1461.2Smrg.if ${USE_GENASSYM} == "no"
1471.1Seehassym.h: $S/kern/genassym.sh ${SPARC64}/sparc64/genassym.cf
1481.27Smycroft	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1491.1Seeh	    < ${SPARC64}/sparc64/genassym.cf > assym.h.tmp && \
1501.1Seeh	mv -f assym.h.tmp assym.h
1511.1Seeh.else
1521.1SeehHOSTED_CC=	${CC}
1531.1SeehHOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
1541.27SmycroftHOSTED_CFLAGS=	${CFLAGS}
1551.1Seeh
1561.1SeehHOSTED_C=	${HOSTED_CC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
1571.1Seeh
1581.1Seehassym.h: genassym
1591.1Seeh	./genassym >assym.h
1601.1Seeh
1611.1Seehgenassym: genassym.o
1621.1Seeh	${CC} -o $@ genassym.o
1631.1Seeh
1641.1Seehgenassym.o: ${SPARC64}/sparc64/genassym.c
1651.1Seeh	${HOSTED_C}
1661.1Seeh.endif
1671.1Seeh
1681.1Seehparam.c: $S/conf/param.c
1691.1Seeh	rm -f param.c
1701.1Seeh	cp $S/conf/param.c .
1711.1Seeh
1721.1Seehparam.o: param.c Makefile
1731.1Seeh	${NORMAL_C}
1741.1Seeh
1751.1Seehioconf.o: ioconf.c
1761.1Seeh	${NORMAL_C}
1771.1Seeh
1781.1Seehnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1791.1Seeh	sh $S/conf/newvers.sh
1801.25Seeh	${CC} ${COPTS} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1811.22Seeh
1821.1Seeh
1831.21Smrg__CLEANKERNEL: .USE
1841.21Smrg	@echo "${.TARGET}ing the kernel objects"
1851.1Seeh	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1861.28Smycroft	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1871.21Smrg
1881.21Smrg__CLEANDEPEND: .USE
1891.21Smrg	rm -f .depend
1901.21Smrg
1911.21Smrgclean: __CLEANKERNEL
1921.21Smrg
1931.21Smrgcleandir distclean: __CLEANKERNEL __CLEANDEPEND
1941.1Seeh
1951.1Seehlint:
1961.1Seeh	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
1971.1Seeh	    ${SPARC64}/sparc64/Locore.c ${CFILES} \
1981.1Seeh	    ioconf.c param.c | \
1991.1Seeh	    grep -v 'static function .* unused'
2001.1Seeh
2011.1Seehtags:
2021.1Seeh	@echo "see $S/kern/Makefile for tags"
2031.1Seeh
2041.1Seehlinks:
2051.1Seeh	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
2061.1Seeh	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
2071.1Seeh	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
2081.1Seeh	  sort -u | comm -23 - dontlink | \
2091.1Seeh	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
2101.1Seeh	sh makelinks && rm -f dontlink
2111.1Seeh
2121.1SeehSRCS=	${SPARC64}/sparc64/locore.s \
2131.1Seeh	param.c ioconf.c ${CFILES} ${SFILES}
2141.1Seehdepend: .depend
2151.1Seeh.depend: ${SRCS} assym.h param.c
2161.1Seeh	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${SPARC64}/sparc64/locore.s
2171.1Seeh	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
2181.9Smrg.if (${SFILES} != "")
2191.1Seeh	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
2201.9Smrg.endif
2211.25Seeh	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${COPTS} ${CFLAGS} \
2221.1Seeh	  ${CPPFLAGS} < ${SPARC64}/sparc64/genassym.cf
2231.1Seeh	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
2241.1Seeh	@rm -f assym.dep
2251.17Stron
2261.17Strondependall: depend all
2271.17Stron
2281.1Seeh
2291.1Seeh# depend on root or device configuration
2301.1Seehautoconf.o conf.o: Makefile
2311.2Smrg
2321.1Seeh# depend on network or filesystem configuration 
2331.1Seehuipc_proto.o vfs_conf.o: Makefile 
2341.1Seeh
2351.1Seeh# depend on maxusers
2361.1Seehmachdep.o: Makefile
2371.1Seeh
2381.1Seeh# depend on CPU configuration 
2391.1Seehbwtwo.o cgsix.o cgthree.o cgtwo.o cons.o dma.o esp.o fb.o if_ie.o: Makefile
2401.1Seehms.c obio.o zs.c autoconf.o clock.o cpu.o disksubr.o locore.o: Makefile
2411.1Seehmachdep.o mem.o openprom.o pmap.o vm_machdep.o: Makefile
2421.1Seeh
2431.1Seeh
2441.1Seehlocore.o: ${SPARC64}/sparc64/locore.s assym.h
2451.1Seeh	${NORMAL_S}
2461.23Shubertf
2471.23Shubertf# The install target can be redefined by putting a
2481.23Shubertf# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
2491.23ShubertfMACHINE_NAME!=  uname -n
2501.23Shubertfinstall: install-kernel-${MACHINE_NAME}
2511.23Shubertf.if !target(install-kernel-${MACHINE_NAME}})
2521.23Shubertfinstall-kernel-${MACHINE_NAME}:
2531.23Shubertf	rm -f /onetbsd
2541.23Shubertf	ln /netbsd /onetbsd
2551.23Shubertf	cp netbsd /nnetbsd
2561.23Shubertf	mv /nnetbsd /netbsd
2571.23Shubertf.endif
2581.1Seeh
2591.1Seeh%RULES
260