Makefile.bootprogs revision 1.12
11.12Stsutsui# $NetBSD: Makefile.bootprogs,v 1.12 2014/01/12 15:26:30 tsutsui Exp $
21.4Slukem
31.8Sjoerg.include <bsd.own.mk>
41.11Smatt.include <bsd.klinks.mk>
51.4Slukem.include <bsd.sys.mk>		# for HOST_SH
61.1Scgd
71.1ScgdS=	${.CURDIR}/../../../..
81.1Scgd
91.1Scgd.PATH:	${.CURDIR}/../common
101.1Scgd
111.1ScgdSTRIPFLAG=
121.1ScgdBINMODE= 444
131.3Ssimonb
141.3Ssimonb# XXX SHOULD NOT NEED TO DEFINE THESE!
151.3SsimonbLIBCRT0=
161.12StsutsuiLIBCRTI=
171.3SsimonbLIBC=
181.3SsimonbLIBCRTBEGIN=
191.3SsimonbLIBCRTEND=
201.1Scgd
211.1ScgdSTRIP?=	strip
221.1Scgd
231.4SlukemCHECKSIZE_CMD=	SIZE=${SIZE} ${HOST_SH} ${.CURDIR}/../common/checksize.sh
241.1Scgd
251.9SmattAFLAGS+=	-DASSEMBLER -D_LOCORE -mno-abicalls -mips64
261.1Scgd# -I${.CURDIR}/../.. done by Makefile.inc
271.1ScgdCPPFLAGS+=	-nostdinc -I${.OBJDIR} -D_STANDALONE -I${S}
281.2ScgdCFLAGS=		-Os -g -ffreestanding -mno-abicalls -msoft-float -G 0
291.9SmattCFLAGS+=	-mips64
301.7StsutsuiCFLAGS+=	-Werror ${CWARNFLAGS}
311.1Scgd
321.4SlukemNETBSD_VERS!=${HOST_SH} ${.CURDIR}/../../../../conf/osrelease.sh
331.1ScgdCPPFLAGS+= -DNETBSD_VERS='"${NETBSD_VERS}"'
341.1Scgd
351.1ScgdCWARNFLAGS+=	-Wno-main 
361.7StsutsuiCWARNFLAGS+=	-Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
371.7StsutsuiCWARNFLAGS+=	-Wno-pointer-sign
381.1Scgd
391.1Scgd# if there is a 'version' file, add rule for vers.c and add it to SRCS
401.1Scgd# and CLEANFILES
411.1Scgd.if exists(version)
421.1Scgd.PHONY: vers.c
431.1Scgdvers.c: version
441.8Sjoerg	${HOST_SH} ${S}/conf/newvers_stand.sh ${${MKREPRO} == "yes" :?:-D} \
451.8Sjoerg	    -N ${.CURDIR}/version "sbmips"
461.1Scgd
471.1ScgdSRCS+=	vers.c
481.1ScgdCLEANFILES+= vers.c
491.1Scgd.endif
501.1Scgd
511.1Scgd# 
521.1Scgd# Refer to CFE documentation for a description of these regions.
531.1Scgd# 
541.1Scgd
551.1ScgdREGION1_START=		0x20000000		# "Region 1 start"
561.1ScgdREGION1_SIZE!=		expr 256 \* 1024	# 256k
571.1Scgd
581.10SmattLDSCRIPT=		${.CURDIR}/../common/boot.ldscript
591.10Smatt
601.1Scgd# our memory lauout:
611.1Scgd
621.1Scgd#	'unified' boot loaders (e.g. netboot) can consume all of region
631.1Scgd#	1 for their text+data, or text+data+bss.
641.1Scgd
651.1ScgdUNIFIED_LOAD_ADDRESS=	${REGION1_START}
661.1ScgdUNIFIED_MAX_LOAD!=	expr ${REGION1_SIZE}
671.1ScgdUNIFIED_MAX_TOTAL!=	expr ${REGION1_SIZE}
681.1Scgd
691.1Scgd#UNIFIED_HEAP_START=	right after secondary bss
701.1ScgdUNIFIED_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
711.1Scgd
721.1Scgd#	two-stage boot loaders must share region 1.  The first stage
731.1Scgd#	loads into the lowest portion, and uses the higest portion
741.1Scgd#	for its heap.  The second stage loads in between the primary image
751.1Scgd#	and the heap, and can reuse the memory after it (i.e. the primary's
761.1Scgd#	heap) for its own heap.
771.1Scgd
781.1ScgdPRIMARY_LOAD_ADDRESS=	${REGION1_START}
791.1Scgd#PRIMARY_MAX_LOAD=	booter dependent, no more than ${PRIMARY_MAX_TOTAL}
801.1ScgdPRIMARY_MAX_TOTAL!=	expr 16 \* 1024
811.1Scgd
821.1Scgd# XXX SECONDARY_LOAD_ADDRESS should be
831.1Scgd# XXX (${PRIMARY_LOAD_ADDRESS} + ${PRIMARY_MAX_TOTAL}) bt there's no easy
841.1Scgd# XXX way to do that calculation and 'ld' wants a single number.
851.1ScgdSECONDARY_LOAD_ADDRESS=	0x20004000	# XXX
861.1ScgdSECONDARY_MAX_LOAD!=	expr 112 \* 1024
871.1ScgdSECONDARY_MAX_TOTAL!=	expr ${REGION1_SIZE} - ${PRIMARY_MAX_TOTAL}
881.1Scgd
891.1ScgdPRIMARY_HEAP_START=	(${SECONDARY_LOAD_ADDRESS} + ${SECONDARY_MAX_LOAD})
901.1ScgdPRIMARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
911.1Scgd
921.1Scgd#SECONDARY_HEAP_START=	right after secondary bss
931.1ScgdSECONDARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
941.1Scgd
951.1Scgd#	standalone programs are like kernels.  They load at
961.1Scgd#	0xfffffc0000300000 and can use the rest of memory.
971.1Scgd
981.1ScgdSTANDPROG_LOAD_ADDRESS=	0xfffffc0000300000
991.1Scgd
1001.1Scgd
1011.9SmattFILE_FORMAT_CPPFLAGS=	-DBOOT_ELF
1021.1Scgd
1031.1ScgdUNIFIED_CPPFLAGS=	-DUNIFIED_BOOTBLOCK \
1041.1Scgd			-DHEAP_LIMIT="${UNIFIED_HEAP_LIMIT}" \
1051.1Scgd			${FILE_FORMAT_CPPFLAGS}
1061.1Scgd
1071.1ScgdPRIMARY_CPPFLAGS=	-DPRIMARY_BOOTBLOCK \
1081.1Scgd			-DSECONDARY_LOAD_ADDRESS="${SECONDARY_LOAD_ADDRESS}" \
1091.1Scgd			-DSECONDARY_MAX_LOAD="${SECONDARY_MAX_LOAD}" \
1101.1Scgd			-DHEAP_LIMIT="${PRIMARY_HEAP_LIMIT}" \
1111.1Scgd			-DHEAP_START="${PRIMARY_HEAP_START}"
1121.1Scgd
1131.1ScgdSECONDARY_CPPFLAGS=	-DSECONDARY_BOOTBLOCK \
1141.1Scgd			-DHEAP_LIMIT="${SECONDARY_HEAP_LIMIT}" \
1151.1Scgd			${FILE_FORMAT_CPPFLAGS}
1161.1Scgd
1171.1ScgdSTANDPROG_CPPFLAGS=	-DSTANDALONE_PROGRAM
1181.1Scgd
1191.1Scgd.include <bsd.prog.mk>
1201.1Scgd
1211.1Scgd### find out what to use for libkern
1221.1ScgdKERN_AS=	library
1231.1Scgd.include "${S}/lib/libkern/Makefile.inc"
1241.1ScgdLIBKERN=	${KERNLIB}
1251.1Scgd
1261.1Scgd### find out what to use for libz
1271.1ScgdZ_AS=		library
1281.1Scgd.include "${S}/lib/libz/Makefile.inc"
1291.1ScgdLIBZ=		${ZLIB}
1301.1Scgd
1311.1Scgd### find out what to use for libsa
1321.1ScgdSA_AS=		library
1331.1ScgdSAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
1341.1Scgd.include "${S}/lib/libsa/Makefile.inc"
1351.1ScgdLIBSA=		${SALIB}
1361.1Scgd
1371.1Scgd/usr/lib/crt0.o:
1381.1Scgd	true
1391.1Scgd
1401.1Scgd/usr/lib/crtbegin.o:
1411.1Scgd	true
1421.1Scgd
1431.1Scgd/usr/lib/crtend.o:
1441.1Scgd	true
1451.1Scgd
1461.9Smattcleandir: .WAIT cleandirlocal
1471.1Scgdcleandirlocal:
1481.5Sjmc	-rm -rf lib
149