automake-patches
[Top][All Lists]
Advanced

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

Re: AM_LIBTOOLFLAGS, maude_LIBTOOLFLAGS, and LIBTOOLFLAGS


From: Alexandre Duret-Lutz
Subject: Re: AM_LIBTOOLFLAGS, maude_LIBTOOLFLAGS, and LIBTOOLFLAGS
Date: Mon, 13 Dec 2004 00:38:52 +0100
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

>>> "adl" == Alexandre Duret-Lutz <address@hidden> writes:

[...]

 adl> Here is my proposal.

Here is what I installed.  
The only addition is the tests/subobj9.test chunk.

2004-12-12  Alexandre Duret-Lutz  <address@hidden>

        * automake.in (check_user_variables): New function, extracted
        from ...
        (handle_languages): ... here.
        (handle_languages, define_compiler_variable, define_link_variable):
        Honore LIBTOOLFLAGS.
        (handle_single_transform): Check _LIBTOOLFLAGS in
        addition to other per-target flags for Libtool objects.
        (handle_libtool): Warn if LIBTOOLFLAGS is defined.
        * doc/automake.texi (Libtool Flags, Program and Library Variables,
        Flag Variables Ordering): Document LIBTOOLFLAGS.
        * tests/libtool7.test: Check basic support for LIBTOOLFLAGS.
        * tests/libtool8.test: Make sure Automake warns about LIBTOOLFLAGS
        definitions.
        * tests/subobj9.test: Adjust.

Index: NEWS
===================================================================
RCS file: /cvs/automake/automake/NEWS,v
retrieving revision 1.290
diff -u -r1.290 NEWS
--- NEWS        4 Nov 2004 22:19:41 -0000       1.290
+++ NEWS        12 Dec 2004 23:36:56 -0000
@@ -14,6 +14,9 @@
     AM_CPPFLAGS and per-target _CPPFLAGS, and supports dependency
     tracking, unlike non-preprocessed assembler (*.s).
 
+  - Libtool generic flags (those that go before the --mode=MODE option)
+    can be specified using AM_LIBTOOLFLAGS and target_LIBTOOLFLAGS.
+
   - aclocal now also supports -Wmumble and -Wno-mumble options.
 
 New in 1.9:
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1590
diff -u -r1.1590 automake.in
--- automake.in 8 Dec 2004 22:00:47 -0000       1.1590
+++ automake.in 12 Dec 2004 23:36:58 -0000
@@ -1087,6 +1087,31 @@
     return $extension;
 }
 
+# check_user_variables (@LIST)
+# ----------------------------
+# Make sure each variable VAR in @LIST do not exist, suggest using AM_VAR
+# otherwise.
+sub check_user_variables (@)
+{
+  my @dont_override = @_;
+  foreach my $flag (@dont_override)
+    {
+      my $var = var $flag;
+      if ($var)
+       {
+         for my $cond ($var->conditions->conds)
+           {
+             if ($var->rdef ($cond)->owner == VAR_MAKEFILE)
+               {
+                 msg_cond_var ('gnu', $cond, $flag,
+                               "`$flag' is a user variable, "
+                               . "you should not override it;\n"
+                               . "use `AM_$flag' instead.");
+               }
+           }
+       }
+    }
+}
 
 # Call finish function for each language that was used.
 sub handle_languages
@@ -1261,8 +1286,12 @@
                $libtool_tag = '--tag=' . $lang->libtool_tag . ' '
              }
 
+           my $ptltflags = "${derived}_LIBTOOLFLAGS";
+           $ptltflags = 'AM_LIBTOOLFLAGS' unless set_seen $ptltflags;
+
            my $obj_ltcompile =
-             "\$(LIBTOOL) $libtool_tag--mode=compile $obj_compile";
+             "\$(LIBTOOL) $libtool_tag\$($ptltflags) \$(LIBTOOLFLAGS) "
+             . "--mode=compile $obj_compile";
 
            # We _need_ `-o' for per object rules.
            my $output_flag = $lang->output_flag || '-o';
