# Script to create "Makefile.in".
# Requires `gcc' and `scheme'.
-# generate "config.h".
-[ -f Makefile.in ] || touch Makefile.in
+# We make an empty Makefile.in for the sake of spoofing the configure
+# script, but we don't want to leave it around in case anything fails.
+
+clean_makefile=yes
+
+clean ()
+{
+ if [ "${clean_makefile}" = yes ]; then
+ rm -f Makefile.in
+ fi
+}
+
+trap clean EXIT SIGINT SIGQUIT SIGTERM
+
+# Generate "config.h".
+
+touch Makefile.in
./configure --disable-native-code "$@"
-# Generate "Makefile.in" from "Makefile.in.in". Requires "config.h",
-# because dependencies are generated by running GCC -M on the source
-# files, which refer to "config.h".
+# Generate the real "Makefile.in" from "Makefile.in.in". Requires
+# "config.h", because dependencies are generated by running GCC -M on
+# the source files, which refer to "config.h".
${MIT_SCHEME_EXE:=mit-scheme} <<EOF
(begin
(generate-makefile))
EOF
+# If we succeeded in creating the real Makefile.in, don't delete it on
+# exit.
+
+if [ $? -eq 0 ]; then
+ clean_makefile=no
+fi
+
# Clean up.
# We need to generate "Makefile" to run the clean,
# but "make distclean" will delete it.