20090819-2-trim-down-cbfs:
[coreboot.git] / src / arch / i386 / Config.lb
1 uses CONFIG_CBFS
2 uses CONFIG_SMP
3 uses CONFIG_PRECOMPRESSED_PAYLOAD
4 uses CONFIG_USE_INIT
5 uses CONFIG_HAVE_FAILOVER_BOOT
6 uses CONFIG_USE_FAILOVER_IMAGE
7 uses CONFIG_USE_FALLBACK_IMAGE
8 uses CONFIG_CBFS
9
10 init init/crt0.S.lb
11
12 if CONFIG_CBFS
13         if CONFIG_USE_FAILOVER_IMAGE
14         else
15                 initobject /src/lib/cbfs.o
16                 initobject /src/lib/lzma.o
17         end
18 end
19
20 if CONFIG_HAVE_FAILOVER_BOOT
21         if CONFIG_USE_FAILOVER_IMAGE
22                 ldscript init/ldscript_failover.lb
23         else
24                 if CONFIG_CBFS
25                         ldscript init/ldscript_cbfs.lb
26                 else
27                         ldscript init/ldscript.lb
28                 end
29         end
30 else
31         if CONFIG_CBFS
32                 if CONFIG_USE_FALLBACK_IMAGE
33                         ldscript init/ldscript_fallback_cbfs.lb
34                 else
35                         ldscript init/ldscript_cbfs.lb
36                 end
37         else
38                 if CONFIG_USE_FALLBACK_IMAGE
39                         ldscript init/ldscript_fallback.lb
40                 else
41                         ldscript init/ldscript.lb
42                 end
43         end
44 end
45
46 makerule all
47         depends "coreboot.rom"
48 end
49
50 makerule floppy 
51         depends "all" 
52         action  "mcopy -o coreboot.rom a:"
53 end
54
55 makerule nrv2b 
56         depends "$(TOP)/util/nrv2b/nrv2b.c"
57         action  "$(HOSTCC) -O2 -DENCODE -DDECODE -DMAIN -DVERBOSE -DNDEBUG -DBITSIZE=32 -DENDIAN=0 $< -o $@"
58 end
59
60 makerule payload
61         depends "$(PAYLOAD)"
62         action  "cp $< $@"
63 end
64
65 makerule payload.nrv2b
66         depends "$(PAYLOAD) nrv2b"
67         action  "./nrv2b e $(PAYLOAD) $@"
68 end
69
70 # unlike nrv2b, lzma is a huge build mess. If they want lzma, they have to have built it
71 makerule payload.lzma
72         depends "$(PAYLOAD) "
73         action  "lzma -zc $(PAYLOAD) > $@ || lzma e $(PAYLOAD) $@"
74 end
75
76
77 # this one example shows the mess that has occurred. People are now mixing
78 # conditional if in the make style with if in the config language style. 
79 # The -1 is linux standard. 
80 # I don't much like it but it is the mode nowadays. So coreboot will change
81 # what a mess. -- RGM
82 # catch the case where there is no compression
83 makedefine PAYLOAD-1:=payload
84
85 if CONFIG_CBFS
86 else
87 # match the case where a compression type is specified.
88 makedefine PAYLOAD-$(CONFIG_COMPRESSED_PAYLOAD_NRV2B):=payload.nrv2b
89 makedefine PAYLOAD-$(CONFIG_COMPRESSED_PAYLOAD_LZMA):=payload.lzma
90 end
91
92 # catch the case where there is precompression. Yes, this bites. 
93 if CONFIG_PRECOMPRESSED_PAYLOAD 
94         makedefine PAYLOAD-1:=payload
95 end
96
97 if CONFIG_USE_FAILOVER_IMAGE
98         makedefine COREBOOT_APC:=
99         makedefine COREBOOT_RAM_ROM:=
100
101         makerule coreboot.rom 
102                 depends "coreboot.strip" 
103                 action "cp $< $@"
104         end
105 else
106         makerule coreboot.rom 
107                 depends "coreboot.strip buildrom $(PAYLOAD-1)"
108                 action "PAYLOAD=$(PAYLOAD-1); if [ $(CONFIG_CBFS) -eq 1 ]; then PAYLOAD=/dev/null; touch cbfs-support; fi; ./buildrom $< $@ $$PAYLOAD $(CONFIG_ROM_IMAGE_SIZE) $(CONFIG_ROM_SECTION_SIZE)"
109                 action "if [ $(CONFIG_COMPRESSED_PAYLOAD_LZMA) -eq 1 -a $(CONFIG_CBFS) -eq 1 ]; then echo l > cbfs-support; fi"
110         end
111 end
112
113 makerule crt0.S
114         depends "$(CONFIG_CRT0)"
115         action  "cp $< $@"
116 end
117
118 addaction clean "rm -f romimage payload.*"
119
120 if CONFIG_USE_INIT
121         makerule init.o
122                 depends "$(INIT-OBJECTS)"
123                 action  "$(LD) -melf_i386 -r -o init.pre.o $(INIT-OBJECTS)"
124                 action  "$(CONFIG_OBJCOPY) --rename-section .text=.init.text --rename-section .data=.init.data --rename-section .rodata=.init.rodata --rename-section .rodata.str1.1=.init.rodata.str1.1 init.pre.o init.o"
125         end
126
127         makerule coreboot   
128                 depends "crt0.o init.o $(COREBOOT_APC) $(COREBOOT_RAM_ROM) ldscript.ld"
129                 action  "$(CC) -nostdlib -nostartfiles -static -o $@ -T ldscript.ld crt0.o init.o"
130                 action  "$(CONFIG_CROSS_COMPILE)nm -n coreboot | sort > coreboot.map"
131         end
132
133 end
134
135 dir lib
136 dir boot
137 if CONFIG_SMP
138         dir smp
139 end