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