2 # Copyright (C) 2012-2013 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 # Ideally, the 'compile' script should not be required by C++ compilers.
98 # But alas, LT_INIT seems to invoke AC_PROG_CC anyway, and that brings in
100 for f in ltmain.sh depcomp compile config.guess config.sub; do
101 test -f ax/$f && test ! -h ax/$f || exit 1
104 cat > src/main.cc << 'END'
105 #include "libfoo.h++"
110 cout << "Howdy, " << target () << "!" << endl;
115 cat > lib/libfoo.c++ << 'END'
116 #include "libfoo.h++"
117 std::string target (void)
119 std::string s1 = "Test";
120 std::string s2 = "suite";
127 ls -l . src lib # For debugging.
129 VERBOSE=yes $MAKE check-TESTS
130 grep 'Howdy.*Testsuite' try.log || grep 'Skip:.*cross-compiled' try.log