Nico Huber submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Nico Huber: Looks good to me, approved
Makefile: Revise C compiler check

Clean up the compiler target by outsourcing the test to an own variable.
Change the print output and don't write to the build-details file.

This is in preparation for further changes.

Change-Id: I3d6f08ef030744c772b4ec0dc2c9e614fb90461d
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58616
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
---
M Makefile
A Makefile.d/cc_test.c
M Makefile.include
3 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/Makefile b/Makefile
index be1d59c..1c3181a 100644
--- a/Makefile
+++ b/Makefile
@@ -158,6 +158,8 @@
CC = gcc
endif

+CC_WORKING := $(call c_compile_test, Makefile.d/cc_test.c)
+
# Determine the destination OS, architecture and endian
# IMPORTANT: The following lines must be placed before TARGET_OS, ARCH or ENDIAN
# is ever used (of course), but should come after any lines setting CC because
@@ -887,13 +889,10 @@
# to environment variables and are referenced with $$<varname> later

compiler: featuresavailable
- @printf "Checking for a C compiler... " | tee -a $(BUILD_DETAILS_FILE)
- @echo "$$COMPILER_TEST" > .test.c
- @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
- @{ { { { { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test.c -o .test$(EXEC_SUFFIX) >&2 && \
- echo "found." || { echo "not found."; \
- rm -f .test.c .test$(EXEC_SUFFIX); exit 1; }; } 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
- @rm -f .test.c .test$(EXEC_SUFFIX)
+ @echo -n "C compiler found: "
+ @if [ $(CC_WORKING) = yes ]; \
+ then $(CC) --version 2>/dev/null | head -1; \
+ else echo no; echo Aborting.; exit 1; fi
@echo Target arch is $(ARCH)
@if [ $(ARCH) = unknown ]; then echo Aborting.; exit 1; fi
@echo Target OS is $(TARGET_OS)
diff --git a/Makefile.d/cc_test.c b/Makefile.d/cc_test.c
new file mode 100644
index 0000000..0610964
--- /dev/null
+++ b/Makefile.d/cc_test.c
@@ -0,0 +1,6 @@
+int main(int argc, char **argv)
+{
+ (void)argc;
+ (void)argv;
+ return 0;
+}
diff --git a/Makefile.include b/Makefile.include
index ca70d05..2b5a344 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -36,15 +36,9 @@
$(strip $(shell $(CC) -E $1 2>/dev/null | tail -1 | tr -d '"'))
endef

-define COMPILER_TEST
-int main(int argc, char **argv)
-{
- (void) argc;
- (void) argv;
- return 0;
-}
+define c_compile_test
+$(shell $(CC) -c -Wall -Werror -o /dev/null $1 2>/dev/null && echo yes || echo no)
endef
-export COMPILER_TEST

define LIBPCI_TEST
/* Avoid a failing test due to libpci header symbol shadowing breakage */

3 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one.

To view, visit change 58616. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I3d6f08ef030744c772b4ec0dc2c9e614fb90461d
Gerrit-Change-Number: 58616
Gerrit-PatchSet: 5
Gerrit-Owner: Thomas Heijligen <src@posteo.de>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: Paul Menzel <paulepanter@mailbox.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-MessageType: merged