Merge from emacs-24; up to 2012-12-25T17:37:29Z!eliz@gnu.org
[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
ab422c4d 7# Copyright 2012-2013 Free Software Foundation, Inc.
9b4ee616
PE
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
73dcdb9f 31 dtoastr dtotimespec dup2 environ execinfo faccessat
8654f9d7 32 fcntl-h fdopendir filemode fstatat getloadavg getopt-gnu gettime gettimeofday
d35af63c 33 ignore-value intprops largefile lstat
a84b7c53
PE
34 manywarnings memrchr mktime
35 pselect pthread_sigmask putenv readlink readlinkat
d983a10b 36 sig2str socklen stat-time stdalign stdarg stdbool stdio
e32a5799 37 strftime strtoimax strtoumax symlink sys_stat
5745a7df 38 sys_time time timer-time timespec-add timespec-sub unsetenv utimens
9b4ee616
PE
39 warnings
40'
41
42GNULIB_TOOL_FLAGS='
8654f9d7 43 --avoid=dup
73dcdb9f
PE
44 --avoid=errno --avoid=fchdir --avoid=fcntl --avoid=fstat
45 --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow
8654f9d7 46 --avoid=open --avoid=openat-die --avoid=opendir
73dcdb9f
PE
47 --avoid=raise
48 --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types
d35af63c 49 --avoid=threadlib
9b4ee616
PE
50 --conditional-dependencies --import --no-changelog --no-vc-files
51 --makefile-name=gnulib.mk
52'
53
54# The source directory, with a trailing '/'.
55# If empty, the source directory is the working directory.
56src=$2
57case $src in
58 */ | '') ;;
59 *) src=$src/ ;;
60esac
61
62# Gnulib's source directory.
63gnulib_srcdir=${1-$src../gnulib}
64
65case $gnulib_srcdir in
66 -*) src=- ;;
67esac
68case $src in
69 -*)
70 echo >&2 "$0: usage: $0 [GNULIB_SRCDIR [SRCDIR]]
71
72 SRCDIR is the Emacs source directory (default: working directory).
73 GNULIB_SRCDIR is the Gnulib source directory (default: SRCDIR/../gnulib)."
74 exit 1 ;;
75esac
76
77test -x "$src"autogen.sh || {
78 echo >&2 "$0: '${src:-.}' is not an Emacs source directory."
79 exit 1
80}
81
82test -d "$gnulib_srcdir" ||
83git clone -- "$GNULIB_URL" "$gnulib_srcdir" ||
84exit
85
86test -x "$gnulib_srcdir"/gnulib-tool || {
87 echo >&2 "$0: '$gnulib_srcdir' is not a Gnulib source directory."
88 exit 1
89}
90
9b4ee616 91"$gnulib_srcdir"/gnulib-tool --dir="$src" $GNULIB_TOOL_FLAGS $GNULIB_MODULES &&
73dcdb9f 92rm -- "$src"m4/fcntl-o.m4 "$src"m4/gnulib-cache.m4 "$src"m4/warn-on-use.m4 &&
9b4ee616
PE
93cp -- "$gnulib_srcdir"/build-aux/texinfo.tex "$src"doc/misc &&
94cp -- "$gnulib_srcdir"/build-aux/move-if-change "$src"build-aux &&
95autoreconf -i -I m4 -- ${src:+"$src"}