]> sourceware.org Git - automake.git/commitdiff
* m4/mkdirp.m4 (AM_PROG_MKDIR_P): Append `.' to $(mkdir_p).
authorAlexandre Duret-Lutz <adl@gnu.org>
Thu, 8 Jan 2004 23:32:09 +0000 (23:32 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Thu, 8 Jan 2004 23:32:09 +0000 (23:32 +0000)
* 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.

ChangeLog
TODO
configure
lib/install-sh
m4/mkdirp.m4
tests/Makefile.am
tests/Makefile.in
tests/cond33.test [new file with mode: 0755]
tests/instsh2.test
tests/transform.test

index b7837666f544cc603c87bae6b3bdf80582e4beb2..720eb484a96c05b6a5fe54d1c6c7d750ac9f2bdc 100644 (file)
--- 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 7959de00568f708caffac67cf2c21513b437ebc4..8152a6ef2fd3395cce367be8afb80c737beffb17 100644 (file)
--- 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?
index 97e1dd2d85cde7c35c11dda274e4f54c5a433073..41cfc2b13b55eee2c07640d195cb54040f4d1c13 100755 (executable)
--- 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
index f5061e7e2696cfc2c6d1e5c03935c7eebbf4ca0b..acf44a6e0318c270090647e2a7f24575896ddff1 100755 (executable)
@@ -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.
 {
index e2c39d0ce6087811718b5fa9902a920a7fdcfeeb..f54005f54044b428b392279f12ffe531bb623a53 100644 (file)
 # 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 02ffcd4b56d8fb2c73dbec8d20a48b00cfe37524..9e93caf3d5b623b6b159d9931e129e4a96f5b3ab 100644 (file)
@@ -119,6 +119,7 @@ cond29.test \
 cond30.test \
 cond31.test \
 cond32.test \
+cond33.test \
 condd.test \
 condinc.test \
 condinc2.test \
index bfa78d7992d9d468fe3a44f4057f76724bef9436..39c53534368d19b51342e07dc1f1b2244ff572a0 100644 (file)
@@ -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 (executable)
index 0000000..3896ce2
--- /dev/null
@@ -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 7e9fd2febce5bd0eea54aa6ac0bd610f3c59739d..10f9f2b73ece711cac3e7178cd5156e0f7a614d8 100755 (executable)
@@ -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.
 #
 # 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 025ffca49cfb5343227f8350dce1a1781acb527b..37c266b85e92f32f28e3859f5a2750b2f9be1289 100755 (executable)
@@ -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
This page took 0.0559 seconds and 5 git commands to generate.