diff options
| author | Paul Eggert | 2016-02-02 23:11:36 -0800 |
|---|---|---|
| committer | Paul Eggert | 2016-02-02 23:14:30 -0800 |
| commit | aca31e3815b9bd9c696cf0c74cc4a80ad7e35ec9 (patch) | |
| tree | 5c32bcba93ddbbc019705fa22e900237d848644a | |
| parent | b50075dd056b1c18afe96f29142981fe5774ceb1 (diff) | |
| download | emacs-aca31e3815b9bd9c696cf0c74cc4a80ad7e35ec9.tar.gz emacs-aca31e3815b9bd9c696cf0c74cc4a80ad7e35ec9.zip | |
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'.
| -rw-r--r-- | GNUmakefile | 7 | ||||
| -rw-r--r-- | INSTALL.REPO | 5 | ||||
| -rwxr-xr-x | autogen.sh | 172 |
3 files changed, 124 insertions, 60 deletions
diff --git a/GNUmakefile b/GNUmakefile index 83bb718a960..e6941b03b30 100644 --- a/GNUmakefile +++ b/GNUmakefile | |||
| @@ -62,10 +62,13 @@ default $(ORDINARY_GOALS): Makefile | |||
| 62 | # Execute in sequence, so that multiple user goals don't conflict. | 62 | # Execute in sequence, so that multiple user goals don't conflict. |
| 63 | .NOTPARALLEL: | 63 | .NOTPARALLEL: |
| 64 | 64 | ||
| 65 | # 'all' if a .git subdirectory is present, empty otherwise. | ||
| 66 | ALL_IF_GIT = $(subst .git,all,$(wildcard .git)) | ||
| 67 | |||
| 65 | configure: | 68 | configure: |
| 66 | @echo >&2 'There seems to be no "configure" file in this directory.' | 69 | @echo >&2 'There seems to be no "configure" file in this directory.' |
| 67 | @echo >&2 'Running ./autogen.sh ...' | 70 | @echo >&2 Running ./autogen.sh $(ALL_IF_GIT) ... |
| 68 | ./autogen.sh | 71 | ./autogen.sh $(ALL_IF_GIT) |
| 69 | @echo >&2 '"configure" file built.' | 72 | @echo >&2 '"configure" file built.' |
| 70 | 73 | ||
| 71 | Makefile: configure | 74 | 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 | |||
| 18 | you can build the manuals. | 18 | you can build the manuals. |
| 19 | 19 | ||
| 20 | To use the autotools, run the following shell command to generate the | 20 | To use the autotools, run the following shell command to generate the |
| 21 | 'configure' script and some related files: | 21 | 'configure' script and some related files, and to set up your git |
| 22 | configuration: | ||
| 22 | 23 | ||
| 23 | $ ./autogen.sh | 24 | $ ./autogen.sh all |
| 24 | 25 | ||
| 25 | You can then configure your build as follows: | 26 | You can then configure your build as follows: |
| 26 | 27 | ||
diff --git a/autogen.sh b/autogen.sh index a63c53c903c..2ed58e15aea 100755 --- a/autogen.sh +++ b/autogen.sh | |||
| @@ -103,16 +103,35 @@ check_version () | |||
| 103 | return 2 | 103 | return 2 |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | do_autoconf=false | ||
| 107 | do_git=false | ||
| 108 | |||
| 109 | for arg in ${*-autoconf}; do | ||
| 110 | case $arg in | ||
| 111 | --help) | ||
| 112 | exec echo "$0: usage: $0 [all|autoconf|git]";; | ||
| 113 | all) | ||
| 114 | do_autoconf=true do_git=true;; | ||
| 115 | autoconf) | ||
| 116 | do_autoconf=true;; | ||
| 117 | git) | ||
| 118 | do_git=true;; | ||
| 119 | *) | ||
| 120 | echo >&2 "$0: $arg: unknown argument"; exit 1;; | ||
| 121 | esac | ||
| 122 | done | ||
| 123 | |||
| 124 | |||
| 125 | # Generate Autoconf and Automake related files, if requested. | ||
| 106 | 126 | ||
| 107 | cat <<EOF | 127 | if $do_autoconf; then |
| 108 | Checking whether you have the necessary tools... | ||
| 109 | (Read INSTALL.REPO for more details on building Emacs) | ||
| 110 | 128 | ||
| 111 | EOF | 129 | echo 'Checking whether you have the necessary tools... |
| 130 | (Read INSTALL.REPO for more details on building Emacs)' | ||
| 112 | 131 | ||
| 113 | missing= | 132 | missing= |
| 114 | 133 | ||
| 115 | for prog in $progs; do | 134 | for prog in $progs; do |
| 116 | 135 | ||
| 117 | sprog=`echo "$prog" | sed 's/-/_/g'` | 136 | sprog=`echo "$prog" | sed 's/-/_/g'` |
| 118 | 137 | ||
| @@ -138,15 +157,13 @@ for prog in $progs; do | |||
| 138 | eval ${sprog}_why=\""$stat"\" | 157 | eval ${sprog}_why=\""$stat"\" |
| 139 | fi | 158 | fi |
| 140 | 159 | ||
| 141 | done | 160 | done |
| 142 | |||
| 143 | 161 | ||
| 144 | if [ x"$missing" != x ]; then | ||
| 145 | 162 | ||
| 146 | cat <<EOF | 163 | if [ x"$missing" != x ]; then |
| 147 | 164 | ||
| 148 | Building Emacs from the repository requires the following specialized programs: | 165 | echo ' |
| 149 | EOF | 166 | Building Emacs from the repository requires the following specialized programs:' |
| 150 | 167 | ||
| 151 | for prog in $progs; do | 168 | for prog in $progs; do |
| 152 | sprog=`echo "$prog" | sed 's/-/_/g'` | 169 | sprog=`echo "$prog" | sed 's/-/_/g'` |
| @@ -157,10 +174,8 @@ EOF | |||
| 157 | done | 174 | done |
| 158 | 175 | ||
| 159 | 176 | ||
| 160 | cat <<EOF | 177 | echo ' |
| 161 | 178 | Your system seems to be missing the following tool(s):' | |
| 162 | Your system seems to be missing the following tool(s): | ||
| 163 | EOF | ||
| 164 | 179 | ||
| 165 | for prog in $missing; do | 180 | for prog in $missing; do |
| 166 | sprog=`echo "$prog" | sed 's/-/_/g'` | 181 | sprog=`echo "$prog" | sed 's/-/_/g'` |
| @@ -170,8 +185,7 @@ EOF | |||
| 170 | echo "$prog ($why)" | 185 | echo "$prog ($why)" |
| 171 | done | 186 | done |
| 172 | 187 | ||
| 173 | cat <<EOF | 188 | echo ' |
| 174 | |||
| 175 | If you think you have the required tools, please add them to your PATH | 189 | If you think you have the required tools, please add them to your PATH |
| 176 | and re-run this script. | 190 | and re-run this script. |
| 177 | 191 | ||
| @@ -198,65 +212,102 @@ autoreconf -fi -I m4 | |||
| 198 | 212 | ||
| 199 | instead of this script. | 213 | instead of this script. |
| 200 | 214 | ||
| 201 | Please report any problems with this script to bug-gnu-emacs@gnu.org . | 215 | Please report any problems with this script to bug-gnu-emacs@gnu.org .' |
| 202 | EOF | ||
| 203 | 216 | ||
| 204 | exit 1 | 217 | exit 1 |
| 218 | fi | ||
| 219 | |||
| 220 | echo 'Your system has the required tools.' | ||
| 221 | echo "Running 'autoreconf -fi -I m4' ..." | ||
| 222 | |||
| 223 | |||
| 224 | ## Let autoreconf figure out what, if anything, needs doing. | ||
| 225 | ## Use autoreconf's -f option in case autoreconf itself has changed. | ||
| 226 | autoreconf -fi -I m4 || exit $? | ||
| 227 | |||
| 228 | ## Create a timestamp, so that './autogen.sh; make' doesn't | ||
| 229 | ## cause 'make' to needlessly run 'autoheader'. | ||
| 230 | echo timestamp > src/stamp-h.in || exit | ||
| 205 | fi | 231 | fi |
| 206 | 232 | ||
| 207 | echo 'Your system has the required tools.' | ||
| 208 | echo "Running 'autoreconf -fi -I m4' ..." | ||
| 209 | 233 | ||
| 234 | # True if the Git setup was OK before autogen.sh was run. | ||
| 210 | 235 | ||
| 211 | ## Let autoreconf figure out what, if anything, needs doing. | 236 | git_was_ok=true |
| 212 | ## Use autoreconf's -f option in case autoreconf itself has changed. | ||
| 213 | autoreconf -fi -I m4 || exit $? | ||
| 214 | 237 | ||
| 215 | ## Create a timestamp, so that './autogen.sh; make' doesn't | 238 | if $do_git; then |
| 216 | ## cause 'make' to needlessly run 'autoheader'. | 239 | case `cp --help 2>/dev/null` in |
| 217 | echo timestamp > src/stamp-h.in || exit | 240 | *--backup*--verbose*) |
| 241 | cp_options='--backup=numbered --verbose';; | ||
| 242 | *) | ||
| 243 | cp_options='-f';; | ||
| 244 | esac | ||
| 245 | fi | ||
| 218 | 246 | ||
| 219 | 247 | ||
| 220 | ## Configure Git, if using Git. | 248 | # Like 'git config NAME VALUE' but verbose on change and exiting on failure. |
| 221 | if test -d .git && (git status -s) >/dev/null 2>&1; then | 249 | # Also, do not configure unless requested. |
| 222 | 250 | ||
| 223 | # Configure 'git diff' hunk header format. | 251 | git_config () |
| 252 | { | ||
| 253 | name=$1 | ||
| 254 | value=$2 | ||
| 255 | |||
| 256 | ovalue=`git config --get "$name"` && test "$ovalue" = "$value" || { | ||
| 257 | if $do_git; then | ||
| 258 | if $git_was_ok; then | ||
| 259 | echo 'Configuring local git repository...' | ||
| 260 | case $cp_options in | ||
| 261 | --backup=*) | ||
| 262 | cp $cp_options --force .git/config .git/config || exit;; | ||
| 263 | esac | ||
| 264 | fi | ||
| 265 | echo "git config $name '$value'" | ||
| 266 | git config "$name" "$value" || exit | ||
| 267 | fi | ||
| 268 | git_was_ok=false | ||
| 269 | } | ||
| 270 | } | ||
| 271 | |||
| 272 | ## Configure Git, if requested. | ||
| 273 | |||
| 274 | # Check hashes when transferring objects among repositories. | ||
| 275 | |||
| 276 | git_config transfer.fsckObjects true | ||
| 277 | |||
| 278 | |||
| 279 | # Configure 'git diff' hunk header format. | ||
| 224 | 280 | ||
| 225 | git config 'diff.elisp.xfuncname' \ | 281 | git_config diff.elisp.xfuncname \ |
| 226 | '^\(def[^[:space:]]+[[:space:]]+([^()[:space:]]+)' || exit | 282 | '^\(def[^[:space:]]+[[:space:]]+([^()[:space:]]+)' |
| 227 | git config 'diff.texinfo.xfuncname' \ | 283 | git_config diff.texinfo.xfuncname \ |
| 228 | '^@node[[:space:]]+([^,[:space:]][^,]+)' || exit | 284 | '^@node[[:space:]]+([^,[:space:]][^,]+)' |
| 229 | 285 | ||
| 230 | 286 | ||
| 231 | # Install Git hooks. | 287 | # Install Git hooks. |
| 232 | 288 | ||
| 233 | tailored_hooks= | 289 | tailored_hooks= |
| 234 | sample_hooks= | 290 | sample_hooks= |
| 235 | 291 | ||
| 236 | for hook in commit-msg pre-commit; do | 292 | for hook in commit-msg pre-commit; do |
| 237 | cmp build-aux/git-hooks/$hook .git/hooks/$hook >/dev/null 2>&1 || | 293 | cmp build-aux/git-hooks/$hook .git/hooks/$hook >/dev/null 2>&1 || |
| 238 | tailored_hooks="$tailored_hooks $hook" | 294 | tailored_hooks="$tailored_hooks $hook" |
| 239 | done | 295 | done |
| 240 | for hook in applypatch-msg pre-applypatch; do | 296 | for hook in applypatch-msg pre-applypatch; do |
| 241 | test ! -r .git/hooks/$hook.sample || | 297 | src=.git/hooks/$hook.sample |
| 242 | cmp .git/hooks/$hook.sample .git/hooks/$hook >/dev/null 2>&1 || | 298 | cmp "$src" .git/hooks/$hook >/dev/null 2>&1 || |
| 243 | sample_hooks="$sample_hooks $hook" | 299 | sample_hooks="$sample_hooks $hook" |
| 244 | done | 300 | done |
| 245 | 301 | ||
| 246 | if test -n "$tailored_hooks$sample_hooks"; then | 302 | if test -n "$tailored_hooks$sample_hooks"; then |
| 303 | if $do_git; then | ||
| 247 | echo "Installing git hooks..." | 304 | echo "Installing git hooks..." |
| 248 | 305 | ||
| 249 | case `cp --help 2>/dev/null` in | ||
| 250 | *--backup*--verbose*) | ||
| 251 | cp_options='--backup=numbered --verbose';; | ||
| 252 | *) | ||
| 253 | cp_options='-f';; | ||
| 254 | esac | ||
| 255 | |||
| 256 | if test -n "$tailored_hooks"; then | 306 | if test -n "$tailored_hooks"; then |
| 257 | for hook in $tailored_hooks; do | 307 | for hook in $tailored_hooks; do |
| 258 | cp $cp_options build-aux/git-hooks/$hook .git/hooks || exit | 308 | dst=.git/hooks/$hook |
| 259 | chmod a-w .git/hooks/$hook || exit | 309 | cp $cp_options build-aux/git-hooks/$hook "$dst" || exit |
| 310 | chmod a-w "$dst" || exit | ||
| 260 | done | 311 | done |
| 261 | fi | 312 | fi |
| 262 | 313 | ||
| @@ -266,10 +317,19 @@ if test -d .git && (git status -s) >/dev/null 2>&1; then | |||
| 266 | chmod a-w .git/hooks/$hook || exit | 317 | chmod a-w .git/hooks/$hook || exit |
| 267 | done | 318 | done |
| 268 | fi | 319 | fi |
| 320 | else | ||
| 321 | git_was_ok=false | ||
| 269 | fi | 322 | fi |
| 270 | fi | 323 | fi |
| 271 | 324 | ||
| 272 | echo "You can now run './configure'." | 325 | if test ! -f configure; then |
| 326 | echo "You can now run '$0 autoconf'." | ||
| 327 | elif test -d .git && test $git_was_ok = false && test $do_git = false; then | ||
| 328 | echo "You can now run '$0 git'." | ||
| 329 | elif test ! -f config.status || | ||
| 330 | test -n "`find src/stamp-h.in -newer config.status`"; then | ||
| 331 | echo "You can now run './configure'." | ||
| 332 | fi | ||
| 273 | 333 | ||
| 274 | exit 0 | 334 | exit 0 |
| 275 | 335 | ||