aboutsummaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorMåns Rullgård <mans@mansr.com>2009-03-03 08:53:55 +0000
committerMåns Rullgård <mans@mansr.com>2009-03-03 08:53:55 +0000
commit54460a8347b8ff3bd7a9fbe89ceb8b5d8a087e4e (patch)
treeec6457516865b4f323218d4f1ca0ebbcbf386420 /configure
parent2e78513ceee5c75248f2b765709307e339ede0b6 (diff)
downloadffmpeg-54460a8347b8ff3bd7a9fbe89ceb8b5d8a087e4e.tar.gz
configure: improve temp file creation and cleanup
Originally committed as revision 17752 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure37
1 files changed, 27 insertions, 10 deletions
diff --git a/configure b/configure
index 281ce24a17..c8c0e5a691 100755
--- a/configure
+++ b/configure
@@ -257,7 +257,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
}
@@ -1342,12 +1341,33 @@ 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"
-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 TMPSH .sh
+
+unset -f mktemp
# make sure we can execute files in $TMPDIR
cat > $TMPSH 2>> $logfile <<EOF
@@ -1361,7 +1381,6 @@ variable to another directory and make sure that it is not mounted noexec.
EOF
die "Sanity test failed."
fi
-rm $TMPSH
if $cc --version 2>/dev/null | grep -qi gcc; then
cc_type=gcc
@@ -2484,8 +2503,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="\