gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master c7b62c8 2/3: Check for C++ executable to avoid


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master c7b62c8 2/3: Check for C++ executable to avoid make check crash
Date: Tue, 10 Jul 2018 23:01:02 -0400 (EDT)

branch: master
commit c7b62c888990b6799f429c4cfdf3649ae7203e55
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    Check for C++ executable to avoid make check crash
    
    According to the Autoconf manual: "if none of the [AC_PROG_CXX] checks
    succeed, then as a last resort [it will] set `CXX' to `g++'". Therefore,
    when a C++ compiler doesn't exist, when trying to build the
    `versioncxx.cpp' test, `make check' will fail! I found this in a fresh
    install of Fedora 28 (in Live USB), where `g++' doesn't exist and `make
    check' failed.
    
    To fix the problem, a check has been added in `configure.ac' and if the C++
    compiler doesn't exist, then the `versioncxx' test will not be executed and
    completely ignored!
    
    This fixes bug #54285.
---
 NEWS              |  1 +
 configure.ac      | 18 ++++++++++++++++++
 tests/Makefile.am | 10 +++++++---
 3 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index ec8e18a..93dfe39 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,7 @@ GNU Astronomy Utilities NEWS                          -*- 
outline -*-
   bug #54186: MakeCatalog's --checkupperlimit not keeping output's name.
   bug #54188: MakeCatalog's Upperlimit not being sigma-clipped properly.
   bug #54284: Crop segrault when catalog contains no data.
+  bug #54285: make check fails if g++ not present.
 
 
 
diff --git a/configure.ac b/configure.ac
index dcb470f..a5694db 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,6 +95,23 @@ CXXFLAGS="-Wall -O3 $CXXFLAGS"
 
 
 
+# See if the C++ compiler was present. `CXX' has already been set by
+# `AC_PROG_CXX' (above). According to the Autoconf manual: "if none of the
+# [AC_PROG_CXX] checks succeed, then as a last resort [it will] set `CXX'
+# to `g++'". Therefore, we can't rely on it to see if the compiler
+# executable is actually usable. Therefore tests that rely on it will
+# fail. Unfortunately some OSs (like Fedora), don't install `g++' with
+# `gcc', so it may not always be present. To fix this, here we are just
+# using `AC_CHECK_PROG' to see if the `CXX' executable is reachable in the
+# search path and if it isn't, we'll disable the C++ check during `make
+# check' with an Automake conditional.
+AC_CHECK_PROG(has_cxx, $CXX, "yes", "no")
+AM_CONDITIONAL([COND_HASCXX], [test "x$has_cxx" = "xyes"])
+
+
+
+
+
 # Check for pthreads and add the appropriate compilation flags. AX_PTHREAD
 # comes from the GNU Autoconf Archive's ax_pthread.m4, see there for the
 # documentation. Note that
@@ -258,6 +275,7 @@ gl_INIT
 
 
 
+
 # Gnulib checks for the proper name for the C99 equivalent `restrict'
 # keyword and puts it in the `ac_cv_c_restrict' variable. If none exists,
 # it will put a `no' inside of this variable. As described in the output
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2678a7a..d298d56 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -51,6 +51,11 @@ endif
 if COND_HASGNULIBTOOL
   MAYBE_HASGNULIBTOOL = "yes"
 endif
+if COND_HASCXX
+  MAYBE_CXX_PROGS    = versioncxx
+  MAYBE_CXX_TESTS    = lib/versioncxx.sh
+  versioncxx_SOURCES = lib/versioncxx.cpp
+endif
 if COND_ARITHMETIC
   MAYBE_ARITHMETIC_TESTS = arithmetic/snimage.sh arithmetic/onlynumbers.sh \
   arithmetic/where.sh arithmetic/or.sh arithmetic/connected-components.sh
@@ -220,9 +225,8 @@ AM_CPPFLAGS = -I\$(top_srcdir)/lib -I\$(top_builddir)/lib
 
 # Rest of library check settings.
 LDADD = -lgnuastro
-check_PROGRAMS = multithread versioncxx
+check_PROGRAMS = multithread $(MAYBE_CXX_PROGS)
 multithread_SOURCES = lib/multithread.c
-versioncxx_SOURCES  = lib/versioncxx.cpp
 lib/multithread.sh: mkprof/mosaic1.sh.log
 
 
@@ -231,7 +235,7 @@ lib/multithread.sh: mkprof/mosaic1.sh.log
 
 # Final Tests
 # ===========
-TESTS = prepconf.sh lib/multithread.sh lib/versioncxx.sh                   \
+TESTS = prepconf.sh lib/multithread.sh $(MAYBE_CXX_TESTS)                  \
   $(MAYBE_ARITHMETIC_TESTS) $(MAYBE_BUILDPROG_TESTS)                       \
   $(MAYBE_CONVERTT_TESTS) $(MAYBE_CONVOLVE_TESTS) $(MAYBE_COSMICCAL_TESTS) \
   $(MAYBE_CROP_TESTS) $(MAYBE_FITS_TESTS) $(MAYBE_MATCH_TESTS)             \



reply via email to

[Prev in Thread] Current Thread [Next in Thread]