Allow Git config options to be passed to configure

The Git configuration value ocaml.configure is now passed to the
configure script's arguments before $@ if (and only if) OCaml is being
configured from a Git clone.

This allows, for example:

- Developer-specific preferences (e.g. `--disable-ocamldoc` or
  `--disable-debug-runtime`)
- Automatic use of autoconf cach files (-C option)

It is implemented by inserting a test at the top of `configure`, which
is bypassed if `.git` doesn't exist.
This commit is contained in:
David Allsopp 2019-09-29 12:11:57 +01:00
parent 16a13e668b
commit 345fd4c3f9
6 changed files with 60 additions and 2 deletions

View File

@ -265,6 +265,10 @@ Working version
incompatible with C.
(David Allsopp, review by Nicolás Ojeda Bär, report by Sebastian Rasmussen)
- #8995: allow developers to specify frequently-used configure options in
Git (ocaml.configure option) See HACKING.adoc for further details.
(David Allsopp, review by Gabriel Scherer)
### Compiler user-interface and warnings:
- #8702, #8777: improved error messages for fixed row polymorphic variants

View File

@ -233,6 +233,22 @@ Additionally, there are some developer specific targets in link:Makefile.dev[].
These targets are automatically available when working in a Git clone of the
repository, but are not available from a tarball.
=== Automatic configure options
If you have options to `configure` which you always (or at least frequently)
use, it's possible to store them in Git, and `configure` will automatically add
them. For example, you may wish to avoid building the debug runtime by default
while developing, in which case you can issue
`git config --global ocaml.configure '--disable-debug-runtime'`. The `configure`
script will alert you that it has picked up this option and added it _before_
any options you specified for `configure`.
Options are added before those passed on the command line, so it's possible to
override them, for example `./configure --enable-debug-runtime` will build the
debug runtime, since the enable flag appears after the disable flag. You can
also use the full power of Git's `config` command and have options specific to
particular clone or worktree.
=== Bootstrapping
The OCaml compiler is bootstrapped. This means that

View File

@ -326,7 +326,7 @@ utils/config.ml: utils/config.mlp Makefile.config utils/Makefile
.PHONY: reconfigure
reconfigure:
./configure $(CONFIGURE_ARGS)
ac_read_git_config=true ./configure $(CONFIGURE_ARGS)
utils/domainstate.ml: utils/domainstate.ml.c runtime/caml/domain_state.tbl
$(CPP) -I runtime/caml $< > $@

10
autogen
View File

@ -17,6 +17,11 @@
rm -rf autom4te.cache
autoconf --force --warnings=all,error
# Allow pre-processing of configure arguments for Git check-outs
# The sed call removes dra27's copyright on the whole configure script...
sed -e '/^#[^!]/d' tools/git-dev-options.sh > configure.tmp
# Some distros have the 2013 --runstatedir patch to autoconf (see
# http://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=a197431414088a417b407b9b20583b2e8f7363bd
# in the GNU autoconf repo), and some don't, so ensure its effects are
@ -27,6 +32,9 @@ autoconf --force --warnings=all,error
sed -e '/^runstatedir/d' \
-e '/-runstatedir /{N;N;N;N;N;N;N;N;d;}' \
-e '/--runstatedir=DIR/d' \
-e 's/ runstatedir//' configure > configure.tmp
-e 's/ runstatedir//' \
-e '1d' \
configure >> configure.tmp
mv -f configure.tmp configure
chmod +x configure

BIN
configure vendored

Binary file not shown.

30
tools/git-dev-options.sh Executable file
View File

@ -0,0 +1,30 @@
#! /bin/sh
#**************************************************************************
#* *
#* OCaml *
#* *
#* David Allsopp, OCaml Labs, Cambridge. *
#* *
#* Copyright 2019 MetaStack Solutions Ltd. *
#* *
#* All rights reserved. This file is distributed under the terms of *
#* the GNU Lesser General Public License version 2.1, with the *
#* special exception on linking described in the file LICENSE. *
#* *
#**************************************************************************
# This script should have the same shebang as configure
if test -e '.git' ; then :
extra_args=$(git config ocaml.configure 2>/dev/null)
if test -n "$extra_args" ; then :
if test -z "$ac_read_git_config" ; then :
echo "Detected Git configuration option ocaml.configure set to \
\"$extra_args\""
# Too much effort to get the echo to show appropriate quoting - the
# invocation itself intentionally quotes $0 and passes $@ exactly as given
# but allows a single expansion of ocaml.configure
echo "Re-running $0 $extra_args $@"
ac_read_git_config=true exec "$0" $extra_args "$@"
fi
fi
fi