Commit aca31e38 authored by Paul Eggert's avatar Paul Eggert

autogen.sh now configures git only on request

* autogen.sh (do_autoconf, do_git): New vars.
Support new arguments --help, all, autoconf, git.
By default, just do autoconf-related configuration, not git.
Prefer 'echo' to 'cat <<EOF ...', as this tends to avoid temp files.
If GNU cp is available, use it to backup .git/config before
changing it.  When configuring git, chatter about what is being
done, and configure git to check hashes.  Avoid some duplicate
file name specification when creating git hooks.

* GNUmakefile (ALL_IF_GIT): New macro.
(configure): Use it.
* INSTALL.REPO: Suggest './autogen.sh all'.
parent b50075dd
...@@ -62,10 +62,13 @@ default $(ORDINARY_GOALS): Makefile ...@@ -62,10 +62,13 @@ default $(ORDINARY_GOALS): Makefile
# Execute in sequence, so that multiple user goals don't conflict. # Execute in sequence, so that multiple user goals don't conflict.
.NOTPARALLEL: .NOTPARALLEL:
# 'all' if a .git subdirectory is present, empty otherwise.
ALL_IF_GIT = $(subst .git,all,$(wildcard .git))
configure: configure:
@echo >&2 'There seems to be no "configure" file in this directory.' @echo >&2 'There seems to be no "configure" file in this directory.'
@echo >&2 'Running ./autogen.sh ...' @echo >&2 Running ./autogen.sh $(ALL_IF_GIT) ...
./autogen.sh ./autogen.sh $(ALL_IF_GIT)
@echo >&2 '"configure" file built.' @echo >&2 '"configure" file built.'
Makefile: configure Makefile: configure
......
...@@ -18,9 +18,10 @@ makeinfo - not strictly necessary, but highly recommended, so that ...@@ -18,9 +18,10 @@ makeinfo - not strictly necessary, but highly recommended, so that
you can build the manuals. you can build the manuals.
To use the autotools, run the following shell command to generate the To use the autotools, run the following shell command to generate the
'configure' script and some related files: 'configure' script and some related files, and to set up your git
configuration:
$ ./autogen.sh $ ./autogen.sh all
You can then configure your build as follows: You can then configure your build as follows:
......
...@@ -103,16 +103,35 @@ check_version () ...@@ -103,16 +103,35 @@ check_version ()
return 2 return 2
} }
do_autoconf=false
do_git=false
for arg in ${*-autoconf}; do
case $arg in
--help)
exec echo "$0: usage: $0 [all|autoconf|git]";;
all)
do_autoconf=true do_git=true;;
autoconf)
do_autoconf=true;;
git)
do_git=true;;
*)
echo >&2 "$0: $arg: unknown argument"; exit 1;;
esac
done
# Generate Autoconf and Automake related files, if requested.
cat <<EOF if $do_autoconf; then
Checking whether you have the necessary tools...
(Read INSTALL.REPO for more details on building Emacs)
EOF echo 'Checking whether you have the necessary tools...
(Read INSTALL.REPO for more details on building Emacs)'
missing= missing=
for prog in $progs; do for prog in $progs; do
sprog=`echo "$prog" | sed 's/-/_/g'` sprog=`echo "$prog" | sed 's/-/_/g'`
...@@ -138,15 +157,13 @@ for prog in $progs; do ...@@ -138,15 +157,13 @@ for prog in $progs; do
eval ${sprog}_why=\""$stat"\" eval ${sprog}_why=\""$stat"\"
fi fi
done done
if [ x"$missing" != x ]; then
cat <<EOF if [ x"$missing" != x ]; then
Building Emacs from the repository requires the following specialized programs: echo '
EOF Building Emacs from the repository requires the following specialized programs:'
for prog in $progs; do for prog in $progs; do
sprog=`echo "$prog" | sed 's/-/_/g'` sprog=`echo "$prog" | sed 's/-/_/g'`
...@@ -157,10 +174,8 @@ EOF ...@@ -157,10 +174,8 @@ EOF
done done
cat <<EOF echo '
Your system seems to be missing the following tool(s):'
Your system seems to be missing the following tool(s):
EOF
for prog in $missing; do for prog in $missing; do
sprog=`echo "$prog" | sed 's/-/_/g'` sprog=`echo "$prog" | sed 's/-/_/g'`
...@@ -170,8 +185,7 @@ EOF ...@@ -170,8 +185,7 @@ EOF
echo "$prog ($why)" echo "$prog ($why)"
done done
cat <<EOF echo '
If you think you have the required tools, please add them to your PATH If you think you have the required tools, please add them to your PATH
and re-run this script. and re-run this script.
...@@ -198,65 +212,102 @@ autoreconf -fi -I m4 ...@@ -198,65 +212,102 @@ autoreconf -fi -I m4
instead of this script. instead of this script.
Please report any problems with this script to bug-gnu-emacs@gnu.org . Please report any problems with this script to bug-gnu-emacs@gnu.org .'
EOF
exit 1 exit 1
fi
echo 'Your system has the required tools.'
echo "Running 'autoreconf -fi -I m4' ..."
## Let autoreconf figure out what, if anything, needs doing.
## Use autoreconf's -f option in case autoreconf itself has changed.
autoreconf -fi -I m4 || exit $?
## Create a timestamp, so that './autogen.sh; make' doesn't
## cause 'make' to needlessly run 'autoheader'.
echo timestamp > src/stamp-h.in || exit
fi fi
echo 'Your system has the required tools.'
echo "Running 'autoreconf -fi -I m4' ..."
# True if the Git setup was OK before autogen.sh was run.
## Let autoreconf figure out what, if anything, needs doing. git_was_ok=true
## Use autoreconf's -f option in case autoreconf itself has changed.
autoreconf -fi -I m4 || exit $?
## Create a timestamp, so that './autogen.sh; make' doesn't if $do_git; then
## cause 'make' to needlessly run 'autoheader'. case `cp --help 2>/dev/null` in
echo timestamp > src/stamp-h.in || exit *--backup*--verbose*)
cp_options='--backup=numbered --verbose';;
*)
cp_options='-f';;
esac
fi
## Configure Git, if using Git. # Like 'git config NAME VALUE' but verbose on change and exiting on failure.
if test -d .git && (git status -s) >/dev/null 2>&1; then # Also, do not configure unless requested.
# Configure 'git diff' hunk header format. git_config ()
{
name=$1
value=$2
ovalue=`git config --get "$name"` && test "$ovalue" = "$value" || {
if $do_git; then
if $git_was_ok; then
echo 'Configuring local git repository...'
case $cp_options in
--backup=*)
cp $cp_options --force .git/config .git/config || exit;;
esac
fi
echo "git config $name '$value'"
git config "$name" "$value" || exit
fi
git_was_ok=false
}
}
## Configure Git, if requested.
# Check hashes when transferring objects among repositories.
git_config transfer.fsckObjects true
# Configure 'git diff' hunk header format.
git config 'diff.elisp.xfuncname' \ git_config diff.elisp.xfuncname \
'^\(def[^[:space:]]+[[:space:]]+([^()[:space:]]+)' || exit '^\(def[^[:space:]]+[[:space:]]+([^()[:space:]]+)'
git config 'diff.texinfo.xfuncname' \ git_config diff.texinfo.xfuncname \
'^@node[[:space:]]+([^,[:space:]][^,]+)' || exit '^@node[[:space:]]+([^,[:space:]][^,]+)'
# Install Git hooks. # Install Git hooks.
tailored_hooks= tailored_hooks=
sample_hooks= sample_hooks=
for hook in commit-msg pre-commit; do for hook in commit-msg pre-commit; do
cmp build-aux/git-hooks/$hook .git/hooks/$hook >/dev/null 2>&1 || cmp build-aux/git-hooks/$hook .git/hooks/$hook >/dev/null 2>&1 ||
tailored_hooks="$tailored_hooks $hook" tailored_hooks="$tailored_hooks $hook"
done done
for hook in applypatch-msg pre-applypatch; do for hook in applypatch-msg pre-applypatch; do
test ! -r .git/hooks/$hook.sample || src=.git/hooks/$hook.sample
cmp .git/hooks/$hook.sample .git/hooks/$hook >/dev/null 2>&1 || cmp "$src" .git/hooks/$hook >/dev/null 2>&1 ||
sample_hooks="$sample_hooks $hook" sample_hooks="$sample_hooks $hook"
done done
if test -n "$tailored_hooks$sample_hooks"; then if test -n "$tailored_hooks$sample_hooks"; then
if $do_git; then
echo "Installing git hooks..." echo "Installing git hooks..."
case `cp --help 2>/dev/null` in
*--backup*--verbose*)
cp_options='--backup=numbered --verbose';;
*)
cp_options='-f';;
esac
if test -n "$tailored_hooks"; then if test -n "$tailored_hooks"; then
for hook in $tailored_hooks; do for hook in $tailored_hooks; do
cp $cp_options build-aux/git-hooks/$hook .git/hooks || exit dst=.git/hooks/$hook
chmod a-w .git/hooks/$hook || exit cp $cp_options build-aux/git-hooks/$hook "$dst" || exit
chmod a-w "$dst" || exit
done done
fi fi
...@@ -266,10 +317,19 @@ if test -d .git && (git status -s) >/dev/null 2>&1; then ...@@ -266,10 +317,19 @@ if test -d .git && (git status -s) >/dev/null 2>&1; then
chmod a-w .git/hooks/$hook || exit chmod a-w .git/hooks/$hook || exit
done done
fi fi
else
git_was_ok=false
fi fi
fi fi
echo "You can now run './configure'." if test ! -f configure; then
echo "You can now run '$0 autoconf'."
elif test -d .git && test $git_was_ok = false && test $do_git = false; then
echo "You can now run '$0 git'."
elif test ! -f config.status ||
test -n "`find src/stamp-h.in -newer config.status`"; then
echo "You can now run './configure'."
fi
exit 0 exit 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment