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