1 # Process with autom4te to create an -*- Autotest -*- test suite.
3 # Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
5 # Written by Gary V. Vaughan, 2004
7 # This file is part of GNU Libtool.
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.
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.
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.
26 m4_divert_push([PREPARE_TESTS])dnl
29 : ${AUTOHEADER=autoheader}
30 : ${AUTOCONF=autoconf}
31 : ${AUTOMAKE=automake}
32 : ${AUTORECONF=autoreconf}
33 test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
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
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"
45 if test -n "$build_alias"; then
46 configure_options="$configure_options --build $build_alias"
48 if test -n "$to_host_file_cmd"; then
49 configure_options="$configure_options lt_cv_to_host_file_cmd=$to_host_file_cmd"
51 if test -n "$to_tool_file_cmd"; then
52 configure_options="$configure_options lt_cv_to_tool_file_cmd=$to_tool_file_cmd"
54 if (FOO=bar; unset FOO) >/dev/null 2>&1; then
59 : ${mkdir_p="$abs_top_srcdir/libltdl/config/install-sh -d"}
60 # Fix relative paths in $lt_INSTALL
62 *libltdl/config/install-sh*)
63 lt_INSTALL=$abs_top_srcdir/libltdl/config/install-sh
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
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.
80 m4_divert_pop([PREPARE_TESTS])dnl
83 # LT_AT_LIBTOOLIZE([ARGS])
84 # ------------------------
85 m4_define([LT_AT_LIBTOOLIZE],
87 AT_KEYWORDS([libtoolize])
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
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])],
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])
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])
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])
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])
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])])
155 [case ,$AUTORECONF,$AUTOCONF,$AUTOHEADER,$ACLOCAL,$AUTOMAKE, in *,no,*) :;; *) false;; esac])
156 AT_KEYWORDS([autoconf automake])
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])
171 # LT_AT_MAKE([TGTS], [VARS])
172 # --------------------------
173 m4_define([LT_AT_MAKE],
174 [for target in m4_default([$1], [all])
176 AT_CHECK([$unset LIBTOOL LIBTOOLIZE; $MAKE $target $2], [0], [ignore], [ignore])
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])])
197 # Escape command for output (expand only parameters).
198 m4_define([LT_ESCAPE],
200 m4_dquote(m4_default([$2], [\"`])),
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($@)])
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],
217 case $host_os in mingw*)
218 while read -r l; do printf "%s\r\n" "$l"; done < $1 > $1.t
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],
230 tr -d '\015' < $1 > m4_ifval([$2], [$2], [$1.t
231 mv -f $1.t $1]) ;; m4_ifval([$2], [
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
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])
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])
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],
296 AT_CHECK([{ test -n "[$]$1" && test "X[$]$1" != Xno; } || (exit 77)])
299 [AT_CHECK([test "X$CXX" != Xg++ || (g++ -v >/dev/null 2>&1) || (exit 77)])],
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) { }
308 AT_CHECK([$GCJ $GCJFLAGS -c gcj_test.java || exit 77],
309 [], [ignore], [ignore])])
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],
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])])
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],
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`
342 ## ------------------------------- ##
343 ## Files for a small ltdl project. ##
344 ## ------------------------------- ##
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],
370 const char *(*func) (void) = 0;
373 LTDL_SET_PRELOADED_SYMBOLS();
374 if (lt_dlinit() != 0) {
375 fprintf (stderr, "error during initialisation: %s\n", lt_dlerror());
379 module = lt_dlopen("./module.la");
381 fprintf (stderr, "error dlopening ./module.la: %s\n", lt_dlerror());
385 func = (const char *(*)(void)) lt_dlsym (module, "hello");
387 fprintf (stderr, "error fetching func: %s\n", lt_dlerror());
391 printf ("%s\n", (*func) ());
395 if (lt_dlexit() != 0) {
396 fprintf (stderr, "error during finalisation: %s\n", lt_dlerror());
404 m4_pushdef([_ARG_DIR], m4_bpatsubst([$1], [/*$]))
408 LIBTOOL = ./]_ARG_DIR[/libtool
409 INCLUDES = -I./]_ARG_DIR[
410 MODFLAGS = -module -avoid-version -no-undefined
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)
417 TARGETS = ]_ARG_DIR[/libltdlc.la module.la ltdldemo$(EXEEXT)
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)"
427 $(LIBTOOL): ]_ARG_DIR[/Makefile
430 cd ]_ARG_DIR[ && CONFIG_SHELL="$(SHELL)" $(SHELL) ./configure $(CONFIGURE_OPTIONS)
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
435 main.lo: $(LIBTOOL) main.c
436 $(LTCOMPILE) -c main.c
438 module.la: $(LIBTOOL) module.lo
439 $(LTLINK) -o module.la module.lo $(MODFLAGS) -rpath /dev/null
441 module.lo: $(LIBTOOL) module.c
442 $(LTCOMPILE) -c module.c
444 cat >> Makefile <<EOF
448 m4_popdef([_ARG_DIR])
449 ])# _LTDL_PROJECT_FILES
452 # We use `dnl' in zillions of places...
453 m4_pattern_allow([^dnl$])
455 # We exercise these tools.
456 dnl AT_TESTED([grep autoreconf autom4te automake])
458 # Enable colored output if available.
459 m4_ifdef([AT_COLOR_TESTS], [AT_COLOR_TESTS])
467 # Tests will be appended here by the Makefile rule.