blob: 44278129236f4ae4e2bc64cc2a6cf9dcb5c51e51 [file] [log] [blame]
Ronald G. Minnich99acb492003-06-17 16:51:06 +00001## This is Architecture independant part of the makefile
2
Greg Watson51305ee2003-06-24 16:07:07 +00003uses HAVE_OPTION_TABLE
Yinghai Lud4b278c2006-10-04 20:46:15 +00004uses CONFIG_AP_CODE_IN_CAR
Ronald G. Minnich99acb492003-06-17 16:51:06 +00005
Eric Biedermanb78c1972004-10-14 20:54:17 +00006makedefine CPP:= $(CC) -x assembler-with-cpp -DASSEMBLY -E
Ronald G. Minnich99acb492003-06-17 16:51:06 +00007makedefine LIBGCC_FILE_NAME := $(shell $(CC) -print-libgcc-file-name)
Patrick Georgieaca2c32008-01-08 10:28:06 +00008makedefine GCC_INC_DIR := $(shell LC_ALL=C $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
Ronald G. Minnich99acb492003-06-17 16:51:06 +00009
10makedefine CPPFLAGS := -I$(TOP)/src/include -I$(TOP)/src/arch/$(ARCH)/include -I$(GCC_INC_DIR) $(CPUFLAGS)
Marc Karasek14a3af12008-01-22 16:09:36 +000011makedefine CFLAGS := $(CPU_OPT) $(DISTRO_CFLAGS) $(CPPFLAGS) -Os -nostdinc -nostdlib -fno-builtin -Wall
Ronald G. Minnich99acb492003-06-17 16:51:06 +000012
13makedefine HOSTCFLAGS:= -Os -Wall
14
Greg Watson109959d2003-07-14 18:00:10 +000015makerule ldscript.ld
16 depends "ldoptions $(LDSUBSCRIPTS-1)"
Ronald G. Minnichb7ac85c2006-01-28 22:01:56 +000017 action "echo '/*ldoptions*/' > $@; cat ldoptions >> $@ ; for file in $(LDSUBSCRIPTS-1) ; do echo /\* $$file \*/ >> $@; cat $$file >> $@ ; done"
Greg Watson109959d2003-07-14 18:00:10 +000018end
Ronald G. Minnich99acb492003-06-17 16:51:06 +000019
Greg Watson109959d2003-07-14 18:00:10 +000020#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
Ronald G. Minnich99acb492003-06-17 16:51:06 +000024
Greg Watson109959d2003-07-14 18:00:10 +000025#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
Ronald G. Minnich99acb492003-06-17 16:51:06 +000029
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000030makerule coreboot.strip
31 depends "coreboot"
32 action "$(OBJCOPY) -O binary coreboot coreboot.strip"
Greg Watson109959d2003-07-14 18:00:10 +000033end
Ronald G. Minnich99acb492003-06-17 16:51:06 +000034
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000035makerule coreboot.a
Yinghai Lud4b278c2006-10-04 20:46:15 +000036 depends "$(OBJECTS)"
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000037 action "rm -f coreboot.a"
Marc Jones5eb25bf2008-02-09 13:06:45 +000038 action "$(CROSS_COMPILE)ar cr coreboot.a $(OBJECTS)"
Yinghai Lud4b278c2006-10-04 20:46:15 +000039end
40
Marc Karasek14a3af12008-01-22 16:09:36 +000041
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000042makerule coreboot_ram.o
43 depends "$(DRIVER) coreboot.a $(LIBGCC_FILE_NAME)"
Marc Karasek14a3af12008-01-22 16:09:36 +000044 action "$(CC) $(DISTRO_LFLAGS) -nostdlib -r -o $@ c_start.o $(DRIVER) coreboot.a $(LIBGCC_FILE_NAME)"
Greg Watson109959d2003-07-14 18:00:10 +000045end
Ronald G. Minnich99acb492003-06-17 16:51:06 +000046
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000047makerule coreboot_ram
Stefan Reinauerca374d42008-01-18 16:16:45 +000048 depends "coreboot_ram.o $(TOP)/src/config/coreboot_ram.ld ldoptions"
Marc Karasek14a3af12008-01-22 16:09:36 +000049 action "$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/coreboot_ram.ld coreboot_ram.o"
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000050 action "$(CROSS_COMPILE)nm -n coreboot_ram | sort > coreboot_ram.map"
Greg Watson109959d2003-07-14 18:00:10 +000051end
Ronald G. Minnich99acb492003-06-17 16:51:06 +000052
53##
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000054## By default compress the part of coreboot that runs from RAM
Ronald G. Minnich99acb492003-06-17 16:51:06 +000055##
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000056makedefine COREBOOT_RAM-$(CONFIG_COMPRESS):=coreboot_ram.nrv2b
57makedefine COREBOOT_RAM-$(CONFIG_UNCOMPRESSED):=coreboot_ram.bin
Ronald G. Minnich99acb492003-06-17 16:51:06 +000058
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000059makerule coreboot_ram.bin
60 depends "coreboot_ram"
Greg Watson109959d2003-07-14 18:00:10 +000061 action "$(OBJCOPY) -O binary $< $@"
62end
Ronald G. Minnich99acb492003-06-17 16:51:06 +000063
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000064makerule coreboot_ram.nrv2b
65 depends "coreboot_ram.bin nrv2b"
Greg Watson109959d2003-07-14 18:00:10 +000066 action "./nrv2b e $< $@"
67end
Ronald G. Minnich99acb492003-06-17 16:51:06 +000068
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000069makerule coreboot_ram.rom
70 depends "$(COREBOOT_RAM-1)"
71 action "cp $(COREBOOT_RAM-1) coreboot_ram.rom"
Greg Watson109959d2003-07-14 18:00:10 +000072end
73
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000074makedefine COREBOOT_APC:=
Yinghai Lud4b278c2006-10-04 20:46:15 +000075
76if CONFIG_AP_CODE_IN_CAR
77 #for ap code in cache
78
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000079 makerule coreboot_apc.a
Yinghai Lud4b278c2006-10-04 20:46:15 +000080 depends "apc_auto.o"
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000081 action "rm -f coreboot_apc.a"
Marc Jones5eb25bf2008-02-09 13:06:45 +000082 action "$(CROSS_COMPILE)ar cr coreboot_apc.a apc_auto.o"
Yinghai Lud4b278c2006-10-04 20:46:15 +000083 end
84
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000085 makerule coreboot_apc.o
86 depends "coreboot_apc.a c_start.o $(LIBGCC_FILE_NAME)"
Marc Karasek14a3af12008-01-22 16:09:36 +000087 action "$(CC) $(DISTRO_LFLAGS) -nostdlib -r -o $@ c_start.o coreboot_apc.a $(LIBGCC_FILE_NAME)"
Yinghai Lud4b278c2006-10-04 20:46:15 +000088 end
89
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000090 makerule coreboot_apc
Stefan Reinauerca374d42008-01-18 16:16:45 +000091 depends "coreboot_apc.o $(TOP)/src/config/coreboot_apc.ld ldoptions"
Marc Karasek14a3af12008-01-22 16:09:36 +000092 action "$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/coreboot_apc.ld coreboot_apc.o"
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000093 action "$(CROSS_COMPILE)nm -n coreboot_apc | sort > coreboot_apc.map"
Yinghai Lud4b278c2006-10-04 20:46:15 +000094 end
95
96 ##
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000097 ## By default compress the part of coreboot that runs from cache as ram
Yinghai Lud4b278c2006-10-04 20:46:15 +000098 ##
Stefan Reinauerf8ee1802008-01-18 15:08:58 +000099 makedefine COREBOOT_APC-$(CONFIG_COMPRESS):=coreboot_apc.nrv2b
100 makedefine COREBOOT_APC-$(CONFIG_UNCOMPRESSED):=coreboot_apc.bin
Yinghai Lud4b278c2006-10-04 20:46:15 +0000101
Stefan Reinauerf8ee1802008-01-18 15:08:58 +0000102 makerule coreboot_apc.bin
103 depends "coreboot_apc"
Yinghai Lud4b278c2006-10-04 20:46:15 +0000104 action "$(OBJCOPY) -O binary $< $@"
105 end
106
Stefan Reinauerf8ee1802008-01-18 15:08:58 +0000107 makerule coreboot_apc.nrv2b
108 depends "coreboot_apc.bin nrv2b"
Yinghai Lud4b278c2006-10-04 20:46:15 +0000109 action "./nrv2b e $< $@"
110 end
111
Stefan Reinauerf8ee1802008-01-18 15:08:58 +0000112 makerule coreboot_apc.rom
113 depends "$(COREBOOT_APC-1)"
114 action "cp $(COREBOOT_APC-1) coreboot_apc.rom"
Yinghai Lud4b278c2006-10-04 20:46:15 +0000115 end
116
Stefan Reinauerf8ee1802008-01-18 15:08:58 +0000117 makedefine COREBOOT_APC:=coreboot_apc.rom
Yinghai Lud4b278c2006-10-04 20:46:15 +0000118
Greg Watson109959d2003-07-14 18:00:10 +0000119end
120
Stefan Reinauerf8ee1802008-01-18 15:08:58 +0000121makedefine COREBOOT_RAM_ROM:=coreboot_ram.rom
Yinghai Lud4b278c2006-10-04 20:46:15 +0000122
Stefan Reinauerf8ee1802008-01-18 15:08:58 +0000123makerule coreboot
124 depends "crt0.o $(INIT-OBJECTS) $(COREBOOT_APC) $(COREBOOT_RAM_ROM) ldscript.ld"
Marc Karasek14a3af12008-01-22 16:09:36 +0000125 action "$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T ldscript.ld crt0.o $(INIT-OBJECTS)"
Stefan Reinauerf8ee1802008-01-18 15:08:58 +0000126 action "$(CROSS_COMPILE)nm -n coreboot | sort > coreboot.map"
Greg Watson109959d2003-07-14 18:00:10 +0000127end
128
129#makerule crt0.S
130# depends "$(CRT0)"
131# action "cp $< $@"
132#end
Ronald G. Minnich99acb492003-06-17 16:51:06 +0000133
134# the buildrom tool
Greg Watson109959d2003-07-14 18:00:10 +0000135makerule buildrom
136 depends "$(TOP)/util/buildrom/buildrom.c"
137 action "$(HOSTCC) -o $@ $<"
138end
139
Ronald G. Minnich99acb492003-06-17 16:51:06 +0000140# Force crt0.s (which has build time version code in it to rebuild every time)
141makedefine .PHONY : crt0.s
Greg Watson109959d2003-07-14 18:00:10 +0000142makerule crt0.s
143 depends "crt0.S $(CRT0_INCLUDES)"
144 action "@echo \"$(CPP) ... $< > $@ \""
145 action "$(CPP) $(CPPFLAGS) -I. -I$(TOP)/src $< > $@.new && mv $@.new $@"
146end
Ronald G. Minnich99acb492003-06-17 16:51:06 +0000147
Greg Watson109959d2003-07-14 18:00:10 +0000148makerule crt0.o
Greg Watsonc8ea12d2003-11-09 23:29:05 +0000149 depends "crt0.s"
Greg Watson109959d2003-07-14 18:00:10 +0000150 action "@echo $(CC) ... -o $@ $<"
Greg Watsonc8ea12d2003-11-09 23:29:05 +0000151 action "@$(CC) -c $(CPU_OPT) -o $@ $<"
Greg Watson109959d2003-07-14 18:00:10 +0000152end
Ronald G. Minnich99acb492003-06-17 16:51:06 +0000153
Greg Watson109959d2003-07-14 18:00:10 +0000154makerule etags
155 depends "$(SOURCES)"
156 action "etags $(SOURCES)"
157end
158makerule tags
159 depends "$(SOURCES)"
160 action "ctags $(SOURCES)"
161end
Stefan Reinauerf8ee1802008-01-18 15:08:58 +0000162makerule 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"
Ronald G. Minnich41bac282006-02-06 16:16:46 +0000166end
Greg Watson109959d2003-07-14 18:00:10 +0000167makerule documentation
Stefan Reinauerf8ee1802008-01-18 15:08:58 +0000168 depends "corebootDoc.config"
169 action "doxygen corebootDoc.config"
Greg Watson109959d2003-07-14 18:00:10 +0000170end
Ronald G. Minnich99acb492003-06-17 16:51:06 +0000171
Greg Watson109959d2003-07-14 18:00:10 +0000172makerule ./romcc
173 depends "$(TOP)/util/romcc/romcc.c"
Eric Biedermand67e7652004-05-28 14:18:45 +0000174 action "$(HOSTCC) -g $(HOSTCFLAGS) $< -o $@"
Greg Watson109959d2003-07-14 18:00:10 +0000175end
Ronald G. Minnich99acb492003-06-17 16:51:06 +0000176
Greg Watson109959d2003-07-14 18:00:10 +0000177makerule build_opt_tbl
Stefan Reinauerca374d42008-01-18 16:16:45 +0000178 depends "$(TOP)/util/options/build_opt_tbl.c $(TOP)/src/include/pc80/mc146818rtc.h $(TOP)/src/include/boot/coreboot_tables.h Makefile.settings Makefile"
Eric Biederman5cd81732004-03-11 15:01:31 +0000179 action "$(HOSTCC) $(HOSTCFLAGS) $(CPUFLAGS) $< -o $@"
Greg Watson109959d2003-07-14 18:00:10 +0000180end
Ronald G. Minnich99acb492003-06-17 16:51:06 +0000181
Greg Watson109959d2003-07-14 18:00:10 +0000182#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
187makerule option_table.c
188 depends "build_opt_tbl $(MAINBOARD)/cmos.layout"
Eric Biederman5cd81732004-03-11 15:01:31 +0000189 action "./build_opt_tbl -b --config $(MAINBOARD)/cmos.layout --header option_table.h"
190end
191
192makerule 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"
Greg Watson109959d2003-07-14 18:00:10 +0000195end
Ronald G. Minnich99acb492003-06-17 16:51:06 +0000196
197if HAVE_OPTION_TABLE
198object ./option_table.o
199#special rule
Greg Watson109959d2003-07-14 18:00:10 +0000200#makerule option_table.o
201# depends "option_table.c"
202# action "$(CC) -c $(CFLAGS) -o $@ $<"
203#end
Ronald G. Minnich99acb492003-06-17 16:51:06 +0000204# object option_table.o
205end
206
Greg Watson109959d2003-07-14 18:00:10 +0000207makerule clean
Stefan Reinauerf8ee1802008-01-18 15:08:58 +0000208 action "rm -f coreboot.* *~"
209 action "rm -f coreboot"
Greg Watson109959d2003-07-14 18:00:10 +0000210 action "rm -f ldscript.ld"
Ronald G. Minnichffc161e2003-07-23 01:42:29 +0000211 action "rm -f a.out *.s *.l *.o *.E *.inc"
Steven J. Magnani9a83c992005-09-09 20:06:21 +0000212 action "rm -f TAGS tags romcc*"
Stefan Reinauerf8ee1802008-01-18 15:08:58 +0000213 action "rm -f docipl buildrom* chips.c *chip.c coreboot_apc* coreboot_ram* coreboot_pay*"
Steven J. Magnani9a83c992005-09-09 20:06:21 +0000214 action "rm -f build_opt_tbl* nrv2b* option_table.c crt0.S"
Greg Watson109959d2003-07-14 18:00:10 +0000215end
Ronald G. Minnich99acb492003-06-17 16:51:06 +0000216
217# do standard config files that the user need not specify
218# for now, this is just 'lib', but it may be more later.
219dir /lib
220dir /console
221dir /stream
222dir /devices
223dir /pc80
224dir /boot