3 # import-gnulib.sh -- imports a copy of gnulib into findutils
4 # Copyright (C) 2003,2004,2005,2006,2007 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)
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,
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, just run this script with the top-level sourec directory
27 # as your working directory.
29 # If CDPATH is set, it will sometimes print the name of the directory
30 # to which you have moved. Unsetting CDPATH prevents this, as does
31 # prefixing it with ".".
35 # cvsdir=/doesnotexist
36 configfile
="./import-gnulib.config"
42 usage: $0 [-d gnulib-directory]
44 The default behaviour is to check out the Gnulib code via anonymous
45 CVS (or update it if there is a version already checked out). The
46 checkout or update is performed to the gnulib version indicated in
47 the configuration file $configfile.
49 If you wish to work with a different version of gnulib, use the -d option
50 to specify the directory containing the gnulib code.
57 echo checking out gnulib from CVS
in $cvsdir
59 if [ -z "$gnulib_version" ] ; then
60 echo "Error: There should be a gnulib_version setting in $configfile, but there is not." >&2
65 if ! [ -d "$cvsdir" ] ; then
66 if mkdir
"$cvsdir" ; then
67 echo "Created $cvsdir"
69 echo "Failed to create $cvsdir" >&2
74 # Decide if gnulib_version is probably a date or probably a tag.
75 if date -d yesterday
>/dev
/null
; then
76 # It looks like GNU date is available
77 if date -d "$gnulib_version" >/dev
/null
; then
79 cvs_sticky_option
="-D"
81 echo "Warning: assuming $gnulib_version is a CVS tag rather than a date" >&2
82 cvs_sticky_option
="-r"
85 # GNU date unavailable, assume the version is a date
86 cvs_sticky_option
="-D"
92 # Change directory unconditionally (rater than using checkout -d) so that
93 # cvs does not pick up defaults from ./CVS. Those defaults refer to our
94 # own CVS repository for our code, not to gnulib.
96 if test -d gnulib
/CVS
; then
99 root
="" # use previous
101 root
="-d :pserver:anonymous@cvs.sv.gnu.org:/sources/gnulib"
106 cvs
-q -z3 $root $cmd $cvs_sticky_option "$gnulib_version" $args
117 echo "$tool does not exist, did you specify the right directory?" >&2
125 echo "$tool is not executable" >&2
132 echo "Warning: directory gnulib already exists, removing it." >&2
138 if "$tool" --import --symlink --with-tests --dir=.
--lib=libgnulib
--source-base=gnulib
/lib
--m4-base=gnulib
/m4 $modules
143 echo "$tool failed, exiting." >&2
149 hack_gnulib_tool_output
() {
150 local gnulibdir
="${1}"
151 for file in $extra_files; do
153 */mdate-sh |
*/texinfo.tex
) dest
=doc
;;
156 cp -fp "${gnulibdir}"/"$file" "$dest" ||
exit
162 cat > gnulib
/Makefile.am
<<EOF
163 # Copyright (C) 2004 Free Software Foundation, Inc.
165 # This file is free software, distributed under the terms of the GNU
166 # General Public License. As a special exception to the GNU General
167 # Public License, this file may be distributed as part of a program
168 # that contains a configuration script generated by Automake, under
169 # the same distribution terms as the rest of that program.
171 # This file was generated by $0 $@.
178 refresh_output_files
() {
179 aclocal
-I m4 -I gnulib
/m4 &&
182 automake
--add-missing --copy
188 local gnulibdir
=/doesnotexist
189 while getopts "d:" opt
192 d
) gnulibdir
="$OPTARG" ; need_checkout
=no
;;
197 # We need the config file to tell us which modules
198 # to use, even if we don't want to know the CVS version.
199 .
$configfile ||
exit 1
201 ## If -d was not given, do CVS checkout/update
202 if [ $need_checkout = yes ] ; then
203 do_checkout gnulib-cvs
204 gnulibdir
=gnulib-cvs
/gnulib
206 echo "Warning: using gnulib code which already exists in $gnulibdir" >&2
209 ## Invoke gnulib-tool to import the code.
210 local tool
="${gnulibdir}"/gnulib-tool
212 run_gnulib_tool
"${tool}" &&
213 hack_gnulib_tool_output
"${gnulibdir}" &&
214 refresh_output_files
&& echo Done.