Implement dots and dashes on Android
[emacs.git] / admin / merge-gnulib
blob41531d573b056d0319503bedd99dfa9df5f9c2ef
1 #! /bin/sh
2 # Merge gnulib sources into Emacs sources.
3 # Typical usage:
5 # admin/merge-gnulib
7 # Copyright 2012-2024 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=https://git.savannah.gnu.org/git/gnulib.git
28 GNULIB_MODULES='
29 alignasof alloca-opt binary-io boot-time byteswap c-ctype c-strcase
30 canonicalize-lgpl
31 careadlinkat close-stream copy-file-range
32 count-leading-zeros count-one-bits count-trailing-zeros
33 crypto/md5 crypto/md5-buffer
34 crypto/sha1-buffer crypto/sha256-buffer crypto/sha512-buffer
35 d-type diffseq double-slash-root dtoastr dtotimespec dup2
36 environ execinfo faccessat
37 fchmodat fcntl fcntl-h fdopendir file-has-acl
38 filemode filename filevercmp flexmember fpieee
39 free-posix fstatat fsusage fsync futimens
40 getline getloadavg getopt-gnu getrandom gettime gettimeofday gitlog-to-changelog
41 ieee754-h ignore-value intprops largefile libgmp lstat
42 manywarnings memmem-simple mempcpy memrchr memset_explicit
43 minmax mkostemp mktime
44 nanosleep nproc nstrftime
45 pathmax pipe2 pselect pthread_sigmask
46 qcopy-acl readlink readlinkat regex
47 sig2str sigdescr_np socklen stat-time std-gnu11 stdbool stdckdint stddef stdio
48 stpcpy strnlen strnlen strtoimax symlink sys_stat sys_time
49 tempname time-h time_r time_rz timegm timer-time timespec-add timespec-sub
50 update-copyright unlocked-io utimensat
51 vla warnings year2038
54 AVOIDED_MODULES='
55 access btowc chmod close crypto/af_alg dup fchdir fstat
56 iswblank iswctype iswdigit iswxdigit langinfo localename-unsafe-limited lock
57 mbrtowc mbsinit memchr mkdir msvc-inval msvc-nothrow nl_langinfo
58 openat-die opendir pthread-h raise
59 save-cwd select setenv sigprocmask stat stdarg
60 threadlib tzset unsetenv utime utime-h
61 wchar wcrtomb wctype wctype-h
64 GNULIB_TOOL_FLAGS='
65 --conditional-dependencies --import --no-changelog --no-vc-files
66 --gnu-make
67 --makefile-name=gnulib.mk.in
70 # The source directory, with a trailing '/'.
71 # If empty, the source directory is the working directory.
72 src=$2
73 case $src in
74 */ | '') ;;
75 *) src=$src/ ;;
76 esac
78 # Gnulib's source directory.
79 gnulib_srcdir=${1-$src../gnulib}
81 case $gnulib_srcdir in
82 -*) src=- ;;
83 esac
84 case $src in
85 -*)
86 printf '%s\n' >&2 "$0: usage: $0 [GNULIB_SRCDIR [SRCDIR]]
88 SRCDIR is the Emacs source directory (default: working directory).
89 GNULIB_SRCDIR is the Gnulib source directory (default: SRCDIR/../gnulib)."
90 exit 1 ;;
91 esac
93 test -x "$src"autogen.sh || {
94 printf '%s\n' >&2 "$0: '${src:-.}' is not an Emacs source directory."
95 exit 1
98 test -d "$gnulib_srcdir" ||
99 git clone -- "$GNULIB_URL" "$gnulib_srcdir" ||
100 exit
102 test -x "$gnulib_srcdir"/gnulib-tool || {
103 printf '%s\n' >&2 "$0: '$gnulib_srcdir' is not a Gnulib source directory."
104 exit 1
107 # gnulib-tool has problems with a bare checkout (Bug#32452#65).
108 test -f configure || ./autogen.sh || exit
110 avoided_flags=
111 for module in $AVOIDED_MODULES; do
112 avoided_flags="$avoided_flags --avoid=$module"
113 done
115 # Clean the lib directory as well.
116 if [ -e "$src"/lib/Makefile ]; then
117 make -C "$src"/lib maintainer-clean
120 "$gnulib_srcdir"/gnulib-tool --dir="$src" $GNULIB_TOOL_FLAGS \
121 $avoided_flags $GNULIB_MODULES &&
122 rm -- "$src"lib/gl_openssl.h \
123 "$src"lib/stdio-read.c "$src"lib/stdio-write.c \
124 "$src"m4/fcntl-o.m4 \
125 "$src"m4/gl-openssl.m4 \
126 "$src"m4/gnulib-cache.m4 "$src"m4/gnulib-tool.m4 \
127 "$src"m4/locale-fr.m4 \
128 "$src"m4/manywarnings-c++.m4 \
129 "$src"m4/warn-on-use.m4 "$src"m4/wint_t.m4 &&
130 cp -- "$gnulib_srcdir"/build-aux/texinfo.tex "$src"doc/misc &&
131 cp -- "$gnulib_srcdir"/build-aux/config.guess \
132 "$gnulib_srcdir"/build-aux/config.sub \
133 "$gnulib_srcdir"/build-aux/install-sh \
134 "$gnulib_srcdir"/build-aux/move-if-change \
135 "$src"build-aux &&
136 cp -- "$gnulib_srcdir"/lib/af_alg.h \
137 "$gnulib_srcdir"/lib/save-cwd.h \
138 "$src"lib &&
139 cp -- "$gnulib_srcdir"/m4/codeset.m4 \
140 "$src"m4 &&
141 { test -z "$src" || cd "$src"; } &&
142 ./autogen.sh