ee617c9a60b68f3a9bc745ca1d779cd3728183f9
[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) -no-gcc -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 ROMCCPPFLAGS := -D__ROMCC__=0 -D__ROMCC_MINOR__=34
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 \"INCLUDE ldoptions\" > $@ ; for file in $(LDSUBSCRIPTS-1) ; do echo \"INCLUDE $$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_c.o   
36         depends "$(DRIVER) linuxbios.a $(LIBGCC_FILE_NAME)" 
37         action  "$(CC) -nostdlib -r -o $@ c_start.o $(DRIVER) linuxbios.a $(LIBGCC_FILE_NAME)"
38 end
39
40 makerule linuxbios_c  
41         depends "linuxbios_c.o $(TOP)/src/config/linuxbios_c.ld ldoptions" 
42         action  "$(CC) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/linuxbios_c.ld linuxbios_c.o"
43         action  "$(CROSS_COMPILE)nm -n linuxbios_c | sort > linuxbios_c.map"
44 end
45
46 ##
47 ## By default compress the C part of linuxbios
48 ##
49 makedefine LINUXBIOS_PAYLOAD-$(CONFIG_COMPRESS):=linuxbios_payload.nrv2b
50 makedefine LINUXBIOS_PAYLOAD-$(CONFIG_UNCOMPRESSED):=linuxbios_payload.bin
51
52 makerule linuxbios_payload.bin 
53         depends "linuxbios_c" 
54         action  "$(OBJCOPY) -O binary $< $@"
55 end
56
57 makerule linuxbios_payload.nrv2b 
58         depends "linuxbios_payload.bin nrv2b" 
59         action  "./nrv2b e $< $@"
60 end
61
62 makerule linuxbios_payload   
63         depends "$(LINUXBIOS_PAYLOAD-1)" 
64         action  "cp $(LINUXBIOS_PAYLOAD-1) linuxbios_payload"
65 end
66
67 makerule linuxbios   
68         depends "crt0.o linuxbios_payload ldscript.ld" 
69         action  "$(CC) -nostdlib -nostartfiles -static -o $@ -T ldscript.ld crt0.o"
70         action  "$(CROSS_COMPILE)nm -n linuxbios | sort > linuxbios.map"
71 end
72
73 makerule linuxbios.a   
74         depends "$(OBJECTS)" 
75         action  "rm -f linuxbios.a"
76         action  "ar cr linuxbios.a $(OBJECTS)"
77 end
78
79 #makerule crt0.S   
80 #       depends "$(CRT0)" 
81 #       action          "cp $< $@"
82 #end
83
84 # the buildrom tool
85 makerule buildrom 
86         depends "$(TOP)/util/buildrom/buildrom.c" 
87         action  "$(HOSTCC) -o $@ $<"
88 end
89
90 # Force crt0.s (which has build time version code in it to rebuild every time)
91 makedefine .PHONY : crt0.s
92 makerule crt0.s   
93         depends "crt0.S $(CRT0_INCLUDES)" 
94         action  "@echo \"$(CPP) ... $< > $@ \""
95         action  "$(CPP) $(CPPFLAGS) -I. -I$(TOP)/src  $< > $@.new && mv $@.new $@"
96 end
97
98 makerule crt0.o  
99         depends "crt0.s $(INIT-OBJECTS)" 
100         action  "@echo $(CC) ... -o $@ $<"
101         action  "@$(CC) -c $(CPU_OPT) -o $@ $< $(INIT-OBJECTS)"
102 end
103
104 makerule etags   
105         depends "$(SOURCES)" 
106         action  "etags $(SOURCES)"
107 end
108 makerule tags   
109         depends "$(SOURCES)" 
110         action  "ctags $(SOURCES)"
111 end
112 makerule documentation   
113         depends "$(SOURCES)" 
114         action  "doxygen LinuxBIOSDoc.config"
115 end
116
117 makerule ./romcc   
118         depends "$(TOP)/util/romcc/romcc.c" 
119         action  "$(HOSTCC) -g $(HOSTCFLAGS) -DVERSION='\"0.34\"' -DRELEASE_DATE='\"4 July 2003\"' $< -o $@"
120 end
121
122 makerule build_opt_tbl   
123         depends "$(TOP)/util/options/build_opt_tbl.c $(TOP)/src/include/pc80/mc146818rtc.h $(TOP)/src/include/boot/linuxbios_tables.h" 
124         action  "$(HOSTCC) $(HOSTCFLAGS) $< -o $@"
125 end
126
127 #makerule /$(TARGET_DIR)/option_table.c
128 #       depends "build_opt_tbl $(MAINBOARD)/cmos.layout" 
129 #       action  "./build_opt_tbl -b  --config $(MAINBOARD)/cmos.layout"
130 #end
131
132 makerule option_table.c
133         depends "build_opt_tbl $(MAINBOARD)/cmos.layout" 
134         action  "./build_opt_tbl -b  --config $(MAINBOARD)/cmos.layout"
135 end
136
137 if HAVE_OPTION_TABLE
138 object ./option_table.o 
139 #special rule
140 #makerule option_table.o 
141 #       depends "option_table.c" 
142 #       action  "$(CC) -c $(CFLAGS) -o $@ $<"
143 #end
144 # object option_table.o 
145 end
146
147 makerule clean  
148         action  "rm -f linuxbios.* *~"
149         action  "rm -f linuxbios"
150         action  "rm -f ldscript.ld"
151         action  "rm -f a.out *.s *.l *.o *.E *.inc"
152         action  "rm -f TAGS tags romcc"
153         action  "rm -f docipl buildrom chips.c *chip.c linuxbios_c* linuxbios_pay*"
154         action  "rm -f build_opt_tbl option_table.c crt0.S"
155 end
156
157 # do standard config files that the user need not specify
158 # for now, this is just 'lib', but it may be more later. 
159 dir /lib
160 dir /console
161 dir /stream
162 dir /devices
163 dir /pc80
164 dir /boot