3 # Copyright (C) 2022-2024 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
23 # exits with a given status.
24 # This function needs to be used, rather than 'exit', when a 'trap' handler is
25 # in effect that refers to $?.
31 # func_fatal_error message
32 # outputs to stderr a fatal error message, and terminates the program.
34 # - progname name of this program
37 echo "$progname: *** $1" 1>&2
38 echo "$progname: *** Stop." 1>&2
42 # func_readlink SYMLINK
43 # outputs the target of the given symlink.
44 if (type readlink
) > /dev
/null
2>&1; then
47 # Use the readlink program from GNU coreutils.
53 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
54 # would do the wrong thing if the link target contains " -> ".
55 LC_ALL
=C
ls -l "$1" |
sed -e 's, -> ,#%%#,' |
sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
60 # locates the directory where the gnulib repository lives
62 # - progname name of this program
64 # - self_abspathname absolute pathname of this program
65 # - gnulib_dir absolute pathname of gnulib repository
69 /* | ?
:*) self_abspathname
="$progname" ;;
70 */*) self_abspathname
=`pwd`/"$progname" ;;
73 # Iterate through the elements of $PATH.
74 # We use IFS=: instead of
75 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
76 # because the latter does not work when some PATH element contains spaces.
77 # We use a canonicalized $pathx instead of $PATH, because empty PATH
78 # elements are by definition equivalent to '.', however field splitting
79 # according to IFS=: loses empty fields in many shells:
80 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
81 # beginning, at the end, and in the middle),
82 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
83 # at the beginning and at the end,
84 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
85 # Solaris lose empty fields at the end.
86 # The 'case' statement is an optimization, to avoid evaluating the
87 # explicit canonicalization command when $PATH contains no empty fields.
89 if test "${PATH_SEPARATOR+set}" != set; then
90 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
91 # contains only /bin. Note that ksh looks also at the FPATH variable,
92 # so we have to set that as well for the test.
94 (PATH
='/bin;/bin'; FPATH
=$PATH; sh
-c :) >/dev
/null
2>&1 \
95 && { (PATH
='/bin:/bin'; FPATH
=$PATH; sh
-c :) >/dev
/null
2>&1 \
99 if test "${PATH_SEPARATOR+set}" != set; then
100 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
101 # contains only /bin. Note that ksh looks also at the FPATH variable,
102 # so we have to set that as well for the test.
104 (PATH
='/bin;/bin'; FPATH
=$PATH; sh
-c :) >/dev
/null
2>&1 \
105 && { (PATH
='/bin:/bin'; FPATH
=$PATH; sh
-c :) >/dev
/null
2>&1 \
106 || PATH_SEPARATOR
=';'
109 if test "$PATH_SEPARATOR" = ";"; then
110 # On Windows, programs are searched in "." before $PATH.
113 # On Unix, we have to convert empty PATH elements to ".".
117 pathx
=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
122 IFS
="$PATH_SEPARATOR"
126 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
127 self_abspathname
="$d/$progname"
132 if test -z "$self_abspathname"; then
133 func_fatal_error
"could not locate the all-modules program - how did you invoke it?"
137 while test -h "$self_abspathname"; do
138 # Resolve symbolic link.
139 linkval
=`func_readlink "$self_abspathname"`
140 test -n "$linkval" ||
break
142 /* | ?
:* ) self_abspathname
="$linkval" ;;
143 * ) self_abspathname
=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
146 gnulib_dir
=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
150 # outputs to stdout the --help usage message.
154 Usage: all-modules [option]
156 Lists the gnulib-tool command line options that can be used when creating
157 a testdir of nearly all of gnulib.
161 --for-mingw list only modules that work on mingw
162 --for-msvc list only modules that work on MSVC
164 Report bugs to <bug-gnulib@gnu.org>."
168 # outputs to stdout the --version message.
172 if test -d "$gnulib_dir"/.git \
173 && (git
--version) >/dev
/null
2>/dev
/null \
174 && (date --version) >/dev
/null
2>/dev
/null
; then
175 # gnulib checked out from git.
176 sed_extract_first_date
='/^Date/{
180 date=`cd "$gnulib_dir" && git log -n 1 --format=medium --date=iso ChangeLog | sed -n -e "$sed_extract_first_date"`
181 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
182 sed_year_before_time
='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
183 date=`echo "$date" | sed -e "$sed_year_before_time"`
184 # Use GNU date to compute the time in GMT.
185 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
186 version
=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
188 # gnulib copy without versioning information.
189 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
192 year
=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed 's,^.* ,,'`
194 all-modules (GNU $package $date)$version
195 Copyright (C) $year Free Software Foundation, Inc.
196 License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
197 This is free software: you are free to change and redistribute it.
198 There is NO WARRANTY, to the extent permitted by law.
200 Written by" "Bruno Haible"
203 # Excludes for mingw and MSVC.
205 # <pwd.h> and <grp.h> do not exist.
206 exclude_for_mingw
="$exclude_for_mingw idcache"
207 exclude_for_mingw
="$exclude_for_mingw pt_chown grantpt posix_openpt-tests posix_openpt"
208 exclude_for_mingw
="$exclude_for_mingw userspec-tests userspec"
209 # The functions getuid, getgid, geteuid, getegid don't exist.
210 exclude_for_mingw
="$exclude_for_mingw faccessat"
211 exclude_for_mingw
="$exclude_for_mingw fchownat-tests fchownat chownat"
212 # The functions fork, setsid, ttyname don't exist.
213 exclude_for_mingw
="$exclude_for_mingw forkpty-tests forkpty login_tty-tests login_tty"
216 exclude_for_msvc
="$exclude_for_mingw"
218 # Command-line option processing.
219 exclude
="year2038-recommended"
220 while test $# -gt 0; do
222 --for-mingw |
--for-ming |
--for-min |
--for-mi )
223 exclude
="$exclude $exclude_for_mingw"
225 --for-msvc |
--for-msv |
--for-ms )
226 exclude
="$exclude $exclude_for_msvc"
228 --help |
--hel |
--he |
--h )
231 --version |
--versio |
--versi |
--vers |
--ver |
--ve |
--v )
235 echo "all-modules: unknown option $1" 1>&2
236 echo "Try 'all-modules --help' for more information." 1>&2
239 echo "all-modules: too many arguments" 1>&2
240 echo "Try 'all-modules --help' for more information." 1>&2
245 # gnulib-tool --create-testdir collects all modules by default.
246 # We only need to filter out the excludes.
247 for m
in $exclude; do
248 printf '%s\n' "--avoid=$m"
252 # indent-tabs-mode: nil
253 # whitespace-check-buffer-indent: nil