add $(CROSS_COMPILE) to ar calls.
[coreboot.git] / src / config / Config.lb
index 27c599fe7bd4291102f8d0b24c6b758fa6f327d8..44278129236f4ae4e2bc64cc2a6cf9dcb5c51e51 100644 (file)
 ## This is Architecture independant part of the makefile
 
-option LINUXBIOS_VERSION="1.1.0"
+uses HAVE_OPTION_TABLE
+uses CONFIG_AP_CODE_IN_CAR
 
-option CC="$(CROSS_COMPILE)gcc"
-option HOSTCC="$(CROSS_COMPILE)gcc"
-option OBJCOPY="objcopy"
-
-makedefine CPP:= $(CC) -no-gcc -x assembler-with-cpp -DASSEMBLY -E
+makedefine CPP:= $(CC) -x assembler-with-cpp -DASSEMBLY -E
 makedefine LIBGCC_FILE_NAME := $(shell $(CC) -print-libgcc-file-name)
-makedefine GCC_INC_DIR := $(shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
+makedefine GCC_INC_DIR := $(shell LC_ALL=C $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
 
 makedefine CPPFLAGS := -I$(TOP)/src/include -I$(TOP)/src/arch/$(ARCH)/include -I$(GCC_INC_DIR) $(CPUFLAGS)
-makedefine ROMCCPPFLAGS := -D__ROMCC__=0 -D__ROMCC_MINOR__=23
-makedefine CFLAGS := $(CPU_OPT) $(CPPFLAGS) -Os -nostdinc -nostdlib -fno-builtin  -Wall
+makedefine CFLAGS := $(CPU_OPT) $(DISTRO_CFLAGS) $(CPPFLAGS) -Os -nostdinc -nostdlib -fno-builtin  -Wall
 
 makedefine HOSTCFLAGS:= -Os -Wall
 
-option LINUXBIOS_BUILD          = "$(shell date)       "
-option LINUXBIOS_COMPILE_TIME   = "$(shell date +%T)"
-option LINUXBIOS_COMPILE_BY     = "$(shell whoami)"
-option LINUXBIOS_COMPILE_HOST   = "$(shell hostname)"
-option LINUXBIOS_COMPILE_DOMAIN = "$(shell dnsdomainname)"
-option LINUXBIOS_COMPILER       = "$(shell  $(CC) $(CFLAGS) -v 2>&1 | tail -n 1)"
-option LINUXBIOS_LINKER         = "$(shell  $(CC) -Wl,-v 2>&1 | grep version | tail -n 1)"
-option LINUXBIOS_ASSEMBLER      = "$(shell  touch dummy.s ; $(CC) -c -Wa,-v dummy.s 2>&1; rm -f dummy.s dummy.o )"
+makerule ldscript.ld   
+       depends "ldoptions $(LDSUBSCRIPTS-1)" 
+       action  "echo '/*ldoptions*/' > $@; cat ldoptions >> $@ ; for file in $(LDSUBSCRIPTS-1) ; do echo /\* $$file \*/ >> $@; cat $$file >> $@ ; done"
+end
 
-makerule ldscript.ld   dep "ldoptions $(LDSUBSCRIPTS-1)" act " echo \"INCLUDE ldoptions\" > $@ ; for file in $(LDSUBSCRIPTS-1) ; do echo \"INCLUDE $$file\" >> $@ ; done"
+#makerule cpuflags   
+#      depends "Makefile.settings" 
+#      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\"} }' > $@"
+#end
 
-makerule cpuflags   dep "Makefile.settings" act " 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\"} }' > $@"
+#makerule ldoptions   
+#      depends "Makefile.settings" 
+#      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\"; }}' > $@"
+#end
 
-makerule ldoptions   dep "Makefile.settings" act " 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\"; }}' > $@"
+makerule coreboot.strip  
+       depends "coreboot" 
+       action  "$(OBJCOPY) -O binary coreboot coreboot.strip"
+end
 
-makerule linuxbios.strip  dep "linuxbios" act " $(OBJCOPY) -O binary linuxbios linuxbios.strip"
+makerule coreboot.a
+        depends "$(OBJECTS)"
+        action  "rm -f coreboot.a"
+        action  "$(CROSS_COMPILE)ar cr coreboot.a $(OBJECTS)"
+end
 
 
-makerule linuxbios_c.o   dep "$(DRIVERS-1) linuxbios.a $(LIBGCC_FILE_NAME)" act  " $(CC) -nostdlib -r -o $@ c_start.o $(DRIVERS-1) linuxbios.a $(LIBGCC_FILE_NAME)"
+makerule coreboot_ram.o
+       depends "$(DRIVER) coreboot.a $(LIBGCC_FILE_NAME)" 
+       action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -r -o $@ c_start.o $(DRIVER) coreboot.a $(LIBGCC_FILE_NAME)"
+end
 
-makerule linuxbios_c  dep "linuxbios_c.o $(TOP)/src/config/linuxbios_c.ld ldoptions" act " $(CC) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/linuxbios_c.ld linuxbios_c.o"
+makerule coreboot_ram
+       depends "coreboot_ram.o $(TOP)/src/config/coreboot_ram.ld ldoptions" 
+       action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/coreboot_ram.ld coreboot_ram.o"
+       action  "$(CROSS_COMPILE)nm -n coreboot_ram | sort > coreboot_ram.map"
+end
 
 ##
-## By default compress the C part of linuxbios
+## By default compress the part of coreboot that runs from RAM
 ##
-option CONFIG_COMPRESS=1
-option CONFIG_UNCOMPRESSED=!CONFIG_COMPRESS
-makedefine LINUXBIOS_PAYLOAD-$(CONFIG_COMPRESS):=linuxbios_payload.nrv2b
-makedefine LINUXBIOS_PAYLOAD-$(CONFIG_UNCOMPRESSED):=linuxbios_payload.bin
+makedefine COREBOOT_RAM-$(CONFIG_COMPRESS):=coreboot_ram.nrv2b
+makedefine COREBOOT_RAM-$(CONFIG_UNCOMPRESSED):=coreboot_ram.bin
+
+makerule coreboot_ram.bin 
+       depends "coreboot_ram" 
+       action  "$(OBJCOPY) -O binary $< $@"
+end
+
+makerule coreboot_ram.nrv2b 
+       depends "coreboot_ram.bin nrv2b" 
+       action  "./nrv2b e $< $@"
+end
+
+makerule coreboot_ram.rom
+       depends "$(COREBOOT_RAM-1)" 
+       action  "cp $(COREBOOT_RAM-1) coreboot_ram.rom"
+end
+
+makedefine COREBOOT_APC:=
+
+if CONFIG_AP_CODE_IN_CAR
+       #for ap code in cache
+
+       makerule coreboot_apc.a
+               depends "apc_auto.o"
+               action  "rm -f coreboot_apc.a"
+               action  "$(CROSS_COMPILE)ar cr coreboot_apc.a apc_auto.o"
+       end
+
+       makerule coreboot_apc.o
+               depends "coreboot_apc.a c_start.o $(LIBGCC_FILE_NAME)"
+        action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -r -o $@ c_start.o coreboot_apc.a $(LIBGCC_FILE_NAME)"
+       end
+
+       makerule coreboot_apc
+               depends "coreboot_apc.o $(TOP)/src/config/coreboot_apc.ld ldoptions"
+               action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/coreboot_apc.ld coreboot_apc.o"
+               action  "$(CROSS_COMPILE)nm -n coreboot_apc | sort > coreboot_apc.map"
+       end
+
+       ##
+       ## By default compress the part of coreboot that runs from cache as ram
+       ##
+       makedefine COREBOOT_APC-$(CONFIG_COMPRESS):=coreboot_apc.nrv2b
+       makedefine COREBOOT_APC-$(CONFIG_UNCOMPRESSED):=coreboot_apc.bin
+
+       makerule coreboot_apc.bin
+               depends "coreboot_apc"
+               action  "$(OBJCOPY) -O binary $< $@"
+       end
+
+       makerule coreboot_apc.nrv2b
+        depends "coreboot_apc.bin nrv2b"
+        action  "./nrv2b e $< $@"
+       end
 
-addaction linuxbios_c "$(CROSS_COMPILE)nm -n linuxbios_c | sort > linuxbios_c.map"
-makerule linuxbios_payload.bin dep "linuxbios_c" act " $(OBJCOPY) -O binary $< $@"
-makerule linuxbios_payload.nrv2b dep " linuxbios_payload.bin nrv2b" act " ./nrv2b e $< $@"
-makerule linuxbios_payload   dep "$(LINUXBIOS_PAYLOAD-1) " act "cp $(LINUXBIOS_PAYLOAD-1) linuxbios_payload"
-makerule linuxbios   dep "crt0.o linuxbios_payload ldscript.ld " act "$(CC) -nostdlib -nostartfiles -static -o $@ -T ldscript.ld crt0.o"
-addaction linuxbios "$(CROSS_COMPILE)nm -n linuxbios | sort > linuxbios.map"
+       makerule coreboot_apc.rom
+               depends "$(COREBOOT_APC-1)"
+               action  "cp $(COREBOOT_APC-1) coreboot_apc.rom"
+       end
 
-makerule linuxbios.a   dep "$(OBJECTS-1) " act "rm -f linuxbios.a"
-addaction linuxbios.a "ar cr linuxbios.a $(OBJECTS-1)"
+       makedefine COREBOOT_APC:=coreboot_apc.rom
 
-option CRT0="$(TOP)/src/arch/$(ARCH)/config/crt0.base"
-makerule crt0.S   dep "$(CRT0) " act "cp $< $@"
+end
+
+makedefine COREBOOT_RAM_ROM:=coreboot_ram.rom
+
+makerule coreboot   
+       depends "crt0.o $(INIT-OBJECTS) $(COREBOOT_APC) $(COREBOOT_RAM_ROM) ldscript.ld"
+       action  "$(CC) $(DISTRO_LFLAGS) -nostdlib -nostartfiles -static -o $@ -T ldscript.ld crt0.o $(INIT-OBJECTS)"
+       action  "$(CROSS_COMPILE)nm -n coreboot | sort > coreboot.map"
+end
+
+#makerule crt0.S   
+#      depends "$(CRT0)" 
+#      action          "cp $< $@"
+#end
 
 # the buildrom tool
-makerule buildrom dep "$(TOP)/util/buildrom/buildrom.c" act "$(CC) -o $@ $<"
+makerule buildrom 
+       depends "$(TOP)/util/buildrom/buildrom.c" 
+       action  "$(HOSTCC) -o $@ $<"
+end
+
 # Force crt0.s (which has build time version code in it to rebuild every time)
 makedefine .PHONY : crt0.s
-makerule crt0.s   dep "crt0.S crt0_includes.h $(CRT0_INCLUDES) " act "@echo \"$(CPP) ... $< > $@ \""
-addaction crt0.s "$(CPP) $(CPPFLAGS) -I. -I$(TOP)/src  $< > $@.new && mv $@.new $@ "
+makerule crt0.s   
+       depends "crt0.S $(CRT0_INCLUDES)" 
+       action  "@echo \"$(CPP) ... $< > $@ \""
+       action  "$(CPP) $(CPPFLAGS) -I. -I$(TOP)/src  $< > $@.new && mv $@.new $@"
+end
+
+makerule crt0.o  
+       depends "crt0.s" 
+       action  "@echo $(CC) ... -o $@ $<"
+       action  "@$(CC) -c $(CPU_OPT) -o $@ $<"
+end
 
-makerule crt0.o  dep "crt0.s " act "@echo $(CC) ... -o $@ $<"
-addaction crt0.o "@$(CC) -c $(CPU_OPT) -o $@ $<"
+makerule etags   
+       depends "$(SOURCES)" 
+       action  "etags $(SOURCES)"
+end
+makerule tags   
+       depends "$(SOURCES)" 
+       action  "ctags $(SOURCES)"
+end
+makerule corebootDoc.config
+       depends "$(TOP)/src/config/corebootDoc.config" 
+       action "cat $(TOP)/src/config/corebootDoc.config > corebootDoc.config"
+        action "echo 'INPUT=$(SOURCES)' >> corebootDoc.config"
+end
+makerule documentation   
+       depends "corebootDoc.config"
+       action  "doxygen corebootDoc.config"
+end
+
+makerule ./romcc   
+       depends "$(TOP)/util/romcc/romcc.c" 
+       action  "$(HOSTCC) -g $(HOSTCFLAGS) $< -o $@"
+end
 
+makerule build_opt_tbl   
+       depends "$(TOP)/util/options/build_opt_tbl.c $(TOP)/src/include/pc80/mc146818rtc.h $(TOP)/src/include/boot/coreboot_tables.h Makefile.settings Makefile"
+       action  "$(HOSTCC) $(HOSTCFLAGS) $(CPUFLAGS) $< -o $@" 
+end
 
-makerule etags   dep "$(SOURCES) " act "etags $(SOURCES)"
-makerule tags   dep "$(SOURCES) " act "ctags $(SOURCES)"
-makerule documentation   dep "$(SOURCES) " act "doxygen LinuxBIOSDoc.config "
+#makerule /$(TARGET_DIR)/option_table.c
+#      depends "build_opt_tbl $(MAINBOARD)/cmos.layout" 
+#      action  "./build_opt_tbl -b  --config $(MAINBOARD)/cmos.layout"
+#end
 
-makerule ./romcc   dep "$(TOP)/util/romcc/romcc.c " act "$(HOSTCC) -g $(HOSTCFLAGS) -DVERSION='\"0.21\"' -DRELEASE_DATE='\"7 april 2003\"' $< -o $@"
-makerule build_opt_tbl   dep "$(TOP)/util/options/build_opt_tbl.c $(TOP)/src/include/pc80/mc146818rtc.h $(TOP)/src/include/boot/linuxbios_tables.h " act "$(HOSTCC) $(HOSTCFLAGS) $< -o $@"
+makerule option_table.c
+       depends "build_opt_tbl $(MAINBOARD)/cmos.layout" 
+       action  "./build_opt_tbl -b  --config $(MAINBOARD)/cmos.layout --header option_table.h"
+end
 
-#makerule /$(TARGET_DIR)/option_table.c    dep "build_opt_tbl $(MAINBOARD)/cmos.layout " act "./build_opt_tbl -b  --config $(MAINBOARD)/cmos.layout "
-makerule option_table.c    dep "build_opt_tbl $(MAINBOARD)/cmos.layout " act "./build_opt_tbl -b  --config $(MAINBOARD)/cmos.layout "
+makerule option_table.h
+       depends "build_opt_tbl $(MAINBOARD)/cmos.layout" 
+       action  "./build_opt_tbl -b  --config $(MAINBOARD)/cmos.layout --header option_table.h"
+end
 
 if HAVE_OPTION_TABLE
 object ./option_table.o 
 #special rule
-#makerule option_table.o dep "option_table.c" act "$(CC) -c $(CFLAGS) -o $@ $<"
+#makerule option_table.o 
+#      depends "option_table.c" 
+#      action  "$(CC) -c $(CFLAGS) -o $@ $<"
+#end
 # object option_table.o 
 end
 
-makerule clean  act "rm -f linuxbios.* *~"
-addaction clean "rm -f linuxbios "
-addaction clean "rm -f ldoptions cpuflags ldscript.ld"
-addaction clean "rm -f a.out *.s *.l *.o"
-addaction clean "rm -f TAGS tags"
-addaction clean "rm -f docipl"
-addaction clean "rm -f build_opt_tbl option_table.c crt0.S"
+makerule clean  
+       action  "rm -f coreboot.* *~"
+       action  "rm -f coreboot"
+       action  "rm -f ldscript.ld"
+       action  "rm -f a.out *.s *.l *.o *.E *.inc"
+       action  "rm -f TAGS tags romcc*"
+       action  "rm -f docipl buildrom* chips.c *chip.c coreboot_apc* coreboot_ram* coreboot_pay*"
+       action  "rm -f build_opt_tbl* nrv2b* option_table.c crt0.S"
+end
 
 # do standard config files that the user need not specify
 # for now, this is just 'lib', but it may be more later.