Makefile.bootprogs revision 1.29
11.29Stsutsui# $NetBSD: Makefile.bootprogs,v 1.29 2009/04/13 12:18:56 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.29Stsutsuirealall: ${PROG}
231.1Sthorpej
241.10ScgdAFLAGS+=	-DASSEMBLER
251.10Scgd# -I${.CURDIR}/../.. done by Makefile.inc
261.10ScgdCPPFLAGS+=	-nostdinc -I${.OBJDIR} -D_STANDALONE -I${S}
271.21SthorpejCFLAGS=		-ffreestanding -mno-fp-regs -g
281.12Scgd
291.24SlukemNETBSD_VERS!=${HOST_SH} ${.CURDIR}/../../../../conf/osrelease.sh
301.12ScgdCPPFLAGS+= -DNETBSD_VERS='"${NETBSD_VERS}"'
311.10Scgd
321.28StsutsuiCWARNFLAGS+=	-Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
331.28StsutsuiCFLAGS+=	-Werror ${CWARNFLAGS}
341.18Sjdolecek
351.18Sjdolecek# if there is a 'version' file, add rule for vers.c and add it to SRCS
361.18Sjdolecek# and CLEANFILES
371.18Sjdolecek.if exists(version)
381.18Sjdolecek.PHONY: vers.c
391.18Sjdolecekvers.c: version
401.24Slukem	${HOST_SH} ${S}/conf/newvers_stand.sh -N ${.CURDIR}/version "alpha"
411.18Sjdolecek
421.18SjdolecekSRCS+=	vers.c
431.18SjdolecekCLEANFILES+= vers.c
441.10Scgd.endif
451.1Sthorpej
461.1Sthorpej# For descriptions of regions available to bootstrap programs, see
471.1Sthorpej# section 3.4.1.2 (pp. III 3-14 - III 3-18) of the second edition of
481.1Sthorpej# the Alpha AXP Architecture Reference Manual.
491.1Sthorpej
501.8ScgdREGION1_START=		0x20000000		# "Region 1 start"
511.8ScgdREGION1_SIZE!=		expr 256 \* 1024	# 256k
521.8Scgd
531.8Scgd# our memory lauout:
541.8Scgd
551.8Scgd#	'unified' boot loaders (e.g. netboot) can consume all of region
561.8Scgd#	1 for their text+data, or text+data+bss.
571.8Scgd
581.8ScgdUNIFIED_LOAD_ADDRESS=	${REGION1_START}
591.8ScgdUNIFIED_MAX_LOAD!=	expr ${REGION1_SIZE}
601.8ScgdUNIFIED_MAX_TOTAL!=	expr ${REGION1_SIZE}
611.8Scgd
621.8Scgd#UNIFIED_HEAP_START=	right after secondary bss
631.8ScgdUNIFIED_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
641.8Scgd
651.8Scgd#	two-stage boot loaders must share region 1.  The first stage
661.8Scgd#	loads into the lowest portion, and uses the higest portion
671.8Scgd#	for its heap.  The second stage loads in between the primary image
681.8Scgd#	and the heap, and can reuse the memory after it (i.e. the primary's
691.8Scgd#	heap) for its own heap.
701.8Scgd
711.8ScgdPRIMARY_LOAD_ADDRESS=	${REGION1_START}
721.8Scgd#PRIMARY_MAX_LOAD=	booter dependent, no more than ${PRIMARY_MAX_TOTAL}
731.8ScgdPRIMARY_MAX_TOTAL!=	expr 16 \* 1024
741.8Scgd
751.8Scgd# XXX SECONDARY_LOAD_ADDRESS should be
761.8Scgd# XXX (${PRIMARY_LOAD_ADDRESS} + ${PRIMARY_MAX_TOTAL}) bt there's no easy
771.8Scgd# XXX way to do that calculation and 'ld' wants a single number.
781.8ScgdSECONDARY_LOAD_ADDRESS=	0x20004000	# XXX
791.8ScgdSECONDARY_MAX_LOAD!=	expr 112 \* 1024
801.8ScgdSECONDARY_MAX_TOTAL!=	expr ${REGION1_SIZE} - ${PRIMARY_MAX_TOTAL}
811.8Scgd
821.8ScgdPRIMARY_HEAP_START=	(${SECONDARY_LOAD_ADDRESS} + ${SECONDARY_MAX_LOAD})
831.8ScgdPRIMARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
841.8Scgd
851.8Scgd#SECONDARY_HEAP_START=	right after secondary bss
861.8ScgdSECONDARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
871.1Sthorpej
881.13Scgd#	standalone programs are like kernels.  They load at
891.13Scgd#	0xfffffc0000300000 and can use the rest of memory.
901.13Scgd
911.13ScgdSTANDPROG_LOAD_ADDRESS=	0xfffffc0000300000
921.13Scgd
931.13Scgd
941.19SthorpejFILE_FORMAT_CPPFLAGS=	-DBOOT_ECOFF -DBOOT_ELF64
951.1Sthorpej
961.8ScgdUNIFIED_CPPFLAGS=	-DUNIFIED_BOOTBLOCK \
971.8Scgd			-DHEAP_LIMIT="${UNIFIED_HEAP_LIMIT}" \
981.9Sross			${FILE_FORMAT_CPPFLAGS}
991.8Scgd
1001.8ScgdPRIMARY_CPPFLAGS=	-DPRIMARY_BOOTBLOCK \
1011.8Scgd			-DSECONDARY_LOAD_ADDRESS="${SECONDARY_LOAD_ADDRESS}" \
1021.8Scgd			-DSECONDARY_MAX_LOAD="${SECONDARY_MAX_LOAD}" \
1031.8Scgd			-DHEAP_LIMIT="${PRIMARY_HEAP_LIMIT}" \
1041.8Scgd			-DHEAP_START="${PRIMARY_HEAP_START}"
1051.8Scgd
1061.8ScgdSECONDARY_CPPFLAGS=	-DSECONDARY_BOOTBLOCK \
1071.8Scgd			-DHEAP_LIMIT="${SECONDARY_HEAP_LIMIT}" \
1081.9Sross			${FILE_FORMAT_CPPFLAGS}
1091.13Scgd
1101.13ScgdSTANDPROG_CPPFLAGS=	-DSTANDALONE_PROGRAM
1111.8Scgd
1121.1Sthorpej.include <bsd.prog.mk>
1131.29Stsutsui.include <bsd.klinks.mk>
1141.20Slukem
1151.20SlukemCOPTS+=-Os	# override -O supplied by user
1161.1Sthorpej
1171.1Sthorpej### find out what to use for libkern
1181.1SthorpejKERN_AS=	library
1191.1Sthorpej.include "${S}/lib/libkern/Makefile.inc"
1201.1SthorpejLIBKERN=	${KERNLIB}
1211.1Sthorpej
1221.1Sthorpej### find out what to use for libz
1231.1SthorpejZ_AS=		library
1241.1Sthorpej.include "${S}/lib/libz/Makefile.inc"
1251.1SthorpejLIBZ=		${ZLIB}
1261.1Sthorpej
1271.1Sthorpej### find out what to use for libsa
1281.1SthorpejSA_AS=		library
1291.26SsimonbSAMISCMAKEFLAGS+=SA_USE_LOADFILE=yes
1301.1Sthorpej.include "${S}/lib/libsa/Makefile.inc"
1311.1SthorpejLIBSA=		${SALIB}
132