From fc038df32e43c94a23933f8e8ccef09c11c97cd7 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Mon, 31 May 2010 13:06:51 +0000 Subject: configure: improve temp file creation and cleanup backport r17752 by mru Originally committed as revision 23393 to svn://svn.ffmpeg.org/ffmpeg/branches/0.5 --- configure | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/configure b/configure index bf5adc316a..745d8fdd67 100755 --- a/configure +++ b/configure @@ -261,7 +261,6 @@ Include the log file "$logfile" produced by configure as this will help solving the problem. EOF fi - rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH exit 1 } @@ -1358,13 +1357,36 @@ esac : ${TMPDIR:=$TMP} : ${TMPDIR:=/tmp} -TMPC="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c" -TMPE="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}${EXESUF}" -TMPH="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h" -TMPO="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o" -TMPS="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S" -TMPV="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.ver" -TMPSH="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.sh" + +if ! check_cmd type mktemp; then + # simple replacement for missing mktemp + # NOT SAFE FOR GENERAL USE + mktemp(){ + echo "${2%XXX*}.${HOSTNAME}.${UID}.$$" + } +fi + + +tmpfile(){ + tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 && + (set -C; exec > $tmp) 2>/dev/null || + die "Unable to create temoporary file in $TMPDIR." + append TMPFILES $tmp + eval $1=$tmp +} + +trap 'rm -f -- $TMPFILES' EXIT +trap exit HUP INT TERM + +tmpfile TMPC .c +tmpfile TMPE $EXESUF +tmpfile TMPH .h +tmpfile TMPO .o +tmpfile TMPS .S +tmpfile TMPV .ver +tmpfile TMPSH .sh + +unset -f mktemp # make sure we can execute files in $TMPDIR cat > $TMPSH 2>> $logfile </dev/null | grep -qi gcc; then cc_type=gcc @@ -2522,8 +2543,6 @@ cmp -s $TMPH config.h && echo "config.h is unchanged" || mv -f $TMPH config.h -rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH - # build tree in object directory if source path is different from current one if enabled source_path_used; then DIRS="\ -- cgit v1.2.3