Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / getopt-m4sh.at
1 # getopts-m4sh.at -- test getopts.m4sh option parsers       -*- Autotest -*-
2 #
3 #   Copyright (C) 2010 Free Software Foundation, Inc.
4 #   Written by Gary V. Vaughan, 2010
5 #
6 #   This file is part of GNU Libtool.
7 #
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.
12 #
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.
17 #
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.
23 ####
24
25 AT_BANNER([Shell option parser generator.])
26
27 auxdir="$abs_top_srcdir/libltdl/config"
28
29
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])
37 nl='
38 '
39 list=
40 opts=
41 M4SH_GETOPTS(
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"],
47 [echo "$list" $opts])
48 ]])
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
56
57
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],
62 [dnl {{
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])
68
69
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],
74 [dnl {{
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])
79
80
81 ## ----------------------- ##
82 ## Short option splitting. ##
83 ## ----------------------- ##
84
85 AT_SETUP([short option splitting])
86
87 AT_DATA(expout,
88 [[ force verbose install
89 ]])
90
91 _LT_AT_GETOPT_M4SH_SETUP
92
93 AT_CHECK([$SHELL ./options -fvi], 0, [expout])
94
95 AT_CLEANUP
96
97
98 AT_SETUP([enhanced shell short option splitting])
99
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)])
102
103 AT_DATA(expout,
104 [[ force verbose install
105 ]])
106
107 _LT_AT_GETOPT_M4SH_SETUP
108 _LT_AT_XSI_FUNC_EXTRACT(func_split_short_opt)
109
110 AT_CHECK([$SHELL ./options -fvi], 0, [expout])
111
112 AT_CLEANUP
113
114
115 ## ---------------------- ##
116 ## Long option splitting. ##
117 ## ---------------------- ##
118
119 AT_SETUP([long option splitting])
120
121 AT_DATA(expout,
122 [[ ltdl=long
123 ]])
124
125 _LT_AT_GETOPT_M4SH_SETUP
126
127 AT_CHECK([$SHELL ./options --ltdl=long], 0, [expout])
128
129 AT_CLEANUP
130
131
132 AT_SETUP([XSI long option splitting])
133
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)])
136
137 AT_DATA(expout,
138 [[ ltdl=long
139 ]])
140
141 _LT_AT_GETOPT_M4SH_SETUP
142 _LT_AT_XSI_FUNC_EXTRACT(func_split_long_opt)
143
144 AT_CHECK([$SHELL ./options --ltdl=long], 0, [expout])
145
146 AT_CLEANUP
147
148
149 ## ----------------- ##
150 ## Option appending. ##
151 ## ----------------- ##
152
153 AT_SETUP([option appending])
154
155 AT_DATA(expout,
156 [[first   --append second
157 third
158
159 ]])
160
161 _LT_AT_GETOPT_M4SH_SETUP
162 _LT_AT_FALLBACK_FUNC_EXTRACT(func_append)
163
164 AT_CHECK([$SHELL ./options -a "first   --append second" -athird], 0, [expout])
165
166 AT_CLEANUP
167
168
169 AT_SETUP([enhanced shell option appending])
170
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)])
173
174 AT_DATA(expout,
175 [[first   --append second
176 third
177
178 ]])
179
180 _LT_AT_GETOPT_M4SH_SETUP
181 _LT_AT_FALLBACK_FUNC_EXTRACT(func_append)
182 _LT_AT_XSI_FUNC_EXTRACT(func_append)
183
184 AT_CHECK([$SHELL ./options -a "first   --append second" -athird], 0, [expout])
185
186 AT_CLEANUP