2 # Copyright (C) 2012 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Demo on Libtool/C++ support.
19 required='libtoolize c++'
20 am_create_testdir=empty
23 cat > configure.ac << 'END'
24 AC_INIT([GNU C++/Libtool Demo], [0.73], [bug-automake@gnu.org])
25 AC_CONFIG_SRCDIR([lib/libfoo.c++])
26 AC_CONFIG_AUX_DIR([ax])
44 cat > Makefile.am <<'END'
47 AUTOMAKE_OPTIONS = parallel-tests
49 SH_LOG_COMPILER = $(SHELL) -ex
53 check-local: test-objs
55 test -f src/main.$(OBJEXT)
59 cat > src/Makefile.am << 'END'
61 zardoz_SOURCES = main.cc
62 zardoz_LDADD = $(top_builddir)/lib/libfoo.la
63 AM_CPPFLAGS = -I$(top_builddir)/lib
66 cat > lib/Makefile.am << 'END'
67 lib_LTLIBRARIES = libfoo.la
68 nodist_libfoo_la_SOURCES = libfoo.h++
69 libfoo_la_SOURCES = libfoo.c++
70 libfoo.h++: $(srcdir)/libfoo.c++
71 echo '#include <string>' >$@-t
72 grep "target *(" "$(srcdir)/libfoo.c++" >>$@-t
74 chmod a-w $@-t && mv -f $@-t $@
75 BUILT_SOURCES = libfoo.h++
76 DISTCLEANFILES = $(BUILT_SOURCES)
82 if test x"$host_alias" = x || test x"$build_alias" = x"$host_alias"; then
84 test "`./src/zardoz`" = 'Howdy, Testsuite!'
86 echo "Skip: cannot run a cross-compiled program"
94 $AUTOMAKE --add-missing --copy
96 ls -l . ax # For debugging.
97 for f in ltmain.sh depcomp config.guess config.sub; do
98 test -f ax/$f && test ! -h ax/$f || Exit 1
100 test ! -f ax/compile # Not required by C++ compilers.
102 cat > src/main.cc << 'END'
103 #include "libfoo.h++"
108 cout << "Howdy, " << target () << "!" << endl;
113 cat > lib/libfoo.c++ << 'END'
114 #include "libfoo.h++"
116 std::string target (void)
118 std::string s1 = "Test";
119 std::string s2 = "suite";
126 ls -l . src lib # For debugging.
128 VERBOSE=yes $MAKE check-TESTS
129 grep 'Howdy.*Testsuite' try.log || grep 'Skip:.*cross-compiled' try.log
131 $MAKE -e CC=false distcheck