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