In order to support cross compile the OpenCSD for arm/arm64, this patch added two environment variables, 'CROSS_COMPILE' and 'ARCH' which can be set by users before compiling the code.
Like documented in Kernel Makefile, CROSS_COMPILE specifies the prefix used for all executables used during compilation. CROSS_COMPILE can be set on the command line, as is ARCH.
For example, if you want to build the libraryies for Aarch64, you can set "ARCH=arm64", the the compiled libs will be located at lib/linux-arm64/<rel\dbg>.`
Signed-off-by: Chunyan Zhang zhang.chunyan@linaro.org --- decoder/build/linux/makefile | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/decoder/build/linux/makefile b/decoder/build/linux/makefile index 3b6a623..dc1f32b 100644 --- a/decoder/build/linux/makefile +++ b/decoder/build/linux/makefile @@ -47,7 +47,11 @@ export LIB_CAPI_NAME
# determine base architecture, heavily borrowed from the Linux kernel v4.4's # tools/perf/config/Makefile.arch +# For example, to compile for arm64 on a X86 PC, you can issue the command: +# "export ARCH=arm64" +ifndef ARCH ARCH := $(shell uname -m 2>/dev/null || echo not) +endif
# source root directories export OCSD_LIB_ROOT=$(OCSD_ROOT)/lib @@ -58,10 +62,10 @@ export OCSD_SOURCE=$(OCSD_ROOT)/source export OCSD_TESTS=$(OCSD_ROOT)/tests
# tools -export MASTER_CC=gcc -export MASTER_CPP=g++ -export MASTER_LINKER=g++ -export MASTER_LIB=ar +export MASTER_CC=$(CROSS_COMPILE)gcc +export MASTER_CPP=$(CROSS_COMPILE)g++ +export MASTER_LINKER=$(CROSS_COMPILE)g++ +export MASTER_LIB=$(CROSS_COMPILE)ar
# compile flags MASTER_CC_FLAGS := -c -Wall -DLINUX @@ -87,6 +91,10 @@ ifeq ($(ARCH),x86) else ifeq ($(ARCH),x86_64) MFLAG:="-m64" BIT_VARIANT=64 +else ifeq ($(ARCH),arm) + BIT_VARIANT=-arm +else ifeq ($(ARCH),arm64) + BIT_VARIANT=-arm64 endif
MASTER_CC_FLAGS += $(MFLAG)