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