From 9845b2f97d71f4c54d5ef2d6dcdaa3a7a450c00f Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Sun, 6 Apr 2003 19:26:29 +0000 Subject: [PATCH] * automake.in (handle_installdirs): Rename as ... (handle_install): ... this. Define maybe_BUILT_SOURCES. (generate_makefile): Adjust call to handle_install. * lib/am/install.am (install): Use %maybe_BUILT_SOURCES%. * automake.texi (Sources, Built sources example): BUILT_SOURCES is honored by `make install' too. * tests/check3.test: Make sure that `make install' also depends upon BUILT_SOURCES. Report from Alexander Turbov. --- ChangeLog | 10 ++++++++++ automake.in | 15 ++++++++++----- automake.texi | 25 +++++++++++++------------ lib/am/install.am | 6 +++--- tests/check3.test | 18 +++++++++++++++--- 5 files changed, 51 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 948eb8603..3e426471f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2003-04-06 Alexandre Duret-Lutz + * automake.in (handle_installdirs): Rename as ... + (handle_install): ... this. Define maybe_BUILT_SOURCES. + (generate_makefile): Adjust call to handle_install. + * lib/am/install.am (install): Use %maybe_BUILT_SOURCES%. + * automake.texi (Sources, Built sources example): BUILT_SOURCES + is honored by `make install' too. + * tests/check3.test: Make sure that `make install' also depends + upon BUILT_SOURCES. + Report from Alexander Turbov. + * lib/am/libs.am (ARFLAGS): Define. * automake.in (handle_libraries): Use `$(ARFLAGS)' instead of hard-coding `cru'. diff --git a/automake.in b/automake.in index 1df692850..60608dff0 100755 --- a/automake.in +++ b/automake.in @@ -1571,7 +1571,7 @@ sub generate_makefile $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n"; } - &handle_installdirs; + &handle_install; &handle_clean; &handle_factored_dependencies; @@ -4811,15 +4811,20 @@ sub handle_footer $output_trailer .= file_contents ('footer', new Automake::Location); } -# Deal with installdirs target. -sub handle_installdirs () + +# Generate `make install' rules. +sub handle_install () { $output_rules .= &file_contents ('install', new Automake::Location, - am__installdirs => variable_value ('am__installdirs') || '', + maybe_BUILT_SOURCES => (variable_defined ('BUILT_SOURCES') + ? (" \$(BUILT_SOURCES)\n" + . "\t\$(MAKE) \$(AM_MAKEFLAGS)") + : ''), 'installdirs-local' => (target_defined ('installdirs-local') - ? ' installdirs-local' : '')); + ? ' installdirs-local' : ''), + am__installdirs => variable_value ('am__installdirs') || ''); } diff --git a/automake.texi b/automake.texi index 870347005..042b51843 100644 --- a/automake.texi +++ b/automake.texi @@ -3549,10 +3549,11 @@ rule to build @file{foo.h} first by lack of dependency information. @cindex BUILT_SOURCES, defined The @code{BUILT_SOURCES} variable is a workaround for this problem. A -source file listed in @code{BUILT_SOURCES} is made on @code{make all} or -@code{make check} before other targets are processed. However, such a -source file is not @emph{compiled} unless explicitly requested by -mentioning it in some other @samp{_SOURCES} variable. +source file listed in @code{BUILT_SOURCES} is made on @code{make all} +or @code{make check} (or even @code{make install}) before other +targets are processed. However, such a source file is not +@emph{compiled} unless explicitly requested by mentioning it in some +other @samp{_SOURCES} variable. So, to conclude our introductory example, we could use @code{BUILT_SOURCES = foo.h} to ensure @file{foo.h} gets built before @@ -3567,12 +3568,12 @@ doesn't need to appear in @code{BUILT_SOURCES} (unless it is included by another source), because it's a known dependency of the associated object. -It might be important to emphasize that @code{BUILT_SOURCES} is honored -only by @code{make all} and @code{make check}. This means you cannot -build a specific target (e.g., @code{make foo}) in a clean tree if it -depends on a built source. However it will succeed if you have run -@code{make all} earlier, because accurate dependencies are already -available. +It might be important to emphasize that @code{BUILT_SOURCES} is +honored only by @code{make all}, @code{make check} and @code{make +install}. This means you cannot build a specific target (e.g., +@code{make foo}) in a clean tree if it depends on a built source. +However it will succeed if you have run @code{make all} earlier, +because accurate dependencies are already available. The next section illustrates and discusses the handling of built sources on a toy example. @@ -3657,8 +3658,8 @@ make[1]: Leaving directory `/home/adl/tmp' @end example However, as said earlier, @code{BUILT_SOURCES} applies only to the -@code{all} and @code{check} targets. It still fails if you try to run -@code{make foo} explicitly: +@code{all}, @code{check}, and @code{install} targets. It still fails +if you try to run @code{make foo} explicitly: @example % make clean diff --git a/lib/am/install.am b/lib/am/install.am index f45a8ec00..7216af3b5 100644 --- a/lib/am/install.am +++ b/lib/am/install.am @@ -1,5 +1,5 @@ ## automake - create Makefile.in from Makefile.am -## Copyright 2001 Free Software Foundation, Inc. +## Copyright (C) 2001, 2002, 2003 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 @@ -36,13 +36,13 @@ .PHONY: install install-exec install-data uninstall ?SUBDIRS?.PHONY: install-recursive install-exec-recursive install-data-recursive uninstall-recursive -?SUBDIRS?install: install-recursive +?SUBDIRS?install:%maybe_BUILT_SOURCES% install-recursive ?SUBDIRS?install-exec: install-exec-recursive ?SUBDIRS?install-data: install-data-recursive ?SUBDIRS?uninstall: uninstall-recursive .PHONY: install-exec-am install-data-am uninstall-am -?!SUBDIRS?install: install-am +?!SUBDIRS?install:%maybe_BUILT_SOURCES% install-am ?!SUBDIRS?install-exec: install-exec-am ?!SUBDIRS?install-data: install-data-am ?!SUBDIRS?uninstall: uninstall-am diff --git a/tests/check3.test b/tests/check3.test index 073006631..3b51109fb 100755 --- a/tests/check3.test +++ b/tests/check3.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2002 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003 Free Software Foundation, Inc. # # This file is part of GNU Automake. # @@ -18,7 +18,7 @@ # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. -# Make sure `check:' honors $(BUILT_SOURCES). +# Make sure `check:' and `install:' honor $(BUILT_SOURCES). # PR/359. . ./defs || exit 1 @@ -48,6 +48,9 @@ cat > dir/Makefile.am << 'END' BUILT_SOURCES = command2.inc check_SCRIPTS = echo.sh echo.sh: +## The next line ensures that command1.inc has been built before +## recurring into the subdir. + test -f ../command1.inc (echo '#! /bin/sh'; cat command2.inc) > $@ chmod +x $@ command2.inc: @@ -58,7 +61,7 @@ END $ACLOCAL $AUTOCONF $AUTOMAKE -./configure +./configure --prefix `pwd`/inst $MAKE check >stdout cat stdout grep 'PASS: subrun.sh' stdout @@ -67,3 +70,12 @@ grep 'PASS: subrun.sh' stdout # in check.test and check2.test). $FGREP 'check: $(BUILT_SOURCES)' Makefile.in $FGREP 'check: $(BUILT_SOURCES)' dir/Makefile.in + +$MAKE clean +# Sanity checks +test ! -f command1.inc +test ! -f dir/command2.inc +# Now make sure these two files are rebuilt during make install. +$MAKE install +test -f command1.inc +test -f dir/command2.inc -- 2.47.2