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