From: Alexandre Duret-Lutz Date: Sun, 12 Dec 2004 23:39:02 +0000 (+0000) Subject: * automake.in (check_user_variables): New function, extracted X-Git-Tag: Release-1-9b~233 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c0c49fb38cfa2986cac143c887b6aca5a8074d8;p=thirdparty%2Fautomake.git * 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. --- diff --git a/ChangeLog b/ChangeLog index c3385bfe0..4ffb59066 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2004-12-12 Alexandre Duret-Lutz + + * 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. + 2004-12-11 Alexandre Duret-Lutz * doc/automake.texi (Per-Object Flags): New node. diff --git a/NEWS b/NEWS index 22b2ba8e2..4f99b34f3 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,9 @@ New in 1.9a: 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: diff --git a/automake.in b/automake.in index 84aa4c8be..2ac77c54e 100755 --- a/automake.in +++ b/automake.in @@ -1087,6 +1087,31 @@ sub get_object_extension ($) 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 @@ sub handle_languages $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 @@ sub handle_languages # ... 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 @@ sub handle_single_transform ($$$$$%) # 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 @@ sub handle_libtool 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 @@ sub define_pretty_variable ($$$@) # 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 @@ sub define_compiler_variable ($) 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 @@ sub define_linker_variable ($) # 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); } diff --git a/doc/automake.texi b/doc/automake.texi index a69ec3d67..fa71f5263 100644 --- a/doc/automake.texi +++ b/doc/automake.texi @@ -3038,7 +3038,7 @@ platform-independent way. * 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 @@ If @samp{mymodule_la_SOURCES} is not specified, then it defaults to the single file @file{mymodule.c} (@pxref{Default _SOURCES}). @node Libtool Flags -@subsection _LIBADD and _LDFLAGS +@subsection @code{_LIBADD}, @code{_LDFLAGS}, and @code{_LIBTOOLFLAGS} @cindex @code{_LIBADD}, libtool @cindex @code{_LDFLAGS}, libtool +@cindex @code{_LIBTOOLFLAGS}, libtool +@vindex AM_LIBTOOLFLAGS +@vindex LIBTOOLFLAGS +@vindex maude_LIBTOOLFLAGS As shown in previous sections, the @samp{@var{library}_LIBADD} variable should be used to list extra libtool objects (@file{.lo} files) or libtool libraries (@file{.la}) to add to @var{library}. The @samp{@var{library}_LDFLAGS} variable is the place to list -additional libtool flags, such as @samp{-version-info}, -@samp{-static}, and a lot more. See @xref{Link mode, , Using libltdl, +additional libtool linking flags, such as @samp{-version-info}, +@samp{-static}, 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 +@samp{@var{library}_LDFLAGS} for libtool linking flags). Generic +options include @samp{--tag=@var{TAG}} 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 @samp{@var{library}_LIBTOOLFLAGS} variable. + +If @samp{@var{library}_LIBTOOLFLAGS} is not defined, the global +@samp{AM_LIBTOOLFLAGS} variable is used instead. + +These flags are passed to libtool after the @samp{--tag=@var{TAG}} +option computed by Automake (if any), so +@samp{@var{library}_LIBTOOLFLAGS} (or @samp{AM_LIBTOOLFLAGS}) is the +good place to override or supplement the @samp{--tag=@var{TAG}} +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 @@ maude_LDADD = $(X_PRE_LIBS) $(X_LIBS) $(X_EXTRA_LIBS) This variable is used to pass extra flags to the link step of a program or a shared library. +@item 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 @@ flags, not appended. @cindex @code{AM_GCJFLAGS} and @code{GCJFLAGS} @cindex @code{AM_LDFLAGS} and @code{LDFLAGS} @cindex @code{AM_LFLAGS} and @code{LFLAGS} +@cindex @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 @@ flags, not appended. @cindex @code{GCJFLAGS} and @code{AM_GCJFLAGS} @cindex @code{LDFLAGS} and @code{AM_LDFLAGS} @cindex @code{LFLAGS} and @code{AM_LFLAGS} +@cindex @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 @@ mostly discuss @code{CPPFLAGS} in our examples, but actually the 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}, -@code{LFLAGS}, @code{OBJCFLAGS}, @code{RFLAGS}, and @code{YFLAGS}. +@code{LFLAGS}, @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 @@ The number of test cases in the test suite. @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 -@c LocalWords: LIBFOOCFLAGS LIBFOOLDFLAGS ftable testSubDir obj +@c LocalWords: LIBFOOCFLAGS LIBFOOLDFLAGS ftable testSubDir obj LIBTOOLFLAGS @c LocalWords: barexec Pinard's diff --git a/doc/stamp-vti b/doc/stamp-vti index 678eeec52..5b2a59cda 100644 --- a/doc/stamp-vti +++ b/doc/stamp-vti @@ -1,4 +1,4 @@ -@set UPDATED 10 December 2004 +@set UPDATED 12 December 2004 @set UPDATED-MONTH December 2004 @set EDITION 1.9a @set VERSION 1.9a diff --git a/doc/version.texi b/doc/version.texi index 678eeec52..5b2a59cda 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 10 December 2004 +@set UPDATED 12 December 2004 @set UPDATED-MONTH December 2004 @set EDITION 1.9a @set VERSION 1.9a diff --git a/tests/libtool7.test b/tests/libtool7.test index c40a3f089..5cf8efee6 100755 --- a/tests/libtool7.test +++ b/tests/libtool7.test @@ -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 @@ END 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 @@ prg_LDADD = -dlopen libmod1.la -dlpreopen mod2.la print: @echo 1BEG: $(prg_DEPENDENCIES) :END1 @echo 2BEG: $(libmod1_la_DEPENDENCIES) :END2 - + @echo 3BEG: $(LTCOMPILE) :END3 END mkdir sub liba @@ -83,8 +86,10 @@ $AUTOCONF $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 diff --git a/tests/libtool8.test b/tests/libtool8.test index 18b1d1824..67d80c639 100755 --- a/tests/libtool8.test +++ b/tests/libtool8.test @@ -44,6 +44,7 @@ if COND2 if COND1 pkglib_LTLIBRARIES = liba.la endif +LIBTOOLFLAGS = ouch endif END @@ -54,3 +55,4 @@ grep libb stderr && exit 1 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 diff --git a/tests/subobj9.test b/tests/subobj9.test index 9c5598886..d68e3dcf2 100755 --- a/tests/subobj9.test +++ b/tests/subobj9.test @@ -37,6 +37,10 @@ END 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 @@ $AUTOMAKE -a # 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