summaryrefslogtreecommitdiffstats
path: root/external/common
diff options
context:
space:
mode:
Diffstat (limited to 'external/common')
-rwxr-xr-xexternal/common/get_arch.sh11
-rw-r--r--external/common/rules.mk36
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 $@
+
OpenPOWER on IntegriCloud