Makefile.bootprogs revision 1.28
11.28Stsutsui# $NetBSD: Makefile.bootprogs,v 1.28 2009/01/12 07:10:13 tsutsui 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.28StsutsuiCWARNFLAGS+=	-Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
431.28StsutsuiCFLAGS+=	-Werror ${CWARNFLAGS}
441.18Sjdolecek
451.18Sjdolecek# if there is a 'version' file, add rule for vers.c and add it to SRCS
461.18Sjdolecek# and CLEANFILES
471.18Sjdolecek.if exists(version)
481.18Sjdolecek.PHONY: vers.c
491.18Sjdolecekvers.c: version
501.24Slukem	${HOST_SH} ${S}/conf/newvers_stand.sh -N ${.CURDIR}/version "alpha"
511.18Sjdolecek
521.18SjdolecekSRCS+=	vers.c
531.18SjdolecekCLEANFILES+= vers.c
541.10Scgd.endif
551.1Sthorpej
561.1Sthorpej# For descriptions of regions available to bootstrap programs, see
571.1Sthorpej# section 3.4.1.2 (pp. III 3-14 - III 3-18) of the second edition of
581.1Sthorpej# the Alpha AXP Architecture Reference Manual.
591.1Sthorpej
601.8ScgdREGION1_START=		0x20000000		# "Region 1 start"
611.8ScgdREGION1_SIZE!=		expr 256 \* 1024	# 256k
621.8Scgd
631.8Scgd# our memory lauout:
641.8Scgd
651.8Scgd#	'unified' boot loaders (e.g. netboot) can consume all of region
661.8Scgd#	1 for their text+data, or text+data+bss.
671.8Scgd
681.8ScgdUNIFIED_LOAD_ADDRESS=	${REGION1_START}
691.8ScgdUNIFIED_MAX_LOAD!=	expr ${REGION1_SIZE}
701.8ScgdUNIFIED_MAX_TOTAL!=	expr ${REGION1_SIZE}
711.8Scgd
721.8Scgd#UNIFIED_HEAP_START=	right after secondary bss
731.8ScgdUNIFIED_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
741.8Scgd
751.8Scgd#	two-stage boot loaders must share region 1.  The first stage
761.8Scgd#	loads into the lowest portion, and uses the higest portion
771.8Scgd#	for its heap.  The second stage loads in between the primary image
781.8Scgd#	and the heap, and can reuse the memory after it (i.e. the primary's
791.8Scgd#	heap) for its own heap.
801.8Scgd
811.8ScgdPRIMARY_LOAD_ADDRESS=	${REGION1_START}
821.8Scgd#PRIMARY_MAX_LOAD=	booter dependent, no more than ${PRIMARY_MAX_TOTAL}
831.8ScgdPRIMARY_MAX_TOTAL!=	expr 16 \* 1024
841.8Scgd
851.8Scgd# XXX SECONDARY_LOAD_ADDRESS should be
861.8Scgd# XXX (${PRIMARY_LOAD_ADDRESS} + ${PRIMARY_MAX_TOTAL}) bt there's no easy
871.8Scgd# XXX way to do that calculation and 'ld' wants a single number.
881.8ScgdSECONDARY_LOAD_ADDRESS=	0x20004000	# XXX
891.8ScgdSECONDARY_MAX_LOAD!=	expr 112 \* 1024
901.8ScgdSECONDARY_MAX_TOTAL!=	expr ${REGION1_SIZE} - ${PRIMARY_MAX_TOTAL}
911.8Scgd
921.8ScgdPRIMARY_HEAP_START=	(${SECONDARY_LOAD_ADDRESS} + ${SECONDARY_MAX_LOAD})
931.8ScgdPRIMARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
941.8Scgd
951.8Scgd#SECONDARY_HEAP_START=	right after secondary bss
961.8ScgdSECONDARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
971.1Sthorpej
981.13Scgd#	standalone programs are like kernels.  They load at
991.13Scgd#	0xfffffc0000300000 and can use the rest of memory.
1001.13Scgd
1011.13ScgdSTANDPROG_LOAD_ADDRESS=	0xfffffc0000300000
1021.13Scgd
1031.13Scgd
1041.19SthorpejFILE_FORMAT_CPPFLAGS=	-DBOOT_ECOFF -DBOOT_ELF64
1051.1Sthorpej
1061.8ScgdUNIFIED_CPPFLAGS=	-DUNIFIED_BOOTBLOCK \
1071.8Scgd			-DHEAP_LIMIT="${UNIFIED_HEAP_LIMIT}" \
1081.9Sross			${FILE_FORMAT_CPPFLAGS}
1091.8Scgd
1101.8ScgdPRIMARY_CPPFLAGS=	-DPRIMARY_BOOTBLOCK \
1111.8Scgd			-DSECONDARY_LOAD_ADDRESS="${SECONDARY_LOAD_ADDRESS}" \
1121.8Scgd			-DSECONDARY_MAX_LOAD="${SECONDARY_MAX_LOAD}" \
1131.8Scgd			-DHEAP_LIMIT="${PRIMARY_HEAP_LIMIT}" \
1141.8Scgd			-DHEAP_START="${PRIMARY_HEAP_START}"
1151.8Scgd
1161.8ScgdSECONDARY_CPPFLAGS=	-DSECONDARY_BOOTBLOCK \
1171.8Scgd			-DHEAP_LIMIT="${SECONDARY_HEAP_LIMIT}" \
1181.9Sross			${FILE_FORMAT_CPPFLAGS}
1191.13Scgd
1201.13ScgdSTANDPROG_CPPFLAGS=	-DSTANDALONE_PROGRAM
1211.8Scgd
1221.1Sthorpej.include <bsd.prog.mk>
1231.20Slukem
1241.20SlukemCOPTS+=-Os	# override -O supplied by user
1251.1Sthorpej
1261.1Sthorpej### find out what to use for libkern
1271.1SthorpejKERN_AS=	library
1281.1Sthorpej.include "${S}/lib/libkern/Makefile.inc"
1291.1SthorpejLIBKERN=	${KERNLIB}
1301.1Sthorpej
1311.1Sthorpej### find out what to use for libz
1321.1SthorpejZ_AS=		library
1331.1Sthorpej.include "${S}/lib/libz/Makefile.inc"
1341.1SthorpejLIBZ=		${ZLIB}
1351.1Sthorpej
1361.1Sthorpej### find out what to use for libsa
1371.1SthorpejSA_AS=		library
1381.26SsimonbSAMISCMAKEFLAGS+=SA_USE_LOADFILE=yes
1391.1Sthorpej.include "${S}/lib/libsa/Makefile.inc"
1401.1SthorpejLIBSA=		${SALIB}
141