70fc96de4174a55b3aa3ec86131cc26c3b34d10e
[coreboot.git] / src / config / Config.lb
1 ## This is Architecture independant part of the makefile
2
3 uses HAVE_OPTION_TABLE
4
5 makedefine CPP:= $(CC) -x assembler-with-cpp -DASSEMBLY -E
6 makedefine LIBGCC_FILE_NAME := $(shell $(CC) -print-libgcc-file-name)
7 makedefine GCC_INC_DIR := $(shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
8
9 makedefine CPPFLAGS := -I$(TOP)/src/include -I$(TOP)/src/arch/$(ARCH)/include -I$(GCC_INC_DIR) $(CPUFLAGS)
10 makedefine CFLAGS := $(CPU_OPT) $(CPPFLAGS) -Os -nostdinc -nostdlib -fno-builtin  -Wall
11
12 makedefine HOSTCFLAGS:= -Os -Wall
13
14 makerule ldscript.ld   
15         depends "ldoptions $(LDSUBSCRIPTS-1)" 
16         action  "echo \"INCLUDE ldoptions\" > $@ ; for file in $(LDSUBSCRIPTS-1) ; do echo \"INCLUDE $$file\" >> $@ ; done"
17 end
18
19 #makerule cpuflags   
20 #       depends "Makefile.settings" 
21 #       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\"} }' > $@"
22 #end
23
24 #makerule ldoptions   
25 #       depends "Makefile.settings" 
26 #       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\"; }}' > $@"
27 #end
28
29 makerule linuxbios.strip  
30         depends "linuxbios" 
31         action  "$(OBJCOPY) -O binary linuxbios linuxbios.strip"
32 end
33
34 makerule linuxbios_ram.o
35         depends "$(DRIVER) linuxbios.a $(LIBGCC_FILE_NAME)" 
36         action  "$(CC) -nostdlib -r -o $@ c_start.o $(DRIVER) linuxbios.a $(LIBGCC_FILE_NAME)"
37 end
38
39 makerule linuxbios_ram
40         depends "linuxbios_ram.o $(TOP)/src/config/linuxbios_ram.ld ldoptions" 
41         action  "$(CC) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/linuxbios_ram.ld linuxbios_ram.o"
42         action  "$(CROSS_COMPILE)nm -n linuxbios_ram | sort > linuxbios_ram.map"
43 end
44
45 ##
46 ## By default compress the part of linuxbios that runs from RAM
47 ##
48 makedefine LINUXBIOS_RAM-$(CONFIG_COMPRESS):=linuxbios_ram.nrv2b
49 makedefine LINUXBIOS_RAM-$(CONFIG_UNCOMPRESSED):=linuxbios_ram.bin
50
51 makerule linuxbios_ram.bin 
52         depends "linuxbios_ram" 
53         action  "$(OBJCOPY) -O binary $< $@"
54 end
55
56 makerule linuxbios_ram.nrv2b 
57         depends "linuxbios_ram.bin nrv2b" 
58         action  "./nrv2b e $< $@"
59 end
60
61 makerule linuxbios_ram.rom
62         depends "$(LINUXBIOS_RAM-1)" 
63         action  "cp $(LINUXBIOS_RAM-1) linuxbios_ram.rom"
64 end
65
66 makerule linuxbios   
67         depends "crt0.o $(INIT-OBJECTS) linuxbios_ram.rom ldscript.ld"
68         action  "$(CC) -nostdlib -nostartfiles -static -o $@ -T ldscript.ld crt0.o $(INIT-OBJECTS)"
69         action  "$(CROSS_COMPILE)nm -n linuxbios | sort > linuxbios.map"
70 end
71
72 makerule linuxbios.a   
73         depends "$(OBJECTS)" 
74         action  "rm -f linuxbios.a"
75         action  "ar cr linuxbios.a $(OBJECTS)"
76 end
77
78 #makerule crt0.S   
79 #       depends "$(CRT0)" 
80 #       action          "cp $< $@"
81 #end
82
83 # the buildrom tool
84 makerule buildrom 
85         depends "$(TOP)/util/buildrom/buildrom.c" 
86         action  "$(HOSTCC) -o $@ $<"
87 end
88
89 # Force crt0.s (which has build time version code in it to rebuild every time)
90 makedefine .PHONY : crt0.s
91 makerule crt0.s   
92         depends "crt0.S $(CRT0_INCLUDES)" 
93         action  "@echo \"$(CPP) ... $< > $@ \""
94         action  "$(CPP) $(CPPFLAGS) -I. -I$(TOP)/src  $< > $@.new && mv $@.new $@"
95 end
96
97 makerule crt0.o  
98         depends "crt0.s" 
99         action  "@echo $(CC) ... -o $@ $<"
100         action  "@$(CC) -c $(CPU_OPT) -o $@ $<"
101 end
102
103 makerule etags   
104         depends "$(SOURCES)" 
105         action  "etags $(SOURCES)"
106 end
107 makerule tags   
108         depends "$(SOURCES)" 
109         action  "ctags $(SOURCES)"
110 end
111 makerule documentation   
112         depends "$(SOURCES)" 
113         action  "doxygen LinuxBIOSDoc.config"
114 end
115
116 makerule ./romcc   
117         depends "$(TOP)/util/romcc/romcc.c" 
118         action  "$(HOSTCC) -g $(HOSTCFLAGS) $< -o $@"
119 end
120
121 makerule build_opt_tbl   
122         depends "$(TOP)/util/options/build_opt_tbl.c $(TOP)/src/include/pc80/mc146818rtc.h $(TOP)/src/include/boot/linuxbios_tables.h Makefile.settings Makefile"
123         action  "$(HOSTCC) $(HOSTCFLAGS) $(CPUFLAGS) $< -o $@" 
124 end
125
126 #makerule /$(TARGET_DIR)/option_table.c
127 #       depends "build_opt_tbl $(MAINBOARD)/cmos.layout" 
128 #       action  "./build_opt_tbl -b  --config $(MAINBOARD)/cmos.layout"
129 #end
130
131 makerule option_table.c
132         depends "build_opt_tbl $(MAINBOARD)/cmos.layout" 
133         action  "./build_opt_tbl -b  --config $(MAINBOARD)/cmos.layout --header option_table.h"
134 end
135
136 makerule option_table.h
137         depends "build_opt_tbl $(MAINBOARD)/cmos.layout" 
138         action  "./build_opt_tbl -b  --config $(MAINBOARD)/cmos.layout --header option_table.h"
139 end
140
141 if HAVE_OPTION_TABLE
142 object ./option_table.o 
143 #special rule
144 #makerule option_table.o 
145 #       depends "option_table.c" 
146 #       action  "$(CC) -c $(CFLAGS) -o $@ $<"
147 #end
148 # object option_table.o 
149 end
150
151 makerule clean  
152         action  "rm -f linuxbios.* *~"
153         action  "rm -f linuxbios"
154         action  "rm -f ldscript.ld"
155         action  "rm -f a.out *.s *.l *.o *.E *.inc"
156         action  "rm -f TAGS tags romcc"
157         action  "rm -f docipl buildrom chips.c *chip.c linuxbios_ram* linuxbios_pay*"
158         action  "rm -f build_opt_tbl option_table.c crt0.S"
159 end
160
161 # do standard config files that the user need not specify
162 # for now, this is just 'lib', but it may be more later. 
163 dir /lib
164 dir /console
165 dir /stream
166 dir /devices
167 dir /pc80
168 dir /boot