@@ -1423,23 +1452,7 @@
        # ... and so is LDFLAGS.
        push @dont_override, 'LDFLAGS' if $lang->link;
 
-       foreach my $flag (@dont_override)
-         {
-           my $var = var $flag;
-           if ($var)
-             {
-               for my $cond ($var->conditions->conds)
-                 {
-                   if ($var->rdef ($cond)->owner == VAR_MAKEFILE)
-                     {
-                       msg_cond_var ('gnu', $cond, $flag,
-                                     "`$flag' is a user variable, "
-                                     . "you should not override it;\n"
-                                     . "use `AM_$flag' instead.");
-                     }
-                 }
-             }
-         }
+       check_user_variables @dont_override;
     }
 
     # If the project is entirely C++ or entirely Fortran 77 (i.e., 1
@@ -1571,7 +1584,9 @@
 
            # Do we have per-executable flags for this executable?
            my $have_per_exec_flags = 0;
-           foreach my $flag (@{$lang->flags})
+           my @peflags = @{$lang->flags};
+           push @peflags, 'LIBTOOLFLAGS' if $nonansi_obj eq '.lo';
+           foreach my $flag (@peflags)
              {
                if (set_seen ("${derived}_$flag"))
                  {
@@ -2270,6 +2285,8 @@
       push (@libtool_rms, "\t-rm -rf ${dir}.libs ${dir}_libs");
     }
 
+  check_user_variables 'LIBTOOLFLAGS';
+
   # Output the libtool compilation rules.
   $output_rules .= &file_contents ('libtool',
                                   new Automake::Location,
@@ -5694,7 +5711,8 @@
 
 # define_variable ($VAR, $VALUE, $WHERE)
 # --------------------------------------
-# Define a new user variable VAR to VALUE, but only if not already defined.
+# Define a new Automake Makefile variable VAR to VALUE, but only if
+# not already defined.
 sub define_variable ($$$)
 {
     my ($var, $value, $where) = @_;
@@ -5754,7 +5772,8 @@
       if $lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag};
     &define_variable ($var, $value, INTERNAL);
     &define_variable ("LT$var",
-                     "\$(LIBTOOL) $libtool_tag--mode=compile $value",
+                     "\$(LIBTOOL) $libtool_tag\$(AM_LIBTOOLFLAGS) "
+                     . "\$(LIBTOOLFLAGS) --mode=compile $value",
                      INTERNAL)
       if var ('LIBTOOL');
 }
@@ -5776,7 +5795,8 @@
     # CCLINK = $(CCLD) blah blah...
     &define_variable ($lang->linker,
                      ((var ('LIBTOOL') ?
-                       "\$(LIBTOOL) $libtool_tag--mode=link " : '')
+                       "\$(LIBTOOL) $libtool_tag\$(AM_LIBTOOLFLAGS) "
+                       . "\$(LIBTOOLFLAGS) --mode=link " : '')
                       . $lang->link),
                      INTERNAL);
 }
Index: doc/automake.texi
===================================================================
RCS file: /cvs/automake/automake/doc/automake.texi,v
retrieving revision 1.74
diff -u -r1.74 automake.texi
--- doc/automake.texi   11 Dec 2004 00:29:28 -0000      1.74
+++ doc/automake.texi   12 Dec 2004 23:36:59 -0000
@@ -3038,7 +3038,7 @@
 * Conditional Libtool Sources::  Choosing Library Sources Conditionally
 * Libtool Convenience Libraries::  Building Convenience Libtool Libraries
 * Libtool Modules::             Building Libtool Modules
-* Libtool Flags::               Using _LIBADD and _LDFLAGS
+* Libtool Flags::               Using _LIBADD, _LDFLAGS, and _LIBTOOLFLAGS
 * LTLIBOBJS::                   Using $(LTLIBOBJS) and $(LTALLOCA)
 * Libtool Issues::              Common Issues Related to Libtool's Use
 @end menu
