>From f4e221b65d381243553f82e125c615eaaf8ed5de Mon Sep 17 00:00:00 2001 Message-Id: From: Stefano Lattarini Date: Mon, 2 Jan 2012 09:40:13 +0100 Subject: [PATCH] progs, libs: implement EXTRA_foo_DEPENDENCIES Backported from commit `v1.11-377-g6edafbb'. The feature implemented by that change is quite unobtrusive, so adding it to a maintenance release is acceptable. Also, there have been requests from real-world users for this feature since it has been implemented in master; see automake bug#9320: and this short discussion on the automake list: It would be a pity to make such users wait even more (until Automake 1.12 is out) before they could start using this feature. Thus we backport it, so that it will appear in the next maintenance version of automake (1.11.3). * automake.in (handle_programs, handle_libraries) (handle_ltlibraries): Mark EXTRA_*_DEPENDENCIES as recognized. * doc/automake.texi (Linking, Program and Library Variables) (LIBOBJS): Document EXTRA_*_DEPENDENCIES. * lib/am/library.am (%LIBRARY%): Also depend on $(EXTRA_%XLIBRARY%_DEPENDENCIES). * lib/am/ltlibrary.am (%LTLIBRARY%): Also depend on (%XLTLIBRARY%_DEPENDENCIES). * lib/am/program.am (%PROGRAM%%EXEEXT%): Also depend on $(EXTRA_%XPROGRAM%_DEPENDENCIES). * tests/extradep.test, tests/extradep2.test: New tests. * tests/Makefile.am (TESTS): Update. * NEWS: Update. --- NEWS | 5 ++ automake.in | 7 ++- doc/automake.texi | 25 ++++++++--- lib/am/library.am | 6 +- lib/am/ltlibrary.am | 6 +- lib/am/program.am | 6 +- tests/Makefile.am | 6 ++- tests/extradep.test | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/extradep2.test | 89 +++++++++++++++++++++++++++++++++++++++++ 9 files changed, 239 insertions(+), 19 deletions(-) create mode 100755 tests/extradep.test create mode 100755 tests/extradep2.test diff --git a/NEWS b/NEWS index fa1e75e..599f19f 100644 --- a/NEWS +++ b/NEWS @@ -75,6 +75,11 @@ New in 1.11.0a: the `${infodir}/dir' file, by exporting the new environment variable `AM_UPDATE_INFO_DIR' to the value "no". + - For programs and libraries, automake now detects EXTRA_foo_DEPENDENCIES + and adds them to the normal list of dependencies, but without + overwriting the foo_DEPENDENCIES variable, which is normally computed + by automake. + Bugs fixed in 1.11.0a: * Bugs introduced by 1.11: diff --git a/automake.in b/automake.in index f235c9d..a852195 100644 --- a/automake.in +++ b/automake.in @@ -7,8 +7,8 @@ eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' # automake - create Makefile.in from Makefile.am # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software -# Foundation, Inc. +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free +# Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -2678,6 +2678,7 @@ sub handle_programs "use `${xname}_LDADD', not `${xname}_LIBADD'"); set_seen ($xname . '_DEPENDENCIES'); + set_seen ('EXTRA_' . $xname . '_DEPENDENCIES'); set_seen ($xname . '_LDFLAGS'); # Determine program to use for link. @@ -2789,6 +2790,7 @@ sub handle_libraries # Make sure we at look at this. set_seen ($xlib . '_DEPENDENCIES'); + set_seen ('EXTRA_' . $xlib . '_DEPENDENCIES'); &handle_source_transform ($xlib, $onelib, $obj, $where, NONLIBTOOL => 1, LIBTOOL => 0); @@ -2968,6 +2970,7 @@ sub handle_ltlibraries # Make sure we look at these. set_seen ($xlib . '_LDFLAGS'); set_seen ($xlib . '_DEPENDENCIES'); + set_seen ('EXTRA_' . $xlib . '_DEPENDENCIES'); # Generate support for conditional object inclusion in # libraries. diff --git a/doc/automake.texi b/doc/automake.texi index dd87e93..cebe084 100644 --- a/doc/automake.texi +++ b/doc/automake.texi @@ -24,7 +24,7 @@ This manual is for GNU Automake (version @value{VERSION}, Makefiles from template files. Copyright @copyright{} 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. @quotation @@ -4822,11 +4822,12 @@ this purpose. @cindex @code{_DEPENDENCIES}, defined @vindex maude_DEPENDENCIES address@hidden EXTRA_maude_DEPENDENCIES It is also occasionally useful to have a program depend on some other target that is not actually part of that program. This can be done -using the @address@hidden variable. Each program -depends on the contents of such a variable, but no further -interpretation is done. +using either the @address@hidden or the address@hidden@var{prog}_DEPENDENCIES} variable. Each program depends on +the contents both variables, but no further interpretation is done. Since these dependencies are associated to the link rule used to create the programs they should normally list files used by the link @@ -4849,6 +4850,10 @@ generated. @ref{Conditional Sources} shows a situation where @code{_DEPENDENCIES} may be used. +The @address@hidden may be useful for cases where +you merely want to augment the @command{automake}-generated address@hidden@var{prog}_DEPENDENCIES} rather than replacing it. + @cindex @code{LDADD} and @option{-l} @cindex @option{-l} and @code{LDADD} We recommend that you avoid using @option{-l} options in @code{LDADD} @@ -5723,6 +5728,7 @@ option, so they should not be mode-specific options (those belong to the compiler or linker flags). @xref{Libtool Flags}. @item maude_DEPENDENCIES address@hidden EXTRA_maude_DEPENDENCIES It is also occasionally useful to have a target (program or library) depend on some other file that is not actually part of that target. This can be done using the @code{_DEPENDENCIES} variable. Each @@ -5753,6 +5759,10 @@ compilation using an @code{AC_SUBST} variable that contains a list of objects. @xref{Conditional Sources}, and @ref{Conditional Libtool Sources}. +The @code{EXTRA_*_DEPENDENCIES} variable may be useful for cases where +you merely want to augment the @command{automake}-generated address@hidden variable rather than replacing it. + @item maude_LINK You can override the linker on a per-program basis. By default the linker is chosen according to the languages used by the program. For @@ -5963,9 +5973,10 @@ However there is no need to list the corresponding sources in automatically adds @samp{$(LIBOBJS)} and @samp{$(ALLOCA)} to the dependencies, and it will discover the list of corresponding source files automatically (by tracing the invocations of the address@hidden Autoconf macros). However, if you have already -defined @samp{*_DEPENDENCIES} explicitly for an unrelated reason, then -you have to add these variables manually. address@hidden Autoconf macros). If you have already defined address@hidden explicitly for an unrelated reason, then you +either need to add these variables manually, or use address@hidden instead of @samp{*_DEPENDENCIES}. These variables are usually used to build a portability library that is linked with all the programs of the project. We now review a diff --git a/lib/am/library.am b/lib/am/library.am index ce94e5e..4045558 100644 --- a/lib/am/library.am +++ b/lib/am/library.am @@ -1,6 +1,6 @@ ## automake - create Makefile.in from Makefile.am -## Copyright (C) 1994, 1995, 1996, 1999, 2003, 2009 Free Software -## Foundation, Inc. +## Copyright (C) 1994, 1995, 1996, 1999, 2003, 2009, 2010, 2012 Free +## Software Foundation, Inc. ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -14,7 +14,7 @@ ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . -%LIBRARY%: $(%XLIBRARY%_OBJECTS) $(%XLIBRARY%_DEPENDENCIES) %DIRSTAMP% +%LIBRARY%: $(%XLIBRARY%_OBJECTS) $(%XLIBRARY%_DEPENDENCIES) $(EXTRA_%XLIBRARY%_DEPENDENCIES) %DIRSTAMP% %SILENT%-rm -f %LIBRARY% %VERBOSE%$(%XLIBRARY%_AR) %LIBRARY% $(%XLIBRARY%_OBJECTS) $(%XLIBRARY%_LIBADD) %SILENT%$(RANLIB) %LIBRARY% diff --git a/lib/am/ltlibrary.am b/lib/am/ltlibrary.am index 9455234..dd958fd 100644 --- a/lib/am/ltlibrary.am +++ b/lib/am/ltlibrary.am @@ -1,6 +1,6 @@ ## automake - create Makefile.in from Makefile.am -## Copyright (C) 1994, 1995, 1996, 2003, 2005, 2008, 2009 Free Software -## Foundation, Inc. +## Copyright (C) 1994, 1995, 1996, 2003, 2005, 2008, 2009, 2010, 2012 +## Free Software Foundation, Inc. ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -14,5 +14,5 @@ ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . -%LTLIBRARY%: $(%XLTLIBRARY%_OBJECTS) $(%XLTLIBRARY%_DEPENDENCIES) %DIRSTAMP% +%LTLIBRARY%: $(%XLTLIBRARY%_OBJECTS) $(%XLTLIBRARY%_DEPENDENCIES) $(EXTRA_%XLTLIBRARY%_DEPENDENCIES) %DIRSTAMP% %VERBOSE%$(%XLINK%) %RPATH% $(%XLTLIBRARY%_OBJECTS) $(%XLTLIBRARY%_LIBADD) $(LIBS) diff --git a/lib/am/program.am b/lib/am/program.am index 7e568e7..42c585e 100644 --- a/lib/am/program.am +++ b/lib/am/program.am @@ -1,6 +1,6 @@ ## automake - create Makefile.in from Makefile.am -## Copyright (C) 1994, 1995, 1996, 1997, 2001, 2003, 2005, 2009 -## Free Software Foundation, Inc. +## Copyright (C) 1994, 1995, 1996, 1997, 2001, 2003, 2005, 2009, 2010, +## 2012 Free Software Foundation, Inc. ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -14,7 +14,7 @@ ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . -%PROGRAM%%EXEEXT%: $(%XPROGRAM%_OBJECTS) $(%XPROGRAM%_DEPENDENCIES) %DIRSTAMP% +%PROGRAM%%EXEEXT%: $(%XPROGRAM%_OBJECTS) $(%XPROGRAM%_DEPENDENCIES) $(EXTRA_%XPROGRAM%_DEPENDENCIES) %DIRSTAMP% ## Remove program before linking. Otherwise the link will fail if the ## program is running somewhere. FIXME: this could be a loss if ## you're using an incremental linker. Maybe we should think twice? diff --git a/tests/Makefile.am b/tests/Makefile.am index 2f1ac0d..3d20871 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,7 +1,8 @@ ## Process this file with automake to create Makefile.in # Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005, -# 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +# 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, +# Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -386,6 +387,8 @@ extra8.test \ extra10.test \ extra11.test \ extra12.test \ +extradep.test \ +extradep2.test \ f90only.test \ flavor.test \ flibs.test \ @@ -942,6 +945,7 @@ $(parallel_tests) depcomp4.log: libtool-macros.log depcomp7.log: libtool-macros.log depcomp8b.log: libtool-macros.log +extradep2.log: libtool-macros.log fort5.log: libtool-macros.log instdir-ltlib.log: libtool-macros.log instfail-libtool.log: libtool-macros.log diff --git a/tests/extradep.test b/tests/extradep.test new file mode 100755 index 0000000..4cbfda5 --- /dev/null +++ b/tests/extradep.test @@ -0,0 +1,108 @@ +#! /bin/sh +# Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test EXTRA_*_DEPENDENCIES. See extradep2 for libtool variant. + +required=cc +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_PROG_CC +AC_PROG_RANLIB +AC_SUBST([deps], [bardep]) +AM_CONDITIONAL([COND], [test -n "$cond"]) +AC_OUTPUT +END + +cat > Makefile.am << 'END' +noinst_LIBRARIES = libfoo.a +EXTRA_libfoo_a_DEPENDENCIES = libfoodep +libfoodep: + @echo making $@ + @: > $@ +CLEANFILES = libfoodep + +bin_PROGRAMS = foo bar +EXTRA_foo_DEPENDENCIES = foodep +if COND +EXTRA_foo_DEPENDENCIES += foodep2 +endif +bar_LDADD = libfoo.a +EXTRA_bar_DEPENDENCIES = $(deps) + +EXTRA_DIST = foodep bardep + +.PHONY: bar-has-been-updated +bar-has-been-updated: + stat older bar$(EXEEXT) libfoo.a || : For debugging. + test `ls -t bar$(EXEEXT) older | sed q` = bar$(EXEEXT) +END + +cat >libfoo.c <<'END' +int libfoo () { return 0; } +END + +cat >foo.c <<'END' +int main () { return 0; } +END + +cat >bar.c <<'END' +extern int libfoo (); +int main () { return libfoo (); } +END + +$ACLOCAL +$AUTOMAKE --add-missing +$AUTOCONF + +./configure cond=yes + +# Hypotheses: +# - EXTRA_*_DEPENDENCIES are honored. +# - Conditionals and substitutions are honored. +# - *_DEPENDENCIES are not overwritten by their EXTRA_* counterparts. + +: >foodep +: >foodep2 +: >bardep +$MAKE >stdout || { cat stdout; Exit 1; } +cat stdout +grep 'making libfoodep' stdout + +rm -f foodep +$MAKE && Exit 1 +: >foodep + +rm -f foodep2 +$MAKE && Exit 1 +: >foodep2 + +rm -f bardep +$MAKE && Exit 1 +: >bardep + +$MAKE +: > older +$sleep +touch libfoo.a +$MAKE +$MAKE bar-has-been-updated + +$MAKE distcheck + +: diff --git a/tests/extradep2.test b/tests/extradep2.test new file mode 100755 index 0000000..3d44512 --- /dev/null +++ b/tests/extradep2.test @@ -0,0 +1,89 @@ +#! /bin/sh +# Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test EXTRA_*_DEPENDENCIES, libtool version; see extradep.test. + +required='cc libtoolize' +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_PROG_CC +AC_PROG_LIBTOOL +AC_SUBST([deps], [bardep]) +AC_OUTPUT +END + +cat > Makefile.am << 'END' +noinst_LTLIBRARIES = libfoo.la +EXTRA_libfoo_la_DEPENDENCIES = libfoodep +libfoodep: + @echo making $@ + @: > $@ +CLEANFILES = libfoodep + +bin_PROGRAMS = bar +bar_LDADD = libfoo.la +EXTRA_bar_DEPENDENCIES = $(deps) + +EXTRA_DIST = bardep + +.PHONY: bar-has-been-updated +bar-has-been-updated: + stat older bar$(EXEEXT) libfoo.la || : For debugging. + test `ls -t bar$(EXEEXT) older | sed q` = bar$(EXEEXT) +END + +cat >libfoo.c <<'END' +int libfoo () { return 0; } +END + +cat >bar.c <<'END' +extern int libfoo (); +int main () { return libfoo (); } +END + +libtoolize +$ACLOCAL +$AUTOMAKE --add-missing +$AUTOCONF + +./configure + +# Hypothesis: EXTRA_*_DEPENDENCIES are honored. + +: >foodep +: >foodep2 +: >bardep +$MAKE >stdout || { cat stdout; Exit 1; } +cat stdout +grep 'making libfoodep' stdout + +rm -f bardep +$MAKE && Exit 1 +: >bardep + +$MAKE +: > older +$sleep +touch libfoo.la +$MAKE +$MAKE bar-has-been-updated + +$MAKE distcheck + +: -- 1.7.7.3