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