source: trunk/test/yat_lt_link_la_ifelse_test.sh @ 3036

Last change on this file since 3036 was 3036, checked in by Peter, 8 years ago

common_defs does two things: 1) init test scripts 2) defines some variables. Decouple these into two files: defs.sh and init.sh.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
1#! /bin/sh
2# $Id: yat_lt_link_la_ifelse_test.sh 3036 2013-06-03 08:19:32Z peter $
3#
4# Copyright (C) 2013 Peter Johansson
5#
6# This file is part of the yat library, http://dev.thep.lu.se/yat
7#
8# The yat library is free software; you can redistribute it
9# and/or modify it under the terms of the GNU General Public License as
10# published by the Free Software Foundation; either version 3 of the
11# License, or (at your option) any later version.
12#
13# The yat library 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 GNU
16# General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with yat. If not, see <http://www.gnu.org/licenses/>.
20
21required="autoconf automake libtool"
22set -e
23. ./test/init.sh || exit 99
24
25# create a static and shared libraries
26rm -frv yat3rd/*
27$mkdir_p yat3rd/static
28$mkdir_p yat3rd/shared
29$mkdir_p yat3rd/m4
30cd yat3rd
31
32cat > configure.ac <<EOF
33AC_INIT([yat3rd], [1.0])
34AC_CONFIG_MACRO_DIR([m4])
35AM_INIT_AUTOMAKE([foreign])
36AC_LANG([C++])
37AC_PROG_CXXCPP
38AC_PROG_CXX
39LT_INIT
40AC_CONFIG_FILES([Makefile static/Makefile shared/Makefile])
41AC_OUTPUT
42EOF
43
44cat > Makefile.am <<EOF
45ACLOCAL_AMFLAGS = -I m4
46SUBDIRS = static shared
47EOF
48
49cat > static/Makefile.am <<EOF
50lib_LIBRARIES = libyatfoo.a
51libyatfoo_a_SOURCES = foo.cc
52EOF
53
54cat > static/foo.cc <<EOF
55int foo(void) { return 0; }
56EOF
57
58cat > shared/Makefile.am <<EOF
59lib_LTLIBRARIES = libyatbar.la
60libyatbar_la_SOURCES = bar.cc
61AM_LDFLAGS = -shared
62EOF
63
64cat > shared/bar.cc <<EOF
65int bar(void) { return 0; }
66EOF
67
68bootstrap
69./configure --libdir=${abs_top_builddir}/${test_dir}/lib
70make install
71
72cd ..
73
74ls lib
75
76test -r lib/libyatfoo.a || exit_fail no static yatfoo
77test -r lib/libyatbar.la || exit_fail no shared yatbar
78test -r lib/libbar.a && exit_fail
79
80cat > configure.ac <<EOF
81AC_INIT([hello], [1.0])
82AC_CONFIG_MACRO_DIR([m4])
83AM_INIT_AUTOMAKE([foreign])
84AC_LANG([C++])
85AC_PROG_CXXCPP
86AC_PROG_CXX
87LT_INIT
88
89YAT_USE_LIBTOOL_PUSH
90
91echo =====================================================
92sleep 1
93LDFLAGS="-L`pwd`/lib"
94
95cat > conftest.cc <<___EOF
96int foo(void) { return 0; }
97___EOF
98
99cat conftest.cc
100
101set -x
102
103sh libtool --mode=compile \$CXX \$CXXFLAGS \$LDFLAGS -o conftest.o conftest.cc -static || exit 1
104
105sh libtool --tag=CXX --mode=link \$CXX \$CXXFLAGS \$LDFLAGS -o libconftest.la conftest.o -static || exit 1
106
107
108echo =====================================================
109sleep 2
110
111exit 0
112
113ok=yes
114
115LDFLAGS="-L`pwd`/lib"
116AC_MSG_CHECKING([linking statically against static library])
117LIBS=-lyatfoo
118YAT_LT_LINK_LA_IFELSE([-static],
119                      [AC_MSG_RESULT([OK])],
120                      [ok=no;
121                       AC_MSG_RESULT([failed])
122                       AC_MSG_ERROR([no static -lyatfoo])
123                      ])
124
125AC_MSG_CHECKING([that shared linking fails against static libyatfoo])
126YAT_LT_LINK_LA_IFELSE([-shared],
127                      [ok=no;
128                       AC_MSG_RESULT([no])
129                       AC_MSG_WARN([succesful shared linking against -lyatfoo])
130                      ],
131                      [AC_MSG_RESULT([yes failed])])
132
133LIBS=-lyatbar
134AC_MSG_CHECKING([linking shared against shared library])
135YAT_LT_LINK_LA_IFELSE([-shared], [AC_MSG_RESULT([ok])],
136                      [ok=no;
137                       AC_MSG_RESULT([no])
138                       AC_MSG_WARN([no shared -lyatbar])])
139
140AC_MSG_CHECKING([that static linking fails against shared libyatbar])
141YAT_LT_LINK_LA_IFELSE([-static],
142                      [ok=no;
143                       AC_MSG_RESULT([no])
144                       AC_MSG_WARN([succesful static linking against -lyatbar])
145                      ],
146                      [AC_MSG_RESULT([yes failed])])
147
148AS_VAR_IF([ok], [no], [AC_MSG_ERROR([see WARNINGs above])])
149
150AC_CONFIG_FILES([Makefile])
151AC_OUTPUT
152EOF
153
154bootstrap
155status=0
156./configure || $status=$?
157exit $?
158./configure > stdout 2>stderr || status=$?
159cat stdout
160if test $status != 0; then
161    tail -n 1000 config.log
162    cat stderr >&2
163    exit_fail configure failed
164fi
165
166cat stderr >&2
167exit_success
Note: See TracBrowser for help on using the repository browser.