ltmain.in: Use func_warning for all warnings
[libtool.git] / tests / cdemo.at
blobca80383af86e8ed23eaf370171bfa00637affbcc
1 # cdemo.at -- Using Automake to build a program and library -*- Autotest -*-
3 #   Copyright (C) 2003-2004, 2011-2019, 2021-2024 Free Software
4 #   Foundation, Inc.
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.
24 ####
27 AT_BANNER([Convenience libraries.])
30 # _LT_SETUP
31 # ---------
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])
37 AM_INIT_AUTOMAKE
38 AC_PROG_CC
39 LT_INIT
40 AC_SUBST([LIBTOOL_DEPS])
41 LT_LIB_M
42 AC_CONFIG_FILES([Makefile])
43 AC_CONFIG_HEADERS([config.h:config.in.h])
44 AC_OUTPUT
45 ]])
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
57 bin_PROGRAMS = cdemo
58 cdemo_SOURCES = main.c
59 cdemo_LDADD = libfoo.la
61 libtool: $(LIBTOOL_DEPS)
62          $(SHELL) ./config.status --recheck
63 ]])
65 AT_DATA([foo.h],
66 [[#ifndef FOO_H
67 #define FOO_H 1
69 /* Silly constants that the functions return. */
70 #define HELLO_RET 0xe110
71 #define FOO_RET 0xf00
73 extern int foo();
75 extern int hello();
77 #endif
78 ]])
80 AT_DATA([foo.c],
81 [[#include <config.h>
82 #include <stdio.h>
83 #include <math.h>
85 #include "foo.h"
87 int foo() {
88   printf ("cos (0.0) = %g\n", (double) cos ((double) 0.0));
89   return FOO_RET;
92 int hello() {
93   printf ("** This is libfoo **\n");
94   return HELLO_RET;
96 ]])
98 AT_DATA([main.c],
99 [[#include <config.h>
100 #include <stdio.h>
101 #include "foo.h"
103 int main ()
105   int value;
107   printf ("Welcome to GNU libtool cdemo!\n");
109   value = hello();
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");
117   return 0;
121 LT_AT_HOST_DATA([expout],
122 [[Welcome to GNU libtool cdemo!
123 ** This is libfoo **
124 hello returned: 57616
125 hello is ok!
126 cos (0.0) = 1
127 foo is ok!
129 ]) # _LT_SETUP
132 ## ------------- ##
133 ## Cdemo static. ##
134 ## ------------- ##
136 AT_SETUP([build and link against a static library])
138 _LT_SETUP
140 LT_AT_CHECK_CONFIG([--disable-shared],
141                    [^build_old_libs=yes], [^build_libtool_libs=no])
142 LT_AT_CHECK_EXECUTE([], [./cdemo])
144 AT_CLEANUP
147 ## ------------- ##
148 ## Cdemo shared. ##
149 ## ------------- ##
151 AT_SETUP([build and link against a dynamic library])
153 _LT_SETUP
155 LT_AT_CHECK_CONFIG([--disable-static],
156                    [^build_old_libs=no], [^build_libtool_libs=yes])
157 LT_AT_CHECK_EXECUTE([], [./cdemo])
159 AT_CLEANUP
162 ## ----------- ##
163 ## Cdemo conf. ##
164 ## ----------- ##
166 AT_SETUP([build both static and dynamic])
168 _LT_SETUP
170 LT_AT_CHECK_CONFIG([],
171                    [^build_old_libs=yes], [^build_libtool_libs=yes])
172 LT_AT_CHECK_EXECUTE([], [./cdemo])
174 AT_CLEANUP
177 ## ------------ ##
178 ## Cdemo undef. ##
179 ## ------------ ##
181 AT_SETUP([allow_undefined_flag])
183 _LT_SETUP
185 LT_AT_CHECK_CONFIG([--disable-static])
187 AT_CHECK([$EGREP "^allow_undefined_flag=.\{0,1}unsupported.\{0,1}$" libtool && (exit 77)],
188           1, [ignore])
190 $SED 's|allow_undefined=no|allow_undefined=yes|g' libtool > ltnew && mv -f ltnew libtool
192 LT_AT_CHECK_EXECUTE([], [./cdemo])
194 AT_CLEANUP