gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] (no subject)


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] (no subject)
Date: Thu, 2 Jun 2016 06:12:27 +0000 (UTC)

branch: master
commit 51c907ef9717e184c26499a27e0a155270583ddb
Author: Mohammad Akhlaghi <address@hidden>
Date:   Thu Jun 2 14:06:36 2016 +0900

    Configure sets library flags automatically
    
    Until now we were using Autoconf's `AC_CHECK_LIB' to check for the presence
    of a library. In doing so, for its `ACTION-IF-FOUND' value, we were setting
    an "absolutejunk" variable to intentionally avoid adding the library flags
    for configuration time in the `LIBS' variable. This was based on my wrong
    assumption at the time I first wrote these: I was thinking that linking
    with a library that is not used by the program will be inefficient. I was
    wrong, a library is searched, and only parts that are necessary are used in
    the final executable, so if there is nothing to use in it, it won't be
    used. The "absolutejunk" variable is therefore no longer used.
    
    On the other hand, as recommended in the Autoconf manual, `AC_CHECK_LIB'
    should be avoided in most common cases (we were not using it because of the
    reason above). It will also allow us to accomodate other operating systems
    if their installed libraries have another file name. So we are now using
    `AC_SEARCH_LIBS' to check for the libraries. An great side-effect of
    setting the `LIBS' variable, is that we no longer need the lower-level
    library flags in checking for the higher-level libraries.
    
    With this correction, the `-lLIBRARY' values of `AM_LDFLAGS' variable were
    no longer necessary in any of the subdirectory makefiles. To make things
    even more cleaner and avoid possible bugs due to repetition, the three
    `CFLAGS', `LDFLAGS', and `CPPFLAGS' variables are now set at configure time
    (while respecting Make's variable substitution of `top_builddir' and
    `top_srcdir'). All of these similar definitions in each subdirectory are
    now gone and can help us focus on the issues of that particular
    subdirectory.
    
    This fixes bug #48076.
---
 Makefile.am                 |   14 +++++-----
 configure.ac                |   59 +++++++++++++++++++++++++++++++------------
 lib/Makefile.am             |   12 ---------
 src/arithmetic/Makefile.am  |   12 ---------
 src/convertt/Makefile.am    |   21 ---------------
 src/convolve/Makefile.am    |   12 ---------
 src/cosmiccal/Makefile.am   |   12 ---------
 src/header/Makefile.am      |   12 ---------
 src/imgcrop/Makefile.am     |   16 ++----------
 src/imgstat/Makefile.am     |   12 ---------
 src/imgwarp/Makefile.am     |   12 ---------
 src/mkcatalog/Makefile.am   |   12 ---------
 src/mknoise/Makefile.am     |   12 ---------
 src/mkprof/Makefile.am      |   12 ---------
 src/noisechisel/Makefile.am |   12 ---------
 src/subtractsky/Makefile.am |   14 +---------
 16 files changed, 53 insertions(+), 203 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 533262a..d437df5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -25,8 +25,8 @@
 
 
 
-## Sources to be run before everything else
-## ========================================
+## Sources to be created before everything else
+## ============================================
 ##
 ## These target(s) will be created before anything else when running
 ## `make', `make check', or `make install', see the "Built sources" section
@@ -91,11 +91,11 @@ endif
 if COND_GNULIBCHECK
   MAYBE_GNULIBCHECK = bootstrapped/tests
 endif
-SUBDIRS = bootstrapped/lib $(MAYBE_GNULIBCHECK) lib $(MAYBE_CONVERTT)   \
-$(MAYBE_CONVOLVE) $(MAYBE_COSMICCAL) $(MAYBE_HEADER)                    \
-$(MAYBE_ARITHMETIC) $(MAYBE_IMGCROP) $(MAYBE_IMGSTAT)                   \
-$(MAYBE_IMGWARP) $(MAYBE_MKCATALOG) $(MAYBE_MKNOISE) $(MAYBE_MKPROF)    \
-$(MAYBE_NOISECHISEL) $(MAYBE_SUBTRACTSKY) doc tests
+SUBDIRS = bootstrapped/lib $(MAYBE_GNULIBCHECK) lib $(MAYBE_ARITHMETIC)    \
+$(MAYBE_CONVERTT) $(MAYBE_CONVOLVE) $(MAYBE_COSMICCAL) $(MAYBE_HEADER)    \
+$(MAYBE_IMGCROP) $(MAYBE_IMGSTAT) $(MAYBE_IMGWARP) $(MAYBE_MKCATALOG)     \
+$(MAYBE_MKNOISE) $(MAYBE_MKPROF) $(MAYBE_NOISECHISEL) $(MAYBE_SUBTRACTSKY) \
+doc tests
 
 
 
diff --git a/configure.ac b/configure.ac
index 5b62716..28deddd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -66,6 +66,26 @@ LT_INIT
 
 
 
+# Generic flags for all subdirectories. Note that when order matters, we
+# want the user values to be set (and thus used) after the default
+# values. The "AM_" versions of these variables will be confined to the
+# particular Makefile, so we can't define them in the top Makefile.am.
+#
+# About the quotations: the commands here first go through Autoconf which
+# removes one later of quotations. So if `$' is not quoted, it will try to
+# evaluate it. We can't just quote the full right side, because we wand the
+# (possibly) user defined original values that are passed to configure. For
+# the -D value in CPPFLAGS, we want the quotation marks until gcc, which is
+# two layers away from this text: first Autoconf, then Make. So we need two
+# layers of quotations there.
+CFLAGS="-Wall -O3 $CFLAGS"
+LDFLAGS="-L\$(top_builddir)/lib $LDFLAGS"
+CPPFLAGS="-DSYSCONFIG_DIR=\\\"$sysconfdir\\\" -I\$(top_srcdir)/lib 
-I\$(top_srcdir)/bootstrapped/lib $CPPFLAGS"
+
+
+
+
+
 # Check for pthreads and add the appropriate compilation flags. AX_PTHREAD
 # comes from the GNU Autoconf Archive's ax_pthread.m4.
 AX_PTHREAD([],[AC_MSG_ERROR([AC_PACKAGE_NAME Needs POSIX Threads (pthread)])])
@@ -77,20 +97,27 @@ CC="$PTHREAD_CC"
 
 
 
-
-# Checks for necessary libraries. The `absolutejunk=1` is put here so
-# it doesn't automatically add the library to the LIBS variable that
-# will be appended to all programs, some libraries will not be needed
-# in some programs.
-AC_CHECK_LIB([cfitsio], [ffopen], [absolutejunk=1],
-             [AC_MSG_ERROR([Cannot continue.])], [-lm])
-AC_CHECK_LIB([wcs], [wcspih], [absolutejunk=1],
-             [AC_MSG_ERROR([Cannot continue.])], [-lcfitsio -lm])
-AC_CHECK_LIB([gslcblas], [cblas_sdsdot], [absolutejunk=1],
-             [AC_MSG_ERROR([Cannot continue.])], [-lm])
-AC_CHECK_LIB([gsl], [gsl_integration_qng], [absolutejunk=1],
-             [AC_MSG_ERROR([Cannot continue.])], [-lgslcblas -lm])
-
+# Search for necessary libraries. After each library is found,
+# AC_SEARCH_LIBS adds the -lLIBRARY flag to the LIBS variable which is then
+# given to all the Makefiles. Each new flag is added to the left of the old
+# one so order matters here. Note that the LIBS variable is also used in
+# checking the next libraries, so the linking with their dependent
+# libraries is done automatically with this order, and we don't have to
+# explicitly set the dependency flags.
+AC_SEARCH_LIBS(sqrt, m, [],
+    [AC_MSG_ERROR([C math library not present, cannot continue.])])
+AC_SEARCH_LIBS([cblas_sdsdot], [gslcblas], [],
+    [AC_MSG_ERROR([GSL CBLAS not present, cannot continue.])])
+AC_SEARCH_LIBS([gsl_integration_qng], [gsl], [],
+    [AC_MSG_ERROR([GSL not found, cannot continue.])])
+AC_SEARCH_LIBS([ffopen], [cfitsio], [],
+    [AC_MSG_ERROR([CFITSIO not found, cannot continue.])])
+AC_SEARCH_LIBS([wcspih], [wcs], [],
+    [AC_MSG_ERROR([WCSLIB not found, cannot continue.])])
+
+# These are secondary tests for more fine-grained control in libraries that
+# have already been checked. We don't need to add them to the LIBS
+# variable, so we are using AC_CHECK_LIB for these tests.
 AC_CHECK_LIB([wcs], [wcslib_version],
              [AC_DEFINE([HAVE_WCSLIBVERSION], [1], [Has wcslib_version])],
              [], [-lcfitsio -lm])
@@ -132,8 +159,8 @@ AC_MSG_RESULT([done])
 
 
 # Check libjpeg:
-AC_CHECK_LIB([jpeg], [jpeg_stdio_dest],
-             [has_libjpeg=yes], [has_libjpeg=no], [-lm])
+AC_SEARCH_LIBS([jpeg_stdio_dest], [jpeg],
+               [has_libjpeg=yes], [has_libjpeg=no])
 AS_IF([test "x$has_libjpeg" = "xyes"],
       [AC_DEFINE([HAS_LIBJPEG], [], [Has libjpeg])],
       [anywarnings=yes])
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 440c69c..791c0cd 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -22,18 +22,6 @@
 
 
 
-# Flags:
-AM_CFLAGS = -Wall -O3
-
-LDADD = bootstrapped/lib/libgnu.a
-
-AM_CPPFLAGS = -DSYSCONFIG_DIR=\"$(sysconfdir)\" -I$(top_srcdir)/lib \
-              -I$(top_srcdir)/bootstrapped/lib
-
-
-
-
-
 ## Make libraries of the files that are shared between all the
 ## programs:
 headersdir=$(top_srcdir)/lib/gnuastro
diff --git a/src/arithmetic/Makefile.am b/src/arithmetic/Makefile.am
index 1734929..3fa5b26 100644
--- a/src/arithmetic/Makefile.am
+++ b/src/arithmetic/Makefile.am
@@ -22,18 +22,6 @@
 
 
 
-# Flags:
-AM_CFLAGS = -Wall -O3
-
-AM_LDFLAGS = -lcfitsio -lwcs -lgsl -lgslcblas -lm -L$(top_builddir)/lib
-
-AM_CPPFLAGS = -DSYSCONFIG_DIR=\"$(sysconfdir)\" -I$(top_srcdir)/lib    \
-              -I$(top_srcdir)/bootstrapped/lib
-
-
-
-
-
 ## Utility and its sources
 bin_PROGRAMS = astarithmetic
 
diff --git a/src/convertt/Makefile.am b/src/convertt/Makefile.am
index 8999d6f..0ab864c 100644
--- a/src/convertt/Makefile.am
+++ b/src/convertt/Makefile.am
@@ -22,27 +22,6 @@
 
 
 
-# Check if the system has libjpeg installed.
-if COND_HASLIBJPEG
-   MAYBE_HASLIBJPEG = -ljpeg
-endif
-
-
-
-
-
-# Flags:
-AM_CFLAGS = -Wall -O3
-
-AM_LDFLAGS = -lcfitsio -lwcs -lm $(MAYBE_HASLIBJPEG) -L$(top_builddir)/lib
-
-AM_CPPFLAGS = -DSYSCONFIG_DIR=\"$(sysconfdir)\" -I$(top_srcdir)/lib    \
-              -I$(top_srcdir)/bootstrapped/lib
-
-
-
-
-
 ## Utility and its sources
 bin_PROGRAMS = astconvertt
 
diff --git a/src/convolve/Makefile.am b/src/convolve/Makefile.am
index 46b75de..30acaaf 100644
--- a/src/convolve/Makefile.am
+++ b/src/convolve/Makefile.am
@@ -22,18 +22,6 @@
 
 
 
-# Flags:
-AM_CFLAGS = -Wall -O3
-
-AM_LDFLAGS = -lcfitsio -lwcs  -lgsl -lgslcblas -lm -L$(top_builddir)/lib
-
-AM_CPPFLAGS = -DSYSCONFIG_DIR=\"$(sysconfdir)\" -I$(top_srcdir)/lib    \
-              -I$(top_srcdir)/bootstrapped/lib
-
-
-
-
-
 ## Utility and its sources
 bin_PROGRAMS = astconvolve
 
diff --git a/src/cosmiccal/Makefile.am b/src/cosmiccal/Makefile.am
index f3e0bbc..2ca7826 100644
--- a/src/cosmiccal/Makefile.am
+++ b/src/cosmiccal/Makefile.am
@@ -22,18 +22,6 @@
 
 
 
-# Flags:
-AM_CFLAGS = -Wall -O3
-
-AM_LDFLAGS = -lgsl -lgslcblas -lm -L$(top_builddir)/lib
-
-AM_CPPFLAGS = -DSYSCONFIG_DIR=\"$(sysconfdir)\" -I$(top_srcdir)/lib    \
-              -I$(top_srcdir)/bootstrapped/lib
-
-
-
-
-
 ## Utility and its sources
 bin_PROGRAMS = astcosmiccal
 
diff --git a/src/header/Makefile.am b/src/header/Makefile.am
index 5761cbe..d1bfa4d 100644
--- a/src/header/Makefile.am
+++ b/src/header/Makefile.am
@@ -22,18 +22,6 @@
 
 
 
-# Flags:
-AM_CFLAGS = -Wall -O3
-
-AM_LDFLAGS = -lcfitsio -lwcs -lgsl -lgslcblas -lm -L$(top_builddir)/lib
-
-AM_CPPFLAGS = -DSYSCONFIG_DIR=\"$(sysconfdir)\" -I$(top_srcdir)/lib    \
-              -I$(top_srcdir)/bootstrapped/lib
-
-
-
-
-
 ## Utility and its sources
 bin_PROGRAMS = astheader
 
diff --git a/src/imgcrop/Makefile.am b/src/imgcrop/Makefile.am
index 83ae7bf..4d792c4 100644
--- a/src/imgcrop/Makefile.am
+++ b/src/imgcrop/Makefile.am
@@ -22,26 +22,14 @@
 
 
 
-# Flags:
-AM_CFLAGS = -Wall -O3
-
-AM_LDFLAGS = -lcfitsio -lwcs -lgsl -lgslcblas -lm -L$(top_builddir)/lib
-
-AM_CPPFLAGS = -DSYSCONFIG_DIR=\"$(sysconfdir)\" -I$(top_srcdir)/lib    \
-              -I$(top_srcdir)/bootstrapped/lib
-
-
-
-
-
 ## Utility and its sources
 bin_PROGRAMS = astimgcrop
 
 astimgcrop_SOURCES = main.c main.h cite.h ui.c ui.h args.h imgcrop.c   \
 imgcrop.h wcsmode.c wcsmode.h crop.c crop.h
 
-astimgcrop_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la          \
--lgalconfigfiles -lgalfitsarrayvv -lgaltxtarrayvv -lgalcheckset                
\
+astimgcrop_LDADD = $(top_builddir)/bootstrapped/lib/libgnu.la          \
+-lgalconfigfiles -lgalfitsarrayvv -lgaltxtarrayvv -lgalcheckset         \
 -lgallinkedlist -lgaltiming -lgalthreads -lgalbox -lgalpolygon
 
 
diff --git a/src/imgstat/Makefile.am b/src/imgstat/Makefile.am
index 1a2da92..e103329 100644
--- a/src/imgstat/Makefile.am
+++ b/src/imgstat/Makefile.am
@@ -22,18 +22,6 @@
 
 
 
-# Flags:
-AM_CFLAGS = -Wall -O3
-
-AM_LDFLAGS = -lcfitsio -lwcs -lgsl -lgslcblas -lm -L$(top_builddir)/lib
-
-AM_CPPFLAGS = -DSYSCONFIG_DIR=\"$(sysconfdir)\" -I$(top_srcdir)/lib    \
-              -I$(top_srcdir)/bootstrapped/lib
-
-
-
-
-
 ## Utility and its sources
 bin_PROGRAMS = astimgstat
 
diff --git a/src/imgwarp/Makefile.am b/src/imgwarp/Makefile.am
index 7e8025e..99ec7d4 100644
--- a/src/imgwarp/Makefile.am
+++ b/src/imgwarp/Makefile.am
@@ -22,18 +22,6 @@
 
 
 
-# Flags:
-AM_CFLAGS = -Wall -O3
-
-AM_LDFLAGS = -lcfitsio -lwcs -lgsl -lgslcblas -lm -L$(top_builddir)/lib
-
-AM_CPPFLAGS = -DSYSCONFIG_DIR=\"$(sysconfdir)\" -I$(top_srcdir)/lib    \
-              -I$(top_srcdir)/bootstrapped/lib
-
-
-
-
-
 ## Utility and its sources
 bin_PROGRAMS = astimgwarp
 
diff --git a/src/mkcatalog/Makefile.am b/src/mkcatalog/Makefile.am
index 9ab0505..e459e1b 100644
--- a/src/mkcatalog/Makefile.am
+++ b/src/mkcatalog/Makefile.am
@@ -22,18 +22,6 @@
 
 
 
-# Flags:
-AM_CFLAGS = -Wall -O3
-
-AM_LDFLAGS = -lcfitsio -lwcs -lgsl -lgslcblas -lm -L$(top_builddir)/lib
-
-AM_CPPFLAGS = -DSYSCONFIG_DIR=\"$(sysconfdir)\" -I$(top_srcdir)/lib    \
-              -I$(top_srcdir)/bootstrapped/lib
-
-
-
-
-
 ## Utility and its sources
 bin_PROGRAMS = astmkcatalog
 
diff --git a/src/mknoise/Makefile.am b/src/mknoise/Makefile.am
index 9f5022c..4351c76 100644
--- a/src/mknoise/Makefile.am
+++ b/src/mknoise/Makefile.am
@@ -22,18 +22,6 @@
 
 
 
-# Flags:
-AM_CFLAGS = -Wall -O3
-
-AM_LDFLAGS = -lcfitsio -lwcs -lgsl -lgslcblas -lm -L$(top_builddir)/lib
-
-AM_CPPFLAGS = -DSYSCONFIG_DIR=\"$(sysconfdir)\" -I$(top_srcdir)/lib    \
-              -I$(top_srcdir)/bootstrapped/lib
-
-
-
-
-
 ## Utility and its sources
 bin_PROGRAMS = astmknoise
 
diff --git a/src/mkprof/Makefile.am b/src/mkprof/Makefile.am
index 16f7cfa..84cddc1 100644
--- a/src/mkprof/Makefile.am
+++ b/src/mkprof/Makefile.am
@@ -22,18 +22,6 @@
 
 
 
-# Flags:
-AM_CFLAGS = -Wall -O3
-
-AM_LDFLAGS = -lcfitsio -lwcs -lgsl -lgslcblas -lm -L$(top_builddir)/lib
-
-AM_CPPFLAGS = -DSYSCONFIG_DIR=\"$(sysconfdir)\" -I$(top_srcdir)/lib    \
-              -I$(top_srcdir)/bootstrapped/lib
-
-
-
-
-
 # Utility and its sources
 bin_PROGRAMS = astmkprof
 
diff --git a/src/noisechisel/Makefile.am b/src/noisechisel/Makefile.am
index ad12f83..0a0d2c7 100644
--- a/src/noisechisel/Makefile.am
+++ b/src/noisechisel/Makefile.am
@@ -22,18 +22,6 @@
 
 
 
-# Flags:
-AM_CFLAGS = -Wall -O3
-
-AM_LDFLAGS = -lcfitsio -lwcs -lm -L$(top_builddir)/lib
-
-AM_CPPFLAGS = -DSYSCONFIG_DIR=\"$(sysconfdir)\" -I$(top_srcdir)/lib    \
-              -I$(top_srcdir)/bootstrapped/lib
-
-
-
-
-
 ## Utility and its sources
 bin_PROGRAMS = astnoisechisel
 
diff --git a/src/subtractsky/Makefile.am b/src/subtractsky/Makefile.am
index c198f41..647c9fa 100644
--- a/src/subtractsky/Makefile.am
+++ b/src/subtractsky/Makefile.am
@@ -22,19 +22,7 @@
 
 
 
-# Flags:
-AM_CFLAGS = -Wall -O3
-
-AM_LDFLAGS = -lcfitsio -lwcs -lm -L$(top_builddir)/lib
-
-AM_CPPFLAGS = -DSYSCONFIG_DIR=\"$(sysconfdir)\" -I$(top_srcdir)/lib    \
-              -I$(top_srcdir)/bootstrapped/lib
-
-
-
-
-
-## ImageCrop:
+## Utility and its sources
 bin_PROGRAMS = astsubtractsky
 
 astsubtractsky_SOURCES = main.c main.h cite.h ui.c ui.h args.h \



reply via email to

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