.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
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
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
#!/bin/bash
set -e
+arches="$*"
+if [[ "$arches" == "" ]]; then
+ arches="x86_64 aarch64 ppc64le"
+fi
# need to install g++ first so the local arch will get filtered out later
which g++ > /dev/null || (set -x; sudo apt install build-essential g++)
needed=()
-which x86_64-linux-gnu-g++ > /dev/null || needed+=(g++-x86-64-linux-gnu)
-which aarch64-linux-gnu-g++ > /dev/null || needed+=(g++-aarch64-linux-gnu)
-which powerpc64le-linux-gnu-g++ > /dev/null || needed+=(g++-powerpc64le-linux-gnu)
+for arch in $arches; do
+ case "$arch" in
+ x86_64)
+ which x86_64-linux-gnu-g++ > /dev/null || needed+=(g++-x86-64-linux-gnu)
+ ;;
+ aarch64)
+ which aarch64-linux-gnu-g++ > /dev/null || needed+=(g++-aarch64-linux-gnu)
+ ;;
+ ppc64le)
+ which powerpc64le-linux-gnu-g++ > /dev/null || needed+=(g++-powerpc64le-linux-gnu)
+ ;;
+ *)
+ echo "unknown arch: $arch" >&2
+ exit 1
+ esac
+done
which clang++-11 > /dev/null || needed+=(clang-11)
which make > /dev/null || needed+=(make)
which cmake > /dev/null || needed+=(cmake)