Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / help.at
1 # help.at -- standard command line options          -*- Autotest -*-
2 #
3 #   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4 #
5 #   This file is part of GNU Libtool.
6 #
7 # GNU Libtool is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License as
9 # published by the Free Software Foundation; either version 2 of
10 # the License, or (at your option) any later version.
11 #
12 # GNU Libtool is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Libtool; see the file COPYING.  If not, a copy
19 # can be downloaded from  http://www.gnu.org/licenses/gpl.html,
20 # or obtained by writing to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 ####
23
24 AT_BANNER([Testing libtool functions.])
25
26 AT_SETUP([standard command line options])
27 AT_KEYWORDS([libtool])
28 AT_KEYWORDS([libtoolize])
29
30 AT_CHECK([$LIBTOOLIZE --help], [], [ignore])
31 AT_CHECK([$LIBTOOLIZE --version], [], [stdout])
32 AT_CHECK([grep 'Copyright.*Free Software Foundation' stdout], [], [ignore])
33 AT_CHECK([$LIBTOOL --help], [], [ignore])
34 AT_CHECK([$LIBTOOL --help-all], [], [ignore])
35 AT_CHECK([$LIBTOOL --version], [], [stdout])
36 AT_CHECK([grep 'Copyright.*Free Software Foundation' stdout], [], [ignore])
37
38 AT_CHECK([$LIBTOOL], [1], [ignore], [stderr])
39 AT_CHECK([grep 'specify a MODE' stderr], [], [ignore])
40 AT_CHECK([grep ' --help' stderr], [], [ignore])
41
42 AT_CLEANUP
43
44
45 AT_SETUP([mode short-hands])
46
47 AT_DATA([a.c],
48 [[int a () { return 0; }
49 ]])
50
51 AT_DATA([main.c],
52 [[extern int a ();
53 int main () { return a (); }
54 ]])
55
56 inst=`pwd`/inst
57 libdir=$inst/lib
58 bindir=$inst/bin
59 mkdir $inst $libdir $bindir
60
61 AT_CHECK([$LIBTOOL compile $CC $CPPFLAGS $CFLAGS -c a.c],
62          [], [ignore], [ignore])
63 AT_CHECK([$LIBTOOL co $CC $CPPFLAGS $CFLAGS -c main.c],
64          [], [ignore], [ignore])
65 AT_CHECK([$LIBTOOL co $CC $CPPFLAGS $CFLAGS -c main.c],
66          [], [ignore], [ignore])
67 AT_CHECK([$LIBTOOL link $CC $CFLAGS $LDFLAGS -o liba.la a.lo ]dnl
68          [-no-undefined -rpath $libdir], [], [ignore], [ignore])
69 AT_CHECK([$LIBTOOL l $CC $CFLAGS $LDFLAGS -o main$EXEEXT main.lo ]dnl
70          [liba.la], [], [ignore], [ignore])
71 AT_CHECK([$LIBTOOL execute --dry-run ./main$EXEEXT],
72          [], [ignore], [ignore])
73 AT_CHECK([$LIBTOOL exe --dry-run ./main$EXEEXT],
74          [], [ignore], [ignore])
75 AT_CHECK([$LIBTOOL e --dry-run ./main$EXEEXT],
76          [], [ignore], [ignore])
77 AT_CHECK([$LIBTOOL install cp liba.la $libdir],
78          [], [ignore], [ignore])
79 AT_CHECK([$LIBTOOL i cp main$EXEEXT $bindir],
80          [], [ignore], [ignore])
81 AT_CHECK([$LIBTOOL finish $libdir],
82          [], [ignore], [ignore])
83 AT_CHECK([$LIBTOOL f $libdir],
84          [], [ignore], [ignore])
85 AT_CHECK([$LIBTOOL uninstall rm -f $libdir/liba.la],
86          [], [ignore], [ignore])
87 AT_CHECK([$LIBTOOL u rm -f $bindir/main$EXEEXT],
88          [], [ignore], [ignore])
89 AT_CHECK([$LIBTOOL clean rm -f main$EXEEXT],
90          [], [ignore], [ignore])
91 AT_CHECK([$LIBTOOL cl liba.la],
92          [], [ignore], [ignore])
93
94 AT_CLEANUP
95
96
97 AT_SETUP([debug tracing])
98
99 AT_DATA([a.c],
100 [[int a () { return 0; }
101 ]])
102
103 AT_DATA([b.c],
104 [[extern int a ();
105 int b () { return a (); }
106 ]])
107
108 AT_DATA([main.c],
109 [[extern int b ();
110 int main () { return b (); }
111 ]])
112
113 inst=`pwd`/inst
114 libdir=$inst/lib
115 bindir=$inst/bin
116 mkdir $inst $libdir $bindir
117
118 # This test will not work correctly if --debug is passed.
119 AT_CHECK([case "$LIBTOOL $CC $CPPFLAGS $CFLAGS $LDFLAGS " in ]dnl
120          [  *\ --debug\ *) exit 77;; *) :;; esac])
121
122 check_trace ()
123 {
124   if test "X$trace" = X--debug; then
125     AT_CHECK([grep 'enabling shell trace mode' stdout stderr], [0], [ignore])
126     AT_CHECK([grep ' --mode' stderr], [0], [ignore])
127   else
128     AT_CHECK([grep 'enabling shell trace mode' stdout stderr], [1])
129     AT_CHECK([grep ' --mode' stderr], [1])
130   fi
131 }
132
133 orig_LIBTOOL=$LIBTOOL
134 for trace in '' --debug; do
135   LIBTOOL="$orig_LIBTOOL $trace"
136
137   # Hypothesis: debug output should happen if (and only if) --debug is
138   # passed, for compile, link, install, uninstall, and clean modes.
139   AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a.c],
140            [], [stdout], [stderr])
141   check_trace
142   AT_CHECK([$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c b.c],
143            [], [stdout], [stderr])
144   check_trace
145   AT_CHECK([$CC $CPPFLAGS $CFLAGS -c main.c], [], [ignore], [ignore])
146   AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba.la a.lo ]dnl
147            [ -no-undefined -rpath $libdir], [], [stdout], [stderr])
148   check_trace
149   AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o libb.la b.lo ]dnl
150            [ -no-undefined -rpath $libdir liba.la], [], [stdout], [stderr])
151   check_trace
152   AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main$EXEEXT main.$OBJEXT ]dnl
153            [libb.la], [], [stdout], [stderr])
154   check_trace
155   LT_AT_NOINST_EXEC_CHECK([./main], [], [], [stdout], [stderr])
156   check_trace
157
158   AT_CHECK([$LIBTOOL --mode=install cp liba.la libb.la $libdir],
159            [], [stdout], [stderr])
160   check_trace
161
162   # Hypothesis: --debug should be passed to relink mode if (and only if)
163   # it was passed at link mode.
164   AT_CHECK([$orig_LIBTOOL --mode=install $lt_INSTALL liba.la libb.la $libdir],
165            [], [stdout], [stderr])
166   if grep ': relinking ' stdout stderr; then
167     if test "X$trace" = X--debug; then
168       AT_CHECK([grep ' --mode=relink' stdout stderr | grep ' --debug '],
169                [0], [ignore])
170     else
171       AT_CHECK([grep ' --mode=relink' stdout stderr | grep ' --debug '],
172                [1])
173     fi
174   fi
175
176   AT_CHECK([$LIBTOOL --mode=install cp main$EXEEXT $bindir],
177            [], [stdout], [stderr])
178   check_trace
179   AT_CHECK([$LIBTOOL --mode=finish $bindir], [], [stdout], [stderr])
180   check_trace
181
182   AT_CHECK([$LIBTOOL --mode=uninstall rm -f $bindir/main$EXEEXT ]dnl
183            [$libdir/libb.la $libdir/liba.la], [], [stdout], [stderr])
184   check_trace
185   AT_CHECK([$LIBTOOL --mode=clean rm -f $bindir/main$EXEEXT ]dnl
186            [$libdir/libb.la $libdir/liba.la], [], [stdout], [stderr])
187   check_trace
188
189 done
190
191 AT_CLEANUP