Change abuild ROM_IMAGE_SIZE to match the standard s_c_fam10 Config.lb.
[coreboot.git] / src / config / Config.lb
1 ## This is Architecture independant part of the makefile
2
3 uses HAVE_OPTION_TABLE
4 uses CONFIG_AP_CODE_IN_CAR
5
6 makedefine CPP:= $(CC) -x assembler-with-cpp -DASSEMBLY -E
7 makedefine LIBGCC_FILE_NAME := $(shell $(CC) -print-libgcc-file-name)
8 makedefine GCC_INC_DIR := $(shell LC_ALL=C $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
9
10 makedefine CPPFLAGS := -I$(TOP)/src/include -I$(TOP)/src/arch/$(ARCH)/include -I$(GCC_INC_DIR) $(CPUFLAGS)
11 makedefine CFLAGS := $(CPU_OPT) $(DISTRO_CFLAGS) $(CPPFLAGS) -Os -nostdinc -nostdlib -fno-builtin  -Wall
12
13 makedefine HOSTCFLAGS:= -Os -Wall
14
15 makerule ldscript.ld   
16         depends "ldoptions $(LDSUBSCRIPTS-1)" 
17         action  "echo '/*ldoptions*/' > $@; cat ldoptions >> $@ ; for file in $(LDSUBSCRIPTS-1) ; do echo /\* $$file \*/ >> $@; cat $$file >> $@ ; done"
18 end
19
20 #makerule cpuflags   
21 #       depends "Makefile.settings" 
22 #       action  "perl -e 'print \"CPUFLAGS :=\n\"; foreach $$var (split(\" \", $$ENV{VARIABLES})) { if (exists($$ENV{$$var})) { print \"CPUFLAGS += -D$$var\" . (length($$ENV{$$var})?\"=\x27$$ENV{$$var}\x27\":\"\") .\"\n\"} else { print \"CPUFLAGS += -U$$var\n\"} }' > $@"
23 #end
24
25 #makerule ldoptions   
26 #       depends "Makefile.settings" 
27 #       action  "perl -e 'foreach $$var (split(\" \", $$ENV{VARIABLES})) { if ($$ENV{$$var} =~ m/^(0x[0-9a-fA-F]+|0[0-7]+|[0-9]+)$$/) { print \"$$var = $$ENV{$$var};\n\"; }}' > $@"
28 #end
29
30 makerule coreboot.strip  
31         depends "coreboot" 
32         action  "$(OBJCOPY) -O binary coreboot coreboot.strip"
33 end
34
35 makerule coreboot.a
36         depends "$(OBJECTS)"
37         action  "rm -f coreboot.a"
38         action  "$(CROSS_COMPILE)ar cr coreboot.a $(OBJECTS)"
39 end
40
41
42 makerule coreboot_ram.o
43         depends "$(DRIVER) coreboot.a $(LIBGCC_FILE_NAME)" 
44         action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -r -o $@ c_start.o $(DRIVER) coreboot.a $(LIBGCC_FILE_NAME)"
45 end
46
47 makerule coreboot_ram
48         depends "coreboot_ram.o $(TOP)/src/config/coreboot_ram.ld ldoptions" 
49         action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/coreboot_ram.ld coreboot_ram.o"
50         action  "$(CROSS_COMPILE)nm -n coreboot_ram | sort > coreboot_ram.map"
51 end
52
53 ##
54 ## By default compress the part of coreboot that runs from RAM
55 ##
56 makedefine COREBOOT_RAM-$(CONFIG_COMPRESS):=coreboot_ram.nrv2b
57 makedefine COREBOOT_RAM-$(CONFIG_UNCOMPRESSED):=coreboot_ram.bin
58
59 makerule coreboot_ram.bin 
60         depends "coreboot_ram" 
61         action  "$(OBJCOPY) -O binary $< $@"
62 end
63
64 makerule coreboot_ram.nrv2b 
65         depends "coreboot_ram.bin nrv2b" 
66         action  "./nrv2b e $< $@"
67 end
68
69 makerule coreboot_ram.rom
70         depends "$(COREBOOT_RAM-1)" 
71         action  "cp $(COREBOOT_RAM-1) coreboot_ram.rom"
72 end
73
74 makedefine COREBOOT_APC:=
75
76 if CONFIG_AP_CODE_IN_CAR
77         #for ap code in cache
78
79         makerule coreboot_apc.a
80                 depends "apc_auto.o"
81                 action  "rm -f coreboot_apc.a"
82                 action  "$(CROSS_COMPILE)ar cr coreboot_apc.a apc_auto.o"
83         end
84
85         makerule coreboot_apc.o
86                 depends "coreboot_apc.a c_start.o $(LIBGCC_FILE_NAME)"
87         action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -r -o $@ c_start.o coreboot_apc.a $(LIBGCC_FILE_NAME)"
88         end
89
90         makerule coreboot_apc
91                 depends "coreboot_apc.o $(TOP)/src/config/coreboot_apc.ld ldoptions"
92                 action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/coreboot_apc.ld coreboot_apc.o"
93                 action  "$(CROSS_COMPILE)nm -n coreboot_apc | sort > coreboot_apc.map"
94         end
95
96         ##
97         ## By default compress the part of coreboot that runs from cache as ram
98         ##
99         makedefine COREBOOT_APC-$(CONFIG_COMPRESS):=coreboot_apc.nrv2b
100         makedefine COREBOOT_APC-$(CONFIG_UNCOMPRESSED):=coreboot_apc.bin
101
102         makerule coreboot_apc.bin
103                 depends "coreboot_apc"
104                 action  "$(OBJCOPY) -O binary $< $@"
105         end
106
107         makerule coreboot_apc.nrv2b
108         depends "coreboot_apc.bin nrv2b"
109         action  "./nrv2b e $< $@"
110         end
111
112         makerule coreboot_apc.rom
113                 depends "$(COREBOOT_APC-1)"
114                 action  "cp $(COREBOOT_APC-1) coreboot_apc.rom"
115         end
116
117         makedefine COREBOOT_APC:=coreboot_apc.rom
118
119 end
120
121 makedefine COREBOOT_RAM_ROM:=coreboot_ram.rom
122
123 makerule coreboot   
124         depends "crt0.o $(INIT-OBJECTS) $(COREBOOT_APC) $(COREBOOT_RAM_ROM) ldscript.ld"
125         action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T ldscript.ld crt0.o $(INIT-OBJECTS)"
126         action  "$(CROSS_COMPILE)nm -n coreboot | sort > coreboot.map"
127 end
128
129 #makerule crt0.S   
130 #       depends "$(CRT0)" 
131 #       action          "cp $< $@"
132 #end
133
134 # the buildrom tool
135 makerule buildrom 
136         depends "$(TOP)/util/buildrom/buildrom.c" 
137         action  "$(HOSTCC) -o $@ $<"
138 end
139
140 # Force crt0.s (which has build time version code in it to rebuild every time)
141 makedefine .PHONY : crt0.s
142 makerule crt0.s   
143         depends "crt0.S $(CRT0_INCLUDES)" 
144         action  "@echo \"$(CPP) ... $< > $@ \""
145         action  "$(CPP) $(CPPFLAGS) -I. -I$(TOP)/src  $< > $@.new && mv $@.new $@"
146 end
147
148 makerule crt0.o  
149         depends "crt0.s" 
150         action  "@echo $(CC) ... -o $@ $<"
151         action  "@$(CC) -c $(CPU_OPT) -o $@ $<"
152 end
153
154 makerule etags   
155         depends "$(SOURCES)" 
156         action  "etags $(SOURCES)"
157 end
158 makerule tags   
159         depends "$(SOURCES)" 
160         action  "ctags $(SOURCES)"
161 end
162 makerule corebootDoc.config
163         depends "$(TOP)/src/config/corebootDoc.config" 
164         action "cat $(TOP)/src/config/corebootDoc.config > corebootDoc.config"
165         action "echo 'INPUT=$(SOURCES)' >> corebootDoc.config"
166 end
167 makerule documentation   
168         depends "corebootDoc.config"
169         action  "doxygen corebootDoc.config"
170 end
171
172 makerule ./romcc   
173         depends "$(TOP)/util/romcc/romcc.c" 
174         action  "$(HOSTCC) -g $(HOSTCFLAGS) $< -o $@"
175 end
176
177 makerule build_opt_tbl   
178         depends "$(TOP)/util/options/build_opt_tbl.c $(TOP)/src/include/pc80/mc146818rtc.h $(TOP)/src/include/boot/coreboot_tables.h Makefile.settings Makefile"
179         action  "$(HOSTCC) $(HOSTCFLAGS) $(CPUFLAGS) $< -o $@" 
180 end
181
182 #makerule /$(TARGET_DIR)/option_table.c
183 #       depends "build_opt_tbl $(MAINBOARD)/cmos.layout" 
184 #       action  "./build_opt_tbl -b  --config $(MAINBOARD)/cmos.layout"
185 #end
186
187 makerule option_table.c
188         depends "build_opt_tbl $(MAINBOARD)/cmos.layout" 
189         action  "./build_opt_tbl -b  --config $(MAINBOARD)/cmos.layout --header option_table.h"
190 end
191
192 makerule option_table.h
193         depends "build_opt_tbl $(MAINBOARD)/cmos.layout" 
194         action  "./build_opt_tbl -b  --config $(MAINBOARD)/cmos.layout --header option_table.h"
195 end
196
197 if HAVE_OPTION_TABLE
198 object ./option_table.o 
199 #special rule
200 #makerule option_table.o 
201 #       depends "option_table.c" 
202 #       action  "$(CC) -c $(CFLAGS) -o $@ $<"
203 #end
204 # object option_table.o 
205 end
206
207 makerule clean  
208         action  "rm -f coreboot.* *~"
209         action  "rm -f coreboot"
210         action  "rm -f ldscript.ld"
211         action  "rm -f a.out *.s *.l *.o *.E *.inc"
212         action  "rm -f TAGS tags romcc*"
213         action  "rm -f docipl buildrom* chips.c *chip.c coreboot_apc* coreboot_ram* coreboot_pay*"
214         action  "rm -f build_opt_tbl* nrv2b* option_table.c crt0.S"
215 end
216
217 # do standard config files that the user need not specify
218 # for now, this is just 'lib', but it may be more later. 
219 dir /lib
220 dir /console
221 dir /stream
222 dir /devices
223 dir /pc80
224 dir /boot