Makefile.bootprogs revision 1.33
11.33Stsutsui# $NetBSD: Makefile.bootprogs,v 1.33 2014/01/12 15:26:28 tsutsui Exp $
21.32Sjoerg
31.32SjoergNOMAN=			# defined
41.24Slukem
51.31Sjoerg.include <bsd.own.mk>
61.24Slukem.include <bsd.sys.mk>		# for HOST_SH
71.1Sthorpej
81.1SthorpejS=	${.CURDIR}/../../../..
91.1Sthorpej
101.1Sthorpej.PATH:	${.CURDIR}/../common
111.1Sthorpej
121.1SthorpejBINMODE= 444
131.1Sthorpej
141.17StsutsuiSTRIP?=	strip
151.23Ssimonb
161.23Ssimonb# XXX SHOULD NOT NEED TO DEFINE THESE!
171.23SsimonbLIBCRT0=
181.33StsutsuiLIBCRTI=
191.23SsimonbLIBC=
201.23SsimonbLIBCRTBEGIN=
211.23SsimonbLIBCRTEND=
221.1Sthorpej
231.24SlukemCHECKSIZE_CMD=	SIZE=${SIZE} ${HOST_SH} ${.CURDIR}/../common/checksize.sh
241.8Scgd
251.29Stsutsuirealall: ${PROG}
261.1Sthorpej
271.10ScgdAFLAGS+=	-DASSEMBLER
281.10Scgd# -I${.CURDIR}/../.. done by Makefile.inc
291.10ScgdCPPFLAGS+=	-nostdinc -I${.OBJDIR} -D_STANDALONE -I${S}
301.21SthorpejCFLAGS=		-ffreestanding -mno-fp-regs -g
311.12Scgd
321.24SlukemNETBSD_VERS!=${HOST_SH} ${.CURDIR}/../../../../conf/osrelease.sh
331.12ScgdCPPFLAGS+= -DNETBSD_VERS='"${NETBSD_VERS}"'
341.10Scgd
351.28StsutsuiCWARNFLAGS+=	-Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
361.28StsutsuiCFLAGS+=	-Werror ${CWARNFLAGS}
371.18Sjdolecek
381.18Sjdolecek# if there is a 'version' file, add rule for vers.c and add it to SRCS
391.18Sjdolecek# and CLEANFILES
401.18Sjdolecek.if exists(version)
411.18Sjdolecek.PHONY: vers.c
421.18Sjdolecekvers.c: version
431.31Sjoerg	${HOST_SH} ${S}/conf/newvers_stand.sh ${${MKREPRO} == "yes" :?:-D} \
441.31Sjoerg	    -N ${.CURDIR}/version "alpha"
451.18Sjdolecek
461.18SjdolecekSRCS+=	vers.c
471.18SjdolecekCLEANFILES+= vers.c
481.10Scgd.endif
491.1Sthorpej
501.1Sthorpej# For descriptions of regions available to bootstrap programs, see
511.1Sthorpej# section 3.4.1.2 (pp. III 3-14 - III 3-18) of the second edition of
521.1Sthorpej# the Alpha AXP Architecture Reference Manual.
531.1Sthorpej
541.8ScgdREGION1_START=		0x20000000		# "Region 1 start"
551.8ScgdREGION1_SIZE!=		expr 256 \* 1024	# 256k
561.8Scgd
571.8Scgd# our memory lauout:
581.8Scgd
591.8Scgd#	'unified' boot loaders (e.g. netboot) can consume all of region
601.8Scgd#	1 for their text+data, or text+data+bss.
611.8Scgd
621.8ScgdUNIFIED_LOAD_ADDRESS=	${REGION1_START}
631.8ScgdUNIFIED_MAX_LOAD!=	expr ${REGION1_SIZE}
641.8ScgdUNIFIED_MAX_TOTAL!=	expr ${REGION1_SIZE}
651.8Scgd
661.8Scgd#UNIFIED_HEAP_START=	right after secondary bss
671.8ScgdUNIFIED_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
681.8Scgd
691.8Scgd#	two-stage boot loaders must share region 1.  The first stage
701.8Scgd#	loads into the lowest portion, and uses the higest portion
711.8Scgd#	for its heap.  The second stage loads in between the primary image
721.8Scgd#	and the heap, and can reuse the memory after it (i.e. the primary's
731.8Scgd#	heap) for its own heap.
741.8Scgd
751.8ScgdPRIMARY_LOAD_ADDRESS=	${REGION1_START}
761.8Scgd#PRIMARY_MAX_LOAD=	booter dependent, no more than ${PRIMARY_MAX_TOTAL}
771.8ScgdPRIMARY_MAX_TOTAL!=	expr 16 \* 1024
781.8Scgd
791.8Scgd# XXX SECONDARY_LOAD_ADDRESS should be
801.8Scgd# XXX (${PRIMARY_LOAD_ADDRESS} + ${PRIMARY_MAX_TOTAL}) bt there's no easy
811.8Scgd# XXX way to do that calculation and 'ld' wants a single number.
821.8ScgdSECONDARY_LOAD_ADDRESS=	0x20004000	# XXX
831.8ScgdSECONDARY_MAX_LOAD!=	expr 112 \* 1024
841.8ScgdSECONDARY_MAX_TOTAL!=	expr ${REGION1_SIZE} - ${PRIMARY_MAX_TOTAL}
851.8Scgd
861.8ScgdPRIMARY_HEAP_START=	(${SECONDARY_LOAD_ADDRESS} + ${SECONDARY_MAX_LOAD})
871.8ScgdPRIMARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
881.8Scgd
891.8Scgd#SECONDARY_HEAP_START=	right after secondary bss
901.8ScgdSECONDARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
911.1Sthorpej
921.13Scgd#	standalone programs are like kernels.  They load at
931.13Scgd#	0xfffffc0000300000 and can use the rest of memory.
941.13Scgd
951.13ScgdSTANDPROG_LOAD_ADDRESS=	0xfffffc0000300000
961.13Scgd
971.13Scgd
981.19SthorpejFILE_FORMAT_CPPFLAGS=	-DBOOT_ECOFF -DBOOT_ELF64
991.1Sthorpej
1001.8ScgdUNIFIED_CPPFLAGS=	-DUNIFIED_BOOTBLOCK \
1011.8Scgd			-DHEAP_LIMIT="${UNIFIED_HEAP_LIMIT}" \
1021.9Sross			${FILE_FORMAT_CPPFLAGS}
1031.8Scgd
1041.8ScgdPRIMARY_CPPFLAGS=	-DPRIMARY_BOOTBLOCK \
1051.8Scgd			-DSECONDARY_LOAD_ADDRESS="${SECONDARY_LOAD_ADDRESS}" \
1061.8Scgd			-DSECONDARY_MAX_LOAD="${SECONDARY_MAX_LOAD}" \
1071.8Scgd			-DHEAP_LIMIT="${PRIMARY_HEAP_LIMIT}" \
1081.8Scgd			-DHEAP_START="${PRIMARY_HEAP_START}"
1091.8Scgd
1101.8ScgdSECONDARY_CPPFLAGS=	-DSECONDARY_BOOTBLOCK \
1111.8Scgd			-DHEAP_LIMIT="${SECONDARY_HEAP_LIMIT}" \
1121.9Sross			${FILE_FORMAT_CPPFLAGS}
1131.13Scgd
1141.13ScgdSTANDPROG_CPPFLAGS=	-DSTANDALONE_PROGRAM
1151.8Scgd
1161.1Sthorpej.include <bsd.prog.mk>
1171.29Stsutsui.include <bsd.klinks.mk>
1181.20Slukem
1191.30StsutsuiSTRIPFLAG=	# override values in ${MAKECONF}
1201.20SlukemCOPTS+=-Os	# override -O supplied by user
1211.1Sthorpej
1221.1Sthorpej### find out what to use for libkern
1231.1SthorpejKERN_AS=	library
1241.1Sthorpej.include "${S}/lib/libkern/Makefile.inc"
1251.1SthorpejLIBKERN=	${KERNLIB}
1261.1Sthorpej
1271.1Sthorpej### find out what to use for libz
1281.1SthorpejZ_AS=		library
1291.1Sthorpej.include "${S}/lib/libz/Makefile.inc"
1301.1SthorpejLIBZ=		${ZLIB}
1311.1Sthorpej
1321.1Sthorpej### find out what to use for libsa
1331.1SthorpejSA_AS=		library
1341.26SsimonbSAMISCMAKEFLAGS+=SA_USE_LOADFILE=yes
1351.1Sthorpej.include "${S}/lib/libsa/Makefile.inc"
1361.1SthorpejLIBSA=		${SALIB}
137