]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
[ng] general: support a private directory, for use by automake internals
authorStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 15 Jun 2012 16:50:47 +0000 (18:50 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 15 Jun 2012 16:57:14 +0000 (18:57 +0200)
The directory is pointed to by these new internal make variables:

  -  $(am__dir)
  -  $(am__abs_dir)
  -  $(am__top_dir)
  -  $(am__abs_top_dir)

and cleaned by the new 'am--distclean-amdir' recipe (prerequisite of
'distclean-am').  It is not created by default; recipes needing it
should add an order-only dependency on it, as in:

    am-rule: am-prereq | $(am__dir)
        [recipe creating/using files in $(am__dir)]

* lib/am/am-dir.am: New file, define internal make variables that point
to a sandbox directory where we can play freely to implement internal
details that require interaction with the filesystem, and the rules to
properly clean them.  This file is not used yet, it's simply put here
so that future rules will be able to use it when and if it's needed.
* automake.in (generate_makefile): Include the new file, through the
'&preprocess_file' subroutine.
* Makefile.am (dist_am_DATA): List the new file.
* t/am-dir.sh: New test.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Makefile.am
automake.in
lib/am/am-dir.am [new file with mode: 0644]
t/am-dir.sh [new file with mode: 0755]

index c072b3f80443355f4bb7164a02cc81dfded45a16..f6f9cb2487972e6379a8d36428028452631288ef 100644 (file)
@@ -185,6 +185,7 @@ EXTRA_DIST += lib/Automake/Config.in
 ## --------------------- ##
 
 dist_am_DATA = \
+  lib/am/am-dir.am \
   lib/am/all-target.am \
   lib/am/check-target.am \
   lib/am/serial-tests.am \
index 03d0310f109ebd083b762225723ab14d488ae090..c3a9848da3948cb5715179fb1f2635aef0064d26 100644 (file)
@@ -7107,6 +7107,8 @@ sub generate_makefile ($$)
   check_gnu_standards;
   check_gnits_standards;
 
+  $output_verbatim .= preprocess_file ("$libdir/am/am-dir.am");
+
   handle_configure ($makefile_am, $makefile_in, $makefile, @inputs);
   handle_gettext;
   handle_libraries;
diff --git a/lib/am/am-dir.am b/lib/am/am-dir.am
new file mode 100644 (file)
index 0000000..6ab0958
--- /dev/null
@@ -0,0 +1,43 @@
+## automake - create Makefile.in from Makefile.am
+## Copyright (C) 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 <http://www.gnu.org/licenses/>.
+
+# Internal make variables that point to a sandbox directory where we can
+# play freely to implement internal details that require interaction with
+# the filesystem.  It is not created by default; recipes needing it
+# should add an order-only dependency on it, as in:
+#
+#     am-rule: am-prereqs | $(am__dir)
+#         [recipe creating/using files in $(am__dir)]
+#
+am__dir = .am
+
+# Its counterpart with an absolute path, for recipes that can chdir around.
+am__abs_dir = $(abs_builddir)/$(am__dir)
+
+# Its counterpart for use in subdir makefiles, in case they need to refer
+# to the top-leve $(am__dir) directory.
+am__top_dir = $(top_builddir)/$(am__dir)
+
+# Its counterpart with an absolute path and for use in subdir makefiles.
+am__abs_top_dir = $(abs_top_builddir)/$(am__dir)
+
+.PHONY: am--distclean-amdir
+am--distclean-amdir:
+       rm -rf $(am__dir)
+distclean-am: am--distclean-amdir
+
+$(am__dir):
+       @mkdir $@
diff --git a/t/am-dir.sh b/t/am-dir.sh
new file mode 100755 (executable)
index 0000000..f302659
--- /dev/null
@@ -0,0 +1,92 @@
+#! /bin/sh
+# Copyright (C) 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 <http://www.gnu.org/licenses/>.
+
+#
+# Check support for private automake working directory in builddir:
+#
+#  * internal variables:
+#      $(am__dir)
+#      $(am__abs_dir)
+#      $(am__top_dir)
+#      $(am__abs_top_dir)
+#
+#  * cleaning rules and "make distcheck" interaction.
+#
+
+. ./defs || Exit 1
+
+d=.am
+
+cat >> configure.ac <<'END'
+AC_CONFIG_FILES([xsrc/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = . xsrc
+all-local: | $(am__dir)
+END
+
+mkdir xsrc
+cat >> xsrc/Makefile.am <<'END'
+subdir:
+       mkdir $@
+all-local: | $(am__dir) subdir
+       : > $(am__dir)/sub
+       : > $(am__top_dir)/top
+       (cd ./subdir && : > $(am__abs_dir)/abs-sub)
+       rmdir subdir
+       (cd /tmp && : > $(am__abs_top_dir)/abs-top)
+END
+
+sort > exp <<END
+$d
+$d/top
+$d/abs-top
+xsrc/$d
+xsrc/$d/sub
+xsrc/$d/abs-sub
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+do_check ()
+{
+  srcdir=$1
+  $srcdir/configure
+  $MAKE
+  find $d xsrc/$d | sort > got
+  cat $srcdir/exp
+  cat got
+  diff $srcdir/exp got
+}
+
+mkdir build
+cd build
+do_check ..
+
+cd ..
+do_check .
+
+$MAKE distcheck
+$MAKE clean
+test -d $d
+$MAKE distclean
+test ! -e $d
+
+: