Makefile.bootprogs revision 1.31
11.31Sjoerg# $NetBSD: Makefile.bootprogs,v 1.31 2011/01/22 19:19:15 joerg Exp $
21.24Slukem
31.31Sjoerg.include <bsd.own.mk>
41.24Slukem.include <bsd.sys.mk>		# for HOST_SH
51.1Sthorpej
61.1SthorpejS=	${.CURDIR}/../../../..
71.1Sthorpej
81.1Sthorpej.PATH:	${.CURDIR}/../common
91.1Sthorpej
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.31Sjoerg	${HOST_SH} ${S}/conf/newvers_stand.sh ${${MKREPRO} == "yes" :?:-D} \
411.31Sjoerg	    -N ${.CURDIR}/version "alpha"
421.18Sjdolecek
431.18SjdolecekSRCS+=	vers.c
441.18SjdolecekCLEANFILES+= vers.c
451.10Scgd.endif
461.1Sthorpej
471.1Sthorpej# For descriptions of regions available to bootstrap programs, see
481.1Sthorpej# section 3.4.1.2 (pp. III 3-14 - III 3-18) of the second edition of
491.1Sthorpej# the Alpha AXP Architecture Reference Manual.
501.1Sthorpej
511.8ScgdREGION1_START=		0x20000000		# "Region 1 start"
521.8ScgdREGION1_SIZE!=		expr 256 \* 1024	# 256k
531.8Scgd
541.8Scgd# our memory lauout:
551.8Scgd
561.8Scgd#	'unified' boot loaders (e.g. netboot) can consume all of region
571.8Scgd#	1 for their text+data, or text+data+bss.
581.8Scgd
591.8ScgdUNIFIED_LOAD_ADDRESS=	${REGION1_START}
601.8ScgdUNIFIED_MAX_LOAD!=	expr ${REGION1_SIZE}
611.8ScgdUNIFIED_MAX_TOTAL!=	expr ${REGION1_SIZE}
621.8Scgd
631.8Scgd#UNIFIED_HEAP_START=	right after secondary bss
641.8ScgdUNIFIED_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
651.8Scgd
661.8Scgd#	two-stage boot loaders must share region 1.  The first stage
671.8Scgd#	loads into the lowest portion, and uses the higest portion
681.8Scgd#	for its heap.  The second stage loads in between the primary image
691.8Scgd#	and the heap, and can reuse the memory after it (i.e. the primary's
701.8Scgd#	heap) for its own heap.
711.8Scgd
721.8ScgdPRIMARY_LOAD_ADDRESS=	${REGION1_START}
731.8Scgd#PRIMARY_MAX_LOAD=	booter dependent, no more than ${PRIMARY_MAX_TOTAL}
741.8ScgdPRIMARY_MAX_TOTAL!=	expr 16 \* 1024
751.8Scgd
761.8Scgd# XXX SECONDARY_LOAD_ADDRESS should be
771.8Scgd# XXX (${PRIMARY_LOAD_ADDRESS} + ${PRIMARY_MAX_TOTAL}) bt there's no easy
781.8Scgd# XXX way to do that calculation and 'ld' wants a single number.
791.8ScgdSECONDARY_LOAD_ADDRESS=	0x20004000	# XXX
801.8ScgdSECONDARY_MAX_LOAD!=	expr 112 \* 1024
811.8ScgdSECONDARY_MAX_TOTAL!=	expr ${REGION1_SIZE} - ${PRIMARY_MAX_TOTAL}
821.8Scgd
831.8ScgdPRIMARY_HEAP_START=	(${SECONDARY_LOAD_ADDRESS} + ${SECONDARY_MAX_LOAD})
841.8ScgdPRIMARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
851.8Scgd
861.8Scgd#SECONDARY_HEAP_START=	right after secondary bss
871.8ScgdSECONDARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
881.1Sthorpej
891.13Scgd#	standalone programs are like kernels.  They load at
901.13Scgd#	0xfffffc0000300000 and can use the rest of memory.
911.13Scgd
921.13ScgdSTANDPROG_LOAD_ADDRESS=	0xfffffc0000300000
931.13Scgd
941.13Scgd
951.19SthorpejFILE_FORMAT_CPPFLAGS=	-DBOOT_ECOFF -DBOOT_ELF64
961.1Sthorpej
971.8ScgdUNIFIED_CPPFLAGS=	-DUNIFIED_BOOTBLOCK \
981.8Scgd			-DHEAP_LIMIT="${UNIFIED_HEAP_LIMIT}" \
991.9Sross			${FILE_FORMAT_CPPFLAGS}
1001.8Scgd
1011.8ScgdPRIMARY_CPPFLAGS=	-DPRIMARY_BOOTBLOCK \
1021.8Scgd			-DSECONDARY_LOAD_ADDRESS="${SECONDARY_LOAD_ADDRESS}" \
1031.8Scgd			-DSECONDARY_MAX_LOAD="${SECONDARY_MAX_LOAD}" \
1041.8Scgd			-DHEAP_LIMIT="${PRIMARY_HEAP_LIMIT}" \
1051.8Scgd			-DHEAP_START="${PRIMARY_HEAP_START}"
1061.8Scgd
1071.8ScgdSECONDARY_CPPFLAGS=	-DSECONDARY_BOOTBLOCK \
1081.8Scgd			-DHEAP_LIMIT="${SECONDARY_HEAP_LIMIT}" \
1091.9Sross			${FILE_FORMAT_CPPFLAGS}
1101.13Scgd
1111.13ScgdSTANDPROG_CPPFLAGS=	-DSTANDALONE_PROGRAM
1121.8Scgd
1131.1Sthorpej.include <bsd.prog.mk>
1141.29Stsutsui.include <bsd.klinks.mk>
1151.20Slukem
1161.30StsutsuiSTRIPFLAG=	# override values in ${MAKECONF}
1171.20SlukemCOPTS+=-Os	# override -O supplied by user
1181.1Sthorpej
1191.1Sthorpej### find out what to use for libkern
1201.1SthorpejKERN_AS=	library
1211.1Sthorpej.include "${S}/lib/libkern/Makefile.inc"
1221.1SthorpejLIBKERN=	${KERNLIB}
1231.1Sthorpej
1241.1Sthorpej### find out what to use for libz
1251.1SthorpejZ_AS=		library
1261.1Sthorpej.include "${S}/lib/libz/Makefile.inc"
1271.1SthorpejLIBZ=		${ZLIB}
1281.1Sthorpej
1291.1Sthorpej### find out what to use for libsa
1301.1SthorpejSA_AS=		library
1311.26SsimonbSAMISCMAKEFLAGS+=SA_USE_LOADFILE=yes
1321.1Sthorpej.include "${S}/lib/libsa/Makefile.inc"
1331.1SthorpejLIBSA=		${SALIB}
134