[PATCH] configure: $(CC) -o /dev/null when output not run

Subject: [PATCH] configure: $(CC) -o /dev/null when output not run

Date: Sat, 22 May 2021 00:02:50 +0300

To: notmuch@notmuchmail.org

Cc: tomi.ollila@iki.fi

From: Tomi Ollila


When C compilation is used just to see whether compilation
succeeds, there is no need to write any output file.

Some compilations in configure already did this.

Now also rm -f lines are used more consistently.

While at it reformatted code that prints
LIBNOTMUCH_{MAJOR,MINOR,MICRO}_VERSION).
---

Hmm, these
    printf("libnotmuch_version_major=%d\n", LIBNOTMUCH_MAJOR_VERSION)
lines leaked into this commit. I've always wanted to make
this change (as it fits and looks clearer) but haven't found
good commit for that.... Now edited commit message to mention 
the change.

 configure | 57 ++++++++++++++++++++++---------------------------------
 1 file changed, 23 insertions(+), 34 deletions(-)

diff --git a/configure b/configure
index cfa9c09b..e907c6fc 100755
--- a/configure
+++ b/configure
@@ -362,7 +362,7 @@ errors=0
 printf "int main(void){return 0;}\n" > minimal.c
 
 printf "Sanity checking C compilation environment... "
-test_cmdline="${CC} ${CFLAGS} ${CPPFLAGS} minimal.c ${LDFLAGS} -o minimal"
+test_cmdline="${CC} ${CFLAGS} ${CPPFLAGS} minimal.c ${LDFLAGS} -o /dev/null"
 if  ${test_cmdline} > /dev/null 2>&1
 then
     printf "OK.\n"
@@ -374,7 +374,7 @@ else
 fi
 
 printf "Sanity checking C++ compilation environment... "
-test_cmdline="${CXX} ${CXXFLAGS_for_sh} ${CPPFLAGS} minimal.c ${LDFLAGS} -o minimal"
+test_cmdline="${CXX} ${CXXFLAGS_for_sh} ${CPPFLAGS} minimal.c ${LDFLAGS} -o /dev/null"
 if ${test_cmdline} > /dev/null 2>&1
 then
     printf "OK.\n"
@@ -392,7 +392,7 @@ if [ $errors -gt 0 ]; then
 running configure in a clean environment, and if the problem persists,
 report a bug.
 EOF
-    rm -f minimal minimal.c
+    rm -f minimal.c
     exit 1
 fi
 
@@ -401,12 +401,9 @@ cat > _libversion.c <<EOF
 #include <stdio.h>
 #include "lib/notmuch.h"
 int main(void) {
-    printf("libnotmuch_version_major=%d\n",
-		LIBNOTMUCH_MAJOR_VERSION);
-    printf("libnotmuch_version_minor=%d\n",
-		LIBNOTMUCH_MINOR_VERSION);
-    printf("libnotmuch_version_release=%d\n",
-		LIBNOTMUCH_MICRO_VERSION);
+    printf("libnotmuch_version_major=%d\n",	LIBNOTMUCH_MAJOR_VERSION);
+    printf("libnotmuch_version_minor=%d\n",	LIBNOTMUCH_MINOR_VERSION);
+    printf("libnotmuch_version_release=%d\n",	LIBNOTMUCH_MICRO_VERSION);
     return 0;
 }
 EOF
@@ -432,7 +429,6 @@ else
 fi
 
 
-
 printf "Checking for Xapian development files (>= 1.4.0)... "
 have_xapian=0
 for xapian_config in ${XAPIAN_CONFIG} xapian-config; do
@@ -1045,7 +1041,7 @@ EOF
 fi
 
 printf "Checking for canonicalize_file_name... "
-if ${CC} -o compat/have_canonicalize_file_name "$srcdir"/compat/have_canonicalize_file_name.c > /dev/null 2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/have_canonicalize_file_name.c > /dev/null 2>&1
 then
     printf "Yes.\n"
     have_canonicalize_file_name=1
@@ -1053,11 +1049,9 @@ else
     printf "No (will use our own instead).\n"
     have_canonicalize_file_name=0
 fi
-rm -f compat/have_canonicalize_file_name
-
 
 printf "Checking for getline... "
-if ${CC} -o compat/have_getline "$srcdir"/compat/have_getline.c > /dev/null 2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/have_getline.c > /dev/null 2>&1
 then
     printf "Yes.\n"
     have_getline=1
@@ -1065,10 +1059,9 @@ else
     printf "No (will use our own instead).\n"
     have_getline=0
 fi
-rm -f compat/have_getline
 
 printf "Checking for strcasestr... "
-if ${CC} -o compat/have_strcasestr "$srcdir"/compat/have_strcasestr.c > /dev/null 2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/have_strcasestr.c > /dev/null 2>&1
 then
     printf "Yes.\n"
     have_strcasestr=1
@@ -1076,10 +1069,9 @@ else
     printf "No (will use our own instead).\n"
     have_strcasestr=0
 fi
-rm -f compat/have_strcasestr
 
 printf "Checking for strsep... "
-if ${CC} -o compat/have_strsep "$srcdir"/compat/have_strsep.c > /dev/null 2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/have_strsep.c > /dev/null 2>&1
 then
     printf "Yes.\n"
     have_strsep="1"
