summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Duret-Lutz <adl@gnu.org>2004-01-08 23:32:11 +0000
committerAlexandre Duret-Lutz <adl@gnu.org>2004-01-08 23:32:11 +0000
commit7dd9fee1c389ec41a9ecff56e642eea82eec9b9b (patch)
treee8f2b5f2a0820f09917b282727b9475cf18ba7ba
parentf323a7a72bc2f93d95f08d27c616b0904308d502 (diff)
downloadautomake-7dd9fee1c389ec41a9ecff56e642eea82eec9b9b.tar.gz
* 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.
-rw-r--r--ChangeLog9
-rw-r--r--TODO6
-rwxr-xr-xconfigure8
-rwxr-xr-xlib/install-sh266
-rw-r--r--m4/mkdirp.m48
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/Makefile.in1
-rwxr-xr-xtests/cond33.test69
-rwxr-xr-xtests/instsh2.test50
-rwxr-xr-xtests/transform.test8
10 files changed, 293 insertions, 133 deletions
diff --git a/ChangeLog b/ChangeLog
index b7837666f..720eb484a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2004-01-08 Alexandre Duret-Lutz <adl@gnu.org>
+ * 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.
+
* automake.in (handle_configure): Skip AC_CONFIG_LINKS items which
do not look like DEST:SRC.
* tests/conflnk3.test: Check for AC_CONFIG_LINKS($computed).
diff --git a/TODO b/TODO
index 7959de005..8152a6ef2 100644
--- a/TODO
+++ b/TODO
@@ -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?
diff --git a/configure b/configure
index 97e1dd2d8..41cfc2b13 100755
--- a/configure
+++ b/configure
@@ -1456,7 +1456,13 @@ echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
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
diff --git a/lib/install-sh b/lib/install-sh
index f5061e7e2..acf44a6e0 100755
--- a/lib/install-sh
+++ b/lib/install-sh
@@ -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 @@ dst=
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,153 +135,166 @@ while test -n "$1"; do
--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
- shift
- continue;;
+ *) # 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 $@.
+ for arg
+ do
+ shift
+ if test -n "$dstarg"; then
+ set fnord "$@" "$dstarg"
+ shift
+ fi
+ dstarg=$arg
+ done
+ break;;
esac
done
-if test -z "$src"; then
- echo "$0: no input file specified." >&2
- exit 1
+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
-# Protect names starting with `-'.
-case $src in
- -*) src=./$src ;;
-esac
+for src
+do
+ # Protect names starting with `-'.
+ case $src in
+ -*) src=./$src ;;
+ esac
-if test -n "$dir_arg"; then
- dst=$src
- src=
+ if test -n "$dir_arg"; then
+ dst=$src
+ src=
- if test -d "$dst"; then
- instcmd=:
- chmodcmd=
+ if test -d "$dst"; then
+ instcmd=:
+ chmodcmd=
+ else
+ instcmd=$mkdirprog
+ fi
else
- instcmd=$mkdirprog
- fi
-else
- # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
- # might cause directories to be created, which would be especially bad
- # if $src (and thus $dsttmp) contains '*'.
- if test ! -f "$src" && test ! -d "$src"; then
- echo "$0: $src does not exist." >&2
- exit 1
- fi
+ # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+ # might cause directories to be created, which would be especially bad
+ # if $src (and thus $dsttmp) contains '*'.
+ if test ! -f "$src" && test ! -d "$src"; then
+ echo "$0: $src does not exist." >&2
+ exit 1
+ fi
- if test -z "$dst"; then
- echo "$0: no destination specified." >&2
- exit 1
- fi
+ if test -z "$dstarg"; then
+ echo "$0: no destination specified." >&2
+ exit 1
+ fi
- # Protect names starting with `-'.
- case $dst in
- -*) dst=./$dst ;;
- esac
+ dst=$dstarg
+ # Protect names starting with `-'.
+ case $dst in
+ -*) dst=./$dst ;;
+ esac
- # If destination is a directory, append the input filename; won't work
- # if double slashes aren't ignored.
- if test -d "$dst"; then
- dst=$dst/`basename "$src"`
+ # If destination is a directory, append the input filename; won't work
+ # if double slashes aren't ignored.
+ if test -d "$dst"; then
+ dst=$dst/`basename "$src"`
+ fi
fi
-fi
-# This sed command emulates the dirname command.
-dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+ # This sed command emulates the dirname command.
+ dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
-# Make sure that the destination directory exists.
+ # Make sure that the destination directory exists.
-# Skip lots of stat calls in the usual case.
-if test ! -d "$dstdir"; then
- defaultIFS='
- '
- IFS="${IFS-$defaultIFS}"
+ # Skip lots of stat calls in the usual case.
+ if test ! -d "$dstdir"; then
+ defaultIFS='
+ '
+ IFS="${IFS-$defaultIFS}"
- oIFS=$IFS
- # Some sh's can't handle IFS=/ for some reason.
- IFS='%'
- set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
- IFS=$oIFS
+ oIFS=$IFS
+ # Some sh's can't handle IFS=/ for some reason.
+ IFS='%'
+ set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
+ IFS=$oIFS
- pathcomp=
+ pathcomp=
- while test $# -ne 0 ; do
- pathcomp=$pathcomp$1
- shift
- test -d "$pathcomp" || $mkdirprog "$pathcomp"
- pathcomp=$pathcomp/
- done
-fi
-
-if test -n "$dir_arg"; then
- $doit $instcmd "$dst" \
- && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
- && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
- && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
- && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
-
-else
- # If we're going to rename the final executable, determine the name now.
- if test -z "$transformarg"; then
- dstfile=`basename "$dst"`
- else
- dstfile=`basename "$dst" $transformbasename \
- | sed $transformarg`$transformbasename
+ while test $# -ne 0 ; do
+ pathcomp=$pathcomp$1
+ shift
+ test -d "$pathcomp" || $mkdirprog "$pathcomp"
+ pathcomp=$pathcomp/
+ done
fi
- # don't allow the sed command to completely eliminate the filename.
- test -z "$dstfile" && dstfile=`basename "$dst"`
-
- # Make a couple of temp file names in the proper directory.
- dsttmp=$dstdir/_inst.$$_
- rmtmp=$dstdir/_rm.$$_
-
- # Trap to clean up those temp files at exit.
- trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
- trap '(exit $?); exit' 1 2 13 15
-
- # Move or copy the file name to the temp name
- $doit $instcmd "$src" "$dsttmp" &&
-
- # and set any options; do chmod last to preserve setuid bits.
- #
- # If any of these fail, we abort the whole thing. If we want to
- # ignore errors from any of these, just make sure not to ignore
- # errors from the above "$doit $instcmd $src $dsttmp" command.
- #
- { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
- && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
- && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
- && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
-
- # Now remove or move aside any old file at destination location. We
- # try this two ways since rm can't unlink itself on some systems and
- # the destination file might be busy for other reasons. In this case,
- # the final cleanup might fail but the new file should still install
- # successfully.
- {
- if test -f "$dstdir/$dstfile"; then
- $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
- || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
- || {
- echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
- (exit 1); exit
- }
+ if test -n "$dir_arg"; then
+ $doit $instcmd "$dst" \
+ && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
+ && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
+ && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
+ && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
+
+ else
+ # If we're going to rename the final executable, determine the name now.
+ if test -z "$transformarg"; then
+ dstfile=`basename "$dst"`
else
- :
+ dstfile=`basename "$dst" $transformbasename \
+ | sed $transformarg`$transformbasename
fi
- } &&
- # Now rename the file to the real destination.
- $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
-fi &&
+ # don't allow the sed command to completely eliminate the filename.
+ test -z "$dstfile" && dstfile=`basename "$dst"`
+
+ # Make a couple of temp file names in the proper directory.
+ dsttmp=$dstdir/_inst.$$_
+ rmtmp=$dstdir/_rm.$$_
+
+ # Trap to clean up those temp files at exit.
+ trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
+ trap '(exit $?); exit' 1 2 13 15
+
+ # Move or copy the file name to the temp name
+ $doit $instcmd "$src" "$dsttmp" &&
+
+ # and set any options; do chmod last to preserve setuid bits.
+ #
+ # If any of these fail, we abort the whole thing. If we want to
+ # ignore errors from any of these, just make sure not to ignore
+ # errors from the above "$doit $instcmd $src $dsttmp" command.
+ #
+ { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
+ && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
+ && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
+ && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
+
+ # Now remove or move aside any old file at destination location. We
+ # try this two ways since rm can't unlink itself on some systems and
+ # the destination file might be busy for other reasons. In this case,
+ # the final cleanup might fail but the new file should still install
+ # successfully.
+ {
+ if test -f "$dstdir/$dstfile"; then
+ $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
+ || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
+ || {
+ echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
+ (exit 1); exit
+ }
+ else
+ :
+ fi
+ } &&
+
+ # Now rename the file to the real destination.
+ $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
+ fi || { (exit 1); exit; }
+done
# The final little trick to "correctly" pass the exit status to the exit trap.
{
diff --git a/m4/mkdirp.m4 b/m4/mkdirp.m4
index e2c39d0ce..f54005f54 100644
--- a/m4/mkdirp.m4
+++ b/m4/mkdirp.m4
@@ -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
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 02ffcd4b5..9e93caf3d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -119,6 +119,7 @@ cond29.test \
cond30.test \
cond31.test \
cond32.test \
+cond33.test \
condd.test \
condinc.test \
condinc2.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index bfa78d799..39c535343 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -233,6 +233,7 @@ cond29.test \
cond30.test \
cond31.test \
cond32.test \
+cond33.test \
condd.test \
condinc.test \
condinc2.test \
diff --git a/tests/cond33.test b/tests/cond33.test
new file mode 100755
index 000000000..3896ce23a
--- /dev/null
+++ b/tests/cond33.test
@@ -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
diff --git a/tests/instsh2.test b/tests/instsh2.test
index 7e9fd2feb..10f9f2b73 100755
--- a/tests/instsh2.test
+++ b/tests/instsh2.test
@@ -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'
diff --git a/tests/transform.test b/tests/transform.test
index 025ffca49..37c266b85 100755
--- a/tests/transform.test
+++ b/tests/transform.test
@@ -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
$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