* [PATCH] configure: $(CC) -o /dev/null when output not run
@ 2021-05-21 21:02 Tomi Ollila
2021-05-22 11:51 ` David Bremner
0 siblings, 1 reply; 3+ messages in thread
From: Tomi Ollila @ 2021-05-21 21:02 UTC (permalink / raw)
To: notmuch; +Cc: 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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] configure: $(CC) -o /dev/null when output not run
2021-05-21 21:02 [PATCH] configure: $(CC) -o /dev/null when output not run Tomi Ollila
@ 2021-05-22 11:51 ` David Bremner
2021-05-23 15:12 ` Tomi Ollila
0 siblings, 1 reply; 3+ messages in thread
From: David Bremner @ 2021-05-22 11:51 UTC (permalink / raw)
To: Tomi Ollila, notmuch; +Cc: tomi.ollila
Tomi Ollila <tomi.ollila@iki.fi> writes:
> 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).
no objection in principle, but has anyone tried a compiler other than
gcc to make sure it doesn't puke when writing to /dev/null. Not sure
why it would, but...
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] configure: $(CC) -o /dev/null when output not run
2021-05-22 11:51 ` David Bremner
@ 2021-05-23 15:12 ` Tomi Ollila
0 siblings, 0 replies; 3+ messages in thread
From: Tomi Ollila @ 2021-05-23 15:12 UTC (permalink / raw)
To: David Bremner, notmuch
On Sat, May 22 2021, David Bremner wrote:
> Tomi Ollila <tomi.ollila@iki.fi> writes:
>
>> 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).
>
> no objection in principle, but has anyone tried a compiler other than
> gcc to make sure it doesn't puke when writing to /dev/null. Not sure
> why it would, but...
I gave it some thought and was sure there would be no such case...
But now that I tested with 'zig cc' -- it apparently tries to remove
the target file before recreating and fails with accessDenied if cannot
(or, hopefully it just checks permissions, as removing /dev/null as
root would be nasty...)
Too bad, I had some plans that this change would have helped but...
Tomi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-05-23 15:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-21 21:02 [PATCH] configure: $(CC) -o /dev/null when output not run Tomi Ollila
2021-05-22 11:51 ` David Bremner
2021-05-23 15:12 ` Tomi Ollila
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).