Subject: bug#10997: pkglibexecdir is unconditionally created when make install

From: Stefano Lattarini <[email-masked]>
Date: Mon, 12 Mar 2012 14:43:39 +0100

On 03/12/2012 12:21 PM, Peter Breitenlohner wrote:
>
> Fixing this particular case might be fine, but please watch out.
> In the quite similar (unconditional) case
>   pkglibexec_SCRIPTS =
> one might actually expect that that $(pkglibexecdir) is created
> unconditionally.
>
> [SNIP]
> 
> To summarize: 'nodist_bin_SCRIPTS =' is an extremely convenient way to
> ensure that $(bindir) -- or rather $(DESTDIR)$(bindir) -- exists.
>
I agree, and in fact I regard this as a feature (which automake has been known
to use in its own build system for some time).

But I see (with a simple "grep 'test -d' tests/*" command) that this behaviour
wasn't covered by our testsuite.  I've thus added a new test to ensure we don't
unwittingly break this feature (see attached patch, pushed to maint).

Thanks,
  Stefano
>From e9927ea32d8fe5056123b021ff771cb906b1b3df Mon Sep 17 00:00:00 2001
Message-Id: <e9927ea32[email-masked]>
From: Stefano Lattarini <[email-masked]>
Date: Mon, 12 Mar 2012 14:41:04 +0100
Subject: [PATCH] coverage: an empty foo_PRIMARY should create directory
 $(foodir)

For example, a Makefile.am containing the definition:

  pkgdata_DATA =

should cause the 'install' rule of the generated Makefile.in to
create the '$(pkgdatadir)' directory (respecting any DESTDIR
setting as well).

Suggestion by Peter Breitenlohner in automake bug#10997.

Signed-off-by: Stefano Lattarini <[email-masked]>
---
 tests/instdir-empty.test |   58 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/list-of-tests.mk   |    1 +
 2 files changed, 59 insertions(+), 0 deletions(-)
 create mode 100644 tests/instdir-empty.test

diff --git a/tests/instdir-empty.test b/tests/instdir-empty.test
new file mode 100644
index 0000000..f699583
--- /dev/null
+++ b/tests/instdir-empty.test
@@ -0,0 +1,58 @@
+#! /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/>.
+
+# An empty "foo_PRIMARY" declaration should cause "make install" to create
+# directory $(foodir).  Suggested in discussion on automake bug#10997.
+
+. ./defs || Exit 1
+
+set -e
+
+echo AC_OUTPUT >> configure.in
+
+cat > Makefile.am << 'END'
+pkgdata_DATA =
+libexec_SCRIPTS =
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+cwd=`pwd`
+./configure --prefix="$cwd/inst"
+
+$MAKE install
+test -d inst/share/$me
+test -d inst/libexec
+rm -rf inst
+
+$MAKE install-exec
+test ! -d inst/share
+test -d inst/libexec
+rm -rf inst
+
+$MAKE install-data
+test -d inst/share/$me
+test ! -d inst/libexec
+rm -rf inst
+
+./configure --prefix=/foo
+$MAKE install DESTDIR=$cwd/dest
+test -d dest/foo/share/$me
+test -d dest/foo/libexec
+
+:
diff --git a/tests/list-of-tests.mk b/tests/list-of-tests.mk
index 7fd0376..0ee0711 100644
--- a/tests/list-of-tests.mk
+++ b/tests/list-of-tests.mk
@@ -460,6 +460,7 @@ instdat2.test \
 instdir.test \
 instdir2.test \
 instdir-cond.test \
+instdir-empty.test \
 instdir-java.test \
 instdir-lisp.test \
 instdir-ltlib.test \
-- 
1.7.9