Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / am-subdir.at
1 # am-subdir.at -- libtool subdir-objects support              -*- Autotest -*-
2
3 #   Copyright (C) 2004, 2008 Free Software Foundation, Inc.
4 #   Written by Gary V. Vaughan, 2004
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
26 AT_BANNER([Libtool subdir-objects support.])
27
28
29 ## ----------- ##
30 ## C Language. ##
31 ## ----------- ##
32
33 AT_SETUP([C subdir-objects])
34
35 AT_DATA([[configure.ac]],
36 [[AC_INIT([subdir-demo], ]]AT_PACKAGE_VERSION[[, ]]AT_PACKAGE_BUGREPORT[[)
37 AM_INIT_AUTOMAKE
38 LT_INIT([win32-dll])
39 AC_PROG_CC
40 AM_PROG_CC_C_O
41 AC_CONFIG_FILES([Makefile])
42 AC_OUTPUT
43 ]])
44
45 AT_DATA([[Makefile.am]],
46 [[ACLOCAL_AMFLAGS = -I m4
47 AUTOMAKE_OPTIONS = subdir-objects foreign 1.6
48 AM_CPPFLAGS     = -I$(top_srcdir)/../..
49
50 lib_LTLIBRARIES         = subdir/libsub.la
51 subdir_libsub_la_SOURCES= subdir/sub.c
52
53 bin_PROGRAMS            = subdir/subdemo
54 subdir_subdemo_SOURCES  = subdir/main.c
55 subdir_subdemo_LDADD    = subdir/libsub.la
56 ]])
57
58 test -d subdir || { rm -f subdir && mkdir subdir; }
59
60 AT_DATA([[subdir/main.c]],
61 [[#include <stdio.h>
62
63 extern void sub (void);
64
65 int main (void)
66 {
67   printf ("Welcome to GNU Libtool subdir-objects test!\n");
68   sub();
69   return 0;
70 }
71 ]])
72
73 AT_DATA([[subdir/sub.c]],
74 [[#include <stdio.h>
75 void sub (void) { printf ("** This is libsub **\n"); }
76 ]])
77
78 LT_AT_BOOTSTRAP([--copy], [-I m4], [ignore], [--add-missing])
79
80 LT_AT_EXEC_CHECK([subdir/subdemo], 0, stdout)
81 AT_CHECK([grep 'Welcome to GNU Libtool subdir-objects test' stdout],
82          [], [ignore])
83 AT_CHECK([grep 'This is libsub' stdout],
84          [], [ignore])
85
86 AT_CLEANUP
87
88
89 ## ------------- ##
90 ## C++ Language. ##
91 ## ------------- ##
92
93 AT_SETUP([C++ subdir-objects])
94 LT_AT_TAG([CXX])
95
96 AT_DATA([[configure.ac]],
97 [[AC_INIT([subdir-demo], ]]AT_PACKAGE_VERSION[[, ]]AT_PACKAGE_BUGREPORT[[)
98 AM_INIT_AUTOMAKE
99 AC_PROG_CC
100 AM_PROG_CC_C_O
101 AC_PROG_CXX
102 AC_PROG_CXXCPP
103
104 AC_LANG([C++])
105 LT_INIT([win32-dll])
106
107 AC_CONFIG_FILES([Makefile])
108 AC_OUTPUT
109 ]])
110
111 AT_DATA([[Makefile.am]],
112 [[ACLOCAL_AMFLAGS = -I m4
113 AUTOMAKE_OPTIONS = subdir-objects foreign 1.6
114 AM_CPPFLAGS     = -I$(top_srcdir)/../..
115
116 lib_LTLIBRARIES         = subdir/libsub.la
117 subdir_libsub_la_SOURCES= subdir/sub.cxx subdir/sub.hxx
118
119 bin_PROGRAMS            = subdir/subdemo
120 subdir_subdemo_SOURCES  = subdir/main.cxx
121 subdir_subdemo_LDADD    = subdir/libsub.la
122 ]])
123
124 test -d subdir || { rm -f subdir && mkdir subdir; }
125
126 AT_DATA([[subdir/sub.hxx]],
127 [[class libsub { public: int sub (void); };
128 ]])
129
130 AT_DATA([[subdir/main.cxx]],
131 [[#include "sub.hxx"
132
133 int main (void)
134 {
135   libsub SUB;
136   return SUB.sub() != 27;
137 }
138 ]])
139
140 AT_DATA([[subdir/sub.cxx]],
141 [[#include "sub.hxx"
142
143 int libsub::sub (void) { return 27; }
144 ]])
145
146 LT_AT_BOOTSTRAP([--copy], [-I m4], [ignore], [--add-missing])
147
148 LT_AT_EXEC_CHECK([subdir/subdemo], 0)
149
150 AT_CLEANUP