[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: conditional install dirs vs. mkdir_p
From: |
Alexandre Duret-Lutz |
Subject: |
Re: conditional install dirs vs. mkdir_p |
Date: |
Fri, 09 Jan 2004 00:31:55 +0100 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) |
>>> "Ralf" == Ralf Corsepius <address@hidden> writes:
Ralf> Given a Makefile.am, that conditionally installs headers to a directory
Ralf> defined inside of the condition, similar to this:
Ralf> if HAVE_FOO
Ralf> include_foodir = $(includedir)/foo
Ralf> include_foo_HEADERS = foo.h
Ralf> endif
Ralf> If HAVE_FOO is false, with automake-1.8 this happens:
Ralf> make install
Ralf> make[1]: Entering directory `/tmp/autobug'
Ralf> make[1]: Nothing to be done for `install-exec-am'.
Ralf> mkdir -m 0755 -p --
Ralf> mkdir: too few arguments
Ralf> Try `mkdir --help' for more information.
Ralf> make[1]: *** [install-include_fooHEADERS] Error 1
Ralf> make[1]: Leaving directory `/tmp/autobug'
-> mkdir -p is invoked with an empty directory and chokes.
Damned. And so would `install-sh -d'. Worse, `install-sh -d'
does not accept multiple arguments, but $(mkdir_p) is used that
way in `make installdirs'.
I'm installing the following patch on HEAD and branch-1-8.
(It's a diff -w to hide the reindentation of the body of the
for/do/done addition to install-sh)
The support of `install-sh sources... dest' comes as
side-effect. This might turn handy.
2004-01-08 Alexandre Duret-Lutz <address@hidden>
* m4/mkdirp.m4 (AM_PROG_MKDIR_P): Append `.' to $(mkdir_p).
* lib/install-sh: Accept `install-sh -d' with 0..n arguments,
as well as `install-sh sources... dest' with multiple sources.
* tests/cond33.test: New file.
* tests/instsh2.test: Add more checks for install-sh.
* tests/transform.test: Test for installdirs.
* tests/Makefile.am (TESTS): Add cond33.test
Report from Ralf Corsepius.
Index: NEWS
===================================================================
RCS file: /cvs/automake/automake/NEWS,v
retrieving revision 1.256.2.11
diff -u -w -r1.256.2.11 NEWS
--- NEWS 8 Jan 2004 20:22:43 -0000 1.256.2.11
+++ NEWS 8 Jan 2004 22:39:53 -0000
@@ -46,6 +46,17 @@
AC_CONFIG_LINKS($computedlinks). This version no longer abort in
that situation.
+ - Contrary to mkinstalldirs, $(mkdir_p) was expecting exactly one
+ argument. This caused two kinds of failures:
+ - Rules installing data in a conditionally defined directory
+ failed when that directory was undefined. In this case no
+ argument was supplied.
+ - `make installdirs' failed, because several directories were
+ passed to $(mkdir_p). This was an issue only on platforms
+ were $(mkdir_p) is implemented with `install-sh -d'.
+ $(mkdir_p) as been changed to accept 0 or more arguments, as
+ mkinstalldirs did.
+
* Long-standing bugs:
- Fix an unexpected diagnostic occurring when users attempt
Index: TODO
===================================================================
RCS file: /cvs/automake/automake/TODO,v
retrieving revision 1.421
diff -u -w -r1.421 TODO
--- TODO 4 Dec 2003 21:11:12 -0000 1.421
+++ TODO 8 Jan 2004 22:39:54 -0000
@@ -1,3 +1,9 @@
+We should arrange so that install-%DIR%%PRIMARY% is run conditionally
+when %DIR%_%PRIMARY% is defined conditionally. Currently it is always
+run, and that will therefore always create %DIR% (unless %DIR%dir is
+also defined conditionally). Likewise, installdirs should not
+create %DIR% in conditions were no %DIR%_%PRIMARY% is enabled.
+
we can't seem to AC_SUBST(pkgdatadir)
the version from header-vars overrides
why is that?
Index: configure
===================================================================
RCS file: /cvs/automake/automake/configure,v
retrieving revision 1.176.2.4
diff -u -w -r1.176.2.4 configure
--- configure 6 Jan 2004 20:37:22 -0000 1.176.2.4
+++ configure 8 Jan 2004 22:39:55 -0000
@@ -1456,7 +1456,13 @@
fi
if mkdir -p -- . 2>/dev/null; then
- mkdir_p='mkdir -p --'
+ # Keeping the `.' argument allows $(mkdir_p) to be used without
+ # argument. Indeed, we sometimes output rules like
+ # $(mkdir_p) $(somedir)
+ # where $(somedir) is conditionally defined.
+ # (`test -n '$(somedir)' && $(mkdir_p) $(somedir)' is a more
+ # expensive solution, as it forces Make to start a sub-shell.)
+ mkdir_p='mkdir -p -- .'
else
# On NextStep and OpenStep, the `mkdir' command does not
# recognize any option. It will interpret all options as
Index: lib/install-sh
===================================================================
RCS file: /cvs/automake/automake/lib/install-sh,v
retrieving revision 1.13
diff -u -w -r1.13 install-sh
--- lib/install-sh 24 Sep 2003 21:57:26 -0000 1.13
+++ lib/install-sh 8 Jan 2004 22:39:56 -0000
@@ -1,7 +1,7 @@
#!/bin/sh
# install - install a program, script, or datafile
-scriptversion=2003-09-24.23
+scriptversion=2004-01-08.23
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
@@ -72,7 +72,8 @@
dir_arg=
usage="Usage: $0 [OPTION]... SRCFILE DSTFILE
- or: $0 -d DIR1 DIR2...
+ or: $0 [OPTION]... SRCFILES... DIRECTORY
+ or: $0 -d DIRECTORIES...
In the first form, install SRCFILE to DSTFILE, removing SRCFILE by default.
In the second, create the directory path DIR.
@@ -134,23 +135,34 @@
--version) echo "$0 $scriptversion"; exit 0;;
- *) if test -z "$src"; then
- src=$1
- else
- # this colon is to work around a 386BSD /bin/sh bug
- :
- dst=$1
- fi
+ *) # When -d is used, all remaining arguments are directories to create.
+ test -n "$dir_arg" && break
+ # Otherwise, the last argument is the destination. Remove it from
address@hidden
+ for arg
+ do
shift
- continue;;
+ if test -n "$dstarg"; then
+ set fnord "$@" "$dstarg"
+ shift
+ fi
+ dstarg=$arg
+ done
+ break;;
esac
done
-if test -z "$src"; then
+if test -z "$1"; then
+ if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
+ # It's OK to call `install-sh -d' without argument.
+ # This can happen when creating conditional directories.
+ exit 0
+fi
+for src
+do
# Protect names starting with `-'.
case $src in
-*) src=./$src ;;
@@ -175,11 +187,12 @@
exit 1
fi
- if test -z "$dst"; then
+ if test -z "$dstarg"; then
echo "$0: no destination specified." >&2
exit 1
fi
+ dst=$dstarg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst ;;
@@ -280,7 +293,8 @@
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
-fi &&
+ fi || { (exit 1); exit; }
+done
# The final little trick to "correctly" pass the exit status to the exit trap.
{
Index: m4/mkdirp.m4
===================================================================
RCS file: /cvs/automake/automake/m4/mkdirp.m4,v
retrieving revision 1.2.2.1
diff -u -w -r1.2.2.1 mkdirp.m4
--- m4/mkdirp.m4 4 Jan 2004 00:02:44 -0000 1.2.2.1
+++ m4/mkdirp.m4 8 Jan 2004 22:39:56 -0000
@@ -31,7 +31,13 @@
# setting umask.
AC_DEFUN([AM_PROG_MKDIR_P],
[if mkdir -p -- . 2>/dev/null; then
- mkdir_p='mkdir -p --'
+ # Keeping the `.' argument allows $(mkdir_p) to be used without
+ # argument. Indeed, we sometimes output rules like
+ # $(mkdir_p) $(somedir)
+ # where $(somedir) is conditionally defined.
+ # (`test -n '$(somedir)' && $(mkdir_p) $(somedir)' is a more
+ # expensive solution, as it forces Make to start a sub-shell.)
+ mkdir_p='mkdir -p -- .'
else
# On NextStep and OpenStep, the `mkdir' command does not
# recognize any option. It will interpret all options as
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.539.2.3
diff -u -w -r1.539.2.3 Makefile.am
--- tests/Makefile.am 3 Jan 2004 12:42:54 -0000 1.539.2.3
+++ tests/Makefile.am 8 Jan 2004 22:39:56 -0000
@@ -119,6 +119,7 @@
cond30.test \
cond31.test \
cond32.test \
+cond33.test \
condd.test \
condinc.test \
condinc2.test \
Index: tests/Makefile.in
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.in,v
retrieving revision 1.698.2.7
diff -u -w -r1.698.2.7 Makefile.in
--- tests/Makefile.in 6 Jan 2004 22:08:32 -0000 1.698.2.7
+++ tests/Makefile.in 8 Jan 2004 22:39:56 -0000
@@ -233,6 +233,7 @@
cond30.test \
cond31.test \
cond32.test \
+cond33.test \
condd.test \
condinc.test \
condinc2.test \
Index: tests/cond33.test
===================================================================
RCS file: tests/cond33.test
diff -N tests/cond33.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/cond33.test 8 Jan 2004 22:39:56 -0000
@@ -0,0 +1,69 @@
+#!/bin/sh
+# Copyright (C) 2004 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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.
+#
+# GNU Automake 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 Automake; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# Check for conditional library with a conditional directory.
+# Report from Ralf Corsepius
+
+. ./defs
+
+set -e
+
+cat >>configure.in <<'EOF'
+AM_CONDITIONAL([INC], [test -z "$two"])
+AC_OUTPUT
+EOF
+
+cat >>Makefile.am <<'EOF'
+if INC
+include_foodir = $(includedir)/foo
+include_foo_HEADERS = foo.h
+else
+bardir = $(bindir)
+dist_bar_SCRIPTS = x.sh
+endif
+
+foo.h x.sh:
+ :>$@
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+mkdir nowhere
+chmod a-w nowhere
+./configure --prefix=`pwd`/nowhere --bindir=`pwd`/bin --includedir=`pwd`/inc
+$MAKE installdirs
+test ! -d bin
+test -d inc/foo
+test ! -f inc/foo/foo.h
+rm -rf inc
+$MAKE install
+test ! -d bin
+test -f inc/foo/foo.h
+rm -rf inc
+./configure two=two \
+ --prefix=`pwd`/nowhere --bindir=`pwd`/bin --includedir=`pwd`/inc
+$MAKE install
+test ! -d inc
+test -f bin/x.sh
+$MAKE installdirs
+test ! -d inc
+test -d bin
Index: tests/instsh2.test
===================================================================
RCS file: /cvs/automake/automake/tests/instsh2.test,v
retrieving revision 1.2
diff -u -w -r1.2 instsh2.test
--- tests/instsh2.test 14 Nov 2003 21:25:58 -0000 1.2
+++ tests/instsh2.test 8 Jan 2004 22:39:56 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2002 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2004 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -18,11 +18,53 @@
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
-# Ensure that install-sh works with names that include spaces
+# Various install-sh checks
. ./defs || exit 1
+set -e
+
+# Basic errors
+./install-sh && exit 1
+./install-sh -m 644 dest && exit 1
+
+# Directories
+
+# It should be OK to create no directory. We sometimes need
+# this when directory are conditionally defined.
+./install-sh -d
+# One directory.
+./install-sh -d d0
+test -d d0
+# Multiple directories (for make installdirs).
+./install-sh -d d1 d2 d3
+test -d d1
+test -d d2
+test -d d3
+
+# Files.
+: > x
+./install-sh -c -m 644 x y
+test -f x
+test -f y
+./install-sh -m 644 y z
+test ! -f y
+test -f z
+# Multiple files
+./install-sh -m 644 -c x z d1
+test -f x
+test -f z
+test -f d1/x
+test -f d1/z
+./install-sh -m 644 x z d2
+test ! -f x
+test ! -f z
+test -f d2/x
+test -f d2/z
+
+# Ensure that install-sh works with names that include spaces
touch 'a b'
-mkdir 'x y' || exit 1
-/bin/sh install-sh 'a b' 'x y' || exit 1
+mkdir 'x y'
+./install-sh 'a b' 'x y'
test -f x\ y/a\ b
+test ! -f 'a b'
Index: tests/transform.test
===================================================================
RCS file: /cvs/automake/automake/tests/transform.test,v
retrieving revision 1.5
diff -u -w -r1.5 transform.test
--- tests/transform.test 14 Nov 2003 21:26:01 -0000 1.5
+++ tests/transform.test 8 Jan 2004 22:39:56 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -61,3 +61,9 @@
$MAKE test-install
$MAKE uninstall
test `find inst/foo -type f -print | wc -l` = 0
+
+# Opportunistically test for installdirs.
+rm -rf inst
+$MAKE installdirs
+test -d inst/bin
+test -d inst/man/man1
--
Alexandre Duret-Lutz
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: conditional install dirs vs. mkdir_p,
Alexandre Duret-Lutz <=