build: make configure relocatable (out-of-tree)
Enable `mkdir build; cd build; ../configure` to run entirely in the build
directory, with generated config landing there instead of in the source
tree. This is the autoconf-layer groundwork for a full VPATH build; the
make layer (defs.mak/rules.mak VPATH support, per-dir orchestration) is
still to come, so an out-of-tree `make` is not yet expected to work.
Changes:
* configure (wrapper): run the generated config.status in the *current*
directory with --srcdir pointing back at the source tree (instead of
`cd scripts`), so outputs land in the build dir. Uses an absolute
basedir so any build-dir location works, not just a subdir of srcdir.
* scripts/configure.in:
- AC_CONFIG_AUX_DIR(.) -> AC_CONFIG_AUX_DIR(scripts). Once srcdir
resolves to the true top (scripts' parent, where rules.mak lives),
autoconf searches for install-sh/config.sub/... relative to srcdir;
"." pointed at the wrong place and out-of-tree configure died with
"cannot find install-sh".
- Name the .in templates explicitly
(defs.mak:scripts/defs.mak.in, scripts/makedbh:scripts/makedbh.in)
so config.status finds them from a separate build dir. defs.mak is
written to the build top; makedbh under build/scripts/ to match
${SCRIPTS}/makedbh.
- Drop the trailing `cp defs.mak ..`; defs.mak is now generated in the
build top directly, and from a build dir the copy would clobber the
source tree's defs.mak.
* scripts/configure: regenerated with autoconf 2.69.
Verified: out-of-tree `../configure` completes rc=0, writes defs.mak /
scripts/makedbh / config.status into the build dir, records
srcdir=<source top>, and leaves the source tree's tracked files and
generated defs.mak/makedbh untouched.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0518b6914a
commit
a4e6289035
|
|
@ -9,5 +9,9 @@
|
||||||
# script itself. It also sets up CFLAGS without the default optimizer
|
# script itself. It also sets up CFLAGS without the default optimizer
|
||||||
# flag (-O2).
|
# flag (-O2).
|
||||||
|
|
||||||
basedir=$(dirname "$0")
|
# Run the generated config.status in the *current* directory (which may be a
|
||||||
( CFLAGS=${CFLAGS:-"-g"}; export CFLAGS; cd "${basedir}/scripts" ; ./configure "$@" )
|
# separate build directory), with --srcdir pointing back at the source tree, so
|
||||||
|
# that generated files (defs.mak, makedbh, ...) land in the build directory
|
||||||
|
# rather than in the source tree.
|
||||||
|
basedir=$(cd "$(dirname "$0")" && pwd)
|
||||||
|
( CFLAGS=${CFLAGS:-"-g"}; export CFLAGS; exec "${basedir}/scripts/configure" --srcdir="${basedir}" "$@" )
|
||||||
|
|
|
||||||
|
|
@ -734,7 +734,6 @@ infodir
|
||||||
docdir
|
docdir
|
||||||
oldincludedir
|
oldincludedir
|
||||||
includedir
|
includedir
|
||||||
runstatedir
|
|
||||||
localstatedir
|
localstatedir
|
||||||
sharedstatedir
|
sharedstatedir
|
||||||
sysconfdir
|
sysconfdir
|
||||||
|
|
@ -843,7 +842,6 @@ datadir='${datarootdir}'
|
||||||
sysconfdir='${prefix}/etc'
|
sysconfdir='${prefix}/etc'
|
||||||
sharedstatedir='${prefix}/com'
|
sharedstatedir='${prefix}/com'
|
||||||
localstatedir='${prefix}/var'
|
localstatedir='${prefix}/var'
|
||||||
runstatedir='${localstatedir}/run'
|
|
||||||
includedir='${prefix}/include'
|
includedir='${prefix}/include'
|
||||||
oldincludedir='/usr/include'
|
oldincludedir='/usr/include'
|
||||||
docdir='${datarootdir}/doc/${PACKAGE}'
|
docdir='${datarootdir}/doc/${PACKAGE}'
|
||||||
|
|
@ -1096,15 +1094,6 @@ do
|
||||||
| -silent | --silent | --silen | --sile | --sil)
|
| -silent | --silent | --silen | --sile | --sil)
|
||||||
silent=yes ;;
|
silent=yes ;;
|
||||||
|
|
||||||
-runstatedir | --runstatedir | --runstatedi | --runstated \
|
|
||||||
| --runstate | --runstat | --runsta | --runst | --runs \
|
|
||||||
| --run | --ru | --r)
|
|
||||||
ac_prev=runstatedir ;;
|
|
||||||
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
|
|
||||||
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
|
|
||||||
| --run=* | --ru=* | --r=*)
|
|
||||||
runstatedir=$ac_optarg ;;
|
|
||||||
|
|
||||||
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
|
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
|
||||||
ac_prev=sbindir ;;
|
ac_prev=sbindir ;;
|
||||||
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
|
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
|
||||||
|
|
@ -1242,7 +1231,7 @@ fi
|
||||||
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
|
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
|
||||||
datadir sysconfdir sharedstatedir localstatedir includedir \
|
datadir sysconfdir sharedstatedir localstatedir includedir \
|
||||||
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
|
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
|
||||||
libdir localedir mandir runstatedir
|
libdir localedir mandir
|
||||||
do
|
do
|
||||||
eval ac_val=\$$ac_var
|
eval ac_val=\$$ac_var
|
||||||
# Remove trailing slashes.
|
# Remove trailing slashes.
|
||||||
|
|
@ -1395,7 +1384,6 @@ Fine tuning of the installation directories:
|
||||||
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
|
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
|
||||||
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
|
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
|
||||||
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
|
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
|
||||||
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
|
|
||||||
--libdir=DIR object code libraries [EPREFIX/lib]
|
--libdir=DIR object code libraries [EPREFIX/lib]
|
||||||
--includedir=DIR C header files [PREFIX/include]
|
--includedir=DIR C header files [PREFIX/include]
|
||||||
--oldincludedir=DIR C header files for non-gcc [/usr/include]
|
--oldincludedir=DIR C header files for non-gcc [/usr/include]
|
||||||
|
|
@ -2598,7 +2586,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
||||||
|
|
||||||
|
|
||||||
ac_aux_dir=
|
ac_aux_dir=
|
||||||
for ac_dir in . "$srcdir"/.; do
|
for ac_dir in scripts "$srcdir"/scripts; do
|
||||||
if test -f "$ac_dir/install-sh"; then
|
if test -f "$ac_dir/install-sh"; then
|
||||||
ac_aux_dir=$ac_dir
|
ac_aux_dir=$ac_dir
|
||||||
ac_install_sh="$ac_aux_dir/install-sh -c"
|
ac_install_sh="$ac_aux_dir/install-sh -c"
|
||||||
|
|
@ -2614,7 +2602,7 @@ for ac_dir in . "$srcdir"/.; do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if test -z "$ac_aux_dir"; then
|
if test -z "$ac_aux_dir"; then
|
||||||
as_fn_error $? "cannot find install-sh, install.sh, or shtool in . \"$srcdir\"/." "$LINENO" 5
|
as_fn_error $? "cannot find install-sh, install.sh, or shtool in scripts \"$srcdir\"/scripts" "$LINENO" 5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# These three variables are undocumented and unsupported,
|
# These three variables are undocumented and unsupported,
|
||||||
|
|
@ -9308,9 +9296,9 @@ MAKE_CAIRO=$usingCairo
|
||||||
MAKE_READLINE=$use_bundled_readline
|
MAKE_READLINE=$use_bundled_readline
|
||||||
|
|
||||||
|
|
||||||
ac_config_files="$ac_config_files defs.mak"
|
ac_config_files="$ac_config_files defs.mak:scripts/defs.mak.in"
|
||||||
|
|
||||||
ac_config_files="$ac_config_files makedbh"
|
ac_config_files="$ac_config_files scripts/makedbh:scripts/makedbh.in"
|
||||||
|
|
||||||
cat >confcache <<\_ACEOF
|
cat >confcache <<\_ACEOF
|
||||||
# This file is a shell script that caches the results of configure
|
# This file is a shell script that caches the results of configure
|
||||||
|
|
@ -10019,8 +10007,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||||
for ac_config_target in $ac_config_targets
|
for ac_config_target in $ac_config_targets
|
||||||
do
|
do
|
||||||
case $ac_config_target in
|
case $ac_config_target in
|
||||||
"defs.mak") CONFIG_FILES="$CONFIG_FILES defs.mak" ;;
|
"defs.mak") CONFIG_FILES="$CONFIG_FILES defs.mak:scripts/defs.mak.in" ;;
|
||||||
"makedbh") CONFIG_FILES="$CONFIG_FILES makedbh" ;;
|
"scripts/makedbh") CONFIG_FILES="$CONFIG_FILES scripts/makedbh:scripts/makedbh.in" ;;
|
||||||
|
|
||||||
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
|
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
|
||||||
esac
|
esac
|
||||||
|
|
@ -10441,7 +10429,7 @@ which seems to be undefined. Please make sure it is defined" >&2;}
|
||||||
|
|
||||||
|
|
||||||
case $ac_file$ac_mode in
|
case $ac_file$ac_mode in
|
||||||
"makedbh":F) chmod +x makedbh ;;
|
"scripts/makedbh":F) chmod +x scripts/makedbh ;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
done # for ac_tag
|
done # for ac_tag
|
||||||
|
|
@ -10591,4 +10579,3 @@ echo
|
||||||
echo "-----------------------------------------------------------"
|
echo "-----------------------------------------------------------"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
cp defs.mak ..
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,12 @@ dnl Use autoconf 2.52 or newer.
|
||||||
AC_INIT(magic,, magic-hackers@csl.cornell.edu)
|
AC_INIT(magic,, magic-hackers@csl.cornell.edu)
|
||||||
AC_PREREQ(2.52)
|
AC_PREREQ(2.52)
|
||||||
AC_CONFIG_SRCDIR(rules.mak)
|
AC_CONFIG_SRCDIR(rules.mak)
|
||||||
AC_CONFIG_AUX_DIR(.)
|
dnl configure.in lives in scripts/, but the source root is its parent (that is
|
||||||
|
dnl where rules.mak is, so srcdir resolves there). The aux scripts (install-sh,
|
||||||
|
dnl config.sub, config.guess, missing, mkinstalldirs) live in scripts/, which is
|
||||||
|
dnl "scripts" relative to that srcdir -- not ".". Using "." breaks out-of-tree
|
||||||
|
dnl configure with "cannot find install-sh".
|
||||||
|
AC_CONFIG_AUX_DIR(scripts)
|
||||||
|
|
||||||
AC_CANONICAL_SYSTEM
|
AC_CANONICAL_SYSTEM
|
||||||
|
|
||||||
|
|
@ -1971,8 +1976,12 @@ AC_SUBST(MAKE_GLU, [$usingGLU])
|
||||||
AC_SUBST(MAKE_CAIRO, [$usingCairo])
|
AC_SUBST(MAKE_CAIRO, [$usingCairo])
|
||||||
AC_SUBST(MAKE_READLINE, [$use_bundled_readline])
|
AC_SUBST(MAKE_READLINE, [$use_bundled_readline])
|
||||||
|
|
||||||
AC_CONFIG_FILES([defs.mak])
|
dnl Name the .in templates explicitly (relative to srcdir) so config.status can
|
||||||
AC_CONFIG_FILES([makedbh], [chmod +x makedbh])
|
dnl find them when run from a separate build directory. Outputs land in the
|
||||||
|
dnl build directory (config.status' CWD): defs.mak at the build top, makedbh
|
||||||
|
dnl under build/scripts/ (matching ${SCRIPTS}/makedbh = ${MAGICDIR}/scripts).
|
||||||
|
AC_CONFIG_FILES([defs.mak:scripts/defs.mak.in])
|
||||||
|
AC_CONFIG_FILES([scripts/makedbh:scripts/makedbh.in], [chmod +x scripts/makedbh])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
|
|
@ -2087,5 +2096,6 @@ echo
|
||||||
echo "-----------------------------------------------------------"
|
echo "-----------------------------------------------------------"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
dnl Put "defs.mak" in the top-level directory
|
dnl "defs.mak" is now generated directly into the build top (config.status'
|
||||||
cp defs.mak ..
|
dnl CWD), so the old `cp defs.mak ..` is gone -- from a separate build directory
|
||||||
|
dnl it would clobber the source tree's copy.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue