From 11a44231a057b6dbc15d3fe83f0b652176442241 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Fri, 15 Jun 2012 18:50:47 +0200 Subject: [PATCH] [ng] general: support a private directory, for use by automake internals 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 --- Makefile.am | 1 + automake.in | 2 ++ lib/am/am-dir.am | 43 ++++++++++++++++++++++ t/am-dir.sh | 92 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 138 insertions(+) create mode 100644 lib/am/am-dir.am create mode 100755 t/am-dir.sh diff --git a/Makefile.am b/Makefile.am index c072b3f80..f6f9cb248 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/automake.in b/automake.in index 03d0310f1..c3a9848da 100644 --- a/automake.in +++ b/automake.in @@ -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 index 000000000..6ab095899 --- /dev/null +++ b/lib/am/am-dir.am @@ -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 . + +# 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 index 000000000..f3026598b --- /dev/null +++ b/t/am-dir.sh @@ -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 . + +# +# 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 < 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 + +: -- 2.47.2