gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 65905372: Library (config.h): added macros for


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 65905372: Library (config.h): added macros for python and gnumake checks
Date: Thu, 8 Sep 2022 06:03:20 -0400 (EDT)

branch: master
commit 659053720e1725f773c76f1d2ce5a2390a56ef04
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    Library (config.h): added macros for python and gnumake checks
    
    Until now, the recently added checks for the availability of Python or GNU
    Make's extension libraries weren't provided to the user of the library
    through macros.
    
    With this commit, two new macros have been defined in 'gnuastro/config.h'
    for informing the library user if these are available or not.
    
    I also arranged the macros in 'lib/gnuastro-internal/config.h.in' (which
    acts as the basis for the built 'config.h', in order of increasing macro
    name length.
---
 NEWS                              |  4 +++-
 configure.ac                      |  7 ++++---
 doc/gnuastro.texi                 | 20 +++++++++++++++++++-
 lib/Makefile.am                   |  4 +++-
 lib/gnuastro-internal/config.h.in |  9 +++++----
 5 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/NEWS b/NEWS
index 8251eda9..ecd2090e 100644
--- a/NEWS
+++ b/NEWS
@@ -117,7 +117,9 @@ See the end of the file for license conditions.
       FITS files. It will return all the unique values given to that
       keyword within the FITS files.
 
-  Library functions:
+  Library:
+  - GAL_CONFIG_HAVE_PYTHON: non-zero if Python3+Numpy features included.
+  - GAL_CONFIG_HAVE_GNUMAKE_H: non-zero if GNU Make extensions can be made.
   - gal_box_border_rotate_around_center: width of box after rotation.
   - gal_color_id_to_name: return the name of a color from its ID.
   - gal_color_in_rgb: return the fraction of red-green-blue in a color.
diff --git a/configure.ac b/configure.ac
index 8a302305..bac0e33d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -487,6 +487,7 @@ AS_IF([test "x$LIBGIT2" = x],
        AS_IF([ test "x$enable_shared" = "xno" ],
              [LDADD="$LIBGIT2   $LDADD"],
              [LDADD="$LTLIBGIT2 $LDADD"]) ])
+AC_SUBST(HAVE_LIBGIT2_FOR_CONF, [$has_libgit2])
 AC_DEFINE_UNQUOTED([GAL_CONFIG_HAVE_LIBGIT2], [$has_libgit2],
                    [libgit2 is installed on the system])
 AS_IF([test "x$has_libgit2" = "x1"], [], [anywarnings=yes])
@@ -494,7 +495,6 @@ AS_IF([test "x$has_libgit2" = "x1"], [], [anywarnings=yes])
 
 
 
