1 # configure-iface.at -- test ltdl configure interface -*- Autotest -*-
3 # Copyright (C) 2007, 2008 Free Software Foundation, Inc.
4 # Written by Gary V. Vaughan, 2007
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([configure interface to libltdl.])
29 m4_pushdef([_LT_AT_LTDL_SETUP],
34 typedef int funcp (void);
36 static int errors = 0;
43 LTDL_SET_PRELOADED_SYMBOLS();
45 if (lt_dlinit () != 0)
47 fprintf (stderr, "error during initialization: %s\n", lt_dlerror ());
51 handle = lt_dlopenext ("libmodule");
54 fprintf (stderr, "can't open libmodule: %s\n", lt_dlerror ());
59 funcp *f = (funcp *) lt_dlsym (handle, "f");
63 printf ("%d\n", f ());
67 fprintf (stderr, "function `f' not found: %s\n", lt_dlerror ());
72 if (lt_dlexit () != 0)
74 fprintf (stderr, "error during exit: %s\n", lt_dlerror ());
82 AT_DATA([libmodule.c],
86 int f (void) { return 5150; }
92 LT_AT_HOST_DATA([expout],
98 ## -------------------- ##
99 ## Installable libltdl. ##
100 ## -------------------- ##
102 AT_SETUP([installable libltdl])
103 AT_KEYWORDS([libltdl])
107 AT_DATA([configure.ac],
108 [[AC_INIT([installable-ltdl-demo], ]AT_PACKAGE_VERSION[, ]AT_PACKAGE_BUGREPORT[)
109 AC_CONFIG_AUX_DIR([libltdl/config])
110 AC_CONFIG_MACRO_DIR([libltdl/m4])
111 AC_CONFIG_HEADERS([config.h:config.hin])
112 LT_CONFIG_LTDL_DIR([libltdl])
113 AM_INIT_AUTOMAKE([foreign])
117 LTDL_INIT([installable])
118 AC_CONFIG_FILES([Makefile])
122 AT_DATA([Makefile.am],
123 [[AUTOMAKE_OPTIONS = 1.7
127 AM_CPPFLAGS = $(LTDLINCL)
129 lib_LTLIBRARIES = libmodule.la
130 # Automake < 1.8 will use libmodule.la.c as default source,
131 # while newer will choose libmodule.c; so specify it here.
132 libmodule_la_SOURCES = libmodule.c
133 libmodule_la_LDFLAGS = -module
136 main_LDFLAGS = -dlopen libmodule.la
137 main_LDADD = $(LIBLTDL)
138 main_DEPENDENCIES = $(LTDLDEPS) libmodule.la
141 # Install everything!
144 LT_AT_BOOTSTRAP([--ltdl], [-I libltdl/m4], [], [--add-missing], [],
145 [--with-included-ltdl --prefix=$prefix], [all install])
147 # TODO: Check that the installed program `main' is linked against our libltdl
148 AT_CHECK([test -f $prefix/lib/libltdl.la])
149 AT_CHECK([test -f $prefix/include/ltdl.h])
151 # Check that main is rebuilt if libltdl.la is newer
152 rm -f libltdl/libltdl.la
153 AT_CHECK([$MAKE -q main$EXEEXT || exit 1], [1], [ignore], [ignore])
158 ## ------------------------------- ##
159 ## Link against installed libltdl. ##
160 ## ------------------------------- ##
162 AT_SETUP([--with-ltdl-include/lib])
163 AT_KEYWORDS([libltdl])
168 LT_AT_LIBTOOLIZE([--copy --ltdl=ltdl])
171 LT_AT_CONFIGURE([--enable-ltdl-install --prefix=$prefix])
172 LT_AT_MAKE([all install])
178 AT_CHECK([test -f $prefix/lib/libltdl.la])
179 AT_CHECK([test -f $prefix/include/ltdl.h])
183 AT_DATA([configure.ac],
184 [[AC_INIT([configure-iface-demo], ]AT_PACKAGE_VERSION[, ]AT_PACKAGE_BUGREPORT[)
185 AC_CONFIG_MACRO_DIR([_inst/aclocal])
186 AC_CONFIG_HEADERS([config.h:config.hin])
187 AM_INIT_AUTOMAKE([foreign])
192 AC_CONFIG_FILES([Makefile])
196 AT_DATA([Makefile.am],
197 [[AUTOMAKE_OPTIONS = 1.7
199 AM_CPPFLAGS = $(LTDLINCL)
201 lib_LTLIBRARIES = libmodule.la
202 # Automake < 1.8 will use libmodule.la.c as default source,
203 # while newer will choose libmodule.c; so specify it here.
204 libmodule_la_SOURCES = libmodule.c
205 libmodule_la_LDFLAGS = -module
208 main_LDFLAGS = -dlopen libmodule.la
209 main_LDADD = $(LIBLTDL)
210 main_DEPENDENCIES = $(LTDLDEPS) libmodule.la
213 ## Try to avoid linking against a previously installed libltdl found
214 ## with an explicit -L/path.
215 save_LDFLAGS=$LDFLAGS
217 for l in $save_LDFLAGS
221 *) LDFLAGS="$LDFLAGS $l" ;;
225 # We don't use 'libtoolize --ltdl', so that we get an error if the test
226 # tries to build and link against its own ltdl sources:
227 LT_AT_BOOTSTRAP([], [-I _inst/aclocal], [], [--add-missing], [],
228 [--with-ltdl-lib=$prefix/lib --with-ltdl-include=$prefix/include],
231 ## TODO: portable ldd check for correct libltdl
232 ## Currently, this test doesn't fail if `main' ends up linking against a
233 ## previously installed system libltdl.
234 LT_AT_NOINST_EXEC_CHECK([./main], [-dlopen libmodule.la], [], [expout], [])
239 ## ------------------------------------- ##
240 ## Link against shipped libltdl sources. ##
241 ## ------------------------------------- ##
243 AT_SETUP([--with-included-ltdl])
244 AT_KEYWORDS([libltdl])
248 AT_DATA([configure.ac],
249 [[AC_INIT([configure-iface-demo], ]AT_PACKAGE_VERSION[, ]AT_PACKAGE_BUGREPORT[)
250 AC_CONFIG_AUX_DIR([libltdl/config])
251 AC_CONFIG_MACRO_DIR([libltdl/m4])
252 AC_CONFIG_HEADERS([config.h:config.hin])
253 LT_CONFIG_LTDL_DIR([libltdl])
254 AM_INIT_AUTOMAKE([foreign])
259 AC_CONFIG_FILES([Makefile])
263 AT_DATA([Makefile.am],
264 [[AUTOMAKE_OPTIONS = 1.7
268 AM_CPPFLAGS = $(LTDLINCL)
270 lib_LTLIBRARIES = libmodule.la
271 # Automake < 1.8 will use libmodule.la.c as default source,
272 # while newer will choose libmodule.c; so specify it here.
273 libmodule_la_SOURCES = libmodule.c
274 libmodule_la_LDFLAGS = -module
277 main_LDFLAGS = -dlopen libmodule.la
278 main_LDADD = $(LIBLTDL)
279 main_DEPENDENCIES = $(LTDLDEPS) libmodule.la
282 LT_AT_BOOTSTRAP([--ltdl], [-I libltdl/m4], [], [--add-missing], [],
283 [--with-included-ltdl], [all])
285 # --with-included-ltdl should build a convenience lib by default
286 AT_CHECK([test -f libltdl/libltdlc.la])
288 ## TODO: portable ldd check for correct libltdl
289 ## Currently, this test doesn't fail if `main' ends up linking against a
290 ## previously installed system libltdl.
291 LT_AT_NOINST_EXEC_CHECK([./main], [-dlopen libmodule.la], [], [expout], [])
293 # Check that main is rebuilt if libltdlc.la is newer
294 rm -f libltdl/libltdlc.la
295 AT_CHECK([$MAKE -q main$EXEEXT || exit 1], [1], [ignore], [ignore])
300 ## -------------------- ##
301 ## Convenience libltdl. ##
302 ## -------------------- ##
304 AT_SETUP([convenience libltdl])
306 AT_DATA([configure.ac],
308 AC_CONFIG_AUX_DIR([libltdl/config])
309 AC_LIBLTDL_CONVENIENCE
312 AC_CONFIG_FILES(Makefile)
315 AT_DATA([Makefile.in],
316 [[LIBLTDL = @LIBLTDL@
321 LT_AT_BOOTSTRAP([--ltdl], [-I libltdl/m4], [ignore], [ignore], [], [], [ignore])
322 AT_CHECK([$MAKE print-ltdl], [], [stdout], [ignore])
323 AT_CHECK([grep libltdl/libltdlc.la stdout], [], [ignore])
327 dnl Be careful not to let the definition leak into other tests
328 m4_popdef([_LT_AT_LTDL_SETUP])