Makefile.bootprogs revision 1.9
11.9Smatt# $NetBSD: Makefile.bootprogs,v 1.9 2011/02/20 07:47:39 matt Exp $
21.4Slukem
31.8Sjoerg.include <bsd.own.mk>
41.4Slukem.include <bsd.sys.mk>		# for HOST_SH
51.1Scgd
61.1ScgdS=	${.CURDIR}/../../../..
71.1Scgd
81.1Scgd.PATH:	${.CURDIR}/../common
91.1Scgd
101.1ScgdSTRIPFLAG=
111.1ScgdBINMODE= 444
121.3Ssimonb
131.3Ssimonb# XXX SHOULD NOT NEED TO DEFINE THESE!
141.3SsimonbLIBCRT0=
151.3SsimonbLIBC=
161.3SsimonbLIBCRTBEGIN=
171.3SsimonbLIBCRTEND=
181.1Scgd
191.1ScgdSTRIP?=	strip
201.1Scgd
211.4SlukemCHECKSIZE_CMD=	SIZE=${SIZE} ${HOST_SH} ${.CURDIR}/../common/checksize.sh
221.1Scgd
231.1Scgd.PHONY: machine-links
241.9Smattbeforedepend: machine-links .WAIT
251.1Scgd# ${MACHINE} then ${MACHINE_ARCH}
261.1Scgdmachine-links:
271.1Scgd	-rm -f machine && \
281.1Scgd	    ln -s $S/arch/sbmips/include machine
291.1Scgd	-rm -f mips && \
301.1Scgd	    ln -s $S/arch/mips/include mips
311.1ScgdCLEANFILES+=machine mips
321.1Scgd
331.1Scgdrealall: machine-links ${PROG}
341.1Scgd
351.9SmattAFLAGS+=	-DASSEMBLER -D_LOCORE -mno-abicalls -mips64
361.1Scgd# -I${.CURDIR}/../.. done by Makefile.inc
371.1ScgdCPPFLAGS+=	-nostdinc -I${.OBJDIR} -D_STANDALONE -I${S}
381.2ScgdCFLAGS=		-Os -g -ffreestanding -mno-abicalls -msoft-float -G 0
391.9SmattCFLAGS+=	-mips64
401.7StsutsuiCFLAGS+=	-Werror ${CWARNFLAGS}
411.1Scgd
421.4SlukemNETBSD_VERS!=${HOST_SH} ${.CURDIR}/../../../../conf/osrelease.sh
431.1ScgdCPPFLAGS+= -DNETBSD_VERS='"${NETBSD_VERS}"'
441.1Scgd
451.1ScgdCWARNFLAGS+=	-Wno-main 
461.7StsutsuiCWARNFLAGS+=	-Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
471.7StsutsuiCWARNFLAGS+=	-Wno-pointer-sign
481.1Scgd
491.1Scgd# if there is a 'version' file, add rule for vers.c and add it to SRCS
501.1Scgd# and CLEANFILES
511.1Scgd.if exists(version)
521.1Scgd.PHONY: vers.c
531.1Scgdvers.c: version
541.8Sjoerg	${HOST_SH} ${S}/conf/newvers_stand.sh ${${MKREPRO} == "yes" :?:-D} \
551.8Sjoerg	    -N ${.CURDIR}/version "sbmips"
561.1Scgd
571.1ScgdSRCS+=	vers.c
581.1ScgdCLEANFILES+= vers.c
591.1Scgd.endif
601.1Scgd
611.1Scgd# 
621.1Scgd# Refer to CFE documentation for a description of these regions.
631.1Scgd# 
641.1Scgd
651.1ScgdREGION1_START=		0x20000000		# "Region 1 start"
661.1ScgdREGION1_SIZE!=		expr 256 \* 1024	# 256k
671.1Scgd
681.1Scgd# our memory lauout:
691.1Scgd
701.1Scgd#	'unified' boot loaders (e.g. netboot) can consume all of region
711.1Scgd#	1 for their text+data, or text+data+bss.
721.1Scgd
731.1ScgdUNIFIED_LOAD_ADDRESS=	${REGION1_START}
741.1ScgdUNIFIED_MAX_LOAD!=	expr ${REGION1_SIZE}
751.1ScgdUNIFIED_MAX_TOTAL!=	expr ${REGION1_SIZE}
761.1Scgd
771.1Scgd#UNIFIED_HEAP_START=	right after secondary bss
781.1ScgdUNIFIED_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
791.1Scgd
801.1Scgd#	two-stage boot loaders must share region 1.  The first stage
811.1Scgd#	loads into the lowest portion, and uses the higest portion
821.1Scgd#	for its heap.  The second stage loads in between the primary image
831.1Scgd#	and the heap, and can reuse the memory after it (i.e. the primary's
841.1Scgd#	heap) for its own heap.
851.1Scgd
861.1ScgdPRIMARY_LOAD_ADDRESS=	${REGION1_START}
871.1Scgd#PRIMARY_MAX_LOAD=	booter dependent, no more than ${PRIMARY_MAX_TOTAL}
881.1ScgdPRIMARY_MAX_TOTAL!=	expr 16 \* 1024
891.1Scgd
901.1Scgd# XXX SECONDARY_LOAD_ADDRESS should be
911.1Scgd# XXX (${PRIMARY_LOAD_ADDRESS} + ${PRIMARY_MAX_TOTAL}) bt there's no easy
921.1Scgd# XXX way to do that calculation and 'ld' wants a single number.
931.1ScgdSECONDARY_LOAD_ADDRESS=	0x20004000	# XXX
941.1ScgdSECONDARY_MAX_LOAD!=	expr 112 \* 1024
951.1ScgdSECONDARY_MAX_TOTAL!=	expr ${REGION1_SIZE} - ${PRIMARY_MAX_TOTAL}
961.1Scgd
971.1ScgdPRIMARY_HEAP_START=	(${SECONDARY_LOAD_ADDRESS} + ${SECONDARY_MAX_LOAD})
981.1ScgdPRIMARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
991.1Scgd
1001.1Scgd#SECONDARY_HEAP_START=	right after secondary bss
1011.1ScgdSECONDARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
1021.1Scgd
1031.1Scgd#	standalone programs are like kernels.  They load at
1041.1Scgd#	0xfffffc0000300000 and can use the rest of memory.
1051.1Scgd
1061.1ScgdSTANDPROG_LOAD_ADDRESS=	0xfffffc0000300000
1071.1Scgd
1081.1Scgd
1091.9SmattFILE_FORMAT_CPPFLAGS=	-DBOOT_ELF
1101.1Scgd
1111.1ScgdUNIFIED_CPPFLAGS=	-DUNIFIED_BOOTBLOCK \
1121.1Scgd			-DHEAP_LIMIT="${UNIFIED_HEAP_LIMIT}" \
1131.1Scgd			${FILE_FORMAT_CPPFLAGS}
1141.1Scgd
1151.1ScgdPRIMARY_CPPFLAGS=	-DPRIMARY_BOOTBLOCK \
1161.1Scgd			-DSECONDARY_LOAD_ADDRESS="${SECONDARY_LOAD_ADDRESS}" \
1171.1Scgd			-DSECONDARY_MAX_LOAD="${SECONDARY_MAX_LOAD}" \
1181.1Scgd			-DHEAP_LIMIT="${PRIMARY_HEAP_LIMIT}" \
1191.1Scgd			-DHEAP_START="${PRIMARY_HEAP_START}"
1201.1Scgd
1211.1ScgdSECONDARY_CPPFLAGS=	-DSECONDARY_BOOTBLOCK \
1221.1Scgd			-DHEAP_LIMIT="${SECONDARY_HEAP_LIMIT}" \
1231.1Scgd			${FILE_FORMAT_CPPFLAGS}
1241.1Scgd
1251.1ScgdSTANDPROG_CPPFLAGS=	-DSTANDALONE_PROGRAM
1261.1Scgd
1271.1Scgd.include <bsd.prog.mk>
1281.1Scgd
1291.1Scgd### find out what to use for libkern
1301.1ScgdKERN_AS=	library
1311.1Scgd.include "${S}/lib/libkern/Makefile.inc"
1321.1ScgdLIBKERN=	${KERNLIB}
1331.1Scgd
1341.1Scgd### find out what to use for libz
1351.1ScgdZ_AS=		library
1361.1Scgd.include "${S}/lib/libz/Makefile.inc"
1371.1ScgdLIBZ=		${ZLIB}
1381.1Scgd
1391.1Scgd### find out what to use for libsa
1401.1ScgdSA_AS=		library
1411.1ScgdSAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
1421.1Scgd.include "${S}/lib/libsa/Makefile.inc"
1431.1ScgdLIBSA=		${SALIB}
1441.1Scgd
1451.1Scgd/usr/lib/crt0.o:
1461.1Scgd	true
1471.1Scgd
1481.1Scgd/usr/lib/crtbegin.o:
1491.1Scgd	true
1501.1Scgd
1511.1Scgd/usr/lib/crtend.o:
1521.1Scgd	true
1531.1Scgd
1541.9Smattcleandir: .WAIT cleandirlocal
1551.1Scgdcleandirlocal:
1561.5Sjmc	-rm -rf lib
157