Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / early-libtool.at
1 # early-libtool.at -- early libtool script generation         -*- Autotest -*-
2
3 #   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4 #   Written by Gary V. Vaughan, 2005
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([libtool script generation.])
26
27
28 ## --------------------------------------------- ##
29 ## Building libtool normally from config.status. ##
30 ## --------------------------------------------- ##
31
32 AT_SETUP([config.status])
33
34 AT_DATA([configure.ac],
35 [[AC_INIT([libtool-demo], ]]AT_PACKAGE_VERSION[[, ]]AT_PACKAGE_BUGREPORT[[)
36 AC_CONFIG_MACRO_DIR([m4])
37 LT_INIT
38 AC_CONFIG_FILES([Makefile])
39 AC_OUTPUT
40 ]])
41
42 AT_DATA([Makefile.in],
43 [[prefix = @prefix@
44 libdir = @libdir@
45 top_builddir = .
46 SHELL = @SHELL@
47 DEFAULT_INCLUDES = -I. -I@srcdir@
48 EXEEXT = @EXEEXT@
49 LIBTOOL = @LIBTOOL@
50 OBJEXT = @OBJEXT@
51
52 CPPFLAGS = @CPPFLAGS@
53 CFLAGS = @CFLAGS@
54 LDFLAGS = @LDFLAGS@
55
56 COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFAULT_INCLUDES)
57 LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFAULT_INCLUDES)
58 LINK = $(LIBTOOL) --mode=link --tag=CC $(CC) $(CFLAGS) $(LDFLAGS) -o $@
59
60 all: hell$(EXEEXT)
61
62 libhello.la: hello.lo
63         $(LINK) -rpath $(libdir) hello.lo
64 hell$(EXEEXT): main.$(OBJEXT) libhello.la
65         $(LINK) main.$(OBJEXT) libhello.la
66
67 .SUFFIXES:
68 .SUFFIXES: .c .$(OBJEXT) .lo
69
70 .c.$(OBJEXT):
71         $(COMPILE) -c $<
72 .c.lo:
73         $(LTCOMPILE) -c -o $@ $<
74 ]])
75
76 AT_DATA([hello.c],
77 [[#include <stdio.h>
78
79 void
80 hello (void)
81 {
82   printf ("** This is not GNU Hello.  There is no built-in mail reader. **\n");
83 }
84 ]])
85
86 AT_DATA([main.c],
87 [[#include <stdio.h>
88
89 extern void hello (void);
90
91 int
92 main (void)
93 {
94   printf ("Welcome to GNU Hell!\n");
95
96   hello ();
97
98   return 0;
99 }
100 ]])
101
102 cat > missing <<_EOF
103 #! /bin/sh
104 exit 0
105 _EOF
106 chmod a+x missing
107
108 LT_AT_LIBTOOLIZE([--copy --verbose --install])
109 LT_AT_ACLOCAL([-I m4])
110 LT_AT_AUTOCONF([--force])
111 LT_AT_CONFIGURE
112 LT_AT_MAKE
113
114 LT_AT_EXEC_CHECK([./hell], [0], [stdout])
115 AT_CHECK([grep 'Welcome to GNU Hell' stdout], [], [ignore])
116 AT_CHECK([grep 'This is not GNU Hello.' stdout],
117          [], [ignore])
118
119 AT_CLEANUP
120
121
122 ## ------------------------------------------ ##
123 ## Building and using libtool from config.lt. ##
124 ## ------------------------------------------ ##
125
126 AT_SETUP([config.lt])
127
128 AT_DATA([configure.ac],
129 [[AC_INIT([libtool-demo], ]]AT_PACKAGE_VERSION[[, ]]AT_PACKAGE_BUGREPORT[[)
130 AC_CONFIG_MACRO_DIR([m4])
131 LT_INIT
132 LT_OUTPUT
133
134 cat >hello.c <<\_EOF
135 #include <stdio.h>
136
137 void
138 hello (void)
139 {
140   printf ("** This is not GNU Hello.  There is no built-in mail reader. **\n");
141 }
142 _EOF
143
144 # Prove that we can run libtool from inside configure:
145 $SHELL ./libtool --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS \
146     -I. -I$srcdir -c -o hello.lo hello.c  || exit 1
147 $SHELL ./libtool --mode=link --tag=CC $CC $CFLAGS $LDFLAGS \
148     -o libhello.la -rpath /notexist hello.lo || exit 1
149
150 AC_CONFIG_FILES([Makefile])
151 AC_OUTPUT
152 ]])
153
154 AT_DATA([Makefile.in],
155 [[prefix = @prefix@
156 libdir = @libdir@
157 top_builddir = .
158 SHELL = @SHELL@
159 DEFAULT_INCLUDES = -I. -I@srcdir@
160 EXEEXT = @EXEEXT@
161 LIBTOOL = @LIBTOOL@
162 OBJEXT = @OBJEXT@
163
164 CPPFLAGS = @CPPFLAGS@
165 CFLAGS = @CFLAGS@
166 LDFLAGS = @LDFLAGS@
167
168 COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFAULT_INCLUDES)
169 LINK = $(LIBTOOL) --mode=link --tag=CC $(CC) $(CFLAGS) $(LDFLAGS) -o $@
170
171 all: hell$(EXEEXT)
172
173 hell$(EXEEXT): main.$(OBJEXT) libhello.la
174         $(LINK) main.$(OBJEXT) libhello.la
175
176 .SUFFIXES:
177 .SUFFIXES: .c .$(OBJEXT)
178
179 .c.$(OBJEXT):
180         $(COMPILE) -c $<
181 ]])
182
183 AT_DATA([hello.c],
184 [[#include <stdio.h>
185
186 void
187 hello (void)
188 {
189   printf ("** This is not GNU Hello.  There is no built-in mail reader. **\n");
190 }
191 ]])
192
193 AT_DATA([main.c],
194 [[#include <stdio.h>
195
196 extern void hello (void);
197
198 int
199 main (int argc, char *argv[])
200 {
201   printf ("Welcome to GNU Hell!\n");
202
203   hello ();
204
205   return 0;
206 }
207 ]])
208
209 cat > missing <<_EOF
210 #! /bin/sh
211 exit 0
212 _EOF
213 chmod a+x missing
214
215 LT_AT_LIBTOOLIZE([--copy --verbose --install])
216 LT_AT_ACLOCAL([-I m4])
217 LT_AT_AUTOCONF([--force])
218 LT_AT_CONFIGURE
219 LT_AT_MAKE
220
221 LT_AT_EXEC_CHECK([./hell], [0], [stdout])
222 AT_CHECK([grep 'Welcome to GNU Hell' stdout], [], [ignore])
223 AT_CHECK([grep 'This is not GNU Hello.' stdout], [], [ignore])
224
225 # Make sure config.status --recheck updates the libtool script
226 rm libtool
227 AT_CHECK([$SHELL ./config.status --recheck],[0],[ignore],[ignore])
228
229 AT_CLEANUP