f56f53aca393e481dbb09b2dc87515a088a519ce
[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 $(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) $(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 linuxbios.strip  
31         depends "linuxbios" 
32         action  "$(OBJCOPY) -O binary linuxbios linuxbios.strip"
33 end
34
35 makerule linuxbios.a
36         depends "$(OBJECTS)"
37         action  "rm -f linuxbios.a"
38         action  "ar cr linuxbios.a $(OBJECTS)"
39 end
40
41 makerule linuxbios_ram.o
42         depends "$(DRIVER) linuxbios.a $(LIBGCC_FILE_NAME)" 
43         action  "$(CC) -nostdlib -r -o $@ c_start.o $(DRIVER) linuxbios.a $(LIBGCC_FILE_NAME)"
44 end
45
46 makerule linuxbios_ram
47         depends "linuxbios_ram.o $(TOP)/src/config/linuxbios_ram.ld ldoptions" 
48         action  "$(CC) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/linuxbios_ram.ld linuxbios_ram.o"
49         action  "$(CROSS_COMPILE)nm -n linuxbios_ram | sort > linuxbios_ram.map"
50 end
51
52 ##
53 ## By default compress the part of linuxbios that runs from RAM
54 ##
55 makedefine LINUXBIOS_RAM-$(CONFIG_COMPRESS):=linuxbios_ram.nrv2b
56 makedefine LINUXBIOS_RAM-$(CONFIG_UNCOMPRESSED):=linuxbios_ram.bin
57
58 makerule linuxbios_ram.bin 
59         depends "linuxbios_ram" 
60         action  "$(OBJCOPY) -O binary $< $@"
61 end
62
63 makerule linuxbios_ram.nrv2b 
64         depends "linuxbios_ram.bin nrv2b" 
65         action  "./nrv2b e $< $@"
66 end
67
68 makerule linuxbios_ram.rom
69         depends "$(LINUXBIOS_RAM-1)" 
70         action  "cp $(LINUXBIOS_RAM-1) linuxbios_ram.rom"
71 end
72
73 makedefine LINUXBIOS_APC:=
74
75 if CONFIG_AP_CODE_IN_CAR
76         #for ap code in cache
77
78         makerule linuxbios_apc.a
79                 depends "apc_auto.o"
80                 action  "rm -f linuxbios_apc.a"
81                 action  "ar cr linuxbios_apc.a apc_auto.o"
82         end
83
84         makerule linuxbios_apc.o
85                 depends "linuxbios_apc.a c_start.o $(LIBGCC_FILE_NAME)"
86         action  "$(CC) -nostdlib -r -o $@ c_start.o linuxbios_apc.a $(LIBGCC_FILE_NAME)"
87         end
88
89         makerule linuxbios_apc
90                 depends "linuxbios_apc.o $(TOP)/src/config/linuxbios_apc.ld ldoptions"
91                 action  "$(CC) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/linuxbios_apc.ld linuxbios_apc.o"
92                 action  "$(CROSS_COMPILE)nm -n linuxbios_apc | sort > linuxbios_apc.map"
93         end
94
95         ##
96         ## By default compress the part of linuxbios that runs from cache as ram
97         ##
98         makedefine LINUXBIOS_APC-$(CONFIG_COMPRESS):=linuxbios_apc.nrv2b
99         makedefine LINUXBIOS_APC-$(CONFIG_UNCOMPRESSED):=linuxbios_apc.bin
100
101         makerule linuxbios_apc.bin
102                 depends "linuxbios_apc"
103                 action  "$(OBJCOPY) -O binary $< $@"
104         end
105
106         makerule linuxbios_apc.nrv2b
107         depends "linuxbios_apc.bin nrv2b"
108         action  "./nrv2b e $< $@"
109         end
110
111         makerule linuxbios_apc.rom
112                 depends "$(LINUXBIOS_APC-1)"
113                 action  "cp $(LINUXBIOS_APC-1) linuxbios_apc.rom"
114         end
115
116         makedefine LINUXBIOS_APC:=linuxbios_apc.rom
117
118 end
119
120 makedefine LINUXBIOS_RAM_ROM:=linuxbios_ram.rom
121
122 makerule linuxbios   
123         depends "crt0.o $(INIT-OBJECTS) $(LINUXBIOS_APC) $(LINUXBIOS_RAM_ROM) ldscript.ld"
124         action  "$(CC) -nostdlib -nostartfiles -static -o $@ -T ldscript.ld crt0.o $(INIT-OBJECTS)"
125         action  "$(CROSS_COMPILE)nm -n linuxbios | sort > linuxbios.map"
126 end
127
128 #makerule crt0.S   
129 #       depends "$(CRT0)" 
130 #       action          "cp $< $@"
131 #end
132
133 # the buildrom tool
134 makerule buildrom 
135         depends "$(TOP)/util/buildrom/buildrom.c" 
136         action  "$(HOSTCC) -o $@ $<"
137 end
138
139 # Force crt0.s (which has build time version code in it to rebuild every time)
140 makedefine .PHONY : crt0.s
141 makerule crt0.s   
142         depends "crt0.S $(CRT0_INCLUDES)" 
143         action  "@echo \"$(CPP) ... $< > $@ \""
144         action  "$(CPP) $(CPPFLAGS) -I. -I$(TOP)/src  $< > $@.new && mv $@.new $@"
145 end
146
147 makerule crt0.o  
148         depends "crt0.s" 
149         action  "@echo $(CC) ... -o $@ $<"
150         action  "@$(CC) -c $(CPU_OPT) -o $@ $<"
151 end
152
153 makerule etags   
154         depends "$(SOURCES)" 
155         action  "etags $(SOURCES)"
156 end
157 makerule tags   
158         depends "$(SOURCES)" 
159         action  "ctags $(SOURCES)"
160 end
161 makerule LinuxBIOSDoc.config
162         depends "$(TOP)/src/config/LinuxBIOSDoc.config" 
163         action "cat $(TOP)/src/config/LinuxBIOSDoc.config > LinuxBIOSDoc.config"
164         action "echo 'INPUT=$(SOURCES)' >> LinuxBIOSDoc.config"
165 end
166 makerule documentation   
167         depends "LinuxBIOSDoc.config"
168         action  "doxygen LinuxBIOSDoc.config"
169 end
170
171 makerule ./romcc   
172         depends "$(TOP)/util/romcc/romcc.c" 
173         action  "$(HOSTCC) -g $(HOSTCFLAGS) $< -o $@"
174 end
175
176 makerule build_opt_tbl   
177         depends "$(TOP)/util/options/build_opt_tbl.c $(TOP)/src/include/pc80/mc146818rtc.h $(TOP)/src/include/boot/linuxbios_tables.h Makefile.settings Makefile"
178         action  "$(HOSTCC) $(HOSTCFLAGS) $(CPUFLAGS) $< -o $@" 
179 end
180
181 #makerule /$(TARGET_DIR)/option_table.c
182 #       depends "build_opt_tbl $(MAINBOARD)/cmos.layout" 
183 #       action  "./build_opt_tbl -b  --config $(MAINBOARD)/cmos.layout"
184 #end
185
186 makerule option_table.c
187         depends "build_opt_tbl $(MAINBOARD)/cmos.layout" 
188         action  "./build_opt_tbl -b  --config $(MAINBOARD)/cmos.layout --header option_table.h"
189 end
190
191 makerule option_table.h
192         depends "build_opt_tbl $(MAINBOARD)/cmos.layout" 
193         action  "./build_opt_tbl -b  --config $(MAINBOARD)/cmos.layout --header option_table.h"
194 end
195
196 if HAVE_OPTION_TABLE
197 object ./option_table.o 
198 #special rule
199 #makerule option_table.o 
200 #       depends "option_table.c" 
201 #       action  "$(CC) -c $(CFLAGS) -o $@ $<"
202 #end
203 # object option_table.o 
204 end
205
206 makerule clean  
207         action  "rm -f linuxbios.* *~"
208         action  "rm -f linuxbios"
209         action  "rm -f ldscript.ld"
210         action  "rm -f a.out *.s *.l *.o *.E *.inc"
211         action  "rm -f TAGS tags romcc*"
212         action  "rm -f docipl buildrom* chips.c *chip.c linuxbios_apc* linuxbios_ram* linuxbios_pay*"
213         action  "rm -f build_opt_tbl* nrv2b* option_table.c crt0.S"
214 end
215
216 # do standard config files that the user need not specify
217 # for now, this is just 'lib', but it may be more later. 
218 dir /lib
219 dir /console
220 dir /stream
221 dir /devices
222 dir /pc80
223 dir /boot