diff options
author | Cyril Bur <cyril.bur@au1.ibm.com> | 2015-08-26 16:02:38 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-08-28 15:24:04 +1000 |
commit | a0a677beeaaea087d855b8226062fd96f3135a5e (patch) | |
tree | a1cd37f69f46e75c04b6e75f8f297089cec91ffd /external/common | |
parent | 5785c02d2bea19e678c87a47de7d78ebceb0f093 (diff) | |
download | blackbird-skiboot-a0a677beeaaea087d855b8226062fd96f3135a5e.tar.gz blackbird-skiboot-a0a677beeaaea087d855b8226062fd96f3135a5e.zip |
external/common: Write an includeable rules.mk.
It would be nice if tools like the gard tool or pflash don't have to worry
about how to build the arch specific code they want to include through the
new external/common code.
This patch adds an external/common/rules.mk which each tool can include and
with some minor tweaking of the existing makefiles it should get the arch
code building nicely.
The one caveat is that it requires a symlink in the directory to create
common/ dir for everything to behave.
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external/common')
-rwxr-xr-x | external/common/get_arch.sh | 11 | ||||
-rw-r--r-- | external/common/rules.mk | 36 |
2 files changed, 47 insertions, 0 deletions
diff --git a/external/common/get_arch.sh b/external/common/get_arch.sh new file mode 100755 index 00000000..18a5cef2 --- /dev/null +++ b/external/common/get_arch.sh @@ -0,0 +1,11 @@ +#!/bin/sh +echo "#if defined(__powerpc__) +echo -n ARCH_POWERPC +#elif defined(__x86_64__) || defined(__i386__) +echo -n ARCH_X86 +#elif defined(__arm__) +echo -n ARCH_ARM +#else +echo -n ARCH_UNKNOWN +#endif" | $1cpp | sh + diff --git a/external/common/rules.mk b/external/common/rules.mk new file mode 100644 index 00000000..bc565e8e --- /dev/null +++ b/external/common/rules.mk @@ -0,0 +1,36 @@ +ARCH = $(shell $(GET_ARCH) "$(CROSS_COMPILE)") + +ifeq ($(ARCH),ARCH_ARM) +arch = arm +ARCH_OBJS = common/arch_flash_common.o common/arch_flash_arm.o common/ast-sf-ctrl.o +else +ifeq ($(ARCH),ARCH_POWERPC) +arch = powerpc +ARCH_OBJS = common/arch_flash_common.o common/arch_flash_powerpc.o +else +ifeq ($(ARCH),ARCH_X86) +arch = x86 +ARCH_OBJS = common/arch_flash_common.o common/arch_flash_x86.o +else +$(error Unsupported architecture $(ARCH)) +endif +endif +endif + +.PHONY: arch_links +arch_links: + ln -sf ../../hw/ast-bmc/ast-sf-ctrl.c common/ast-sf-ctrl.c + ln -sf arch_flash_$(arch)_io.h common/io.h + +.PHONY: arch_clean +arch_clean: + rm -rf $(ARCH_OBJS) + +#If arch changes make won't realise it needs to rebuild... +.PHONY: .FORCE +common/arch_flash_common.o: common/arch_flash_common.c .FORCE + $(CROSS_COMPILE)gcc $(CFLAGS) -c $< -o $@ + +common/arch_flash.o: $(ARCH_OBJS) + $(CROSS_COMPILE)ld -r $(ARCH_OBJS) -o $@ + |