Applied Bas van Gompel's patch implementing --and
[findutils.git] / import-gnulib.sh
blobb151e75cb6d8c7eb857137f08f87da4ac52025eb
1 #! /bin/sh
3 # import-gnulib.sh -- imports a copy of gnulib into findutils
4 # Copyright (C) 2003,2004,2005 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
38 destdir="gnulib"
41 # Modules needed for findutils itself.
42 findutils_modules="\
43 alloca argmatch dirname error fileblocks fnmatch-gnu \
44 getline getopt human idcache lstat malloc memcmp memset mktime \
45 modechange pathmax quotearg realloc regex rpmatch savedir stat \
46 stpcpy strdup strftime strstr strtol strtoul strtoull strtoumax \
47 xalloc xalloc-die xgetcwd xstrtol xstrtoumax yesno human filemode \
48 getline stpcpy canonicalize mountlist closeout gettext stat-macros"
50 # We need regex to ensure that we can build on platforms like
51 # Solaris which lack those functions.
53 modules="$findutils_modules $intl_modules"
54 export modules
56 if test $# -lt 1
57 then
58 echo "You need to specify the name of the directory containing gnulib" >&2
59 exit 1
62 if test -d "$1"
63 then
64 true
65 else
66 echo "$1 is not a directory" >&2
67 exit 1
70 if test -f "$1"/gnulib-tool
71 then
72 true
73 else
74 echo "$1/gnulib-tool does not exist, did you specify the right directory?" >&2
75 exit 1
78 if test -x "$1"/gnulib-tool
79 then
80 true
81 else
82 echo "$1/gnulib-tool is not executable" >&2
83 exit 1
87 # exec "$1"/gnulib-tool --create-testdir --dir="$destdir" --lib=libgnulib $modules
89 if [ -d gnulib ]
90 then
91 echo "Warning: directory gnulib already exists." >&2
92 else
93 mkdir gnulib
97 if "$1"/gnulib-tool --import --dir=. --lib=libgnulib --source-base=gnulib/lib --m4-base=gnulib/m4 $modules
98 then
99 : OK
100 else
101 echo "gnulib-tool failed, exiting." >&2
102 exit 1
107 cat > gnulib/Makefile.am <<EOF
108 # Copyright (C) 2004 Free Software Foundation, Inc.
110 # This file is free software, distributed under the terms of the GNU
111 # General Public License. As a special exception to the GNU General
112 # Public License, this file may be distributed as part of a program
113 # that contains a configuration script generated by Automake, under
114 # the same distribution terms as the rest of that program.
116 # This file was generated by $0 $@.
118 SUBDIRS = lib
122 ## (
123 ## cat <<EOF
124 ## # Copyright (C) 2004 Free Software Foundation, Inc.
125 ## #
126 ## # This file is free software, distributed under the terms of the GNU
127 ## # General Public License. As a special exception to the GNU General
128 ## # Public License, this file may be distributed as part of a program
129 ## # that contains a configuration script generated by Automake, under
130 ## # the same distribution terms as the rest of that program.
131 ## #
132 ## # This file was generated by $0 $@.
133 ## #
134 ## EOF
135 ## printf "%s" "EXTRA_DIST = "
136 ## cd ./gnulib/m4
137 ## ls *.m4 | sed -e 's/$/ \\/' | sed -e '$ s/\\$//'
138 ## echo
139 ## ) > gnulib/m4/Makefile.am
143 # We also need config.rpath, because configure calls it, but for
144 # some reason, "autoreconf -i" doesn't fetch it.
145 for f in config.rpath
147 (set -x; cp "$1"/build-aux/"$f" . )
148 done