Makefile.bootprogs revision 1.35
11.35Sjklos# $NetBSD: Makefile.bootprogs,v 1.35 2016/01/20 12:49:21 jklos Exp $
21.32Sjoerg
31.32SjoergNOMAN=			# defined
41.24Slukem
51.31Sjoerg.include <bsd.own.mk>
61.1Sthorpej
71.1SthorpejS=	${.CURDIR}/../../../..
81.1Sthorpej
91.1Sthorpej.PATH:	${.CURDIR}/../common
101.1Sthorpej
111.1SthorpejBINMODE= 444
121.1Sthorpej
131.17StsutsuiSTRIP?=	strip
141.23Ssimonb
151.23Ssimonb# XXX SHOULD NOT NEED TO DEFINE THESE!
161.23SsimonbLIBCRT0=
171.33StsutsuiLIBCRTI=
181.23SsimonbLIBC=
191.23SsimonbLIBCRTBEGIN=
201.23SsimonbLIBCRTEND=
211.1Sthorpej
221.24SlukemCHECKSIZE_CMD=	SIZE=${SIZE} ${HOST_SH} ${.CURDIR}/../common/checksize.sh
231.8Scgd
241.29Stsutsuirealall: ${PROG}
251.1Sthorpej
261.10ScgdAFLAGS+=	-DASSEMBLER
271.10Scgd# -I${.CURDIR}/../.. done by Makefile.inc
281.10ScgdCPPFLAGS+=	-nostdinc -I${.OBJDIR} -D_STANDALONE -I${S}
291.21SthorpejCFLAGS=		-ffreestanding -mno-fp-regs -g
301.12Scgd
311.24SlukemNETBSD_VERS!=${HOST_SH} ${.CURDIR}/../../../../conf/osrelease.sh
321.12ScgdCPPFLAGS+= -DNETBSD_VERS='"${NETBSD_VERS}"'
331.10Scgd
341.28StsutsuiCWARNFLAGS+=	-Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
351.28StsutsuiCFLAGS+=	-Werror ${CWARNFLAGS}
361.18Sjdolecek
371.18Sjdolecek# if there is a 'version' file, add rule for vers.c and add it to SRCS
381.18Sjdolecek# and CLEANFILES
391.18Sjdolecek.if exists(version)
401.18Sjdolecek.PHONY: vers.c
411.18Sjdolecekvers.c: version
421.31Sjoerg	${HOST_SH} ${S}/conf/newvers_stand.sh ${${MKREPRO} == "yes" :?:-D} \
431.31Sjoerg	    -N ${.CURDIR}/version "alpha"
441.18Sjdolecek
451.18SjdolecekSRCS+=	vers.c
461.18SjdolecekCLEANFILES+= vers.c
471.10Scgd.endif
481.1Sthorpej
491.1Sthorpej# For descriptions of regions available to bootstrap programs, see
501.1Sthorpej# section 3.4.1.2 (pp. III 3-14 - III 3-18) of the second edition of
511.1Sthorpej# the Alpha AXP Architecture Reference Manual.
521.1Sthorpej
531.8ScgdREGION1_START=		0x20000000		# "Region 1 start"
541.8ScgdREGION1_SIZE!=		expr 256 \* 1024	# 256k
551.8Scgd
561.8Scgd# our memory lauout:
571.8Scgd
581.8Scgd#	'unified' boot loaders (e.g. netboot) can consume all of region
591.8Scgd#	1 for their text+data, or text+data+bss.
601.8Scgd
611.8ScgdUNIFIED_LOAD_ADDRESS=	${REGION1_START}
621.8ScgdUNIFIED_MAX_LOAD!=	expr ${REGION1_SIZE}
631.8ScgdUNIFIED_MAX_TOTAL!=	expr ${REGION1_SIZE}
641.8Scgd
651.8Scgd#UNIFIED_HEAP_START=	right after secondary bss
661.8ScgdUNIFIED_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
671.8Scgd
681.8Scgd#	two-stage boot loaders must share region 1.  The first stage
691.8Scgd#	loads into the lowest portion, and uses the higest portion
701.8Scgd#	for its heap.  The second stage loads in between the primary image
711.8Scgd#	and the heap, and can reuse the memory after it (i.e. the primary's
721.8Scgd#	heap) for its own heap.
731.8Scgd
741.8ScgdPRIMARY_LOAD_ADDRESS=	${REGION1_START}
751.8Scgd#PRIMARY_MAX_LOAD=	booter dependent, no more than ${PRIMARY_MAX_TOTAL}
761.8ScgdPRIMARY_MAX_TOTAL!=	expr 16 \* 1024
771.8Scgd
781.8Scgd# XXX SECONDARY_LOAD_ADDRESS should be
791.8Scgd# XXX (${PRIMARY_LOAD_ADDRESS} + ${PRIMARY_MAX_TOTAL}) bt there's no easy
801.8Scgd# XXX way to do that calculation and 'ld' wants a single number.
811.8ScgdSECONDARY_LOAD_ADDRESS=	0x20004000	# XXX
821.8ScgdSECONDARY_MAX_LOAD!=	expr 112 \* 1024
831.8ScgdSECONDARY_MAX_TOTAL!=	expr ${REGION1_SIZE} - ${PRIMARY_MAX_TOTAL}
841.8Scgd
851.8ScgdPRIMARY_HEAP_START=	(${SECONDARY_LOAD_ADDRESS} + ${SECONDARY_MAX_LOAD})
861.8ScgdPRIMARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
871.8Scgd
881.8Scgd#SECONDARY_HEAP_START=	right after secondary bss
891.8ScgdSECONDARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
901.1Sthorpej
911.13Scgd#	standalone programs are like kernels.  They load at
921.35Sjklos#	0xfffffc0000800000 and can use the rest of memory.
931.13Scgd
941.35SjklosSTANDPROG_LOAD_ADDRESS=	0xfffffc0000800000
951.13Scgd
961.13Scgd
971.19SthorpejFILE_FORMAT_CPPFLAGS=	-DBOOT_ECOFF -DBOOT_ELF64
981.1Sthorpej
991.8ScgdUNIFIED_CPPFLAGS=	-DUNIFIED_BOOTBLOCK \
1001.8Scgd			-DHEAP_LIMIT="${UNIFIED_HEAP_LIMIT}" \
1011.9Sross			${FILE_FORMAT_CPPFLAGS}
1021.8Scgd
1031.8ScgdPRIMARY_CPPFLAGS=	-DPRIMARY_BOOTBLOCK \
1041.8Scgd			-DSECONDARY_LOAD_ADDRESS="${SECONDARY_LOAD_ADDRESS}" \
1051.8Scgd			-DSECONDARY_MAX_LOAD="${SECONDARY_MAX_LOAD}" \
1061.8Scgd			-DHEAP_LIMIT="${PRIMARY_HEAP_LIMIT}" \
1071.8Scgd			-DHEAP_START="${PRIMARY_HEAP_START}"
1081.8Scgd
1091.8ScgdSECONDARY_CPPFLAGS=	-DSECONDARY_BOOTBLOCK \
1101.8Scgd			-DHEAP_LIMIT="${SECONDARY_HEAP_LIMIT}" \
1111.9Sross			${FILE_FORMAT_CPPFLAGS}
1121.13Scgd
1131.13ScgdSTANDPROG_CPPFLAGS=	-DSTANDALONE_PROGRAM
1141.8Scgd
1151.1Sthorpej.include <bsd.prog.mk>
1161.29Stsutsui.include <bsd.klinks.mk>
1171.20Slukem
1181.30StsutsuiSTRIPFLAG=	# override values in ${MAKECONF}
1191.20SlukemCOPTS+=-Os	# override -O supplied by user
1201.1Sthorpej
1211.1Sthorpej### find out what to use for libkern
1221.1SthorpejKERN_AS=	library
1231.1Sthorpej.include "${S}/lib/libkern/Makefile.inc"
1241.1SthorpejLIBKERN=	${KERNLIB}
1251.1Sthorpej
1261.1Sthorpej### find out what to use for libz
1271.1SthorpejZ_AS=		library
1281.1Sthorpej.include "${S}/lib/libz/Makefile.inc"
1291.1SthorpejLIBZ=		${ZLIB}
1301.1Sthorpej
1311.1Sthorpej### find out what to use for libsa
1321.1SthorpejSA_AS=		library
1331.26SsimonbSAMISCMAKEFLAGS+=SA_USE_LOADFILE=yes
1341.1Sthorpej.include "${S}/lib/libsa/Makefile.inc"
1351.1SthorpejLIBSA=		${SALIB}
136