summaryrefslogtreecommitdiff
path: root/tests/early-libtool.at
blob: 51ff6ef6529fdf759d14afac0035aef3a31e9a62 (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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# early-libtool.at -- early libtool script generation         -*- Autotest -*-

#   Copyright (C) 2005-2008, 2011-2012 Free Software Foundation, Inc.
#   Written by Gary V. Vaughan, 2005
#
#   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 script generation.])


## --------------------------------------------- ##
## Building libtool normally from config.status. ##
## --------------------------------------------- ##

AT_SETUP([config.status])

AT_DATA([configure.ac],
[[AC_INIT([libtool-demo], ]]AT_PACKAGE_VERSION[[, ]]AT_PACKAGE_BUGREPORT[[)
AC_CONFIG_MACRO_DIR([m4])
LT_INIT
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
]])

AT_DATA([Makefile.in],
[[prefix = @prefix@
libdir = @libdir@
top_builddir = .
SHELL = @SHELL@
DEFAULT_INCLUDES = -I. -I@srcdir@
EXEEXT = @EXEEXT@
LIBTOOL = @LIBTOOL@
OBJEXT = @OBJEXT@

CPPFLAGS = @CPPFLAGS@
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@

COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFAULT_INCLUDES)
LTCOMPILE = $(LIBTOOL) --mode=compile --tag=CC $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFAULT_INCLUDES)
LINK = $(LIBTOOL) --mode=link --tag=CC $(CC) $(CFLAGS) $(LDFLAGS) -o $@

all: hell$(EXEEXT)

libhello.la: hello.lo
	$(LINK) -rpath $(libdir) hello.lo
hell$(EXEEXT): main.$(OBJEXT) libhello.la
	$(LINK) main.$(OBJEXT) libhello.la

.SUFFIXES:
.SUFFIXES: .c .$(OBJEXT) .lo

.c.$(OBJEXT):
	$(COMPILE) -c $<
.c.lo:
	$(LTCOMPILE) -c -o $@ $<
]])

AT_DATA([hello.c],
[[#include <stdio.h>

void
hello (void)
{
  printf ("** This is not GNU Hello.  There is no built-in mail reader. **\n");
}
]])

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

extern void hello (void);

int
main (void)
{
  printf ("Welcome to GNU Hell!\n");

  hello ();

  return 0;
}
]])

cat > missing <<_EOF
#! /bin/sh
exit 0
_EOF
chmod a+x missing

LT_AT_LIBTOOLIZE([--copy --verbose --install])
LT_AT_ACLOCAL([-I m4])
LT_AT_AUTOCONF([--force])
LT_AT_CONFIGURE
LT_AT_MAKE

LT_AT_EXEC_CHECK([./hell], [0], [stdout])
AT_CHECK([grep 'Welcome to GNU Hell' stdout], [], [ignore])
AT_CHECK([grep 'This is not GNU Hello.' stdout],
	 [], [ignore])

AT_CLEANUP


## ------------------------------------------ ##
## Building and using libtool from config.lt. ##
## ------------------------------------------ ##

AT_SETUP([config.lt])

AT_DATA([configure.ac],
[[AC_INIT([libtool-demo], ]]AT_PACKAGE_VERSION[[, ]]AT_PACKAGE_BUGREPORT[[)
AC_CONFIG_MACRO_DIR([m4])
LT_INIT
LT_OUTPUT

cat >hello.c <<\_EOF
#include <stdio.h>

void
hello (void)
{
  printf ("** This is not GNU Hello.  There is no built-in mail reader. **\n");
}
_EOF

# Prove that we can run libtool from inside configure:
$SHELL ./libtool --mode=compile --tag=CC $CC $CPPFLAGS $CFLAGS \
    -I. -I$srcdir -c -o hello.lo hello.c  || exit 1
$SHELL ./libtool --mode=link --tag=CC $CC $CFLAGS $LDFLAGS \
    -o libhello.la -rpath /notexist hello.lo || exit 1

AC_CONFIG_FILES([Makefile])
AC_OUTPUT
]])

AT_DATA([Makefile.in],
[[prefix = @prefix@
libdir = @libdir@
top_builddir = .
SHELL = @SHELL@
DEFAULT_INCLUDES = -I. -I@srcdir@
EXEEXT = @EXEEXT@
LIBTOOL = @LIBTOOL@
OBJEXT = @OBJEXT@

CPPFLAGS = @CPPFLAGS@
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@

COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFAULT_INCLUDES)
LINK = $(LIBTOOL) --mode=link --tag=CC $(CC) $(CFLAGS) $(LDFLAGS) -o $@

all: hell$(EXEEXT)

hell$(EXEEXT): main.$(OBJEXT) libhello.la
	$(LINK) main.$(OBJEXT) libhello.la

.SUFFIXES:
.SUFFIXES: .c .$(OBJEXT)

.c.$(OBJEXT):
	$(COMPILE) -c $<
]])

AT_DATA([hello.c],
[[#include <stdio.h>

void
hello (void)
{
  printf ("** This is not GNU Hello.  There is no built-in mail reader. **\n");
}
]])

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

extern void hello (void);

int
main (int argc, char *argv[])
{
  printf ("Welcome to GNU Hell!\n");

  hello ();

  return 0;
}
]])

cat > missing <<_EOF
#! /bin/sh
exit 0
_EOF
chmod a+x missing

LT_AT_LIBTOOLIZE([--copy --verbose --install])
LT_AT_ACLOCAL([-I m4])
LT_AT_AUTOCONF([--force])
LT_AT_CONFIGURE
LT_AT_MAKE

LT_AT_EXEC_CHECK([./hell], [0], [stdout])
AT_CHECK([grep 'Welcome to GNU Hell' stdout], [], [ignore])
AT_CHECK([grep 'This is not GNU Hello.' stdout], [], [ignore])

# Make sure config.status --recheck updates the libtool script
rm libtool
AT_CHECK([$SHELL ./config.status --recheck],[0],[ignore],[ignore])

AT_CLEANUP