Fix data-loss with --batch.
[bpt/emacs.git] / admin / merge-gnulib
CommitLineData
9b4ee616
PE
1#! /bin/sh
2# Merge gnulib sources into Emacs sources.
3# Typical usage:
4#
5# admin/merge-gnulib
6
7# Copyright 2012 Free Software Foundation, Inc.
8
9# This file is part of GNU Emacs.
10
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.
15
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.
20
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/>.
23
24# written by Paul Eggert
25
26GNULIB_URL=git://git.savannah.gnu.org/gnulib.git
27
28GNULIB_MODULES='
620f13b0 29 alloca-opt c-ctype c-strcase
7ccfb720 30 careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512
f4a681b0 31 dtoastr dtotimespec dup2 environ execinfo
d35af63c
PE
32 filemode getloadavg getopt-gnu gettime gettimeofday
33 ignore-value intprops largefile lstat
34 manywarnings mktime pselect pthread_sigmask readlink
f5d9e83a 35 socklen stat-time stdalign stdarg stdbool stdio
e32a5799 36 strftime strtoimax strtoumax symlink sys_stat
a615a3ae 37 sys_time time timer-time timespec-add timespec-sub utimens
9b4ee616
PE
38 warnings
39'
40
41GNULIB_TOOL_FLAGS='
d35af63c 42 --avoid=errno --avoid=fcntl --avoid=fcntl-h --avoid=fstat
9b4ee616 43 --avoid=msvc-inval --avoid=msvc-nothrow
d35af63c
PE
44 --avoid=raise --avoid=select --avoid=sigprocmask --avoid=sys_types
45 --avoid=threadlib
9b4ee616
PE
46 --conditional-dependencies --import --no-changelog --no-vc-files
47 --makefile-name=gnulib.mk
48'
49
50# The source directory, with a trailing '/'.
51# If empty, the source directory is the working directory.
52src=$2
53case $src in
54 */ | '') ;;
55 *) src=$src/ ;;
56esac
57
58# Gnulib's source directory.
59gnulib_srcdir=${1-$src../gnulib}
60
61case $gnulib_srcdir in
62 -*) src=- ;;
63esac
64case $src in
65 -*)
66 echo >&2 "$0: usage: $0 [GNULIB_SRCDIR [SRCDIR]]
67
68 SRCDIR is the Emacs source directory (default: working directory).
69 GNULIB_SRCDIR is the Gnulib source directory (default: SRCDIR/../gnulib)."
70 exit 1 ;;
71esac
72
73test -x "$src"autogen.sh || {
74 echo >&2 "$0: '${src:-.}' is not an Emacs source directory."
75 exit 1
76}
77
78test -d "$gnulib_srcdir" ||
79git clone -- "$GNULIB_URL" "$gnulib_srcdir" ||
80exit
81
82test -x "$gnulib_srcdir"/gnulib-tool || {
83 echo >&2 "$0: '$gnulib_srcdir' is not a Gnulib source directory."
84 exit 1
85}
86
9b4ee616
PE
87"$gnulib_srcdir"/gnulib-tool --dir="$src" $GNULIB_TOOL_FLAGS $GNULIB_MODULES &&
88rm -- "$src"m4/gnulib-cache.m4 "$src"m4/warn-on-use.m4 &&
9b4ee616
PE
89cp -- "$gnulib_srcdir"/build-aux/texinfo.tex "$src"doc/misc &&
90cp -- "$gnulib_srcdir"/build-aux/move-if-change "$src"build-aux &&
91autoreconf -i -I m4 -- ${src:+"$src"}