Nico Huber submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Nico Huber: Looks good to me, approved
Makefile: Revise utsname and clock_gettime test

Clean up the feature target by outsourcing the test to an own variable.
Change the print output and don't write to the build-details file.
HAS_CLOCK_GETTIME=no replaces DISABLE_CLOCK_GETTIME=yes

This is in preparation for further changes.

Change-Id: Ie1f43b3d5a8ad79bff3f9bbc21f359ec35abc42a
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58618
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
---
M Makefile
A Makefile.d/clock_gettime_test.c
A Makefile.d/utsname_test.c
M Makefile.include
4 files changed, 31 insertions(+), 47 deletions(-)

diff --git a/Makefile b/Makefile
index e84248a..bf363de 100644
--- a/Makefile
+++ b/Makefile
@@ -168,6 +168,9 @@
override ARCH := $(call c_macro_test, Makefile.d/arch_test.h)
override ENDIAN := $(call c_macro_test, Makefile.d/endian_test.h)

+HAS_UTSNAME := $(call c_compile_test, Makefile.d/utsname_test.c)
+HAS_CLOCK_GETTIME := $(call c_compile_test, Makefile.d/clock_gettime_test.c)
+
ifeq ($(TARGET_OS), $(filter $(TARGET_OS), FreeBSD OpenBSD DragonFlyBSD))
override CPPFLAGS += -I/usr/local/include
override LDFLAGS += -L/usr/local/lib
@@ -841,13 +844,17 @@
CLI_OBJS += print_wiki.o
endif

-FEATURE_CFLAGS += $(call debug_shell,grep -q "UTSNAME := yes" .features && printf "%s" "-D'HAVE_UTSNAME=1'")
-
# We could use PULLED_IN_LIBS, but that would be ugly.
FEATURE_LIBS += $(call debug_shell,grep -q "NEEDLIBZ := yes" .libdeps && printf "%s" "-lz")

-FEATURE_CFLAGS += $(call debug_shell,grep -q "CLOCK_GETTIME := yes" .features && printf "%s" "-D'HAVE_CLOCK_GETTIME=1'")
-FEATURE_LIBS += $(call debug_shell,grep -q "CLOCK_GETTIME := yes" .features && printf "%s" "-lrt")
+ifeq ($(HAS_UTSNAME), yes)
+FEATURE_CFLAGS += -D'HAVE_UTSNAME=1'
+endif
+
+ifeq ($(HAS_CLOCK_GETTIME), yes)
+FEATURE_CFLAGS += -D'HAVE_CLOCK_GETTIME=1'
+FEATURE_LIBS += -lrt
+endif

LIBFLASHROM_OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
OBJS = $(CLI_OBJS) $(LIBFLASHROM_OBJS)
@@ -1059,24 +1066,8 @@
exit 1; }; } \
2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1
endif
- @printf "Checking for utsname support... " | tee -a $(BUILD_DETAILS_FILE)
- @echo "$$UTSNAME_TEST" > .featuretest.c
- @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
- @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
- ( echo "found."; echo "UTSNAME := yes" >> .features.tmp ) || \
- ( echo "not found."; echo "UTSNAME := no" >> .features.tmp ) } 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
- @printf "Checking for clock_gettime support... " | tee -a $(BUILD_DETAILS_FILE)
-ifeq ($(DISABLE_CLOCK_GETTIME), yes)
- @ { ( echo "disabled."; echo "CLOCK_GETTIME := no" >>.features.tmp ) } \
- 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
-else
- @echo "$$CLOCK_GETTIME_TEST" >.featuretest.c
- @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lrt .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE)
- @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lrt .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \
- ( echo "found."; echo "CLOCK_GETTIME := yes" >>.features.tmp ) || \
- ( echo "not found."; echo "CLOCK_GETTIME := no" >>.features.tmp ) } \
- 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE)
-endif
+ @echo "Checking for header \"sys/utsname.h\": $(HAS_UTSNAME)"
+ @echo "Checking for function \"clock_gettime\": $(HAS_CLOCK_GETTIME)"
@$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
@rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)

diff --git a/Makefile.d/clock_gettime_test.c b/Makefile.d/clock_gettime_test.c
new file mode 100644
index 0000000..000aa42
--- /dev/null
+++ b/Makefile.d/clock_gettime_test.c
@@ -0,0 +1,9 @@
+#include <time.h>
+int main(int argc, char **argv)
+{
+ (void)argc;
+ (void)argv;
+ struct timespec res;
+ clock_gettime(CLOCK_REALTIME, &res);
+ return 0;
+}
diff --git a/Makefile.d/utsname_test.c b/Makefile.d/utsname_test.c
new file mode 100644
index 0000000..7bc6665
--- /dev/null
+++ b/Makefile.d/utsname_test.c
@@ -0,0 +1,9 @@
+#include <sys/utsname.h>
+struct utsname osinfo;
+int main(int argc, char **argv)
+{
+ (void)argc;
+ (void)argv;
+ uname(&osinfo);
+ return 0;
+}
diff --git a/Makefile.include b/Makefile.include
index 2b5a344..0ea1234 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -130,19 +130,6 @@
endef
export FTDI_232H_TEST

-define UTSNAME_TEST
-#include <sys/utsname.h>
-struct utsname osinfo;
-int main(int argc, char **argv)
-{
- (void) argc;
- (void) argv;
- uname (&osinfo);
- return 0;
-}
-endef
-export UTSNAME_TEST
-
define LINUX_MTD_TEST
#include <mtd/mtd-user.h>

@@ -181,18 +168,6 @@
endef
export LINUX_I2C_TEST

-define CLOCK_GETTIME_TEST
-#include <time.h>
-
-int main(int argc, char **argv)
-{
- struct timespec res;
- clock_gettime(CLOCK_REALTIME, &res);
- return 0;
-}
-endef
-export CLOCK_GETTIME_TEST
-
define NI845X_TEST
#include <ni845x.h>


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

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

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie1f43b3d5a8ad79bff3f9bbc21f359ec35abc42a
Gerrit-Change-Number: 58618
Gerrit-PatchSet: 7
Gerrit-Owner: Thomas Heijligen <src@posteo.de>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Martin Lucina <martin@lucina.net>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter@mailbox.org>
Gerrit-MessageType: merged