Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / testsuite.at
1 # Process with autom4te to create an -*- Autotest -*- test suite.
2 #
3 #   Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
4 #   Foundation, Inc.
5 #   Written by Gary V. Vaughan, 2004
6 #
7 #   This file is part of GNU Libtool.
8 #
9 # GNU Libtool is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation; either version 2 of
12 # the License, or (at your option) any later version.
13 #
14 # GNU Libtool is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with GNU Libtool; see the file COPYING.  If not, a copy
21 # can be downloaded from  http://www.gnu.org/licenses/gpl.html,
22 # or obtained by writing to the Free Software Foundation, Inc.,
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 ####
25
26 m4_divert_push([PREPARE_TESTS])dnl
27 : ${tst_dist=dist}
28 : ${ACLOCAL=aclocal}
29 : ${AUTOHEADER=autoheader}
30 : ${AUTOCONF=autoconf}
31 : ${AUTOMAKE=automake}
32 : ${AUTORECONF=autoreconf}
33 test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
34 : ${ECHO=$as_echo}
35 for tool in ACLOCAL AUTOHEADER AUTOCONF AUTOMAKE AUTORECONF; do
36   if eval \$$tool --version >/dev/null 2>&1; then :; else eval $tool=no; fi
37 done
38 export ACLOCAL AUTOHEADER AUTOCONF AUTOMAKE AUTORECONF
39 eval `$LIBTOOL --config | grep '^EGREP='`
40 eval `$LIBTOOL --config | $EGREP '^(host|host_os|host_alias|build|build_alias|to_host_file_cmd|to_tool_file_cmd)='`
41 configure_options=--prefix=/nonexistent
42 if test -n "$host_alias"; then
43   configure_options="$configure_options --host $host_alias"
44 fi
45 if test -n "$build_alias"; then
46   configure_options="$configure_options --build $build_alias"
47 fi
48 if test -n "$to_host_file_cmd"; then
49   configure_options="$configure_options lt_cv_to_host_file_cmd=$to_host_file_cmd"
50 fi
51 if test -n "$to_tool_file_cmd"; then
52   configure_options="$configure_options lt_cv_to_tool_file_cmd=$to_tool_file_cmd"
53 fi
54 if (FOO=bar; unset FOO) >/dev/null 2>&1; then
55   unset=unset
56 else
57   unset=false
58 fi
59 : ${mkdir_p="$abs_top_srcdir/libltdl/config/install-sh -d"}
60 # Fix relative paths in $lt_INSTALL
61 case $lt_INSTALL in
62   *libltdl/config/install-sh*)
63     lt_INSTALL=$abs_top_srcdir/libltdl/config/install-sh
64     ;;
65 esac
66
67 # Unset some MAKE... variables that may cause $MAKE to act like a
68 # recursively invoked sub-make.  Any $MAKE invocation in a test is
69 # conceptually an independent invocation.
70 unset MFLAGS MAKEFLAGS MAKELEVEL __MKLVL__ MAKE_JOBS_FIFO
71
72 # On AIX, shared libraries remain loaded in memory after use if they
73 # are world-readable, until root issues slibclean.  On NFS, this causes
74 # a testsuite rerun to fail to clean up test group directories.  Avoid
75 # this with a suitable umask.  Do not do this on other systems, for
76 # example HP-UX suffers unless shared libraries are mode 555.
77 case $host_os in
78 aix*) umask o-rwx ;;
79 esac
80 m4_divert_pop([PREPARE_TESTS])dnl
81
82
83 # LT_AT_LIBTOOLIZE([ARGS])
84 # ------------------------
85 m4_define([LT_AT_LIBTOOLIZE],
86 [$LIBTOOLIZE $1
87 AT_KEYWORDS([libtoolize])
88 ])
89
90
91 # _LIBTOOLIZE_TRANSFORM(FILE)
92 # ---------------------------
93 # Fix the expected output of installed libtoolize in presence of --program-*.
94 m4_define([_LIBTOOLIZE_TRANSFORM],
95 [lt_name=`$ECHO "$LIBTOOLIZE" | sed "s,^.*/,,"`
96 sed "s/libtoolize/$lt_name/g
97 s|/usr/local/share/aclocal/|${tst_aclocaldir-$abs_top_srcdir/libltdl/m4}/|" < $1 > $1.t
98 mv -f $1.t $1
99 ])dnl
100
101
102 # LT_AT_CHECK_LIBTOOLIZE(ARGS, [EXIT-STATUS = 0], [STDOUT = `'], [STDERR = `'])
103 # -----------------------------------------------------------------------------
104 m4_define([LT_AT_CHECK_LIBTOOLIZE],
105 [m4_if([$3], [expout], [_LIBTOOLIZE_TRANSFORM([$3])])dnl
106 m4_if([$4], [experr], [_LIBTOOLIZE_TRANSFORM([$4])])dnl
107 AT_CHECK([LT_AT_LIBTOOLIZE([$1])],
108   [$2], [$3], [$4])
109 ])
110
111
112 # LT_AT_ACLOCAL([OPTIONS])
113 # --------------------------
114 m4_define([LT_AT_ACLOCAL],
115 [AT_CHECK([$ACLOCAL $1], [0], [ignore], [ignore])
116 AT_XFAIL_IF([test "$ACLOCAL" = no])
117 AT_KEYWORDS([automake])
118 ])
119
120
121 # LT_AT_AUTOCONF([OPTIONS])
122 # --------------------------
123 m4_define([LT_AT_AUTOCONF],
124 [AT_CHECK([$AUTOCONF $1], [0], [ignore], [ignore])
125 AT_XFAIL_IF([test "$AUTOCONF" = no])
126 AT_KEYWORDS([autoconf])
127 ])
128
129
130 # LT_AT_AUTOMAKE([OPTIONS])
131 # --------------------------
132 m4_define([LT_AT_AUTOMAKE],
133 [AT_CHECK([$AUTOMAKE $1], [0], [ignore], [stderr],
134   [AT_CHECK([grep 'require .*but have' stderr && (exit 77)], [1])])
135 AT_XFAIL_IF([test "$AUTOMAKE" = no])
136 AT_KEYWORDS([automake])
137 ])
138
139
140 # LT_AT_AUTOHEADER([OPTIONS])
141 # ---------------------------
142 m4_define([LT_AT_AUTOHEADER],
143 [AT_CHECK([$AUTOHEADER $1], [0], [ignore], [ignore])
144 AT_XFAIL_IF([test "$AUTOHEADER" = no])
145 AT_KEYWORDS([autoconf])
146 ])
147
148
149 # LT_AT_AUTORECONF([OPTIONS])
150 # --------------------------
151 m4_define([LT_AT_AUTORECONF],
152 [AT_CHECK([$AUTORECONF $1], [0], [ignore], [stderr],
153   [AT_CHECK([grep 'require .*but have' stderr && (exit 77)], [1])])
154 AT_XFAIL_IF(
155   [case ,$AUTORECONF,$AUTOCONF,$AUTOHEADER,$ACLOCAL,$AUTOMAKE, in *,no,*) :;; *) false;; esac])
156 AT_KEYWORDS([autoconf automake])
157 ])
158
159
160 # LT_AT_CONFIGURE([OPTIONS], [CONFIGURE-SCRIPT])
161 # ----------------------------------------------
162 # Configure CONFIGURE-SCRIPT, defaulting to ./configure, with
163 # additional OPTIONS.
164 m4_define([LT_AT_CONFIGURE],
165 [AT_CHECK([: ${CONFIG_SHELL=/bin/sh}; export CONFIG_SHELL; ]dnl
166           [$CONFIG_SHELL m4_default([$2], [./configure]) $configure_options $1],
167           [0], [ignore], [ignore])
168 ])
169
170
171 # LT_AT_MAKE([TGTS], [VARS])
172 # --------------------------
173 m4_define([LT_AT_MAKE],
174 [for target in m4_default([$1], [all])
175 do
176   AT_CHECK([$unset LIBTOOL LIBTOOLIZE; $MAKE $target $2], [0], [ignore], [ignore])
177 done
178 ])
179
180
181 # LT_AT_BOOTSTRAP([LIBTOOLIZE-ARGS], [ACLOCAL-ARGS], [AUTOHEADER-ARGS],
182 #       [AUTOMAKE-ARGS], [AUTOCONF-ARGS], [CONFIGURE-ARGS], [MAKE-ARGS])
183 # ----------------------------------------------------------------------
184 m4_define([LT_AT_BOOTSTRAP],
185 [m4_if([$1], [ignore], [], [LT_AT_LIBTOOLIZE([$1])])
186 m4_if([$2], [ignore], [], [LT_AT_ACLOCAL([$2])])
187 m4_if([$3], [ignore], [], [LT_AT_AUTOHEADER([$3])])
188 m4_if([$4], [ignore], [], [LT_AT_AUTOMAKE([$4])])
189 m4_if([$5], [ignore], [], [LT_AT_AUTOCONF([$5])])
190 m4_if([$6], [ignore], [], [LT_AT_CONFIGURE([$6])])
191 m4_if([$7], [ignore], [], [LT_AT_MAKE([$7])])
192 ])
193
194
195 # LT_ESCAPE(ARG)
196 # --------------
197 # Escape command for output (expand only parameters).
198 m4_define([LT_ESCAPE],
199 [m4_bpatsubst([$1],
200              m4_dquote(m4_default([$2], [\"`])),
201              [\\\&])])
202
203
204 # LT_AT_CHECK
205 # -----------
206 # Wrapper around AT_CHECK that outputs the command first, with
207 # parameters expanded.
208 m4_define([LT_AT_CHECK],
209 [echo "LT_ESCAPE([$1])"; AT_CHECK($@)])
210
211
212 # LT_AT_HOST_DATA(FILE, CONTENTS)
213 # -------------------------------
214 # Ensure correct line ending for expected output of host executables.
215 m4_define([LT_AT_HOST_DATA],
216 [AT_DATA([$1], [$2])
217 case $host_os in mingw*)
218   while read -r l; do printf "%s\r\n" "$l"; done < $1 > $1.t
219   mv -f $1.t $1 ;;
220 esac])
221
222
223 # LT_AT_UNIFY_NL(FILE, [RESULT-FILE])
224 # -----------------------------------
225 # Ensure (text) FILE has predictable line endings.
226 # If RESULT-FILE is given, FILE is left untouched. If not, convert in-place.
227 m4_define([LT_AT_UNIFY_NL],
228 [case $host_os in
229   mingw*)
230     tr -d '\015' < $1 > m4_ifval([$2], [$2], [$1.t
231     mv -f $1.t $1]) ;; m4_ifval([$2], [
232   *)
233     cp $1 $2 ;;])
234 esac])
235
236
237 # LT_AT_NORMALIZE_COMPILER_OUTPUT(FILE, [RESULT-FILE])
238 # ----------------------------------------------------
239 # Normalize differences in compiler output stemming from, e.g.,
240 # - distcc process numbers,
241 # - ccache file location,
242 # - newline encoding,
243 # - location of the libtool script,
244 # - error messages involving unstable temporary file names.
245 m4_define([LT_AT_NORMALIZE_COMPILER_OUTPUT],
246 [_ltbase=`$ECHO "$LIBTOOL" | sed 's,^.*/,,'`
247 [sed "/^distcc\[[0-9]*\]/d
248       /^$_ltbase: compile/d
249       s/\(tmp\/\{1,\}cc\)\([a-zA-Z0-9_]\{1,\}\)/\1-normalized-tmpname/g" < $1 > $1.t]
250 LT_AT_UNIFY_NL([$1.t], [m4_default([$2], [$1])])[]dnl
251 ])
252
253
254 # LT_AT_EXEC_CHECK(EXECUTABLE, [STATUS = 0], [STDOUT], [STDERR],
255 #                  [ARGS-OR-STATUS-ADJUST])
256 # --------------------------------------------------------------
257 # Run EXECUTABLE ARGS-OR-STATUS-ADJUST.  STATUS, STDOUT, and STDERR are
258 # handled as in AT_CHECK.
259 # However, if we are cross-compiling, then SKIP instead of FAIL.
260 # ARGS-OR-STATUS-ADJUST can also contain code like `|| (exit 1)'
261 # to unify different possible exit status values.
262 m4_define([LT_AT_EXEC_CHECK],
263 [lt_exe=$1; if test -f "$1$EXEEXT"; then lt_exe=$lt_exe$EXEEXT; fi
264 AT_CHECK([if "$lt_exe" $5; then :; else lt_status=$?; ]dnl
265          [  m4_ifval([$2], [test $lt_status != $2 && ])]dnl
266          [  test "X$host" != "X$build" && test -x "$lt_exe" && exit 77; ]dnl
267          [  exit $lt_status; fi],[$2],[$3],[$4])
268 ])
269
270
271 # LT_AT_NOINST_EXEC_CHECK(EXECUTABLE, [NOINST-MODULES],
272 #                         [STATUS = 0], [STDOUT], [STDERR],
273 #                         [ARGS-OR-STATUS-ADJUST])
274 # ---------------------------------------------------------
275 # Run EXECUTABLE ARGS-OR-STATUS-ADJUST using `libtool --mode=execute'
276 # with `-dlopen' arguments in NOINST_MODULES.  STATUS, STDOUT, and
277 # STDERR are handled as in AT_CHECK.
278 # However, if we are cross-compiling, then SKIP instead of FAIL.
279 # ARGS-OR-STATUS-ADJUST can also contain code like `|| (exit 1)'
280 # to unify different possible exit status values.
281 m4_define([LT_AT_NOINST_EXEC_CHECK],
282 [lt_exe=$1; if test -f "$1$EXEEXT"; then lt_exe=$lt_exe$EXEEXT; fi
283 AT_CHECK([if $LIBTOOL --mode=execute $2 "$lt_exe" $6; then :; else lt_status=$?; ]dnl
284          [  m4_ifval([$3], [test $lt_status != $3 && ])]dnl
285          [  test "X$host" != "X$build" && test -x "$lt_exe" && exit 77; ]dnl
286          [  exit $lt_status; fi],[$3],[$4],[$5])
287 ])
288
289
290 # LT_AT_TAG(TAG)
291 # --------------
292 # Declare that the language TAG will be used in this test.
293 # Skips the test if the compiler is apparently not functional.
294 m4_define([LT_AT_TAG],
295 [AT_KEYWORDS([$1])
296 AT_CHECK([{ test -n "[$]$1" && test "X[$]$1" != Xno; } || (exit 77)])
297 m4_case([$1],
298   [CXX],
299   [AT_CHECK([test "X$CXX" != Xg++ || (g++ -v >/dev/null 2>&1) || (exit 77)])],
300   [GCJ],
301   [# There are just too many broken gcj installations out there, either missing
302    # libgcj.spec or unable to find it.  Skip the test for them.
303    AT_DATA([gcj_test.java],
304 [[public class gcj_test {
305     public static void main(String[] argv) { }
306   }
307 ]])
308    AT_CHECK([$GCJ $GCJFLAGS -c gcj_test.java || exit 77],
309             [], [ignore], [ignore])])
310 ])
311
312
313 # LT_AT_EXEC_TAG([TAG])
314 # ---------------------
315 # Declare that the language TAG will be used and compiled programs may be run.
316 # Skips the test if the compiler is apparently not functional.
317 m4_define([LT_AT_EXEC_TAG],
318 [LT_AT_TAG([$1])
319 m4_case([$1],
320   [GCJ],
321   [AT_CHECK([$GCJ $GCJFLAGS --main=gcj_test -o gcj_test$EXEEXT gcj_test.java ]dnl
322             [|| exit 77], [], [ignore], [ignore])
323    AT_CHECK([./gcj_test$EXEEXT || exit 77], [], [ignore], [ignore])])
324 ])
325
326
327 # LT_AT_MVDIR(SRC, DEST)
328 # ----------------------
329 # Move contents of a directory recursively.
330 # Avoid `mv DIR ...' due to issues with non-deletable shared libraries
331 # on AIX on NFS mounts.  We cannot use slibclean as non-superuser.
332 m4_define([LT_AT_MVDIR],
333 [$mkdir_p $2
334 (cd $1 && find . -type d) | (cd $2 && xargs $mkdir_p)
335 for file in `cd $1 && find . -type f -print -o -type l -print`
336 do
337   mv $1/$file $2/$file
338 done
339 rm -rf $1
340 ])
341
342 ## ------------------------------- ##
343 ## Files for a small ltdl project. ##
344 ## ------------------------------- ##
345
346 # _LTDL_PROJECT_FILES([LTDL-DIR])
347 # -------------------------------
348 # LTDL-DIR is needed to generate a correct Makefile.  If the argument
349 # is omitted, then no Makefile is created.
350 m4_define([_LTDL_PROJECT_FILES],
351 [AT_DATA([module.c],
352 [[#ifdef __cplusplus
353 extern "C"
354 #endif
355 const char *
356 hello (void)
357 {
358   return "Hello!";
359 }
360 ]])
361
362 AT_DATA([main.c],
363 [[#include <stdio.h>
364 #include "ltdl.h"
365
366 int
367 main ()
368 {
369   lt_dlhandle module;
370   const char *(*func) (void) = 0;
371   int status = 1;
372
373   LTDL_SET_PRELOADED_SYMBOLS();
374   if (lt_dlinit() != 0) {
375     fprintf (stderr, "error during initialisation: %s\n", lt_dlerror());
376     return 1;
377   }
378
379   module = lt_dlopen("./module.la");
380   if (!module) {
381     fprintf (stderr, "error dlopening ./module.la: %s\n", lt_dlerror());
382     goto finish;
383   }
384
385   func = (const char *(*)(void)) lt_dlsym (module, "hello");
386   if (!func) {
387     fprintf (stderr, "error fetching func: %s\n", lt_dlerror());
388     goto finish;
389   }
390
391   printf ("%s\n", (*func) ());
392   status = 0;
393
394 finish:
395   if (lt_dlexit() != 0) {
396     fprintf (stderr, "error during finalisation: %s\n", lt_dlerror());
397     status = 1;
398   }
399
400   return status;
401 }
402 ]])
403
404 m4_pushdef([_ARG_DIR], m4_bpatsubst([$1], [/*$]))
405 m4_ifval([$1],
406 [AT_DATA([Makefile],
407 [[top_builddir  = .
408 LIBTOOL         = ./]_ARG_DIR[/libtool
409 INCLUDES        = -I./]_ARG_DIR[
410 MODFLAGS        = -module -avoid-version -no-undefined
411
412 LTCOMPILE = $(LIBTOOL) --tag=CC $(LIBTOOLFLAGS) --mode=compile \
413         $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
414 LTLINK    = $(LIBTOOL) --tag=CC $(LIBTOOLFLAGS) --mode=link \
415         $(CC) $(CFLAGS) $(LDFLAGS)
416
417 TARGETS         = ]_ARG_DIR[/libltdlc.la module.la ltdldemo$(EXEEXT)
418
419 all: $(TARGETS)
420
421 ]_ARG_DIR[/libltdlc.la: $(LIBTOOL) ]_ARG_DIR[/Makefile
422         MAKE='$(MAKE)'; test -n "$$MAKE" || MAKE=make; \
423         cd ]_ARG_DIR[ && $$MAKE CC="$(CC)" LIBTOOLFLAGS="$(LIBTOOLFLAGS)" \
424           CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
425           CONFIGURE_OPTIONS="$(CONFIGURE_OPTIONS)"
426
427 $(LIBTOOL): ]_ARG_DIR[/Makefile
428
429 ]_ARG_DIR[/Makefile:
430         cd ]_ARG_DIR[ && CONFIG_SHELL="$(SHELL)" $(SHELL) ./configure $(CONFIGURE_OPTIONS)
431
432 ltdldemo$(EXEEXT): $(LIBTOOL) module.la ]_ARG_DIR[/libltdlc.la main.lo
433         $(LTLINK) -o ltdldemo$(EXEEXT) main.lo -dlopen module.la ./]_ARG_DIR[/libltdlc.la
434
435 main.lo: $(LIBTOOL) main.c
436         $(LTCOMPILE) -c main.c
437
438 module.la: $(LIBTOOL) module.lo
439         $(LTLINK) -o module.la module.lo $(MODFLAGS) -rpath /dev/null
440
441 module.lo: $(LIBTOOL) module.c
442         $(LTCOMPILE) -c module.c
443 ]])
444 cat >> Makefile <<EOF
445 SHELL = $SHELL 
446 EOF
447 ])
448 m4_popdef([_ARG_DIR])
449 ])# _LTDL_PROJECT_FILES
450
451
452 # We use `dnl' in zillions of places...
453 m4_pattern_allow([^dnl$])
454
455 # We exercise these tools.
456 dnl AT_TESTED([grep autoreconf autom4te automake])
457
458 # Enable colored output if available.
459 m4_ifdef([AT_COLOR_TESTS], [AT_COLOR_TESTS])
460
461 AT_INIT
462
463 ## ----------- ##
464 ## The suite.  ##
465 ## ----------- ##
466
467 # Tests will be appended here by the Makefile rule.