separate build.h and config.h usage (now possible because newconfig is gone)

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Patrick Georgi <patrick.georgi@coresystems.de>

This patch is slightly reworked to include a necessary romcc change that allows
more than one -include specified on the command line, and gets rid of the
explicit build.h dependencies of all files. (The files do keep an explicit
config.h dependency though)



git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5114 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Stefan Reinauer 2010-02-11 03:21:29 +00:00 committed by Stefan Reinauer
parent e82f4754ee
commit b4d3af8888
5 changed files with 42 additions and 29 deletions

View File

@ -148,31 +148,31 @@ $(obj)/$(1)%.o: src/$(1)%.asl
endef endef
define objs_c_template define objs_c_template
$(obj)/$(1)%.o: src/$(1)%.c $(obj)/build.h $(obj)/$(1)%.o: src/$(1)%.c $(obj)/config.h
@printf " CC $$(subst $$(obj)/,,$$(@))\n" @printf " CC $$(subst $$(obj)/,,$$(@))\n"
$(CC) -m32 $$(CFLAGS) -c -o $$@ $$< $(CC) -m32 $$(CFLAGS) -c -o $$@ $$<
endef endef
define objs_S_template define objs_S_template
$(obj)/$(1)%.o: src/$(1)%.S $(obj)/build.h $(obj)/$(1)%.o: src/$(1)%.S $(obj)/config.h
@printf " CC $$(subst $$(obj)/,,$$(@))\n" @printf " CC $$(subst $$(obj)/,,$$(@))\n"
$(CC) -m32 -DASSEMBLY $$(CFLAGS) -c -o $$@ $$< $(CC) -m32 -DASSEMBLY $$(CFLAGS) -c -o $$@ $$<
endef endef
define initobjs_c_template define initobjs_c_template
$(obj)/$(1)%.o: src/$(1)%.c $(obj)/build.h $(obj)/$(1)%.o: src/$(1)%.c $(obj)/config.h
@printf " CC $$(subst $$(obj)/,,$$(@))\n" @printf " CC $$(subst $$(obj)/,,$$(@))\n"
$(CC) -m32 $$(CFLAGS) -c -o $$@ $$< $(CC) -m32 $$(CFLAGS) -c -o $$@ $$<
endef endef
define initobjs_S_template define initobjs_S_template
$(obj)/$(1)%.o: src/$(1)%.S $(obj)/build.h $(obj)/$(1)%.o: src/$(1)%.S $(obj)/config.h
@printf " CC $$(subst $$(obj)/,,$$(@))\n" @printf " CC $$(subst $$(obj)/,,$$(@))\n"
$(CC) -m32 -DASSEMBLY $$(CFLAGS) -c -o $$@ $$< $(CC) -m32 -DASSEMBLY $$(CFLAGS) -c -o $$@ $$<
endef endef
define drivers_c_template define drivers_c_template
$(obj)/$(1)%.o: src/$(1)%.c $(obj)/build.h $(obj)/$(1)%.o: src/$(1)%.c $(obj)/config.h
@printf " CC $$(subst $$(obj)/,,$$(@))\n" @printf " CC $$(subst $$(obj)/,,$$(@))\n"
$(CC) -m32 $$(CFLAGS) -c -o $$@ $$< $(CC) -m32 $$(CFLAGS) -c -o $$@ $$<
endef endef
@ -219,7 +219,7 @@ OBJS := $(patsubst %,$(obj)/%,$(TARGETS-y))
INCLUDES := -I$(top)/src -I$(top)/src/include -I$(obj) -I$(top)/src/arch/$(ARCHDIR-y)/include INCLUDES := -I$(top)/src -I$(top)/src/include -I$(obj) -I$(top)/src/arch/$(ARCHDIR-y)/include
INCLUDES += -I$(shell $(CC) -print-search-dirs | head -n 1 | cut -d' ' -f2)include INCLUDES += -I$(shell $(CC) -print-search-dirs | head -n 1 | cut -d' ' -f2)include
INCLUDES += -I$(top)/util/x86emu/include INCLUDES += -I$(top)/util/x86emu/include
INCLUDES += -include $(obj)/build.h INCLUDES += -include $(obj)/config.h
CFLAGS = $(INCLUDES) -Os -nostdinc CFLAGS = $(INCLUDES) -Os -nostdinc
CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
@ -250,7 +250,10 @@ prepare2: $(obj)/build.h
$(obj)/build.h: $(obj)/build.h:
@printf " GEN build.h\n" @printf " GEN build.h\n"
rm -f $(obj)/build.h rm -f $(obj)/build.h
printf "#define COREBOOT_VERSION \"$(KERNELVERSION)\"\n" > $(obj)/build.ht printf "/* build system definitions (autogenerated) */\n" > $(obj)/build.ht
printf "#ifndef __BUILD_H\n" >> $(obj)/build.ht
printf "#define __BUILD_H\n\n" >> $(obj)/build.ht
printf "#define COREBOOT_VERSION \"$(KERNELVERSION)\"\n" >> $(obj)/build.ht
printf "#define COREBOOT_EXTRA_VERSION \"$(COREBOOT_EXTRA_VERSION)\"\n" >> $(obj)/build.ht printf "#define COREBOOT_EXTRA_VERSION \"$(COREBOOT_EXTRA_VERSION)\"\n" >> $(obj)/build.ht
printf "#define COREBOOT_BUILD \"`LANG= date`\"\n" >> $(obj)/build.ht printf "#define COREBOOT_BUILD \"`LANG= date`\"\n" >> $(obj)/build.ht
printf "\n" >> $(obj)/build.ht printf "\n" >> $(obj)/build.ht
@ -261,7 +264,7 @@ $(obj)/build.h:
printf "#define COREBOOT_COMPILE_BY \"$(subst \,@,$(shell PATH=$$PATH:/usr/ucb whoami))\"\n" >> $(obj)/build.ht printf "#define COREBOOT_COMPILE_BY \"$(subst \,@,$(shell PATH=$$PATH:/usr/ucb whoami))\"\n" >> $(obj)/build.ht
printf "#define COREBOOT_COMPILE_HOST \"$(shell hostname -s)\"\n" >> $(obj)/build.ht printf "#define COREBOOT_COMPILE_HOST \"$(shell hostname -s)\"\n" >> $(obj)/build.ht
printf "#define COREBOOT_COMPILE_DOMAIN \"$(shell test `uname -s` = "Linux" && dnsdomainname || domainname)\"\n" >> $(obj)/build.ht printf "#define COREBOOT_COMPILE_DOMAIN \"$(shell test `uname -s` = "Linux" && dnsdomainname || domainname)\"\n" >> $(obj)/build.ht
printf "#include \"config.h\"\n" >> $(obj)/build.ht printf "#endif\n" >> $(obj)/build.ht
mv $(obj)/build.ht $(obj)/build.h mv $(obj)/build.ht $(obj)/build.h
doxy: doxygen doxy: doxygen

