Document -newerXY, and indicate when the various features were added.
[findutils.git] / import-gnulib.sh
bloba0a515a220d8ec6db22080c74c0ebe1def932f3c
1 #! /bin/sh
3 # import-gnulib.sh -- imports a copy of gnulib into findutils
4 # Copyright (C) 2003,2004,2005,2006 Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 # USA.
21 ##########################################################################
23 # This script is intended to populate the "gnulib" directory
24 # with a subset of the gnulib code, as provided by "gnulib-tool".
26 # To use it, run this script, speficying the location of the
27 # gnulib code as the only argument. Some sanity-checking is done
28 # before we commit to modifying things. The gnulib code is placed
29 # in the "gnulib" subdirectory, which is where the buid files expect
30 # it to be.
33 # If CDPATH is set, it will sometimes print the name of the directory
34 # to which you have moved. Unsetting CDPATH prevents this, as does
35 # prefixing it with ".".
36 unset CDPATH
37 configfile="./import-gnulib.config"
38 cvsdir="gnulib-cvs"
40 tool="${cvsdir}"/gnulib/gnulib-tool
42 source $configfile
44 if [ -z "$gnulib_version" ]
45 then
46 echo "Error: There should be a gnulib_version setting in $configfile, but there is not." >&2
47 exit 1
51 if ! [ -d "$cvsdir" ] ; then
52 if mkdir "$cvsdir" ; then
53 echo "Created $cvsdir"
54 else
55 echo "Failed to create $cvsdir" >&2
56 exit 1
60 # Decide if gnulib_version is probably a date or probably a tag.
61 if date -d yesterday >/dev/null ; then
62 # It looks like GNU date is available
63 if date -d "$gnulib_version" >/dev/null ; then
64 # Looks like a date.
65 cvs_sticky_option="-D"
66 else
67 echo "Warning: assuming $gnulib_version is a CVS tag rather than a date" >&2
68 cvs_sticky_option="-r"
70 else
71 # GNU date unavailable, assume the version is a date
72 cvs_sticky_option="-D"
78 # Change directory unconditionally (rater than using checkout -d) so that
79 # cvs does not pick up defaults from ./CVS. Those defaults refer to our
80 # own CVS repository for our code, not to gnulib.
81 cd $cvsdir
82 if test -d gnulib/CVS ; then
83 cd gnulib
84 cmd=update
85 root="" # use previous
86 else
87 root="-d :pserver:anonymous@cvs.sv.gnu.org:/sources/gnulib"
88 cmd=checkout
89 args=gnulib
91 set -x
92 cvs -q -z3 $root $cmd $cvs_sticky_option "$gnulib_version" $args
93 set +x
96 if test -f "$tool"
97 then
98 true
99 else
100 echo "$tool does not exist, did you specify the right directory?" >&2
101 exit 1
104 if test -x "$tool"
105 then
106 true
107 else
108 echo "$tool is not executable" >&2
109 exit 1
113 if [ -d gnulib ]
114 then
115 echo "Warning: directory gnulib already exists, removing it." >&2
116 rm -rf gnulib
118 mkdir gnulib
121 if "$tool" --import --symlink --with-tests --dir=. --lib=libgnulib --source-base=gnulib/lib --m4-base=gnulib/m4 $modules
122 then
123 : OK
124 else
125 echo "$tool failed, exiting." >&2
126 exit 1
130 for file in $extra_files; do
131 case $file in
132 */mdate-sh | */texinfo.tex) dest=doc;;
133 *) dest=.;;
134 esac
135 cp -fp "${cvsdir}"/gnulib/"$file" "$dest" || exit
136 done
141 cat > gnulib/Makefile.am <<EOF
142 # Copyright (C) 2004 Free Software Foundation, Inc.
144 # This file is free software, distributed under the terms of the GNU
145 # General Public License. As a special exception to the GNU General
146 # Public License, this file may be distributed as part of a program
147 # that contains a configuration script generated by Automake, under
148 # the same distribution terms as the rest of that program.
150 # This file was generated by $0 $@.
152 SUBDIRS = lib
156 # Now regenerate things...
157 aclocal -I m4 -I gnulib/m4 &&
158 autoheader &&
159 autoconf &&
160 automake --add-missing --copy &&
161 echo Done.