fix broken dependencies when building on aarch64
[benchmarks.git] / Makefile
index 67f9c5866634ec5b711496efd04561b97aab5c32..a7015370a935ed84a43bd7e79a7bd46993a3b3ab 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,18 @@
 .PHONY: all clean configure
-all: build-ppc64le/benchmarks build-aarch64/benchmarks build-x86_64/benchmarks
+
+host_arch = $(shell uname -m)
+ifeq ($(host_arch),x86_64)
+       enabled_arches = ppc64le aarch64 x86_64
+else ifeq ($(host_arch),aarch64)
+       # debian 10 doesn't have cross-compilers for ppc64le from aarch64
+       enabled_arches = aarch64 x86_64
+else ifeq ($(host_arch),ppc64le)
+       enabled_arches = ppc64le aarch64 x86_64
+else
+       $(error unsupported arch $(host_arch))
+endif
+
+all: $(foreach arch,$(enabled_arches),build-$(arch)/benchmarks)
 
 common_cmake_flags = -S .
 common_cmake_flags += -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE
@@ -7,7 +20,7 @@ common_cmake_flags += -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE
 reset_make_env = "MAKEFLAGS=" "MFLAGS=" "MAKELEVEL=" "MAKE_TERMERR=" "MAKE_TERMOUT="
 
 .installed-dependencies: install-deps.sh
-       ./install-deps.sh
+       ./install-deps.sh $(enabled_arches)
        touch .installed-dependencies
 
 build-ppc64le/Makefile: toolchain-powerpc64le-linux-gnu.cmake CMakeLists.txt .installed-dependencies
@@ -22,7 +35,7 @@ build-x86_64/Makefile: toolchain-x86_64-linux-gnu.cmake CMakeLists.txt .installe
        rm -fr build-x86_64
        env $(reset_make_env) cmake $(common_cmake_flags) -B build-x86_64 -DCMAKE_TOOLCHAIN_FILE=toolchain-x86_64-linux-gnu.cmake
 
-configure: build-ppc64le/Makefile build-aarch64/Makefile build-x86_64/Makefile
+configure: $(foreach arch,$(enabled_arches),build-$(arch)/Makefile)
 
 .PHONY: __force-run