Thomas Heijligen has uploaded this change for review.
Makefile: move endian test into the Makefile
Change-Id: I0c2420fd60d7d6a23c94c9962b06bfd7f3c86ad8
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
---
M Makefile
M Makefile.include
D endiantest.c
3 files changed, 17 insertions(+), 8 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/70/58270/1
diff --git a/Makefile b/Makefile
index 3acef60..993cfc0 100644
--- a/Makefile
+++ b/Makefile
@@ -164,8 +164,7 @@
# the line below uses CC itself.
override TARGET_OS := $(call c_macro_test, $(TARGET_OS_TEST))
override ARCH := $(call c_macro_test, $(ARCH_TEST))
-override ENDIAN := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E endiantest.c 2>/dev/null \
- | tail -1))
+override ENDIAN := $(call c_macro_test, $(ENDIAN_TEST))
ifeq ($(TARGET_OS), $(filter $(TARGET_OS), FreeBSD OpenBSD DragonFlyBSD))
override CPPFLAGS += -I/usr/local/include
@@ -869,6 +868,8 @@
@if [ $(ARCH) = unknown ]; then echo Aborting.; exit 1; fi
@echo Target OS os $(TARGET_OS)
@if [ $(TARGET_OS) = unknown ]; then echo Aborting.; exit 1; fi
+ @echo Target endian is $(ENDIAN)
+ @if [ $(ENDIAN) = unknown ]; then echo Aborting.; exit 1; fi
ifeq ($(TARGET_OS), libpayload)
@$(CC) --version 2>&1 | grep -q coreboot || \
( echo "Warning: It seems you are not using coreboot's reference compiler."; \
diff --git a/Makefile.include b/Makefile.include
index eb54acf..212e9be 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -109,6 +109,20 @@
#endif \n
endef
+# This works since gcc 4.6 and with clang
+# https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
+define ENDIAN_TEST
+#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
+ __BYTE_ORDER__ ==__ORDER_BIG_ENDIAN__ \n
+ 'big' \n
+#elif defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
+ __BYTE_ORDER__ ==__ORDER_LITTLE_ENDIAN__ \n
+ 'little' \n
+#else \n
+ 'unknown' \n
+#endif n
+endef
+
define COMPILER_TEST
int main(int argc, char **argv)
{
diff --git a/endiantest.c b/endiantest.c
deleted file mode 100644
index a73b908..0000000
--- a/endiantest.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "platform.h"
-#if defined(__FLASHROM_LITTLE_ENDIAN__)
-little
-#else
-big
-#endif
To view, visit change 58270. To unsubscribe, or for help writing mail filters, visit settings.