@@ -3343,19 +3343,49 @@
 the single file @file{mymodule.c} (@pxref{Default _SOURCES}).
 
 @node Libtool Flags
address@hidden _LIBADD and _LDFLAGS
address@hidden @code{_LIBADD}, @code{_LDFLAGS}, and @code{_LIBTOOLFLAGS}
 @cindex @code{_LIBADD}, libtool
 @cindex @code{_LDFLAGS}, libtool
address@hidden @code{_LIBTOOLFLAGS}, libtool
address@hidden AM_LIBTOOLFLAGS
address@hidden LIBTOOLFLAGS
address@hidden maude_LIBTOOLFLAGS
 
 As shown in previous sections, the @address@hidden
 variable should be used to list extra libtool objects (@file{.lo}
 files) or libtool libraries (@file{.la}) to add to @var{library}.
 
 The @address@hidden variable is the place to list
-additional libtool flags, such as @samp{-version-info},
address@hidden, and a lot more.  See @xref{Link mode, , Using libltdl,
+additional libtool linking flags, such as @samp{-version-info},
address@hidden, and a lot more.  See @xref{Link mode, , Link mode,
 libtool, The Libtool Manual}.
 
+The @command{libtool} command has two kinds of options: mode-specific
+options and generic options.  Mode-specific options such as the
+aforementioned linking flags should be lumped with the other flags
+passed to the tool invoked by @command{libtool} (hence the use of
address@hidden@var{library}_LDFLAGS} for libtool linking flags).  Generic
+options include @address@hidden and @samp{--silent}
+(@pxref{Invoking libtool, , Invoking @command{libtool}, libtool, The
+Libtool Manual} for more options) should appear before the mode
+selection on the command line; in @file{Makefile.am}s they should
+be listed in the @address@hidden variable.
+
+If @address@hidden is not defined, the global
address@hidden variable is used instead.
+
+These flags are passed to libtool after the @address@hidden
+option computed by Automake (if any), so
address@hidden@var{library}_LIBTOOLFLAGS} (or @samp{AM_LIBTOOLFLAGS}) is the
+good place to override or supplement the @address@hidden
+setting.
+
+The libtool rules also use a @code{LIBTOOLFLAGS} variable that should
+not be set in @file{Makefile.am}: this is a user variable (@pxref{Flag
+Variables Ordering}.  It allows users to run @samp{make
+LIBTOOLFLAGS=--silent}, for instance.
+
+
 @node LTLIBOBJS, Libtool Issues, Libtool Flags, A Shared Library
 @subsection @code{LTLIBOBJS} and @code{LTALLOCA}
 @cindex @code{LTLIBOBJS}, special handling
@@ -3572,6 +3602,12 @@
 This variable is used to pass extra flags to the link step of a program
 or a shared library.
 
address@hidden maude_LIBTOOLFLAGS
+This variable is used to pass extra options to @command{libtool}.
+These options are output before @command{libtool}'s @code{--mode=MODE}
+option, so they should not be mode-specific options (those belong to
+the compiler or linker flags).  @xref{Libtool Flags}.
+
 @item maude_DEPENDENCIES
 It is also occasionally useful to have a program depend on some other
 target which is not actually part of that program.  This can be done
@@ -7953,6 +7989,7 @@
 @cindex @code{AM_GCJFLAGS} and @code{GCJFLAGS}
 @cindex @code{AM_LDFLAGS} and @code{LDFLAGS}
 @cindex @code{AM_LFLAGS} and @code{LFLAGS}
address@hidden @code{AM_LIBTOOLFLAGS} and @code{LIBTOOLFLAGS}
 @cindex @code{AM_OBJCFLAGS} and @code{OBJCFLAGS}
 @cindex @code{AM_RFLAGS} and @code{RFLAGS}
 @cindex @code{AM_YFLAGS} and @code{YFLAGS}
@@ -7965,6 +8002,7 @@
 @cindex @code{GCJFLAGS} and @code{AM_GCJFLAGS}
 @cindex @code{LDFLAGS} and @code{AM_LDFLAGS}
 @cindex @code{LFLAGS} and @code{AM_LFLAGS}
address@hidden @code{LIBTOOLFLAGS} and @code{AM_LIBTOOLFLAGS}
 @cindex @code{OBJCFLAGS} and @code{AM_OBJCFLAGS}
 @cindex @code{RFLAGS} and @code{AM_RFLAGS}
 @cindex @code{YFLAGS} and @code{AM_YFLAGS}
@@ -7974,7 +8012,8 @@
 answer holds for all the compile flags used in Automake:
 @code{CCASFLAGS}, @code{CFLAGS}, @code{CPPFLAGS}, @code{CXXFLAGS},
 @code{FCFLAGS}, @code{FFLAGS}, @code{GCJFLAGS}, @code{LDFLAGS},
address@hidden, @code{OBJCFLAGS}, @code{RFLAGS}, and @code{YFLAGS}.
address@hidden, @code{LIBTOOLFLAGS}, @code{OBJCFLAGS}, @code{RFLAGS},
+and @code{YFLAGS}.
 
 @code{CPPFLAGS}, @code{AM_CPPFLAGS}, and @code{mumble_CPPFLAGS} are
 three variables that can be used to pass flags to the C preprocessor
@@ -9696,5 +9735,5 @@
 @c  LocalWords:  syscalls perlhist acl pm multitable headitem fdl appendixsec
 @c  LocalWords:  LTALLOCA MALLOC malloc memcmp strdup alloca libcompat xyz DFOO
 @c  LocalWords:  unprefixed buildable preprocessed DBAZ DDATADIR WARNINGCFLAGS
address@hidden  LocalWords:  LIBFOOCFLAGS LIBFOOLDFLAGS ftable testSubDir obj
address@hidden  LocalWords:  LIBFOOCFLAGS LIBFOOLDFLAGS ftable testSubDir obj 
LIBTOOLFLAGS
 @c  LocalWords:  barexec Pinard's
Index: doc/stamp-vti
===================================================================
RCS file: /cvs/automake/automake/doc/stamp-vti,v
retrieving revision 1.75
diff -u -r1.75 stamp-vti
--- doc/stamp-vti       11 Dec 2004 00:29:29 -0000      1.75
+++ doc/stamp-vti       12 Dec 2004 23:36:59 -0000
@@ -1,4 +1,4 @@
address@hidden UPDATED 10 December 2004
address@hidden UPDATED 12 December 2004
 @set UPDATED-MONTH December 2004
 @set EDITION 1.9a
 @set VERSION 1.9a
Index: doc/version.texi
===================================================================
RCS file: /cvs/automake/automake/doc/version.texi,v
retrieving revision 1.75
diff -u -r1.75 version.texi
--- doc/version.texi    11 Dec 2004 00:29:29 -0000      1.75
+++ doc/version.texi    12 Dec 2004 23:36:59 -0000
@@ -1,4 +1,4 @@
address@hidden UPDATED 10 December 2004
address@hidden UPDATED 12 December 2004
 @set UPDATED-MONTH December 2004
 @set EDITION 1.9a
 @set VERSION 1.9a
Index: tests/libtool7.test
===================================================================
RCS file: /cvs/automake/automake/tests/libtool7.test,v
retrieving revision 1.2
diff -u -r1.2 libtool7.test
--- tests/libtool7.test 7 Sep 2004 21:03:32 -0000       1.2
+++ tests/libtool7.test 12 Dec 2004 23:36:59 -0000
@@ -19,6 +19,7 @@
 # Boston, MA 02111-1307, USA.
 
 # Make sure we allow Libtool's -dlopen/-dlpreopen
+# Also check basic support for AM_LIBTOOLFLAGS/LIBTOOLFLAGS
 
 required='libtoolize gcc'
 . ./defs || exit 1
@@ -34,12 +35,14 @@
 
 cat > Makefile.am << 'END'
 AUTOMAKE_OPTIONS = subdir-objects
+AM_LIBTOOLFLAGS = --silent
 lib_LTLIBRARIES = libmod1.la mod2.la
 libmod1_la_SOURCES = sub/mod1.c
 libmod1_la_LDFLAGS = -module
 libmod1_la_LIBADD = -dlopen mod2.la
 mod2_la_SOURCES = mod2.c
 mod2_la_LDFLAGS = -module
+mod2_la_LIBTOOLFLAGS =
 
 bin_PROGRAMS = prg
 prg_SOURCES = prg.c
@@ -48,7 +51,7 @@
 print:
        @echo 1BEG: $(prg_DEPENDENCIES) :END1
        @echo 2BEG: $(libmod1_la_DEPENDENCIES) :END2
-
+       @echo 3BEG: $(LTCOMPILE) :END3
 END
 
 mkdir sub liba
@@ -83,8 +86,10 @@
 $AUTOMAKE --add-missing --copy
 
 ./configure
-$MAKE print >output 2>&1
+env LIBTOOLFLAGS=--silent $MAKE print >output 2>&1
 cat output
 grep '1BEG: libmod1.la mod2.la :END1' output
 grep '2BEG: mod2.la :END2' output
+grep '3BEG: .*silent.*silent.* :END3' output
+test 2 -le `grep mod2_la_LIBTOOLFLAGS Makefile | wc -l`
 $MAKE
Index: tests/libtool8.test
===================================================================
RCS file: /cvs/automake/automake/tests/libtool8.test,v
retrieving revision 1.1
diff -u -r1.1 libtool8.test
--- tests/libtool8.test 7 Mar 2004 12:36:54 -0000       1.1
+++ tests/libtool8.test 12 Dec 2004 23:36:59 -0000
@@ -44,6 +44,7 @@
 if COND1
     pkglib_LTLIBRARIES = liba.la
 endif
+LIBTOOLFLAGS = ouch
 endif
 END
 
@@ -54,3 +55,4 @@
 grep 'Makefile.am:3:.*libc.la.*multiply defined' stderr
 grep 'Makefile.am:9:.*`pkglib' stderr
 grep 'Makefile.am:2:.*`lib' stderr
+grep 'Makefile.am:11:.*AM_LIBTOOLFLAGS' stderr
Index: tests/subobj9.test
===================================================================
RCS file: /cvs/automake/automake/tests/subobj9.test,v
retrieving revision 1.8
diff -u -r1.8 subobj9.test
--- tests/subobj9.test  28 Sep 2004 22:19:20 -0000      1.8
+++ tests/subobj9.test  12 Dec 2004 23:36:59 -0000
@@ -37,6 +37,10 @@
 cat > Makefile.am << 'END'
 noinst_LTLIBRARIES = libfoo.la
 libfoo_la_SOURCES = src/foo.cc
+
+print:
+       @echo BEG1: "$(LTCXXCOMPILE)" :1END
+       @echo BEG2: "$(CXXLINK)" :2END
 END
 
 mkdir src
@@ -59,8 +63,10 @@
 
 # opportunistically check that --tag=CXX is used when supported
 if test -n "`./libtool --help | grep tag=TAG`"; then
-  grep 'LTCXXCOMPILE.*--tag=CXX --mode=compile' Makefile.in
-  grep 'CXXLINK.*--tag=CXX --mode=link' Makefile.in
+  $MAKE print >stdout
+  cat stdout
+  grep 'BEG1: .*--tag=CXX.*--mode=compile.* :1END' stdout
+  grep 'BEG2: .*--tag=CXX.*--mode=link.* :2END' stdout
 fi
 
 $MAKE
-- 
Alexandre Duret-Lutz





reply via email to

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