Makefile.bootprogs revision 1.24
11.24Slukem# $NetBSD: Makefile.bootprogs,v 1.24 2003/10/26 07:25:35 lukem Exp $
21.24Slukem
31.24Slukem.include <bsd.sys.mk>		# for HOST_SH
41.1Sthorpej
51.1SthorpejS=	${.CURDIR}/../../../..
61.1Sthorpej
71.1Sthorpej.PATH:	${.CURDIR}/../common
81.1Sthorpej
91.1SthorpejSTRIPFLAG=
101.1SthorpejBINMODE= 444
111.1Sthorpej
121.17StsutsuiSTRIP?=	strip
131.23Ssimonb
141.23Ssimonb# XXX SHOULD NOT NEED TO DEFINE THESE!
151.23SsimonbLIBCRT0=
161.23SsimonbLIBC=
171.23SsimonbLIBCRTBEGIN=
181.23SsimonbLIBCRTEND=
191.1Sthorpej
201.24SlukemCHECKSIZE_CMD=	SIZE=${SIZE} ${HOST_SH} ${.CURDIR}/../common/checksize.sh
211.8Scgd
221.1Sthorpej.PHONY: machine-links
231.1Sthorpejbeforedepend: machine-links
241.1Sthorpej# ${MACHINE} then ${MACHINE_ARCH}
251.1Sthorpejmachine-links:
261.1Sthorpej	-rm -f machine && \
271.1Sthorpej	    ln -s $S/arch/alpha/include machine
281.1Sthorpej	-rm -f alpha && \
291.1Sthorpej	    ln -s $S/arch/alpha/include alpha
301.1SthorpejCLEANFILES+=machine alpha
311.1Sthorpej
321.16Smycroftrealall: machine-links ${PROG}
331.1Sthorpej
341.10ScgdAFLAGS+=	-DASSEMBLER
351.10Scgd# -I${.CURDIR}/../.. done by Makefile.inc
361.10ScgdCPPFLAGS+=	-nostdinc -I${.OBJDIR} -D_STANDALONE -I${S}
371.21SthorpejCFLAGS=		-ffreestanding -mno-fp-regs -g
381.12Scgd
391.24SlukemNETBSD_VERS!=${HOST_SH} ${.CURDIR}/../../../../conf/osrelease.sh
401.12ScgdCPPFLAGS+= -DNETBSD_VERS='"${NETBSD_VERS}"'
411.10Scgd
421.10ScgdCWARNFLAGS+=	-Wno-main
431.18Sjdolecek
441.18Sjdolecek# if there is a 'version' file, add rule for vers.c and add it to SRCS
451.18Sjdolecek# and CLEANFILES
461.18Sjdolecek.if exists(version)
471.18Sjdolecek.PHONY: vers.c
481.18Sjdolecekvers.c: version
491.24Slukem	${HOST_SH} ${S}/conf/newvers_stand.sh -N ${.CURDIR}/version "alpha"
501.18Sjdolecek
511.18SjdolecekSRCS+=	vers.c
521.18SjdolecekCLEANFILES+= vers.c
531.10Scgd.endif
541.1Sthorpej
551.1Sthorpej# For descriptions of regions available to bootstrap programs, see
561.1Sthorpej# section 3.4.1.2 (pp. III 3-14 - III 3-18) of the second edition of
571.1Sthorpej# the Alpha AXP Architecture Reference Manual.
581.1Sthorpej
591.8ScgdREGION1_START=		0x20000000		# "Region 1 start"
601.8ScgdREGION1_SIZE!=		expr 256 \* 1024	# 256k
611.8Scgd
621.8Scgd# our memory lauout:
631.8Scgd
641.8Scgd#	'unified' boot loaders (e.g. netboot) can consume all of region
651.8Scgd#	1 for their text+data, or text+data+bss.
661.8Scgd
671.8ScgdUNIFIED_LOAD_ADDRESS=	${REGION1_START}
681.8ScgdUNIFIED_MAX_LOAD!=	expr ${REGION1_SIZE}
691.8ScgdUNIFIED_MAX_TOTAL!=	expr ${REGION1_SIZE}
701.8Scgd
711.8Scgd#UNIFIED_HEAP_START=	right after secondary bss
721.8ScgdUNIFIED_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
731.8Scgd
741.8Scgd#	two-stage boot loaders must share region 1.  The first stage
751.8Scgd#	loads into the lowest portion, and uses the higest portion
761.8Scgd#	for its heap.  The second stage loads in between the primary image
771.8Scgd#	and the heap, and can reuse the memory after it (i.e. the primary's
781.8Scgd#	heap) for its own heap.
791.8Scgd
801.8ScgdPRIMARY_LOAD_ADDRESS=	${REGION1_START}
811.8Scgd#PRIMARY_MAX_LOAD=	booter dependent, no more than ${PRIMARY_MAX_TOTAL}
821.8ScgdPRIMARY_MAX_TOTAL!=	expr 16 \* 1024
831.8Scgd
841.8Scgd# XXX SECONDARY_LOAD_ADDRESS should be
851.8Scgd# XXX (${PRIMARY_LOAD_ADDRESS} + ${PRIMARY_MAX_TOTAL}) bt there's no easy
861.8Scgd# XXX way to do that calculation and 'ld' wants a single number.
871.8ScgdSECONDARY_LOAD_ADDRESS=	0x20004000	# XXX
881.8ScgdSECONDARY_MAX_LOAD!=	expr 112 \* 1024
891.8ScgdSECONDARY_MAX_TOTAL!=	expr ${REGION1_SIZE} - ${PRIMARY_MAX_TOTAL}
901.8Scgd
911.8ScgdPRIMARY_HEAP_START=	(${SECONDARY_LOAD_ADDRESS} + ${SECONDARY_MAX_LOAD})
921.8ScgdPRIMARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
931.8Scgd
941.8Scgd#SECONDARY_HEAP_START=	right after secondary bss
951.8ScgdSECONDARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
961.1Sthorpej
971.13Scgd#	standalone programs are like kernels.  They load at
981.13Scgd#	0xfffffc0000300000 and can use the rest of memory.
991.13Scgd
1001.13ScgdSTANDPROG_LOAD_ADDRESS=	0xfffffc0000300000
1011.13Scgd
1021.13Scgd
1031.19SthorpejFILE_FORMAT_CPPFLAGS=	-DBOOT_ECOFF -DBOOT_ELF64
1041.1Sthorpej
1051.8ScgdUNIFIED_CPPFLAGS=	-DUNIFIED_BOOTBLOCK \
1061.8Scgd			-DHEAP_LIMIT="${UNIFIED_HEAP_LIMIT}" \
1071.9Sross			${FILE_FORMAT_CPPFLAGS}
1081.8Scgd
1091.8ScgdPRIMARY_CPPFLAGS=	-DPRIMARY_BOOTBLOCK \
1101.8Scgd			-DSECONDARY_LOAD_ADDRESS="${SECONDARY_LOAD_ADDRESS}" \
1111.8Scgd			-DSECONDARY_MAX_LOAD="${SECONDARY_MAX_LOAD}" \
1121.8Scgd			-DHEAP_LIMIT="${PRIMARY_HEAP_LIMIT}" \
1131.8Scgd			-DHEAP_START="${PRIMARY_HEAP_START}"
1141.8Scgd
1151.8ScgdSECONDARY_CPPFLAGS=	-DSECONDARY_BOOTBLOCK \
1161.8Scgd			-DHEAP_LIMIT="${SECONDARY_HEAP_LIMIT}" \
1171.9Sross			${FILE_FORMAT_CPPFLAGS}
1181.13Scgd
1191.13ScgdSTANDPROG_CPPFLAGS=	-DSTANDALONE_PROGRAM
1201.8Scgd
1211.1Sthorpej.include <bsd.prog.mk>
1221.20Slukem
1231.20SlukemCOPTS+=-Os	# override -O supplied by user
1241.1Sthorpej
1251.1Sthorpej### find out what to use for libkern
1261.1SthorpejKERN_AS=	library
1271.1Sthorpej.include "${S}/lib/libkern/Makefile.inc"
1281.1SthorpejLIBKERN=	${KERNLIB}
1291.1Sthorpej
1301.1Sthorpej### find out what to use for libz
1311.1SthorpejZ_AS=		library
1321.1Sthorpej.include "${S}/lib/libz/Makefile.inc"
1331.1SthorpejLIBZ=		${ZLIB}
1341.1Sthorpej
1351.1Sthorpej### find out what to use for libsa
1361.1SthorpejSA_AS=		library
1371.14SrossSAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
1381.1Sthorpej.include "${S}/lib/libsa/Makefile.inc"
1391.1SthorpejLIBSA=		${SALIB}
140