From c1b4d59dfb4b751c85cc348c7081c13f572c9958 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Tue, 28 Feb 2017 17:48:47 +0000 Subject: configure: Put temporary directory in build tree, and delete it We were putting the temporary directory we use for configure tests under /tmp/, but never deleting it, so if you ran configure a lot you'd build up a big stock of useless directories. Switch to using a scheme like GNU autotools and QEMU, where we put the configure tempdir in the build tree, and delete it just when configure exits successfully. Signed-off-by: Peter Maydell --- configure | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'configure') diff --git a/configure b/configure index 1fbc27c..055e6d6 100755 --- a/configure +++ b/configure @@ -13,7 +13,20 @@ # Locate the directory where this configure script is SRCDIR="$(cd "$(dirname "$0")"; pwd)" -tmp_dir=`mktemp -d -t risu_configure_check_XXXXXX` +# Temporary directory used for files created by this script. +# Like autoconf (and like QEMU) we put this directory in the +# build directory, which means we can just give it a fixed name and +# blow it away when configure is run, and we don't need to jump +# through complicated hoops to delete it when configure exits +# abnormally (it may be useful for debug purposes on an +# abnormal exit). +tmp_dir="config-temp" +rm -rf "$tmp_dir" +mkdir -p "$tmp_dir" +if [ $? -ne 0 ]; then + echo "ERROR: could not create temporary directory" + exit 1 +fi compile() { $CC $CFLAGS -c -o ${1}.o ${1}.c 2>/dev/null @@ -125,6 +138,8 @@ if test ! -e Makefile; then ln -s "${SRCDIR}/Makefile" . fi +rm -r "$tmp_dir" + echo "type 'make' to start the build" exit 0 -- cgit v1.2.3