1 # cdemo.at -- Using Automake to build a program and library -*- Autotest -*-
3 # Copyright (C) 2003-2004, 2011-2019, 2021-2024 Free Software
5 # Written by Gary V. Vaughan, 2003
7 # This file is part of GNU Libtool.
9 # GNU Libtool is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation; either version 2 of
12 # the License, or (at your option) any later version.
14 # GNU Libtool is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with GNU Libtool; see the file COPYING. If not, a copy
21 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
22 # or obtained by writing to the Free Software Foundation, Inc.,
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 AT_BANNER([Convenience libraries.])
32 m4_define([_LT_SETUP],
33 [AT_DATA([configure.ac],
34 [[AC_INIT([cdemo], ]AT_PACKAGE_VERSION[, ]AT_PACKAGE_BUGREPORT[)
35 AC_CONFIG_AUX_DIR([build-aux])
36 AC_CONFIG_MACRO_DIRS([m4])
40 AC_SUBST([LIBTOOL_DEPS])
42 AC_CONFIG_FILES([Makefile])
43 AC_CONFIG_HEADERS([config.h:config.in.h])
47 AT_DATA([Makefile.am],
48 [[AUTOMAKE_OPTIONS = no-dependencies foreign
49 ACLOCAL_AMFLAGS = -I m4
51 noinst_LTLIBRARIES = libfoo.la
52 libfoo_la_SOURCES = foo.c
53 libfoo_la_LIBADD = $(LIBM)
54 libfoo_la_LDFLAGS = -no-undefined
55 noinst_HEADERS = foo.h
58 cdemo_SOURCES = main.c
59 cdemo_LDADD = libfoo.la
61 libtool: $(LIBTOOL_DEPS)
62 $(SHELL) ./config.status --recheck
69 /* Silly constants that the functions return. */
70 #define HELLO_RET 0xe110
88 printf ("cos (0.0) = %g\n", (double) cos ((double) 0.0));
93 printf ("** This is libfoo **\n");
107 printf ("Welcome to GNU libtool cdemo!\n");
110 printf ("hello returned: %i\n", value);
111 if (value == HELLO_RET)
112 printf("hello is ok!\n");
114 if (foo () == FOO_RET)
115 printf("foo is ok!\n");
121 LT_AT_HOST_DATA([expout],
122 [[Welcome to GNU libtool cdemo!
124 hello returned: 57616
136 AT_SETUP([build and link against a static library])
140 LT_AT_CHECK_CONFIG([--disable-shared],
141 [^build_old_libs=yes], [^build_libtool_libs=no])
142 LT_AT_CHECK_EXECUTE([], [./cdemo])
151 AT_SETUP([build and link against a dynamic library])
155 LT_AT_CHECK_CONFIG([--disable-static],
156 [^build_old_libs=no], [^build_libtool_libs=yes])
157 LT_AT_CHECK_EXECUTE([], [./cdemo])
166 AT_SETUP([build both static and dynamic])
170 LT_AT_CHECK_CONFIG([],
171 [^build_old_libs=yes], [^build_libtool_libs=yes])
172 LT_AT_CHECK_EXECUTE([], [./cdemo])
181 AT_SETUP([allow_undefined_flag])
185 LT_AT_CHECK_CONFIG([--disable-static])
187 AT_CHECK([$EGREP "^allow_undefined_flag=.\{0,1}unsupported.\{0,1}$" libtool && (exit 77)],
190 $SED 's|allow_undefined=no|allow_undefined=yes|g' libtool > ltnew && mv -f ltnew libtool
192 LT_AT_CHECK_EXECUTE([], [./cdemo])