Support nanosecond timestamps and time arguments with fractional parts
[findutils.git] / import-gnulib.sh
blob0f14aafdb4c0ce9e404502823e37b31cdf6ea8c6
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
38 destdir="gnulib"
41 # Random extra gnulib files needed for findutils.
42 # The source path is relative to gnulib, the destination to .
43 findutils_files='
44 build-aux/config.guess
45 build-aux/config.rpath
46 build-aux/config.sub
47 build-aux/depcomp
48 build-aux/install-sh
49 build-aux/mdate-sh
50 build-aux/missing
51 build-aux/texinfo.tex
54 # Modules needed for findutils.
55 findutils_modules="\
56 alloca argmatch dirname error fileblocks fnmatch-gnu fopen-safer fts \
57 getline getopt human idcache lstat malloc memcmp memset mktime \
58 modechange pathmax quotearg realloc regex rpmatch savedir \
59 stpcpy strdup strftime strstr strtol strtoul strtoull strtoumax \
60 xalloc xalloc-die xgetcwd xstrtod xstrtol xstrtoumax yesno human filemode \
61 getline stpcpy canonicalize mountlist closeout gettext stat-macros stat-time \
62 xstrtod"
64 # We need regex to ensure that we can build on platforms like
65 # Solaris which lack those functions.
67 modules="$findutils_modules"
68 export modules
70 if test $# -lt 1
71 then
72 echo "You need to specify the name of the directory containing gnulib" >&2
73 exit 1
76 if test -d "$1"
77 then
78 true
79 else
80 echo "$1 is not a directory" >&2
81 exit 1
84 if test -f "$1"/gnulib-tool
85 then
86 true
87 else
88 echo "$1/gnulib-tool does not exist, did you specify the right directory?" >&2
89 exit 1
92 if test -x "$1"/gnulib-tool
93 then
94 true
95 else
96 echo "$1/gnulib-tool is not executable" >&2
97 exit 1
101 # exec "$1"/gnulib-tool --create-testdir --dir="$destdir" --lib=libgnulib $modules
103 if [ -d gnulib ]
104 then
105 echo "Warning: directory gnulib already exists." >&2
106 else
107 mkdir gnulib
111 if "$1"/gnulib-tool --import --dir=. --lib=libgnulib --source-base=gnulib/lib --m4-base=gnulib/m4 $modules
112 then
113 : OK
114 else
115 echo "gnulib-tool failed, exiting." >&2
116 exit 1
120 for file in $findutils_files; do
121 case $file in
122 */mdate-sh | */texinfo.tex) dest=doc;;
123 *) dest=.;;
124 esac
125 cp -fp "$1"/$file $dest || exit
126 done
130 cat > gnulib/Makefile.am <<EOF
131 # Copyright (C) 2004 Free Software Foundation, Inc.
133 # This file is free software, distributed under the terms of the GNU
134 # General Public License. As a special exception to the GNU General
135 # Public License, this file may be distributed as part of a program
136 # that contains a configuration script generated by Automake, under
137 # the same distribution terms as the rest of that program.
139 # This file was generated by $0 $@.
141 SUBDIRS = lib
145 ## (
146 ## cat <<EOF
147 ## # Copyright (C) 2004 Free Software Foundation, Inc.
148 ## #
149 ## # This file is free software, distributed under the terms of the GNU
150 ## # General Public License. As a special exception to the GNU General
151 ## # Public License, this file may be distributed as part of a program
152 ## # that contains a configuration script generated by Automake, under
153 ## # the same distribution terms as the rest of that program.
154 ## #
155 ## # This file was generated by $0 $@.
156 ## #
157 ## EOF
158 ## printf "%s" "EXTRA_DIST = "
159 ## cd ./gnulib/m4
160 ## ls *.m4 | sed -e 's/$/ \\/' | sed -e '$ s/\\$//'
161 ## echo
162 ## ) > gnulib/m4/Makefile.am