Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / ctor.at
1 # ctor.at -- Test constructors via C++                        -*- Autotest -*-
2 #
3 #   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
4 #   Written by Noah Misch, 2007
5 #
6 #   This file is part of GNU Libtool.
7 #
8 # GNU Libtool is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation; either version 2 of
11 # the License, or (at your option) any later version.
12 #
13 # GNU Libtool 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
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with GNU Libtool; see the file COPYING.  If not, a copy
20 # can be downloaded from  http://www.gnu.org/licenses/gpl.html,
21 # or obtained by writing to the Free Software Foundation, Inc.,
22 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ####
24
25 AT_BANNER([Constructors.])
26
27 AT_SETUP([C++ static constructors])
28 LT_AT_TAG([CXX])
29 AT_KEYWORDS([libtool])
30
31 AT_DATA(class.h,
32 [[#define magic 0xaabbccdd
33 class Foo {
34 public:
35         Foo() { bar = magic; }
36         unsigned bar;
37 };
38
39 extern Foo instance;
40 ]])
41
42 AT_DATA(libctor.cpp,
43 [[#include "class.h"
44 Foo instance;
45 ]])
46
47 AT_DATA(main.cpp,
48 [[#include "class.h"
49
50 int main(void)
51 {
52   return instance.bar != magic;
53 }
54 ]])
55
56 AT_CHECK([$LIBTOOL --tag=CXX --mode=compile $CXX $CPPFLAGS $CXXFLAGS \
57           -c libctor.cpp -o libctor.lo], [0], [ignore], [ignore])
58 AT_CHECK([$LIBTOOL --tag=CXX --mode=compile $CXX $CPPFLAGS $CXXFLAGS \
59           -c main.cpp -o main.lo], [0], [ignore], [ignore])
60 AT_CHECK([$LIBTOOL --tag=CXX --mode=link $CXX $CXXFLAGS $LDFLAGS \
61           libctor.lo -o libctor.la -rpath /none], [0], [ignore], [ignore])
62 AT_CHECK([$LIBTOOL --tag=CXX --mode=link $CXX $CXXFLAGS $LDFLAGS \
63           main.lo libctor.la -o main$EXEEXT], [0], [ignore], [ignore])
64
65 LT_AT_EXEC_CHECK([./main], [0])
66
67 AT_CLEANUP