Makefile.sparc64 revision 1.34
11.34Smrg# 	$NetBSD: Makefile.sparc64,v 1.34 2001/02/28 15:17:48 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.4SmrgCPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL ${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.34SmrgKERN_LDSCRIPT?= kern.ldscript
811.31Seeh
821.15StsutsuiSTRIPFLAGS=	-g
831.10Smrg
841.10Smrg%INCLUDES
851.1Seeh
861.1Seeh### find out what to use for libkern
871.14Seeh# KERN_AS=	obj	# bcopy, bzero, memcpy, memset, etc. are in locore.s
881.1Seeh.include "$S/lib/libkern/Makefile.inc"
891.1Seeh.ifndef PROF
901.1SeehLIBKERN=	${KERNLIB}
911.1Seeh.else
921.1SeehLIBKERN=	${KERNLIB_PROF}
931.1Seeh.endif
941.1Seeh
951.1Seeh### find out what to use for libcompat
961.1Seeh.include "$S/compat/common/Makefile.inc"
971.1Seeh.ifndef PROF
981.1SeehLIBCOMPAT=	${COMPATLIB}
991.1Seeh.else
1001.1SeehLIBCOMPAT=	${COMPATLIB_PROF}
1011.1Seeh.endif
1021.1Seeh
1031.1Seeh# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
1041.1Seeh# HOSTED, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
1051.1Seeh
1061.27SmycroftNORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
1071.27SmycroftNOOPT_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -O0 -c $<
1081.1SeehNORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
1091.1Seeh
1101.1Seeh%OBJS
1111.1Seeh
1121.1Seeh%CFILES
1131.1Seeh
1141.1Seeh%SFILES
1151.1Seeh
1161.1Seeh# load lines for config "xxx" will be emitted as:
1171.1Seeh# xxx: ${SYSTEM_DEP} swapxxx.o
1181.1Seeh#	${SYSTEM_LD_HEAD}
1191.1Seeh#	${SYSTEM_LD} swapxxx.o
1201.1Seeh#	${SYSTEM_LD_TAIL}
1211.1SeehSYSTEM_OBJ=	locore.o \
1221.6Sdrochner		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
1231.1SeehSYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
1241.27SmycroftSYSTEM_LD_HEAD=	rm -f $@
1251.1SeehSYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
1261.1Seeh		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
1271.2SmrgSYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
1281.1Seeh
1291.1SeehDEBUG?=
1301.1Seeh.if ${DEBUG} == "-g"
1311.1SeehLINKFLAGS+=	-X
1321.1SeehSYSTEM_LD_TAIL+=; \
1331.12Scgd		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
1341.19Seeh		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
1351.19Seeh		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
1361.1Seeh.else
1371.1SeehLINKFLAGS+=	-S
1381.1Seeh.endif
1391.1Seeh
1401.1Seeh%LOAD
1411.2Smrg
1421.2Smrg.if ${USE_GENASSYM} == "no"
1431.1Seehassym.h: $S/kern/genassym.sh ${SPARC64}/sparc64/genassym.cf
1441.27Smycroft	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
1451.1Seeh	    < ${SPARC64}/sparc64/genassym.cf > assym.h.tmp && \
1461.1Seeh	mv -f assym.h.tmp assym.h
1471.1Seeh.else
1481.1SeehHOSTED_CC=	${CC}
1491.1SeehHOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
1501.27SmycroftHOSTED_CFLAGS=	${CFLAGS}
1511.1Seeh
1521.1SeehHOSTED_C=	${HOSTED_CC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
1531.1Seeh
1541.1Seehassym.h: genassym
1551.1Seeh	./genassym >assym.h
1561.1Seeh
1571.1Seehgenassym: genassym.o
1581.1Seeh	${CC} -o $@ genassym.o
1591.1Seeh
1601.1Seehgenassym.o: ${SPARC64}/sparc64/genassym.c
1611.1Seeh	${HOSTED_C}
1621.1Seeh.endif
1631.1Seeh
1641.1Seehparam.c: $S/conf/param.c
1651.1Seeh	rm -f param.c
1661.1Seeh	cp $S/conf/param.c .
1671.1Seeh
1681.1Seehparam.o: param.c Makefile
1691.1Seeh	${NORMAL_C}
1701.1Seeh
1711.1Seehioconf.o: ioconf.c
1721.1Seeh	${NORMAL_C}
1731.1Seeh
1741.1Seehnewvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
1751.1Seeh	sh $S/conf/newvers.sh
1761.25Seeh	${CC} ${COPTS} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
1771.22Seeh
1781.1Seeh
1791.21Smrg__CLEANKERNEL: .USE
1801.21Smrg	@echo "${.TARGET}ing the kernel objects"
1811.1Seeh	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
1821.28Smycroft	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
1831.21Smrg
1841.21Smrg__CLEANDEPEND: .USE
1851.21Smrg	rm -f .depend
1861.21Smrg
1871.21Smrgclean: __CLEANKERNEL
1881.21Smrg
1891.21Smrgcleandir distclean: __CLEANKERNEL __CLEANDEPEND
1901.1Seeh
1911.1Seehlint:
1921.1Seeh	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
1931.1Seeh	    ${SPARC64}/sparc64/Locore.c ${CFILES} \
1941.1Seeh	    ioconf.c param.c | \
1951.1Seeh	    grep -v 'static function .* unused'
1961.1Seeh
1971.1Seehtags:
1981.1Seeh	@echo "see $S/kern/Makefile for tags"
1991.1Seeh
2001.1Seehlinks:
2011.1Seeh	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
2021.1Seeh	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
2031.1Seeh	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
2041.1Seeh	  sort -u | comm -23 - dontlink | \
2051.1Seeh	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
2061.1Seeh	sh makelinks && rm -f dontlink
2071.1Seeh
2081.1SeehSRCS=	${SPARC64}/sparc64/locore.s \
2091.1Seeh	param.c ioconf.c ${CFILES} ${SFILES}
2101.1Seehdepend: .depend
2111.1Seeh.depend: ${SRCS} assym.h param.c
2121.1Seeh	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${SPARC64}/sparc64/locore.s
2131.1Seeh	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
2141.9Smrg.if (${SFILES} != "")
2151.1Seeh	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
2161.9Smrg.endif
2171.25Seeh	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${COPTS} ${CFLAGS} \
2181.1Seeh	  ${CPPFLAGS} < ${SPARC64}/sparc64/genassym.cf
2191.1Seeh	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
2201.1Seeh	@rm -f assym.dep
2211.17Stron
2221.17Strondependall: depend all
2231.17Stron
2241.1Seeh
2251.1Seeh# depend on root or device configuration
2261.1Seehautoconf.o conf.o: Makefile
2271.2Smrg
2281.1Seeh# depend on network or filesystem configuration 
2291.1Seehuipc_proto.o vfs_conf.o: Makefile 
2301.1Seeh
2311.1Seeh# depend on maxusers
2321.1Seehmachdep.o: Makefile
2331.1Seeh
2341.1Seeh# depend on CPU configuration 
2351.1Seehbwtwo.o cgsix.o cgthree.o cgtwo.o cons.o dma.o esp.o fb.o if_ie.o: Makefile
2361.1Seehms.c obio.o zs.c autoconf.o clock.o cpu.o disksubr.o locore.o: Makefile
2371.1Seehmachdep.o mem.o openprom.o pmap.o vm_machdep.o: Makefile
2381.1Seeh
2391.1Seeh
2401.1Seehlocore.o: ${SPARC64}/sparc64/locore.s assym.h
2411.1Seeh	${NORMAL_S}
2421.23Shubertf
2431.23Shubertf# The install target can be redefined by putting a
2441.23Shubertf# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
2451.23ShubertfMACHINE_NAME!=  uname -n
2461.23Shubertfinstall: install-kernel-${MACHINE_NAME}
2471.23Shubertf.if !target(install-kernel-${MACHINE_NAME}})
2481.23Shubertfinstall-kernel-${MACHINE_NAME}:
2491.23Shubertf	rm -f /onetbsd
2501.23Shubertf	ln /netbsd /onetbsd
2511.23Shubertf	cp netbsd /nnetbsd
2521.23Shubertf	mv /nnetbsd /netbsd
2531.23Shubertf.endif
2541.1Seeh
2551.1Seeh%RULES
256