Makefile.bootprogs revision 1.2
1# $NetBSD: Makefile.bootprogs,v 1.2 2017/07/24 10:34:54 mrg Exp $
2
3.include <bsd.own.mk>
4.include <bsd.klinks.mk>
5
6S=	${.CURDIR}/../../../../..
7COMMON=	${.CURDIR}/../common
8
9.PATH:	${COMMON}
10
11STRIPFLAG=
12BINMODE= 444
13
14# XXX SHOULD NOT NEED TO DEFINE THESE!
15LIBCRT0=
16LIBCRTI=
17LIBC=
18LIBCRTBEGIN=
19LIBCRTEND=
20
21STRIP?=	strip
22
23CHECKSIZE_CMD=	SIZE=${SIZE} ${HOST_SH} ${COMMON}/checksize.sh
24
25AFLAGS+=	-DASSEMBLER -D_LOCORE -mno-abicalls -mips64
26# -I${.CURDIR}/../.. done by Makefile.inc
27CPPFLAGS+=	-nostdinc -I${.OBJDIR} -D_STANDALONE -I${S}
28CFLAGS=		-Os -g -ffreestanding -mno-abicalls -msoft-float -G 0
29CFLAGS+=	-mips64
30CFLAGS+=	-Werror ${CWARNFLAGS}
31
32NETBSD_VERS!=${HOST_SH} ${S}/conf/osrelease.sh
33CPPFLAGS+= -DNETBSD_VERS='"${NETBSD_VERS}"'
34
35CWARNFLAGS+=	-Wno-main 
36CWARNFLAGS+=	-Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
37CWARNFLAGS+=	-Wno-pointer-sign
38
39VERSIONFLAGS+=-n
40.include "${S}/conf/newvers_stand.mk"
41
42# 
43# Refer to CFE documentation for a description of these regions.
44# 
45
46REGION1_START=		0x20000000		# "Region 1 start"
47REGION1_SIZE!=		expr 256 \* 1024	# 256k
48
49LDSCRIPT=		${COMMON}/boot.ldscript
50
51# our memory lauout:
52
53#	'unified' boot loaders (e.g. netboot) can consume all of region
54#	1 for their text+data, or text+data+bss.
55
56UNIFIED_LOAD_ADDRESS=	${REGION1_START}
57UNIFIED_MAX_LOAD!=	expr ${REGION1_SIZE}
58UNIFIED_MAX_TOTAL!=	expr ${REGION1_SIZE}
59
60#UNIFIED_HEAP_START=	right after secondary bss
61UNIFIED_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
62
63#	two-stage boot loaders must share region 1.  The first stage
64#	loads into the lowest portion, and uses the higest portion
65#	for its heap.  The second stage loads in between the primary image
66#	and the heap, and can reuse the memory after it (i.e. the primary's
67#	heap) for its own heap.
68
69PRIMARY_LOAD_ADDRESS=	${REGION1_START}
70#PRIMARY_MAX_LOAD=	booter dependent, no more than ${PRIMARY_MAX_TOTAL}
71PRIMARY_MAX_TOTAL!=	expr 16 \* 1024
72
73# XXX SECONDARY_LOAD_ADDRESS should be
74# XXX (${PRIMARY_LOAD_ADDRESS} + ${PRIMARY_MAX_TOTAL}) bt there's no easy
75# XXX way to do that calculation and 'ld' wants a single number.
76SECONDARY_LOAD_ADDRESS=	0x20004000	# XXX
77SECONDARY_MAX_LOAD!=	expr 112 \* 1024
78SECONDARY_MAX_TOTAL!=	expr ${REGION1_SIZE} - ${PRIMARY_MAX_TOTAL}
79
80PRIMARY_HEAP_START=	(${SECONDARY_LOAD_ADDRESS} + ${SECONDARY_MAX_LOAD})
81PRIMARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
82
83#SECONDARY_HEAP_START=	right after secondary bss
84SECONDARY_HEAP_LIMIT=	(${REGION1_START} + ${REGION1_SIZE})
85
86#	standalone programs are like kernels.  They load at
87#	0xfffffc0000300000 and can use the rest of memory.
88
89STANDPROG_LOAD_ADDRESS=	0xfffffc0000300000
90
91
92FILE_FORMAT_CPPFLAGS=	-DBOOT_ELF
93
94UNIFIED_CPPFLAGS=	-DUNIFIED_BOOTBLOCK \
95			-DHEAP_LIMIT="${UNIFIED_HEAP_LIMIT}" \
96			${FILE_FORMAT_CPPFLAGS}
97
98PRIMARY_CPPFLAGS=	-DPRIMARY_BOOTBLOCK \
99			-DSECONDARY_LOAD_ADDRESS="${SECONDARY_LOAD_ADDRESS}" \
100			-DSECONDARY_MAX_LOAD="${SECONDARY_MAX_LOAD}" \
101			-DHEAP_LIMIT="${PRIMARY_HEAP_LIMIT}" \
102			-DHEAP_START="${PRIMARY_HEAP_START}"
103
104SECONDARY_CPPFLAGS=	-DSECONDARY_BOOTBLOCK \
105			-DHEAP_LIMIT="${SECONDARY_HEAP_LIMIT}" \
106			${FILE_FORMAT_CPPFLAGS}
107
108STANDPROG_CPPFLAGS=	-DSTANDALONE_PROGRAM
109
110.include <bsd.prog.mk>
111
112### find out what to use for libkern
113KERN_AS=	library
114.include "${S}/lib/libkern/Makefile.inc"
115LIBKERN=	${KERNLIB}
116
117### find out what to use for libz
118Z_AS=		library
119.include "${S}/lib/libz/Makefile.inc"
120LIBZ=		${ZLIB}
121
122### find out what to use for libsa
123SA_AS=		library
124SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
125.include "${S}/lib/libsa/Makefile.inc"
126LIBSA=		${SALIB}
127
128/usr/lib/crt0.o:
129	true
130
131/usr/lib/crtbegin.o:
132	true
133
134/usr/lib/crtend.o:
135	true
136
137cleandir: .WAIT cleandirlocal
138cleandirlocal:
139	-rm -rf lib
140