Improve responsiveness while in 'replace-buffer-contents'
[emacs.git] / admin / merge-gnulib
blob42edfbbd3673c09f6fde96046f8cb331e2f6a2b2
1 #! /bin/sh
2 # Merge gnulib sources into Emacs sources.
3 # Typical usage:
5 # admin/merge-gnulib
7 # Copyright 2012-2018 Free Software Foundation, Inc.
9 # This file is part of GNU Emacs.
11 # GNU Emacs is free software: you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation, either version 3 of the License, or
14 # (at your option) any later version.
16 # GNU Emacs is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
24 # written by Paul Eggert
26 GNULIB_URL=git://git.savannah.gnu.org/gnulib.git
28 GNULIB_MODULES='
29 alloca-opt binary-io byteswap c-ctype c-strcase
30 careadlinkat close-stream
31 count-leading-zeros count-one-bits count-trailing-zeros
32 crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512
33 d-type diffseq dtoastr dtotimespec dup2
34 environ execinfo explicit_bzero faccessat
35 fcntl fcntl-h fdatasync fdopendir
36 filemode filevercmp flexmember fstatat fsync
37 getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog
38 ignore-value intprops largefile lstat
39 manywarnings memrchr minmax mkostemp mktime nstrftime
40 pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat
41 sig2str socklen stat-time std-gnu11 stdalign stddef stdio
42 stpcpy strtoimax symlink sys_stat sys_time
43 tempname time time_r time_rz timegm timer-time timespec-add timespec-sub
44 update-copyright unlocked-io utimens
45 vla warnings
48 AVOIDED_MODULES='
49 close dup fchdir fstat
50 malloc-posix msvc-inval msvc-nothrow
51 openat-die opendir raise
52 save-cwd select setenv sigprocmask stat stdarg stdbool
53 threadlib tzset unsetenv utime utime-h
56 GNULIB_TOOL_FLAGS='
57 --conditional-dependencies --import --no-changelog --no-vc-files
58 --gnu-make
59 --makefile-name=gnulib.mk.in
62 # The source directory, with a trailing '/'.
63 # If empty, the source directory is the working directory.
64 src=$2
65 case $src in
66 */ | '') ;;
67 *) src=$src/ ;;
68 esac
70 # Gnulib's source directory.
71 gnulib_srcdir=${1-$src../gnulib}
73 case $gnulib_srcdir in
74 -*) src=- ;;
75 esac
76 case $src in
77 -*)
78 printf '%s\n' >&2 "$0: usage: $0 [GNULIB_SRCDIR [SRCDIR]]
80 SRCDIR is the Emacs source directory (default: working directory).
81 GNULIB_SRCDIR is the Gnulib source directory (default: SRCDIR/../gnulib)."
82 exit 1 ;;
83 esac
85 test -x "$src"autogen.sh || {
86 printf '%s\n' >&2 "$0: '${src:-.}' is not an Emacs source directory."
87 exit 1
90 test -d "$gnulib_srcdir" ||
91 git clone -- "$GNULIB_URL" "$gnulib_srcdir" ||
92 exit
94 test -x "$gnulib_srcdir"/gnulib-tool || {
95 printf '%s\n' >&2 "$0: '$gnulib_srcdir' is not a Gnulib source directory."
96 exit 1
99 avoided_flags=
100 for module in $AVOIDED_MODULES; do
101 avoided_flags="$avoided_flags --avoid=$module"
102 done
104 "$gnulib_srcdir"/gnulib-tool --dir="$src" $GNULIB_TOOL_FLAGS \
105 $avoided_flags $GNULIB_MODULES &&
106 rm -- "$src"lib/gl_openssl.h "$src"m4/fcntl-o.m4 \
107 "$src"m4/gl-openssl.m4 \
108 "$src"m4/gnulib-cache.m4 "$src"m4/gnulib-tool.m4 \
109 "$src"m4/manywarnings-c++.m4 \
110 "$src"m4/warn-on-use.m4 "$src"m4/wint_t.m4 &&
111 cp -- "$gnulib_srcdir"/build-aux/texinfo.tex "$src"doc/misc &&
112 cp -- "$gnulib_srcdir"/build-aux/config.guess \
113 "$gnulib_srcdir"/build-aux/config.sub \
114 "$gnulib_srcdir"/build-aux/install-sh \
115 "$gnulib_srcdir"/build-aux/move-if-change \
116 "$src"build-aux &&
117 { test -z "$src" || cd "$src"; } &&
118 ./autogen.sh