-
 # Check if the compiler works with static linking
 AS_IF([test "$lt_cv_prog_compiler_static_works" = no ],
       [ AS_IF([test "$enable_shared" = no ],
@@ -794,7 +794,8 @@ AS_IF([test "x$with_python" != xno],
         AC_SUBST(PYTHON_INCLUDE_DIR, [$python_includedir])
       ])
 AS_IF([test "x$numpy_includedir" = x],
-      [has_numpy=no; anywarnings=yes;], [has_numpy=yes;])
+      [has_numpy=0; anywarnings=yes;], [has_numpy=1;])
+AC_SUBST(HAVE_PYTHON, [$has_numpy])
 AM_CONDITIONAL([COND_NUMPY], [test "x$numpy_includedir" != x])
 
 
@@ -1351,7 +1352,7 @@ AS_IF([test x$enable_guide_message = xyes],
                AS_ECHO(["    to improve your Makefiles for data analysis 
workflows."])
                AS_ECHO([]) ])
 
-        AS_IF([test "x$has_numpy" = "xno"],
+        AS_IF([test "x$has_numpy" = "x0"],
               [dependency_notice=yes
                AS_ECHO(["  - Numpy (https://numpy.org) headers couldn't be 
found within a "])
                AS_ECHO(["    Python3 installation. If available, Gnuastro's 
library will be "])
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index ba601c67..388c42e6 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -28882,7 +28882,6 @@ Their values are commonly either 4 or 8 for 32-bit and 
64-bit systems.
 You can also get this value with the expression `@code{sizeof size_t}' for 
example without having to include this header.
 @end deffn
 
-
 @deffn Macro GAL_CONFIG_HAVE_LIBGIT2
 Libgit2 is an optional dependency of Gnuastro (see @ref{Optional 
dependencies}).
 When it is installed and detected at configure time, this macro will have a 
value of @code{1} (one).
@@ -28890,6 +28889,22 @@ Otherwise, it will have a value of @code{0} (zero).
 Gnuastro also comes with some wrappers to make it easier to use libgit2 (see 
@ref{Git wrappers}).
 @end deffn
 
+@deffn Macro GAL_CONFIG_HAVE_PYTHON
+Gnuastro can optionally provide a set of basic functions to facilitate wrapper 
libraries in Python (see @ref{Python interface}).
+If a version of Python 3.X was found on the host system that has the necessary 
Numpy headers, this macro will be given a value of @code{1}.
+Otherwise, it will be given a value of @code{0} and the the Python interface 
functions won't be available in the host's Gnuastro library.
+@end deffn
+
+@deffn Macro GAL_CONFIG_HAVE_GNUMAKE_H
+Gnuastro provides a set of GNU Make extension functions (see @ref{Makefile 
extensions}).
+In order to use those, the host should have @file{gnumake.h} in its include 
paths.
+This check is done at Gnuastro's configuration time.
+If it was found, this macro is given a value of @code{1}, otherwise, it will 
have a value of @code{0}.
+@end deffn
+
+
+
+
 
 @node Multithreaded programming, Library data types, Configuration 
information, Gnuastro library
 @subsection Multithreaded programming (@file{threads.h})
@@ -35989,6 +36004,9 @@ The Python interface of Gnuastro's library is built and 
installed by default if
 Users may disable this interface with the @option{--without-python} option to 
@code{./configure} when they installed Gnuastro, see @ref{Gnuastro configure 
options}.
 If you have problems in a Pythin virtual env, see @ref{Optional dependencies}.
 
+Because Python is an optional dependency of Gnuastro, the following functions 
may not be available on some systems.
+To check if the installed Gnuastro library was compiled with the following 
functions, you can use the @code{GAL_CONFIG_HAVE_PYTHON} macro which is defined 
in @file{gnuastro/config.h}, see @ref{Configuration information}.
+
 
 @deftypefun int gal_python_type_to_numpy (uint8_t @code{type})
 Returns the NumPy datatype corresponding to a certain Gnuastro @code{type}, 
see @ref{Library data types}.
diff --git a/lib/Makefile.am b/lib/Makefile.am
index d4fb552b..94513bb3 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -254,10 +254,12 @@ gnuastro/config.h: Makefile $(internaldir)/config.h.in
        rm -f $@ $@.tmp
        $(MKDIR_P) gnuastro
        $(SED) -e 's|@VERSION[@]|$(VERSION)|g' \
+              -e 's|@HAVE_PYTHON[@]|$(HAVE_PYTHON)|g' \
               -e 's|@SIZEOF_LONG[@]|$(SIZEOF_LONG)|g' \
-              -e 's|@HAVE_LIBGIT2[@]|$(HAVE_LIBGIT2)|g' \
               -e 's|@SIZEOF_SIZE_T[@]|$(SIZEOF_SIZE_T)|g' \
+              -e 's|@HAVE_GNUMAKE_H[@]|$(HAVE_GNUMAKE_H)|g' \
               -e 's|@HAVE_GSL_STEFFEN[@]|$(HAVE_GSL_STEFFEN)|g' \
+              -e 's|@HAVE_LIBGIT2[@]|$(HAVE_LIBGIT2_FOR_CONF)|g' \
               -e 's|@HAVE_WCSLIB_DIS_H[@]|$(HAVE_WCSLIB_DIS_H)|g' \
               -e 's|@HAVE_WCSLIB_MJDREF[@]|$(HAVE_WCSLIB_MJDREF)|g' \
               -e 's|@HAVE_WCSLIB_OBSFIX[@]|$(HAVE_WCSLIB_OBSFIX)|g' \
diff --git a/lib/gnuastro-internal/config.h.in 
b/lib/gnuastro-internal/config.h.in
index eaff909a..55be577b 100644
--- a/lib/gnuastro-internal/config.h.in
+++ b/lib/gnuastro-internal/config.h.in
@@ -37,14 +37,15 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 #define GAL_CONFIG_VERSION                  "@VERSION@"
 
+#define GAL_CONFIG_HAVE_PYTHON              @HAVE_PYTHON@
 #define GAL_CONFIG_HAVE_LIBGIT2             @HAVE_LIBGIT2@
-
-#define GAL_CONFIG_HAVE_GSL_INTERP_STEFFEN  @HAVE_GSL_STEFFEN@
-#define GAL_CONFIG_HAVE_FITS_IS_REENTRANT   @HAVE_FITS_IS_REENTRANT@
-#define GAL_CONFIG_HAVE_WCSLIB_VERSION      @HAVE_WCSLIB_VERSION@
+#define GAL_CONFIG_HAVE_GNUMAKE_H           @HAVE_GNUMAKE_H@
 #define GAL_CONFIG_HAVE_WCSLIB_DIS_H        @HAVE_WCSLIB_DIS_H@
 #define GAL_CONFIG_HAVE_WCSLIB_MJDREF       @HAVE_WCSLIB_MJDREF@
 #define GAL_CONFIG_HAVE_WCSLIB_OBSFIX       @HAVE_WCSLIB_OBSFIX@
+#define GAL_CONFIG_HAVE_WCSLIB_VERSION      @HAVE_WCSLIB_VERSION@
+#define GAL_CONFIG_HAVE_FITS_IS_REENTRANT   @HAVE_FITS_IS_REENTRANT@
+#define GAL_CONFIG_HAVE_GSL_INTERP_STEFFEN  @HAVE_GSL_STEFFEN@
 
 #define GAL_CONFIG_HAVE_PTHREAD_BARRIER     @HAVE_PTHREAD_BARRIER@
 



reply via email to

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