@@ -1087,10 +1079,9 @@ else
     printf "No (will use our own instead).\n"
     have_strsep="0"
 fi
-rm -f compat/have_strsep
 
 printf "Checking for timegm... "
-if ${CC} -o compat/have_timegm "$srcdir"/compat/have_timegm.c > /dev/null 2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/have_timegm.c > /dev/null 2>&1
 then
     printf "Yes.\n"
     have_timegm="1"
@@ -1098,7 +1089,6 @@ else
     printf "No (will use our own instead).\n"
     have_timegm="0"
 fi
-rm -f compat/have_timegm
 
 cat <<EOF > _time_t.c
 #include <time.h>
@@ -1117,7 +1107,7 @@ else
 fi
 
 printf "Checking for dirent.d_type... "
-if ${CC} -o compat/have_d_type "$srcdir"/compat/have_d_type.c > /dev/null 2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/have_d_type.c > /dev/null 2>&1
 then
     printf "Yes.\n"
     have_d_type="1"
@@ -1125,10 +1115,9 @@ else
     printf "No (will use stat instead).\n"
     have_d_type="0"
 fi
-rm -f compat/have_d_type
 
 printf "Checking for standard version of getpwuid_r... "
-if ${CC} -o compat/check_getpwuid "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/check_getpwuid.c > /dev/null 2>&1
 then
     printf "Yes.\n"
     std_getpwuid=1
@@ -1136,10 +1125,9 @@ else
     printf "No (will define _POSIX_PTHREAD_SEMANTICS to get it).\n"
     std_getpwuid=0
 fi
-rm -f compat/check_getpwuid
 
 printf "Checking for standard version of asctime_r... "
-if ${CC} -o compat/check_asctime "$srcdir"/compat/check_asctime.c > /dev/null 2>&1
+if ${CC} -o /dev/null "$srcdir"/compat/check_asctime.c > /dev/null 2>&1
 then
     printf "Yes.\n"
     std_asctime=1
@@ -1147,10 +1135,9 @@ else
     printf "No (will define _POSIX_PTHREAD_SEMANTICS to get it).\n"
     std_asctime=0
 fi
-rm -f compat/check_asctime
 
 printf "Checking for rpath support... "
-if [ $WITH_RPATH = "1" ] && ${CC} -Wl,--enable-new-dtags -Wl,-rpath,/tmp/ -o minimal minimal.c >/dev/null 2>&1
+if [ $WITH_RPATH = "1" ] && ${CC} -Wl,--enable-new-dtags -Wl,-rpath,/tmp/ -o /dev/null minimal.c >/dev/null 2>&1
 then
     printf "Yes.\n"
     rpath_ldflags="-Wl,--enable-new-dtags -Wl,-rpath,\$(libdir)"
@@ -1160,7 +1147,7 @@ else
 fi
 
 printf "Checking for -Wl,--as-needed... "
-if ${CC} -Wl,--as-needed -o minimal minimal.c >/dev/null 2>&1
+if ${CC} -Wl,--as-needed -o /dev/null minimal.c >/dev/null 2>&1
 then
     printf "Yes.\n"
     as_needed_ldflags="-Wl,--as-needed"
@@ -1170,7 +1157,7 @@ else
 fi
 
 printf "Checking for -Wl,--no-undefined... "
-if ${CC} -Wl,--no-undefined -o minimal minimal.c >/dev/null 2>&1
+if ${CC} -Wl,--no-undefined -o /dev/null minimal.c >/dev/null 2>&1
 then
     printf "Yes.\n"
     no_undefined_ldflags="-Wl,--no-undefined"
@@ -1182,7 +1169,7 @@ fi
 WARN_CXXFLAGS=""
 printf "Checking for available C++ compiler warning flags... "
 for flag in -Wall -Wextra -Wwrite-strings; do
-    if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
+    if ${CC} $flag -o /dev/null minimal.c > /dev/null 2>&1
     then
 	WARN_CXXFLAGS="${WARN_CXXFLAGS}${WARN_CXXFLAGS:+ }${flag}"
     fi
@@ -1192,15 +1179,17 @@ printf "\n\t%s\n" "${WARN_CXXFLAGS}"
 WARN_CFLAGS="${WARN_CXXFLAGS}"
 printf "Checking for available C compiler warning flags... "
 for flag in -Wmissing-declarations; do
-    if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
+    if ${CC} $flag -o /dev/null minimal.c > /dev/null 2>&1
     then
 	WARN_CFLAGS="${WARN_CFLAGS}${WARN_CFLAGS:+ }${flag}"
     fi
 done
 printf "\n\t%s\n" "${WARN_CFLAGS}"
 
-rm -f minimal minimal.c _time_t.c _libversion.c _libversion _libversion.sh _check_session_keys.c _check_session_keys _check_x509_validity.c _check_x509_validity \
-   _verify_sig_with_session_key.c _verify_sig_with_session_key
+rm -f minimal.c _time_t.c _libversion.c _libversion _libversion.sh \
+    _check_session_keys.c _check_session_keys \
+    _check_x509_validity.c _check_x509_validity \
+    _verify_sig_with_session_key.c _verify_sig_with_session_key
 
 # construct the Makefile.config
 cat > Makefile.config <<EOF
-- 
2.31.1

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: