summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Magasweran <lucas.magasweran@ieee.org>2019-08-07 14:43:23 +0200
committerLucas Magasweran <lucas.magasweran@ieee.org>2019-08-08 15:26:30 +0200
commit0863eff8fa1d32797e3aec19672878aff893b0ae (patch)
tree10911d26446e51a1531512eabe5e1e1f149404d1
parent5573d9d942f44288f6ff324184a652e54d569826 (diff)
downloadlm-sensors-git-0863eff8fa1d32797e3aec19672878aff893b0ae.tar.gz
makefile: use target arch when determining what programs to compile
To better support cross-compilation, the Makefile should detect the compiler's target architecture instead of using `uname -m`, which returns the host architecture. This approach uses the `gcc`/`clang` compatible `-dumpmachine` option. Cross-compilation worked but because of this bug, `isadump` and `isaset` x86 ISA specific tools were built for PCC and ARM. This run-time issue became a compile-time issue when `glibc` 2.30 removed the `sys/io.h` I/O port functions on ARM. Also renamed `MACHINE` to `ARCH` to match cross-compiler conventions for specifying the target architecture. For example, `make ARCH=arm CC=arm-linux-gnueabi-gcc AR=arm-linux-gnueabi-ar` Fixes #190 Signed-off-by: Lucas Magasweran <lucas.magasweran@ieee.org> Reported-and-tested-by: Millhouse <milhouse@libreelec.tv>
-rw-r--r--Makefile4
1 files changed, 2 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 2f5859f0..47ffe788 100644
--- a/Makefile
+++ b/Makefile
@@ -77,7 +77,7 @@ LIBINCLUDEDIR := $(INCLUDEDIR)/sensors
# manual pages will be installed.
MANDIR := $(PREFIX)/man
-MACHINE := $(shell uname -m)
+ARCH := $(firstword $(subst -, ,$(shell $(CC) -dumpmachine)))
# Extra non-default programs to build; e.g., sensord
#PROG_EXTRA := sensord
@@ -109,7 +109,7 @@ BUILD_STATIC_LIB := 1
SRCDIRS := lib prog/detect prog/pwm \
prog/sensors ${PROG_EXTRA:%=prog/%} etc
# Only build isadump and isaset on x86 machines.
-ifneq (,$(findstring $(MACHINE), i386 i486 i586 i686 x86_64))
+ifneq (,$(findstring $(ARCH), i386 i486 i586 i686 x86_64))
SRCDIRS += prog/dump
endif
SRCDIRS += lib/test