From: Ralf Wildenhues Date: Sat, 2 Oct 2010 18:25:53 +0000 (+0200) Subject: Implement EXTRA_maude_DEPENDENCIES for programs and libraries. X-Git-Tag: ng-0.5a~362 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=v1.11-377-g6edafbb;p=thirdparty%2Fautomake.git Implement EXTRA_maude_DEPENDENCIES for programs and libraries. * 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. Suggested by Eric Blake. Signed-off-by: Ralf Wildenhues --- diff --git a/ChangeLog b/ChangeLog index 90286ac31..356a9fc0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,21 @@ 2010-10-02 Ralf Wildenhues + Implement EXTRA_maude_DEPENDENCIES for programs and libraries. + * 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. + Suggested by Eric Blake. + tests: avoid running into timing issues due to sanity change. * tests/acloca10.test, tests/acloca18.test, tests/aclocal9.test: Insert strategic sleep before aclocal reruns, to ensure files diff --git a/NEWS b/NEWS index 9314bdd0a..121989fa4 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,10 @@ New in 1.11a: at least one second has passed, to avoid time stamp issues with makefile rules rerunning autotools programs. + - 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.11a: - Lots of minor bugfixes. diff --git a/automake.in b/automake.in index 9cbe6c169..52add361c 100644 --- a/automake.in +++ b/automake.in @@ -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 1bd327dd6..487f230cc 100644 --- a/doc/automake.texi +++ b/doc/automake.texi @@ -4698,11 +4698,12 @@ this purpose. @cindex @code{_DEPENDENCIES}, defined @vindex maude_DEPENDENCIES +@vindex 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 @code{@var{prog}_DEPENDENCIES} variable. Each program -depends on the contents of such a variable, but no further -interpretation is done. +using either the @code{@var{prog}_DEPENDENCIES} or the +@code{EXTRA_@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 @@ -4725,6 +4726,10 @@ generated. @ref{Conditional Sources} shows a situation where @code{_DEPENDENCIES} may be used. +The @code{EXTRA_@var{prog}_DEPENDENCIES} may be useful for cases where +you merely want to augment the @command{automake}-generated +@code{@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} @@ -5592,6 +5597,7 @@ option, so they should not be mode-specific options (those belong to the compiler or linker flags). @xref{Libtool Flags}. @item maude_DEPENDENCIES +@itemx 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 @@ -5622,6 +5628,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 +@code{_DEPENDENCIES} 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 @@ -5832,9 +5842,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 -@code{AC_LIBSOURCE} Autoconf macros). However, if you have already -defined @samp{*_DEPENDENCIES} explicitly for an unrelated reason, then -you have to add these variables manually. +@code{AC_LIBSOURCE} Autoconf macros). If you have already defined +@samp{*_DEPENDENCIES} explicitly for an unrelated reason, then you +either need to add these variables manually, or use +@samp{EXTRA_*_DEPENDENCIES} 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 ce94e5e8f..db096c762 100644 --- a/lib/am/library.am +++ b/lib/am/library.am @@ -1,5 +1,5 @@ ## automake - create Makefile.in from Makefile.am -## Copyright (C) 1994, 1995, 1996, 1999, 2003, 2009 Free Software +## Copyright (C) 1994, 1995, 1996, 1999, 2003, 2009, 2010 Free Software ## Foundation, Inc. ## This program is free software; you can redistribute it and/or modify @@ -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 945523468..3cd2941dc 100644 --- a/lib/am/ltlibrary.am +++ b/lib/am/ltlibrary.am @@ -1,5 +1,5 @@ ## automake - create Makefile.in from Makefile.am -## Copyright (C) 1994, 1995, 1996, 2003, 2005, 2008, 2009 Free Software +## Copyright (C) 1994, 1995, 1996, 2003, 2005, 2008, 2009, 2010 Free Software ## Foundation, Inc. ## This program is free software; you can redistribute it and/or modify @@ -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 7e568e79a..c0e188f96 100644 --- a/lib/am/program.am +++ b/lib/am/program.am @@ -1,5 +1,5 @@ ## automake - create Makefile.in from Makefile.am -## Copyright (C) 1994, 1995, 1996, 1997, 2001, 2003, 2005, 2009 +## Copyright (C) 1994, 1995, 1996, 1997, 2001, 2003, 2005, 2009, 2010 ## Free Software Foundation, Inc. ## This program is free software; you can redistribute it and/or modify @@ -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 6352a1152..8b2ca8440 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -345,6 +345,8 @@ extra9.test \ extra10.test \ extra11.test \ extra12.test \ +extradep.test \ +extradep2.test \ f90only.test \ flavor.test \ flibs.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 8d5622c7e..4bb1e914d 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -556,6 +556,8 @@ extra9.test \ extra10.test \ extra11.test \ extra12.test \ +extradep.test \ +extradep2.test \ f90only.test \ flavor.test \ flibs.test \ diff --git a/tests/extradep.test b/tests/extradep.test new file mode 100755 index 000000000..d84182d8f --- /dev/null +++ b/tests/extradep.test @@ -0,0 +1,104 @@ +#! /bin/sh +# Copyright (C) 2010 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. + +. ./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 + +bar-is-newer-than-libfoo.a: + test `ls -1t bar$(EXEEXT) libfoo.a | 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 +$sleep +touch libfoo.a +$MAKE +$MAKE bar-is-newer-than-libfoo.a + +$MAKE distcheck + +: diff --git a/tests/extradep2.test b/tests/extradep2.test new file mode 100755 index 000000000..7d72e8222 --- /dev/null +++ b/tests/extradep2.test @@ -0,0 +1,86 @@ +#! /bin/sh +# Copyright (C) 2010 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=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 + +bar-is-newer-than-libfoo.la: + test `ls -1t bar$(EXEEXT) libfoo.la | 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 +$sleep +touch libfoo.la +$MAKE +$MAKE bar-is-newer-than-libfoo.la + +$MAKE distcheck + +: