summaryrefslogtreecommitdiff
path: root/tests/am-subdir.at
blob: 5d5dfcd20114009f11452c8155c4f131b49b198d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# am-subdir.at -- libtool subdir-objects support              -*- Autotest -*-

#   Copyright (C) 2004, 2008, 2011-2015 Free Software Foundation, Inc.
#   Written by Gary V. Vaughan, 2004
#
#   This file is part of GNU Libtool.
#
# GNU Libtool is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# GNU Libtool is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Libtool; see the file COPYING.  If not, a copy
# can be downloaded from  http://www.gnu.org/licenses/gpl.html,
# or obtained by writing to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
####


AT_BANNER([Libtool subdir-objects support.])


## ----------- ##
## C Language. ##
## ----------- ##

AT_SETUP([C subdir-objects])

AT_DATA([[configure.ac]],
[[AC_INIT([subdir-demo], ]]AT_PACKAGE_VERSION[[, ]]AT_PACKAGE_BUGREPORT[[)
AM_INIT_AUTOMAKE
LT_INIT([win32-dll])
AC_PROG_CC
AM_PROG_CC_C_O
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
]])

AT_DATA([[Makefile.am]],
[[ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = subdir-objects foreign 1.6
AM_CPPFLAGS	= -I$(top_srcdir)/../..

lib_LTLIBRARIES		= subdir/libsub.la
subdir_libsub_la_SOURCES= subdir/sub.c

bin_PROGRAMS		= subdir/subdemo
subdir_subdemo_SOURCES	= subdir/main.c
subdir_subdemo_LDADD	= subdir/libsub.la
]])

test -d subdir || { rm -f subdir && mkdir subdir; }

AT_DATA([[subdir/main.c]],
[[#include <stdio.h>

extern void sub (void);

int main (void)
{
  printf ("Welcome to GNU Libtool subdir-objects test!\n");
  sub();
  return 0;
}
]])

AT_DATA([[subdir/sub.c]],
[[#include <stdio.h>
void sub (void) { printf ("** This is libsub **\n"); }
]])

LT_AT_BOOTSTRAP([--copy], [-I m4], [ignore], [--add-missing])

LT_AT_EXEC_CHECK([subdir/subdemo], 0, stdout)
AT_CHECK([$GREP 'Welcome to GNU Libtool subdir-objects test' stdout],
	 [], [ignore])
AT_CHECK([$GREP 'This is libsub' stdout],
	 [], [ignore])

AT_CLEANUP


## ------------- ##
## C++ Language. ##
## ------------- ##

AT_SETUP([C++ subdir-objects])
LT_AT_TAG([CXX])

AT_DATA([[configure.ac]],
[[AC_INIT([subdir-demo], ]]AT_PACKAGE_VERSION[[, ]]AT_PACKAGE_BUGREPORT[[)
AM_INIT_AUTOMAKE
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CXX
AC_PROG_CXXCPP

AC_LANG([C++])
LT_INIT([win32-dll])

AC_CONFIG_FILES([Makefile])
AC_OUTPUT
]])

AT_DATA([[Makefile.am]],
[[ACLOCAL_AMFLAGS = -I m4
AUTOMAKE_OPTIONS = subdir-objects foreign 1.6
AM_CPPFLAGS	= -I$(top_srcdir)/../..

lib_LTLIBRARIES		= subdir/libsub.la
subdir_libsub_la_SOURCES= subdir/sub.cxx subdir/sub.hxx

bin_PROGRAMS		= subdir/subdemo
subdir_subdemo_SOURCES	= subdir/main.cxx
subdir_subdemo_LDADD	= subdir/libsub.la
]])

test -d subdir || { rm -f subdir && mkdir subdir; }

AT_DATA([[subdir/sub.hxx]],
[[class libsub { public: int sub (void); };
]])

AT_DATA([[subdir/main.cxx]],
[[#include "sub.hxx"

int main (void)
{
  libsub SUB;
  return SUB.sub() != 27;
}
]])

AT_DATA([[subdir/sub.cxx]],
[[#include "sub.hxx"

int libsub::sub (void) { return 27; }
]])

LT_AT_BOOTSTRAP([--copy], [-I m4], [ignore], [--add-missing])

LT_AT_EXEC_CHECK([subdir/subdemo], 0)

AT_CLEANUP