View File

@ -79,11 +79,11 @@ $(obj)/mainboard/$(MAINBOARDDIR)/failover.inc: $(obj)/romcc $(src)/arch/i386/lib
$(obj)/romcc $(ROMCCFLAGS) --label-prefix=failover $(INCLUDES) $(src)/arch/i386/lib/failover.c -o $@ $(obj)/romcc $(ROMCCFLAGS) --label-prefix=failover $(INCLUDES) $(src)/arch/i386/lib/failover.c -o $@
$(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(obj)/romcc $(OPTION_TABLE_H) $(obj)/build.h $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(obj)/romcc $(OPTION_TABLE_H) $(obj)/build.h
$(obj)/romcc $(ROMCCFLAGS) $(INCLUDES) $< -o $@ $(obj)/romcc $(ROMCCFLAGS) -include $(obj)/build.h $(INCLUDES) $< -o $@
else else
$(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(OPTION_TABLE_H) $(obj)/build.h $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(OPTION_TABLE_H) $(obj)/build.h
$(CC) $(DISTRO_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(DEBUG_CFLAGS) -I$(src) -I. -c -S $< -o - | sed -e 's/\.rodata/.rom.data/g' -e 's/\.text/.section .rom.text/g' > $@.tmp $(CC) $(DISTRO_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(DEBUG_CFLAGS) -include $(obj)/build.h -I$(src) -I. -c -S $< -o - | sed -e 's/\.rodata/.rom.data/g' -e 's/\.text/.section .rom.text/g' > $@.tmp
mv $@.tmp $@ mv $@.tmp $@
endif endif
endif endif

View File

@ -1,3 +1,4 @@
#include <build.h>
#include <console/loglevel.h> #include <console/loglevel.h>
#if CONFIG_USE_PRINTK_IN_CAR == 0 #if CONFIG_USE_PRINTK_IN_CAR == 0
@ -6,10 +7,6 @@
#include "console_printk.c" #include "console_printk.c"
#endif /* CONFIG_USE_PRINTK_IN_CAR */ #endif /* CONFIG_USE_PRINTK_IN_CAR */
#ifndef COREBOOT_EXTRA_VERSION
#define COREBOOT_EXTRA_VERSION ""
#endif
void console_init(void) void console_init(void)
{ {
static const char console_test[] = static const char console_test[] =
@ -22,7 +19,6 @@ void console_init(void)
print_info(console_test); print_info(console_test);
} }
void die(const char *str) void die(const char *str)
{ {
print_emerg(str); print_emerg(str);

View File

@ -1,4 +1,5 @@
#include <version.h> #include <version.h>
#include <build.h>
#ifndef CONFIG_MAINBOARD_VENDOR #ifndef CONFIG_MAINBOARD_VENDOR
#error CONFIG_MAINBOARD_VENDOR not defined #error CONFIG_MAINBOARD_VENDOR not defined

View File

@ -3,8 +3,8 @@
#undef RELEASE_DATE #undef RELEASE_DATE
#undef VERSION #undef VERSION
#define VERSION_MAJOR "0" #define VERSION_MAJOR "0"
#define VERSION_MINOR "71" #define VERSION_MINOR "72"
#define RELEASE_DATE "03 April 2009" #define RELEASE_DATE "10 February 2010"
#define VERSION VERSION_MAJOR "." VERSION_MINOR #define VERSION VERSION_MAJOR "." VERSION_MINOR
#include <stdarg.h> #include <stdarg.h>
@ -127,6 +127,14 @@
* Where do I place phi functions and how do I make that decision. * Where do I place phi functions and how do I make that decision.
* *
*/ */
struct filelist {
const char *filename;
struct filelist *next;
};
struct filelist *include_filelist = NULL;
static void die(char *fmt, ...) static void die(char *fmt, ...)
{ {
va_list args; va_list args;
@ -24927,12 +24935,13 @@ static void print_preprocessed_tokens(struct compile_state *state)
} }
} }
static void compile(const char *filename, const char *includefile, static void compile(const char *filename,
struct compiler_state *compiler, struct arch_state *arch) struct compiler_state *compiler, struct arch_state *arch)
{ {
int i; int i;
struct compile_state state; struct compile_state state;
struct triple *ptr; struct triple *ptr;
struct filelist *includes = include_filelist;
memset(&state, 0, sizeof(state)); memset(&state, 0, sizeof(state));
state.compiler = compiler; state.compiler = compiler;
state.arch = arch; state.arch = arch;
@ -25002,8 +25011,11 @@ static void compile(const char *filename, const char *includefile,
register_builtins(&state); register_builtins(&state);
compile_file(&state, filename, 1); compile_file(&state, filename, 1);
if (includefile)
compile_file(&state, includefile, 1); while (includes) {
compile_file(&state, includes->filename, 1);
includes=includes->next;
}
/* Stop if all we want is preprocessor output */ /* Stop if all we want is preprocessor output */
if (state.compiler->flags & COMPILER_PP_ONLY) { if (state.compiler->flags & COMPILER_PP_ONLY) {
@ -25070,7 +25082,6 @@ static void arg_error(char *fmt, ...)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
const char *filename; const char *filename;
const char *includefile = NULL;
struct compiler_state compiler; struct compiler_state compiler;
struct arch_state arch; struct arch_state arch;
int all_opts; int all_opts;
@ -25121,14 +25132,16 @@ int main(int argc, char **argv)
result = arch_encode_flag(&arch, argv[1]+2); result = arch_encode_flag(&arch, argv[1]+2);
} }
else if (strncmp(argv[1], "-include", 10) == 0) { else if (strncmp(argv[1], "-include", 10) == 0) {
if (includefile) { struct filelist *old_head = include_filelist;
arg_error("Only one -include option may be specified.\n"); include_filelist = malloc(sizeof(struct filelist));
} else { if (!include_filelist) {
argv++; die("Out of memory.\n");
argc--;
includefile = argv[1];
result = 0;
} }
argv++;
argc--;
include_filelist->filename = argv[1];
include_filelist->next = old_head;
result = 0;
} }
if (result < 0) { if (result < 0) {
arg_error("Invalid option specified: %s\n", arg_error("Invalid option specified: %s\n",
@ -25149,7 +25162,7 @@ int main(int argc, char **argv)
if (!filename) { if (!filename) {
arg_error("No filename specified\n"); arg_error("No filename specified\n");
} }
compile(filename, includefile, &compiler, &arch); compile(filename, &compiler, &arch);
return 0; return 0;
} }