Avoid an overflow error in emacs-module.c
[emacs.git] / admin / merge-gnulib
blobabb192911d99d0037788a8a518dbbd9aae6cca4d
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-buffer crypto/sha1-buffer crypto/sha256-buffer crypto/sha512-buffer
33 d-type diffseq dtoastr dtotimespec dup2
34 environ execinfo explicit_bzero faccessat
35 fcntl fcntl-h fdatasync fdopendir
36 filemode filevercmp flexmember fpieee fstatat fsusage fsync
37 getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog
38 ieee754-h ignore-value intprops largefile lstat
39 manywarnings memrchr minmax mkostemp mktime nstrftime
40 pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat regex
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 btowc close dup fchdir fstat langinfo lock
50 malloc-posix mbrtowc mbsinit msvc-inval msvc-nothrow nl_langinfo
51 openat-die opendir raise
52 save-cwd select setenv sigprocmask stat stdarg stdbool
53 threadlib tzset unsetenv utime utime-h
54 wchar wcrtomb wctype-h
57 GNULIB_TOOL_FLAGS='
58 --conditional-dependencies --import --no-changelog --no-vc-files
59 --gnu-make
60 --makefile-name=gnulib.mk.in
63 # The source directory, with a trailing '/'.
64 # If empty, the source directory is the working directory.
65 src=$2
66 case $src in
67 */ | '') ;;
68 *) src=$src/ ;;
69 esac
71 # Gnulib's source directory.
72 gnulib_srcdir=${1-$src../gnulib}
74 case $gnulib_srcdir in
75 -*) src=- ;;
76 esac
77 case $src in
78 -*)
79 printf '%s\n' >&2 "$0: usage: $0 [GNULIB_SRCDIR [SRCDIR]]
81 SRCDIR is the Emacs source directory (default: working directory).
82 GNULIB_SRCDIR is the Gnulib source directory (default: SRCDIR/../gnulib)."
83 exit 1 ;;
84 esac
86 test -x "$src"autogen.sh || {
87 printf '%s\n' >&2 "$0: '${src:-.}' is not an Emacs source directory."
88 exit 1
91 test -d "$gnulib_srcdir" ||
92 git clone -- "$GNULIB_URL" "$gnulib_srcdir" ||
93 exit
95 test -x "$gnulib_srcdir"/gnulib-tool || {
96 printf '%s\n' >&2 "$0: '$gnulib_srcdir' is not a Gnulib source directory."
97 exit 1
100 avoided_flags=
101 for module in $AVOIDED_MODULES; do
102 avoided_flags="$avoided_flags --avoid=$module"
103 done
105 "$gnulib_srcdir"/gnulib-tool --dir="$src" $GNULIB_TOOL_FLAGS \
106 $avoided_flags $GNULIB_MODULES &&
107 rm -- "$src"lib/gl_openssl.h "$src"m4/fcntl-o.m4 \
108 "$src"m4/gl-openssl.m4 \
109 "$src"m4/gnulib-cache.m4 "$src"m4/gnulib-tool.m4 \
110 "$src"m4/manywarnings-c++.m4 \
111 "$src"m4/warn-on-use.m4 "$src"m4/wint_t.m4 &&
112 cp -- "$gnulib_srcdir"/build-aux/texinfo.tex "$src"doc/misc &&
113 cp -- "$gnulib_srcdir"/build-aux/config.guess \
114 "$gnulib_srcdir"/build-aux/config.sub \
115 "$gnulib_srcdir"/build-aux/install-sh \
116 "$gnulib_srcdir"/build-aux/move-if-change \
117 "$src"build-aux &&
118 { test -z "$src" || cd "$src"; } &&
119 ./autogen.sh