Merge from gnulib
[emacs.git] / admin / merge-gnulib
blob18c9ee8def726fc3cff6254ad3c545afc12c62cc
1 #! /bin/sh
2 # Merge gnulib sources into Emacs sources.
3 # Typical usage:
5 # admin/merge-gnulib
7 # Copyright 2012-2017 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 <http://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 diffseq dtoastr dtotimespec dup2 environ execinfo explicit_bzero faccessat
34 fcntl fcntl-h fdatasync fdopendir
35 filemode filevercmp flexmember fstatat fsync
36 getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog
37 ignore-value intprops largefile lstat
38 manywarnings memrchr minmax mkostemp mktime nstrftime
39 pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat
40 sig2str socklen stat-time std-gnu11 stdalign stddef stdio
41 stpcpy strtoimax symlink sys_stat
42 sys_time time time_r time_rz timegm timer-time timespec-add timespec-sub
43 update-copyright unlocked-io utimens
44 vla warnings
47 AVOIDED_MODULES='
48 close dup fchdir fstat
49 malloc-posix msvc-inval msvc-nothrow
50 open openat-die opendir raise
51 save-cwd select setenv sigprocmask stat stdarg stdbool
52 threadlib tzset unsetenv utime utime-h
55 GNULIB_TOOL_FLAGS='
56 --conditional-dependencies --import --no-changelog --no-vc-files
57 --gnu-make
58 --makefile-name=gnulib.mk.in
61 # The source directory, with a trailing '/'.
62 # If empty, the source directory is the working directory.
63 src=$2
64 case $src in
65 */ | '') ;;
66 *) src=$src/ ;;
67 esac
69 # Gnulib's source directory.
70 gnulib_srcdir=${1-$src../gnulib}
72 case $gnulib_srcdir in
73 -*) src=- ;;
74 esac
75 case $src in
76 -*)
77 printf '%s\n' >&2 "$0: usage: $0 [GNULIB_SRCDIR [SRCDIR]]
79 SRCDIR is the Emacs source directory (default: working directory).
80 GNULIB_SRCDIR is the Gnulib source directory (default: SRCDIR/../gnulib)."
81 exit 1 ;;
82 esac
84 test -x "$src"autogen.sh || {
85 printf '%s\n' >&2 "$0: '${src:-.}' is not an Emacs source directory."
86 exit 1
89 test -d "$gnulib_srcdir" ||
90 git clone -- "$GNULIB_URL" "$gnulib_srcdir" ||
91 exit
93 test -x "$gnulib_srcdir"/gnulib-tool || {
94 printf '%s\n' >&2 "$0: '$gnulib_srcdir' is not a Gnulib source directory."
95 exit 1
98 avoided_flags=
99 for module in $AVOIDED_MODULES; do
100 avoided_flags="$avoided_flags --avoid=$module"
101 done
103 "$gnulib_srcdir"/gnulib-tool --dir="$src" $GNULIB_TOOL_FLAGS \
104 $avoided_flags $GNULIB_MODULES &&
105 rm -- "$src"lib/gl_openssl.h "$src"m4/fcntl-o.m4 \
106 "$src"m4/gl-openssl.m4 \
107 "$src"m4/gnulib-cache.m4 "$src"m4/gnulib-tool.m4 \
108 "$src"m4/warn-on-use.m4 "$src"m4/wint_t.m4 &&
109 cp -- "$gnulib_srcdir"/build-aux/texinfo.tex "$src"doc/misc &&
110 cp -- "$gnulib_srcdir"/build-aux/config.guess \
111 "$gnulib_srcdir"/build-aux/config.sub \
112 "$gnulib_srcdir"/build-aux/install-sh \
113 "$gnulib_srcdir"/build-aux/move-if-change \
114 "$src"build-aux &&
115 { test -z "$src" || cd "$src"; } &&
116 ./autogen.sh