diff --git a/GNUmakefile b/GNUmakefile index 83bb718a960..e6941b03b30 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -62,10 +62,13 @@ default $(ORDINARY_GOALS): Makefile # Execute in sequence, so that multiple user goals don't conflict. .NOTPARALLEL: +# 'all' if a .git subdirectory is present, empty otherwise. +ALL_IF_GIT = $(subst .git,all,$(wildcard .git)) + configure: @echo >&2 'There seems to be no "configure" file in this directory.' - @echo >&2 'Running ./autogen.sh ...' - ./autogen.sh + @echo >&2 Running ./autogen.sh $(ALL_IF_GIT) ... + ./autogen.sh $(ALL_IF_GIT) @echo >&2 '"configure" file built.' Makefile: configure diff --git a/INSTALL.REPO b/INSTALL.REPO index 1720758928c..7497f1f2969 100644 --- a/INSTALL.REPO +++ b/INSTALL.REPO @@ -18,9 +18,10 @@ makeinfo - not strictly necessary, but highly recommended, so that you can build the manuals. 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: diff --git a/autogen.sh b/autogen.sh index a63c53c903c..2ed58e15aea 100755 --- a/autogen.sh +++ b/autogen.sh @@ -103,16 +103,35 @@ check_version () return 2 } +do_autoconf=false +do_git=false -cat <&2 "$0: $arg: unknown argument"; exit 1;; + esac +done -EOF -missing= +# Generate Autoconf and Automake related files, if requested. -for prog in $progs; do +if $do_autoconf; then + + echo 'Checking whether you have the necessary tools... +(Read INSTALL.REPO for more details on building Emacs)' + + missing= + + for prog in $progs; do sprog=`echo "$prog" | sed 's/-/_/g'` @@ -138,15 +157,13 @@ for prog in $progs; do eval ${sprog}_why=\""$stat"\" fi -done + done -if [ x"$missing" != x ]; then + if [ x"$missing" != x ]; then - cat < src/stamp-h.in || exit 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. + +git_was_ok=true + +if $do_git; then + case `cp --help 2>/dev/null` in + *--backup*--verbose*) + cp_options='--backup=numbered --verbose';; + *) + cp_options='-f';; + esac +fi -## 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 $? +# Like 'git config NAME VALUE' but verbose on change and exiting on failure. +# Also, do not configure unless requested. -## Create a timestamp, so that './autogen.sh; make' doesn't -## cause 'make' to needlessly run 'autoheader'. -echo timestamp > src/stamp-h.in || exit +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, if using Git. -if test -d .git && (git status -s) >/dev/null 2>&1; then +# Configure 'git diff' hunk header format. - # Configure 'git diff' hunk header format. - - git config 'diff.elisp.xfuncname' \ - '^\(def[^[:space:]]+[[:space:]]+([^()[:space:]]+)' || exit - git config 'diff.texinfo.xfuncname' \ - '^@node[[:space:]]+([^,[:space:]][^,]+)' || exit +git_config diff.elisp.xfuncname \ + '^\(def[^[:space:]]+[[:space:]]+([^()[:space:]]+)' +git_config diff.texinfo.xfuncname \ + '^@node[[:space:]]+([^,[:space:]][^,]+)' - # Install Git hooks. +# Install Git hooks. - tailored_hooks= - sample_hooks= +tailored_hooks= +sample_hooks= - for hook in commit-msg pre-commit; do - cmp build-aux/git-hooks/$hook .git/hooks/$hook >/dev/null 2>&1 || +for hook in commit-msg pre-commit; do + cmp build-aux/git-hooks/$hook .git/hooks/$hook >/dev/null 2>&1 || tailored_hooks="$tailored_hooks $hook" - done - for hook in applypatch-msg pre-applypatch; do - test ! -r .git/hooks/$hook.sample || - cmp .git/hooks/$hook.sample .git/hooks/$hook >/dev/null 2>&1 || +done +for hook in applypatch-msg pre-applypatch; do + src=.git/hooks/$hook.sample + cmp "$src" .git/hooks/$hook >/dev/null 2>&1 || 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..." - case `cp --help 2>/dev/null` in - *--backup*--verbose*) - cp_options='--backup=numbered --verbose';; - *) - cp_options='-f';; - esac - if test -n "$tailored_hooks"; then for hook in $tailored_hooks; do - cp $cp_options build-aux/git-hooks/$hook .git/hooks || exit - chmod a-w .git/hooks/$hook || exit + dst=.git/hooks/$hook + cp $cp_options build-aux/git-hooks/$hook "$dst" || exit + chmod a-w "$dst" || exit done fi @@ -266,10 +317,19 @@ if test -d .git && (git status -s) >/dev/null 2>&1; then chmod a-w .git/hooks/$hook || exit done fi + else + git_was_ok=false 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