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
This commit is contained in:
parent
021054a196
commit
fc038df32e
41
configure
vendored
41
configure
vendored
@ -261,7 +261,6 @@ Include the log file "$logfile" produced by configure as this will help
|
|||||||
solving the problem.
|
solving the problem.
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1358,13 +1357,36 @@ esac
|
|||||||
: ${TMPDIR:=$TMP}
|
: ${TMPDIR:=$TMP}
|
||||||
: ${TMPDIR:=/tmp}
|
: ${TMPDIR:=/tmp}
|
||||||
|
|
||||||
TMPC="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
|
|
||||||
TMPE="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}${EXESUF}"
|
if ! check_cmd type mktemp; then
|
||||||
TMPH="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
|
# simple replacement for missing mktemp
|
||||||
TMPO="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
|
# NOT SAFE FOR GENERAL USE
|
||||||
TMPS="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
|
mktemp(){
|
||||||
TMPV="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.ver"
|
echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
|
||||||
TMPSH="${TMPDIR}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.sh"
|
}
|
||||||
|
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
|
# make sure we can execute files in $TMPDIR
|
||||||
cat > $TMPSH 2>> $logfile <<EOF
|
cat > $TMPSH 2>> $logfile <<EOF
|
||||||
@ -1378,7 +1400,6 @@ variable to another directory and make sure that it is not mounted noexec.
|
|||||||
EOF
|
EOF
|
||||||
die "Sanity test failed."
|
die "Sanity test failed."
|
||||||
fi
|
fi
|
||||||
rm $TMPSH
|
|
||||||
|
|
||||||
if $cc --version 2>/dev/null | grep -qi gcc; then
|
if $cc --version 2>/dev/null | grep -qi gcc; then
|
||||||
cc_type=gcc
|
cc_type=gcc
|
||||||
@ -2522,8 +2543,6 @@ cmp -s $TMPH config.h &&
|
|||||||
echo "config.h is unchanged" ||
|
echo "config.h is unchanged" ||
|
||||||
mv -f $TMPH config.h
|
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
|
# build tree in object directory if source path is different from current one
|
||||||
if enabled source_path_used; then
|
if enabled source_path_used; then
|
||||||
DIRS="\
|
DIRS="\
|
||||||
|
Loading…
x
Reference in New Issue
Block a user