+2004-09-17 Gary V. Vaughan <gary@gnu.org>
+
+ Missed a couple of MKDIR_P references in ltmain.in in my last
+ patch; fix them carefully. Introduce an opt_dry_run to ltmain.in
+ so that the implementations of func_mkdir_p can converge, and a
+ func_mktempdir to do a better job of temporary directory creation:
+
+ * libtoolize.in (func_mkdir_p): Don't fail if the directory wasn't
+ created in dry run mode.
+ * tests/defs (func_mkdir_p): Ditto. We don't actually have a dry
+ run mode for the tests, but the function is written carefully to
+ be kept in synch and work correctly here too.
+ * config/ltmain.in (func_mkdir_p): Ditto. This copy of the
+ function now only differs in its use of $echo over $ECHO.
+ (func_extract_archive): Removed first redundant mkdir call.
+ (func_mktempdir): New function that tries to avoid races when
+ making temporary directories.
+ (opt_dry_run): Set this if --dry-run is given at the CLI, or if
+ tests/mdemo-dryrun.test has forced the value of $run.
+ (func_mode_install): Call $MKDIR directly and error out if the
+ directory cannot be created.
+ (func_mode_link): Rather than copying func_mkdir_p into the
+ wrapper script as a replacement for $MKDIR_P, we know that the
+ script won't be called my `make -j', so write the current value of
+ $MKDIR.
+
2004-09-17 Peter O'Gorman <peter@pogma.com>
* m4/libtool.m4: remove an extra "]"
lo2o="s/\\.lo\$/.${objext}/"
o2lo="s/\\.${objext}\$/.lo/"
-opt_help=false
+opt_dry_run=${run-false} ## inherit $run when mdemo-dryrun.test sets it above
opt_duplicate_deps=false
+opt_help=false
# If this variable is set in any of the actions, the command in it
# will be execed at the end. This prevents here-documents from being
set -x
;;
- --dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break
+ -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break
execute_dlfiles="$execute_dlfiles $1"
+ shift
+ ;;
+
+ --dry-run | -n) opt_dry_run=:
+ run=:
;;
- --dry-run | -n) run=: ;;
--features) func_features ;;
--finish) mode="finish" ;;
;;
# Separate optargs to long options:
- --dlopen=*|--mode=*|--tag=*)
+ -dlopen=*|--mode=*|--tag=*)
arg=`echo "$opt" | $SED "$my_sed_long_arg"`
opt=`echo "$opt" | $SED "$my_sed_long_opt"`
set -- "$opt" "$arg" ${1+"$@"}
my_directory_path="$1"
my_dir_list=
- if test -n "$my_directory_path"; then
+ if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
# Protect directory names starting with `-'
case $my_directory_path in
$MKDIR "$my_dir" 2>/dev/null || :
done
IFS="$save_mkdir_p_IFS"
+
+ # Bail out if we (or some other process) failed to create a directory.
+ test -d "$my_directory_path" || \
+ func_fatal_error "Failed to create \`$1'"
+ fi
+}
+
+
+# func_mktempdir
+# Make a temporary directory that won't clash with other running
+# libtool processes, and avoids race conditions if possible
+func_mktempdir ()
+{
+ my_template="${TMPDIR-/tmp}/libtool"
+
+ if test "$opt_dry_run" = ":"; then
+ # Return a directory name, but don't create it in dry-run mode
+ my_tmpdir="${my_template}-$$"
+ else
+
+ # If mktemp works, use that first and foremost
+ my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+
+ if test ! -d "$my_tmpdir"; then
+ # Failing that, at least try and use $RANDOM to avoid a race
+ my_tmpdir="${my_template}-${RANDOM-0}$$"
+
+ save_mktempdir_umask=`umask`
+ umask 0077
+ $MKDIR "$my_tmpdir"
+ umask $save_mktempdir_umask
+ fi
+
+ # If we're not in dry-run mode, bomb out on failure
+ test -d "$my_tmpdir" || \
+ func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
fi
- # Bail out if we (or some other process) failed to create a directory.
- test -d "$my_directory_path" || \
- func_fatal_error "Failed to create \`$1'"
+ echo "$my_tmpdir"
}
my_xabs=""
my_xdir=""
- func_mkdir_p "$my_gentop"
-
for my_xlib in $my_oldlibs; do
# Extract the objects.
case $my_xlib in
$RM "${darwin_base_archive}"
cd "$darwin_curdir"
done # $darwin_arches
- ## Okay now we have a bunch of thin objects, gotta fatten them up :)
+ ## Okay now we've a bunch of thin objects, gotta fatten them up :)
darwin_filelist=`find unfat-$$ -type f | xargs basename | sort -u | $NL2SP`
darwin_file=
darwin_files=
outputname=
if test "$fast_install" = no && test -n "$relink_command"; then
if test "$finalize" = yes && test -z "$run"; then
- tmpdir="/tmp"
- test -n "$TMPDIR" && tmpdir="$TMPDIR"
- tmpdir="$tmpdir/libtool-$$"
- save_umask=`umask`
- umask 0077
- if $MKDIR_P "$tmpdir"; then
- umask $save_umask
- else
- umask $save_umask
- func_error "error: cannot create temporary directory \`$tmpdir'"
- continue
- fi
+ func_mktempdir "${TMPDIR-/tmp}/libtool-XXXXXXXX"
file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
outputname="$tmpdir/$file"
# Replace the output file specification.
file=\"\$\$-\$program\"
if test ! -d \"\$progdir\"; then
- $MKDIR_P \"\$progdir\"
+ $MKDIR \"\$progdir\"
else
$RM \"\$progdir/\$file\"
fi"