Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / old-m4-iface.at
1 # old-m4-iface.at -- exercise old m4 interface to libtool     -*- Autotest -*-
2 #
3 #   Copyright (C) 2005, 2008, 2009 Free Software Foundation, Inc.
4 #   Written by Gary V. Vaughan, 2005
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([Support for older m4 interface.])
27
28 ########################################################################
29 ##
30 ## TODO:
31 ##   test all the interfaces currently supported by AU_DEFUN/AU_ALIAS
32 ##   test autoupdate on all of those tests' configure.in
33 ##
34 ########################################################################
35
36 ## -------------------------------------------------------- ##
37 ## An overtly simple old-school AM_PROG_LIBTOOL invocation. ##
38 ## -------------------------------------------------------- ##
39
40 AT_SETUP([AM_PROG_LIBTOOL])
41
42 AT_DATA([configure.in],
43 [[AC_INIT(old.c)
44 AM_PROG_LIBTOOL
45 AC_SUBST([LIBTOOL_DEPS])
46 AC_OUTPUT(Makefile)
47 ]])
48
49 AT_DATA([Makefile.in],
50 [[COMPILE = @CC@ @CPPFLAGS@ @CFLAGS@
51 LINK      = @CC@ @CFLAGS@ @LDFLAGS@ -o $@
52 SHELL     = @SHELL@
53 LIBTOOL_DEPS = @LIBTOOL_DEPS@
54
55 all: libtool old@EXEEXT@
56
57 old@EXEEXT@: old.@OBJEXT@
58         $(LINK) old.@OBJEXT@
59
60 .SUFFIXES:
61 .SUFFIXES: .c .@OBJEXT@
62
63 .c.@OBJEXT@:
64         $(COMPILE) -c $<
65
66 libtool: $(LIBTOOL_DEPS)
67         $(SHELL) ./config.status --recheck
68 ]])
69
70
71 AT_DATA([old.c],
72 [[#include <stdio.h>
73
74 int main (void)
75 {
76   printf ("Hello, World!");
77   return 0;
78 }
79 ]])
80
81 LT_AT_LIBTOOLIZE([--install])
82
83 # This is slightly bogus, since only libtool.m4 was required in aclocal.m4
84 # with libtool-1.5x...
85 AT_CHECK([test -f aclocal.m4 ||
86   cat "$tst_aclocaldir/libtool.m4" "$tst_aclocaldir/ltoptions.m4" \
87     "$tst_aclocaldir/ltsugar.m4" "$tst_aclocaldir/ltversion.m4" \
88     "$tst_aclocaldir/lt~obsolete.m4" > aclocal.m4])
89
90 LT_AT_BOOTSTRAP([ignore], [ignore], [ignore], [ignore], [--force])
91
92 LT_AT_EXEC_CHECK([./old], 0, [Hello, World!])
93
94 # Now, test that libtoolize doesn't mistakenly think the user called
95 # any libtool macros if in fact she didn't.
96 sed '/AM_PROG_LIBTOOL/d' configure.in >configure.int
97 mv -f configure.int configure.in
98 AT_CHECK([$LIBTOOLIZE -n], [0], [stdout], [stderr])
99 # ensure no shell errors:
100 AT_CHECK([grep -v "^libtoolize: " stderr], [1])
101 AT_CHECK([grep "Remember to add.*LT_INIT.*to configure.in" stdout], [0], [ignore])
102 AT_CHECK([grep "Consider adding.*LT_WITH_LTDL" stdout], [1])
103 AT_CHECK([grep "Remember to add.*LT_CONFIG_LTDL_DIR" stdout], [1])
104
105 AT_CLEANUP
106
107
108 ## --------------------------- ##
109 ## An old style libltdl build. ##
110 ## --------------------------- ##
111
112 AT_SETUP([AC_WITH_LTDL])
113
114 _LTDL_PROJECT_FILES
115
116 AT_DATA([configure.in],
117 [[AC_PREREQ(2.50)
118 AC_INIT([main.c])
119 AC_PROG_MAKE_SET
120 AC_LIBTOOL_DLOPEN
121 AM_PROG_LIBTOOL
122 AC_WITH_LTDL
123 AC_OUTPUT(Makefile)
124 ]])
125
126 AT_DATA([Makefile.in],
127 [[top_srcdir    = .
128 top_builddir    = .
129 COMPILE         = @CC@ @INCLTDL@  @CPPFLAGS@ @CFLAGS@
130 LTCOMPILE       = @LIBTOOL@ --mode=compile $(COMPILE)
131 LTLINK          = @LIBTOOL@ --mode=link @CC@ -no-undefined @CFLAGS@ @LDFLAGS@ -o $@
132 SHELL           = @SHELL@
133 @SET_MAKE@
134
135 TARGETS    = libltdl/libltdlc.la module.la ltdldemo@EXEEXT@
136
137 all: $(TARGETS)
138
139 libltdl/libltdlc.la:
140         cd libltdl && $(MAKE)
141
142 module.la: module.lo
143         $(LTLINK) module.lo -module -avoid-version -rpath /dev/null
144
145 ltdldemo@EXEEXT@: main.@OBJEXT@ module.la libltdl/libltdlc.la
146         $(LTLINK) main.@OBJEXT@ -dlopen module.la @LIBLTDL@ @LIBS@
147
148 .SUFFIXES:
149 .SUFFIXES: .c .@OBJEXT@ .lo
150
151 .c.@OBJEXT@:
152         $(COMPILE) -c $<
153
154 .c.lo:
155         $(LTCOMPILE) -c -o $@ $<
156 ]])
157
158 # Be sure to use the in-tree libltdl, somebody might have removed
159 # an installed libltdl.la file.
160 LT_AT_BOOTSTRAP([--ltdl --install], [-I libltdl/m4], [ignore], [ignore],
161         [--force], [--with-included-ltdl])
162
163 LT_AT_EXEC_CHECK([./ltdldemo], 0, [ignore])
164
165 AT_CLEANUP