gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master f8bfedb 3/3: BuildProgram can use a different


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master f8bfedb 3/3: BuildProgram can use a different Libtool .la file
Date: Mon, 2 Oct 2017 16:15:46 -0400 (EDT)

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

    BuildProgram can use a different Libtool .la file
    
    Until now, BuildProgram could only use the installed `libgnuastro.la'
    file. This caused a failure when Gnuastro wasn't already installed on the
    system and the user ran `make check'. However, this test `PASS'ed, because
    there was no check to see if `libtool' fails in BuildProgram!
    
    With this commit, both these issues are fixed: if `libtool' fails (for any
    reason, including not finding the `.la' file), it will abort with a message
    and it is now possible to identify a different `.la' file to use instead of
    the default one (with the `--la' option).
---
 NEWS                        |  5 ++++-
 bin/buildprog/args.h        | 14 ++++++++++++++
 bin/buildprog/buildprog.c   | 17 +++++++++++++----
 bin/buildprog/main.h        |  1 +
 bin/buildprog/ui.h          |  3 ++-
 tests/buildprog/simpleio.sh |  8 +++++++-
 6 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/NEWS b/NEWS
index ae40f2e..67992d1 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,9 @@ GNU Astronomy Utilities NEWS                          -*- 
outline -*-
   All programs: a value of `0' to the `--numthreads' option will use the
   number of threads available to the system at run time.
 
+  BuildProgram: The new `--la' option allows the identification of a
+  different Libtool `.la' file for Libtool linking information.
+
   Fits: when an extension/HDU is identified on the command-line with the
   `--hdu' option and no operation is requested, the full list of header
   keywords in that HDU will be printed (as if only `--printallkeys' was
@@ -68,7 +71,7 @@ GNU Astronomy Utilities NEWS                          -*- 
outline -*-
 
   NoiseChisel segfault when memory mapping to a file (bug #52043).
 
-
+  CFITSIO 3.42 and libcurl crash at Gnuastro configure time (bug #52152).
 
 
 
diff --git a/bin/buildprog/args.h b/bin/buildprog/args.h
index 6d4f9fd..01a96fc 100644
--- a/bin/buildprog/args.h
+++ b/bin/buildprog/args.h
@@ -73,6 +73,20 @@ struct argp_option program_options[] =
       GAL_OPTIONS_NOT_SET
     },
 
+    {
+      "la",
+      UI_KEY_LA,
+      "STR",
+      0,
+      "Libtool `.la' to use instead of default.",
+      GAL_OPTIONS_GROUP_INPUT,
+      &p->la,
+      GAL_TYPE_STRING,
+      GAL_OPTIONS_RANGE_ANY,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET
+    },
+
 
     {
       "debug",
diff --git a/bin/buildprog/buildprog.c b/bin/buildprog/buildprog.c
index 16e4a8c..24fbce1 100644
--- a/bin/buildprog/buildprog.c
+++ b/bin/buildprog/buildprog.c
@@ -23,6 +23,8 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <config.h>
 
 #include <stdio.h>
+#include <errno.h>
+#include <error.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -71,6 +73,7 @@ buildprog(struct buildprogparams *p)
   /* Note that the first node of `sourceargs' is the acutal source and the
      rest are arguments to be run later. */
   int retval;
+  char *fullla;
   char *command, *optimize=NULL, *warning=NULL;
   char *include   = buildprog_as_one_string("-I", p->include);
   char *linkdir   = buildprog_as_one_string("-L", p->linkdir);
@@ -88,9 +91,13 @@ buildprog(struct buildprogparams *p)
   if(p->warning)   asprintf(&warning,  "-W%s", p->warning);
   if(p->optimize)  asprintf(&optimize, "-O%s", p->optimize);
 
+  /* Libtool `.la' file: */
+  if(p->la) fullla=p->la;
+  else      asprintf(&fullla, "%s/libgnuastro.la", LIBDIR);
+
   /* Put the command to run into a string. */
   asprintf(&command, "libtool %s --mode=link gcc %s %s %s %s %s %s %s "
-           "-I%s %s/libgnuastro.la -o %s",
+           "-I%s %s -o %s",
            p->cp.quiet ? "--quiet" : "",
            warning     ? warning   : "",
            p->debug    ? "-g"      : "",
@@ -100,12 +107,14 @@ buildprog(struct buildprogparams *p)
            p->sourceargs->v,
            linklib     ?linklib    : "",
            INCLUDEDIR,
-           LIBDIR,
+           fullla,
            p->cp.output);
 
   /* Compile (and link): */
   retval=system(command);
-  if( retval==EXIT_SUCCESS && p->onlybuild==0)
+  if(retval!=EXIT_SUCCESS)
+    error(EXIT_FAILURE, 0, "failed to build, see libtool error above");
+  else if(p->onlybuild==0)
     {
       /* Free the initial command. */
       free(command);
@@ -127,7 +136,7 @@ buildprog(struct buildprogparams *p)
       /* Print the executed command if necessary, then run it. */
       if(!p->cp.quiet)
         {
-          printf("\nRun the compiled program\n");
+          printf("Run the compiled program\n");
           printf("------------------------\n");
           printf("%s\n", command);
         }
diff --git a/bin/buildprog/main.h b/bin/buildprog/main.h
index 56a9eed..2e3902c 100644
--- a/bin/buildprog/main.h
+++ b/bin/buildprog/main.h
@@ -48,6 +48,7 @@ struct buildprogparams
   gal_list_str_t     *include;    /* Libraries to link against.         */
   gal_list_str_t     *linkdir;    /* Libraries to link against.         */
   gal_list_str_t     *linklib;    /* Libraries to link against.         */
+  char                    *la;    /* Libtool `.la' instead of default.  */
 
   char              *optimize;    /* Optimization level.                */
   char                 *debug;    /* Keep debugging information.        */
diff --git a/bin/buildprog/ui.h b/bin/buildprog/ui.h
index 7adccb3..40c72ad 100644
--- a/bin/buildprog/ui.h
+++ b/bin/buildprog/ui.h
@@ -29,7 +29,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 /* Available letters for short options:
 
-   a c d e f i j k l n p r s t u v w x y z
+   c d e f i j k n p r s t u v w x y z
    A B C E G H J Q R X Y
 */
 enum option_keys_enum
@@ -38,6 +38,7 @@ enum option_keys_enum
   UI_KEY_INCLUDE     = 'I',
   UI_KEY_LINKDIR     = 'L',
   UI_KEY_LINKLIB     = 'l',
+  UI_KEY_LA          = 'a',
   UI_KEY_ONLYBUILD   = 'b',
   UI_KEY_DEBUG       = 'g',
   UI_KEY_OPTIMIZE    = 'O',
diff --git a/tests/buildprog/simpleio.sh b/tests/buildprog/simpleio.sh
index 8eef3ba..6fa9e83 100755
--- a/tests/buildprog/simpleio.sh
+++ b/tests/buildprog/simpleio.sh
@@ -56,4 +56,10 @@ if [ "x$haslibtool" != "xyes" ];then echo "libtool not 
present.";  exit 77;fi
 
 # Actual test script
 # ==================
-$execname $source $img 1
+#
+# We want to use the `libgnuastro.la' corresponding to this install, not
+# the one (that is possibly) installed (hence the use of `--la').
+#
+# Except for `gnuastro/config.h', all headers are installed in
+# `$topsrc/lib' and `gnuastro/config.h' is in "../lib/"
+$execname $source $img 1 --la=../lib/libgnuastro.la -I$topsrc/lib -I../lib/



reply via email to

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