1 # getopts-m4sh.at -- test getopts.m4sh option parsers -*- Autotest -*-
3 # Copyright (C) 2010 Free Software Foundation, Inc.
4 # Written by Gary V. Vaughan, 2010
6 # This file is part of GNU Libtool.
8 # GNU Libtool is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation; either version 2 of
11 # the License, or (at your option) any later version.
13 # GNU Libtool is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with GNU Libtool; see the file COPYING. If not, a copy
20 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
21 # or obtained by writing to the Free Software Foundation, Inc.,
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 AT_BANNER([Shell option parser generator.])
27 auxdir="$abs_top_srcdir/libltdl/config"
30 # _LT_AT_GETOPT_M4SH_SETUP
31 # ------------------------
32 m4_define([_LT_AT_GETOPT_M4SH_SETUP],
33 [m4_pattern_allow([AS_INIT])
34 m4_pattern_allow([m4_include])
35 AT_DATA([options.m4sh],
36 [[AS_INIT[]m4_include([getopt.m4sh])
42 [a!], [--append], [], [func_append list "$optarg$nl"],
43 [f], [--force], [], [opts="$opts force"],
44 [i], [--install], [], [opts="$opts install"],
45 [v], [--verbose], [], [opts="$opts verbose"],
46 [!], [--ltdl], [false],[opts="$opts ltdl=$optarg"],
49 m4_pattern_forbid([m4_include])
50 m4_pattern_forbid([AS_INIT])
51 AT_CHECK([$M4SH --version || exit 77], [], [ignore], [ignore])
52 AT_CHECK([$M4SH -B $abs_top_srcdir/libltdl/config options.m4sh > t-options],
53 [], [], [], [AT_CHECK([test $at_status -eq 63 && exit 77])])
54 $SED "s,@LN_S\@,$LN_S,g;s,@SED\@,$SED,g" t-options > options
55 ])# _LT_AT_GETOPT_M4SH_SETUP
58 # _LT_AT_FALLBACK_FUNC_EXTRACT(FUNC-NAME)
59 # ---------------------------------------
60 # Extract the fallback function FUNC-NAME from ltmain.m4sh
61 m4_define([_LT_AT_FALLBACK_FUNC_EXTRACT],
63 $SED '/^# func_dirname /q' options > options.tmp
64 echo '# func_append var value' >> options.tmp
65 $SED -n '/^$1 ()/,/^} # $1 /p' $abs_top_srcdir/libltdl/config/ltmain.m4sh >> options.tmp
66 $SED '1,/^# func_dirname/d' options >> options.tmp
67 rm -f options && mv options.tmp options])
70 # _LT_AT_EXTENDED_SHELL_FUNC_EXTRACT(FUNC-NAME)
71 # ---------------------------------------------
72 # Extract the 'Extended-shell'-decorated function FUNC-NAME from libtool
73 m4_define([_LT_AT_XSI_FUNC_EXTRACT],
75 $SED '/^# $1/q' options > options.tmp
76 $SED -n '/^$1 ()/,/^} # Extended-shell $1 /p' $abs_top_builddir/libtool >> options.tmp
77 $SED '1,/^} # $1 /d' options >> options.tmp
78 rm -f options && mv options.tmp options])
81 ## ----------------------- ##
82 ## Short option splitting. ##
83 ## ----------------------- ##
85 AT_SETUP([short option splitting])
88 [[ force verbose install
91 _LT_AT_GETOPT_M4SH_SETUP
93 AT_CHECK([$SHELL ./options -fvi], 0, [expout])
98 AT_SETUP([enhanced shell short option splitting])
100 # Don't bother with additional XSI checks unless functions were substituted
101 AT_CHECK([fgrep '@%:@ Extended-shell func_split_short_opt' $abs_top_builddir/libtool >/dev/null 2>&1 || (exit 77)])
104 [[ force verbose install
107 _LT_AT_GETOPT_M4SH_SETUP
108 _LT_AT_XSI_FUNC_EXTRACT(func_split_short_opt)
110 AT_CHECK([$SHELL ./options -fvi], 0, [expout])
115 ## ---------------------- ##
116 ## Long option splitting. ##
117 ## ---------------------- ##
119 AT_SETUP([long option splitting])
125 _LT_AT_GETOPT_M4SH_SETUP
127 AT_CHECK([$SHELL ./options --ltdl=long], 0, [expout])
132 AT_SETUP([XSI long option splitting])
134 # Don't bother with additional XSI checks unless functions were substituted
135 AT_CHECK([fgrep '@%:@ Extended-shell func_split_long_opt' $abs_top_builddir/libtool >/dev/null 2>&1 || (exit 77)])
141 _LT_AT_GETOPT_M4SH_SETUP
142 _LT_AT_XSI_FUNC_EXTRACT(func_split_long_opt)
144 AT_CHECK([$SHELL ./options --ltdl=long], 0, [expout])
149 ## ----------------- ##
150 ## Option appending. ##
151 ## ----------------- ##
153 AT_SETUP([option appending])
156 [[first --append second
161 _LT_AT_GETOPT_M4SH_SETUP
162 _LT_AT_FALLBACK_FUNC_EXTRACT(func_append)
164 AT_CHECK([$SHELL ./options -a "first --append second" -athird], 0, [expout])
169 AT_SETUP([enhanced shell option appending])
171 # Don't bother with additional += check unless functions were substituted
172 AT_CHECK([fgrep '@%:@ Extended-shell func_append ' $abs_top_builddir/libtool >/dev/null 2>&1 || (exit 77)])
175 [[first --append second
180 _LT_AT_GETOPT_M4SH_SETUP
181 _LT_AT_FALLBACK_FUNC_EXTRACT(func_append)
182 _LT_AT_XSI_FUNC_EXTRACT(func_append)
184 AT_CHECK([$SHELL ./options -a "first --append second" -athird], 0, [expout])