Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / defs.in
1 #! /bin/sh
2 # Generated from tests/defs.m4sh by GNU Autoconf 2.68.
3
4 # defs -- Defines for Libtool testing environment.
5 #
6 #   Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free Software
7 #   Foundation, Inc.
8 #   Written by Gord Matzigkeit, 1996
9 #   Rewritten by Gary V. Vaughan, 2003
10 #
11 #   This file is part of GNU Libtool.
12 #
13 # GNU Libtool is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation; either version 2 of
16 # the License, or (at your option) any later version.
17 #
18 # GNU Libtool is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with GNU Libtool; see the file COPYING.  If not, a copy
25 # can be downloaded from  http://www.gnu.org/licenses/gpl.html,
26 # or obtained by writing to the Free Software Foundation, Inc.,
27 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 ####
29
30 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
31 # is ksh but when the shell is invoked as "sh" and the current value of
32 # the _XPG environment variable is not equal to 1 (one), the special
33 # positional parameter $0, within a function call, is the name of the
34 # function.
35 progpath="$0"
36
37 ## -------------------- ##
38 ## M4sh Initialization. ##
39 ## -------------------- ##
40
41 # Be more Bourne compatible
42 DUALCASE=1; export DUALCASE # for MKS sh
43 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
44   emulate sh
45   NULLCMD=:
46   # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
47   # is contrary to our usage.  Disable this feature.
48   alias -g '${1+"$@"}'='"$@"'
49   setopt NO_GLOB_SUBST
50 else
51   case `(set -o) 2>/dev/null` in #(
52   *posix*) :
53     set -o posix ;; #(
54   *) :
55      ;;
56 esac
57 fi
58
59
60 as_nl='
61 '
62 export as_nl
63 # Printing a long string crashes Solaris 7 /usr/bin/printf.
64 as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
65 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
66 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
67 # Prefer a ksh shell builtin over an external printf program on Solaris,
68 # but without wasting forks for bash or zsh.
69 if test -z "$BASH_VERSION$ZSH_VERSION" \
70     && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
71   as_echo='print -r --'
72   as_echo_n='print -rn --'
73 elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
74   as_echo='printf %s\n'
75   as_echo_n='printf %s'
76 else
77   if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
78     as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
79     as_echo_n='/usr/ucb/echo -n'
80   else
81     as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
82     as_echo_n_body='eval
83       arg=$1;
84       case $arg in #(
85       *"$as_nl"*)
86         expr "X$arg" : "X\\(.*\\)$as_nl";
87         arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
88       esac;
89       expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
90     '
91     export as_echo_n_body
92     as_echo_n='sh -c $as_echo_n_body as_echo'
93   fi
94   export as_echo_body
95   as_echo='sh -c $as_echo_body as_echo'
96 fi
97
98 # The user is always right.
99 if test "${PATH_SEPARATOR+set}" != set; then
100   PATH_SEPARATOR=:
101   (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
102     (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
103       PATH_SEPARATOR=';'
104   }
105 fi
106
107
108 # IFS
109 # We need space, tab and new line, in precisely that order.  Quoting is
110 # there to prevent editors from complaining about space-tab.
111 # (If _AS_PATH_WALK were called with IFS unset, it would disable word
112 # splitting by setting IFS to empty value.)
113 IFS=" ""        $as_nl"
114
115 # Find who we are.  Look in the path if we contain no directory separator.
116 as_myself=
117 case $0 in #((
118   *[\\/]* ) as_myself=$0 ;;
119   *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
120 for as_dir in $PATH
121 do
122   IFS=$as_save_IFS
123   test -z "$as_dir" && as_dir=.
124     test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
125   done
126 IFS=$as_save_IFS
127
128      ;;
129 esac
130 # We did not find ourselves, most probably we were run as `sh COMMAND'
131 # in which case we are not to be found in the path.
132 if test "x$as_myself" = x; then
133   as_myself=$0
134 fi
135 if test ! -f "$as_myself"; then
136   $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
137   exit 1
138 fi
139
140 # Unset variables that we do not need and which cause bugs (e.g. in
141 # pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
142 # suppresses any "Segmentation fault" message there.  '((' could
143 # trigger a bug in pdksh 5.2.14.
144 for as_var in BASH_ENV ENV MAIL MAILPATH
145 do eval test x\${$as_var+set} = xset \
146   && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
147 done
148 PS1='$ '
149 PS2='> '
150 PS4='+ '
151
152 # NLS nuisances.
153 LC_ALL=C
154 export LC_ALL
155 LANGUAGE=C
156 export LANGUAGE
157
158 # CDPATH.
159 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
160
161 if test "x$CONFIG_SHELL" = x; then
162   as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
163   emulate sh
164   NULLCMD=:
165   # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
166   # is contrary to our usage.  Disable this feature.
167   alias -g '\${1+\"\$@\"}'='\"\$@\"'
168   setopt NO_GLOB_SUBST
169 else
170   case \`(set -o) 2>/dev/null\` in #(
171   *posix*) :
172     set -o posix ;; #(
173   *) :
174      ;;
175 esac
176 fi
177 "
178   as_required="as_fn_return () { (exit \$1); }
179 as_fn_success () { as_fn_return 0; }
180 as_fn_failure () { as_fn_return 1; }
181 as_fn_ret_success () { return 0; }
182 as_fn_ret_failure () { return 1; }
183
184 exitcode=0
185 as_fn_success || { exitcode=1; echo as_fn_success failed.; }
186 as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
187 as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
188 as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
189 if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
190
191 else
192   exitcode=1; echo positional parameters were not saved.
193 fi
194 test x\$exitcode = x0 || exit 1"
195   as_suggested=""
196   if (eval "$as_required") 2>/dev/null; then :
197   as_have_required=yes
198 else
199   as_have_required=no
200 fi
201   if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
202
203 else
204   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
205 as_found=false
206 for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
207 do
208   IFS=$as_save_IFS
209   test -z "$as_dir" && as_dir=.
210   as_found=:
211   case $as_dir in #(
212          /*)
213            for as_base in sh bash ksh sh5; do
214              # Try only shells that exist, to save several forks.
215              as_shell=$as_dir/$as_base
216              if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
217                     { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
218   CONFIG_SHELL=$as_shell as_have_required=yes
219                    break 2
220 fi
221            done;;
222        esac
223   as_found=false
224 done
225 $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
226               { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
227   CONFIG_SHELL=$SHELL as_have_required=yes
228 fi; }
229 IFS=$as_save_IFS
230
231
232       if test "x$CONFIG_SHELL" != x; then :
233   # We cannot yet assume a decent shell, so we have to provide a
234         # neutralization value for shells without unset; and this also
235         # works around shells that cannot unset nonexistent variables.
236         # Preserve -v and -x to the replacement shell.
237         BASH_ENV=/dev/null
238         ENV=/dev/null
239         (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
240         export CONFIG_SHELL
241         case $- in # ((((
242           *v*x* | *x*v* ) as_opts=-vx ;;
243           *v* ) as_opts=-v ;;
244           *x* ) as_opts=-x ;;
245           * ) as_opts= ;;
246         esac
247         exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
248 fi
249
250     if test x$as_have_required = xno; then :
251   $as_echo "$0: This script requires a shell more modern than all"
252   $as_echo "$0: the shells that I found on your system."
253   if test x${ZSH_VERSION+set} = xset ; then
254     $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
255     $as_echo "$0: be upgraded to zsh 4.3.4 or later."
256   else
257     $as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
258 $0: including any error possibly output before this
259 $0: message. Then install a modern shell, or manually run
260 $0: the script under such a shell if you do have one."
261   fi
262   exit 1
263 fi
264 fi
265 fi
266 SHELL=${CONFIG_SHELL-/bin/sh}
267 export SHELL
268 # Unset more variables known to interfere with behavior of common tools.
269 CLICOLOR_FORCE= GREP_OPTIONS=
270 unset CLICOLOR_FORCE GREP_OPTIONS
271
272 ## --------------------- ##
273 ## M4sh Shell Functions. ##
274 ## --------------------- ##
275 # as_fn_unset VAR
276 # ---------------
277 # Portably unset VAR.
278 as_fn_unset ()
279 {
280   { eval $1=; unset $1;}
281 }
282 as_unset=as_fn_unset
283 ## -------------------- ##
284 ## Main body of script. ##
285 ## -------------------- ##
286
287
288
289
290 : ${CP="cp -f"}
291 test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
292 : ${EGREP="@EGREP@"}
293 : ${FGREP="@FGREP@"}
294 : ${GREP="@GREP@"}
295 : ${LN_S="@LN_S@"}
296 : ${MAKE="make"}
297 : ${MKDIR="mkdir"}
298 : ${MV="mv -f"}
299 : ${RM="rm -f"}
300 : ${SED="@SED@"}
301 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
302 : ${Xsed="$SED -e 1s/^X//"}
303
304 # Global variables:
305 EXIT_SUCCESS=0
306 EXIT_FAILURE=1
307 EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
308 EXIT_SKIP=77      # $? = 77 is used to indicate a skipped test to automake.
309
310 exit_status=$EXIT_SUCCESS
311
312 # Make sure IFS has a sensible default
313 lt_nl='
314 '
315 IFS="   $lt_nl"
316
317 dirname="s,/[^/]*$,,"
318 basename="s,^.*/,,"
319
320 # func_dirname file append nondir_replacement
321 # Compute the dirname of FILE.  If nonempty, add APPEND to the result,
322 # otherwise set result to NONDIR_REPLACEMENT.
323 func_dirname ()
324 {
325     func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
326     if test "X$func_dirname_result" = "X${1}"; then
327       func_dirname_result="${3}"
328     else
329       func_dirname_result="$func_dirname_result${2}"
330     fi
331 } # func_dirname may be replaced by extended shell implementation
332
333
334 # func_basename file
335 func_basename ()
336 {
337     func_basename_result=`$ECHO "${1}" | $SED "$basename"`
338 } # func_basename may be replaced by extended shell implementation
339
340
341 # func_dirname_and_basename file append nondir_replacement
342 # perform func_basename and func_dirname in a single function
343 # call:
344 #   dirname:  Compute the dirname of FILE.  If nonempty,
345 #             add APPEND to the result, otherwise set result
346 #             to NONDIR_REPLACEMENT.
347 #             value returned in "$func_dirname_result"
348 #   basename: Compute filename of FILE.
349 #             value retuned in "$func_basename_result"
350 # Implementation must be kept synchronized with func_dirname
351 # and func_basename. For efficiency, we do not delegate to
352 # those functions but instead duplicate the functionality here.
353 func_dirname_and_basename ()
354 {
355     # Extract subdirectory from the argument.
356     func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
357     if test "X$func_dirname_result" = "X${1}"; then
358       func_dirname_result="${3}"
359     else
360       func_dirname_result="$func_dirname_result${2}"
361     fi
362     func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
363 } # func_dirname_and_basename may be replaced by extended shell implementation
364
365
366 # func_stripname prefix suffix name
367 # strip PREFIX and SUFFIX off of NAME.
368 # PREFIX and SUFFIX must not contain globbing or regex special
369 # characters, hashes, percent signs, but SUFFIX may contain a leading
370 # dot (in which case that matches only a dot).
371 # func_strip_suffix prefix name
372 func_stripname ()
373 {
374     case ${2} in
375       .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
376       *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
377     esac
378 } # func_stripname may be replaced by extended shell implementation
379
380
381 # These SED scripts presuppose an absolute path with a trailing slash.
382 pathcar='s,^/\([^/]*\).*$,\1,'
383 pathcdr='s,^/[^/]*,,'
384 removedotparts=':dotsl
385                 s@/\./@/@g
386                 t dotsl
387                 s,/\.$,/,'
388 collapseslashes='s@/\{1,\}@/@g'
389 finalslash='s,/*$,/,'
390
391 # func_normal_abspath PATH
392 # Remove doubled-up and trailing slashes, "." path components,
393 # and cancel out any ".." path components in PATH after making
394 # it an absolute path.
395 #             value returned in "$func_normal_abspath_result"
396 func_normal_abspath ()
397 {
398   # Start from root dir and reassemble the path.
399   func_normal_abspath_result=
400   func_normal_abspath_tpath=$1
401   func_normal_abspath_altnamespace=
402   case $func_normal_abspath_tpath in
403     "")
404       # Empty path, that just means $cwd.
405       func_stripname '' '/' "`pwd`"
406       func_normal_abspath_result=$func_stripname_result
407       return
408     ;;
409     # The next three entries are used to spot a run of precisely
410     # two leading slashes without using negated character classes;
411     # we take advantage of case's first-match behaviour.
412     ///*)
413       # Unusual form of absolute path, do nothing.
414     ;;
415     //*)
416       # Not necessarily an ordinary path; POSIX reserves leading '//'
417       # and for example Cygwin uses it to access remote file shares
418       # over CIFS/SMB, so we conserve a leading double slash if found.
419       func_normal_abspath_altnamespace=/
420     ;;
421     /*)
422       # Absolute path, do nothing.
423     ;;
424     *)
425       # Relative path, prepend $cwd.
426       func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
427     ;;
428   esac
429   # Cancel out all the simple stuff to save iterations.  We also want
430   # the path to end with a slash for ease of parsing, so make sure
431   # there is one (and only one) here.
432   func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
433         -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
434   while :; do
435     # Processed it all yet?
436     if test "$func_normal_abspath_tpath" = / ; then
437       # If we ascended to the root using ".." the result may be empty now.
438       if test -z "$func_normal_abspath_result" ; then
439         func_normal_abspath_result=/
440       fi
441       break
442     fi
443     func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
444         -e "$pathcar"`
445     func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
446         -e "$pathcdr"`
447     # Figure out what to do with it
448     case $func_normal_abspath_tcomponent in
449       "")
450         # Trailing empty path component, ignore it.
451       ;;
452       ..)
453         # Parent dir; strip last assembled component from result.
454         func_dirname "$func_normal_abspath_result"
455         func_normal_abspath_result=$func_dirname_result
456       ;;
457       *)
458         # Actual path component, append it.
459         func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
460       ;;
461     esac
462   done
463   # Restore leading double-slash if one was found on entry.
464   func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
465 }
466
467 # func_relative_path SRCDIR DSTDIR
468 # generates a relative path from SRCDIR to DSTDIR, with a trailing
469 # slash if non-empty, suitable for immediately appending a filename
470 # without needing to append a separator.
471 #             value returned in "$func_relative_path_result"
472 func_relative_path ()
473 {
474   func_relative_path_result=
475   func_normal_abspath "$1"
476   func_relative_path_tlibdir=$func_normal_abspath_result
477   func_normal_abspath "$2"
478   func_relative_path_tbindir=$func_normal_abspath_result
479
480   # Ascend the tree starting from libdir
481   while :; do
482     # check if we have found a prefix of bindir
483     case $func_relative_path_tbindir in
484       $func_relative_path_tlibdir)
485         # found an exact match
486         func_relative_path_tcancelled=
487         break
488         ;;
489       $func_relative_path_tlibdir*)
490         # found a matching prefix
491         func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
492         func_relative_path_tcancelled=$func_stripname_result
493         if test -z "$func_relative_path_result"; then
494           func_relative_path_result=.
495         fi
496         break
497         ;;
498       *)
499         func_dirname $func_relative_path_tlibdir
500         func_relative_path_tlibdir=${func_dirname_result}
501         if test "x$func_relative_path_tlibdir" = x ; then
502           # Have to descend all the way to the root!
503           func_relative_path_result=../$func_relative_path_result
504           func_relative_path_tcancelled=$func_relative_path_tbindir
505           break
506         fi
507         func_relative_path_result=../$func_relative_path_result
508         ;;
509     esac
510   done
511
512   # Now calculate path; take care to avoid doubling-up slashes.
513   func_stripname '' '/' "$func_relative_path_result"
514   func_relative_path_result=$func_stripname_result
515   func_stripname '/' '/' "$func_relative_path_tcancelled"
516   if test "x$func_stripname_result" != x ; then
517     func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
518   fi
519
520   # Normalisation. If bindir is libdir, return empty string,
521   # else relative path ending with a slash; either way, target
522   # file name can be directly appended.
523   if test ! -z "$func_relative_path_result"; then
524     func_stripname './' '' "$func_relative_path_result/"
525     func_relative_path_result=$func_stripname_result
526   fi
527 }
528
529 # The name of this program:
530 func_dirname_and_basename "$progpath"
531 progname=$func_basename_result
532
533 # Make sure we have an absolute path for reexecution:
534 case $progpath in
535   [\\/]*|[A-Za-z]:\\*) ;;
536   *[\\/]*)
537      progdir=$func_dirname_result
538      progdir=`cd "$progdir" && pwd`
539      progpath="$progdir/$progname"
540      ;;
541   *)
542      save_IFS="$IFS"
543      IFS=${PATH_SEPARATOR-:}
544      for progdir in $PATH; do
545        IFS="$save_IFS"
546        test -x "$progdir/$progname" && break
547      done
548      IFS="$save_IFS"
549      test -n "$progdir" || progdir=`pwd`
550      progpath="$progdir/$progname"
551      ;;
552 esac
553
554 # Sed substitution that helps us do robust quoting.  It backslashifies
555 # metacharacters that are still active within double-quoted strings.
556 Xsed="${SED}"' -e 1s/^X//'
557 sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
558
559 # Same as above, but do not quote variable references.
560 double_quote_subst='s/\(["`\\]\)/\\\1/g'
561
562 # Sed substitution that turns a string into a regex matching for the
563 # string literally.
564 sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
565
566 # Sed substitution that converts a w32 file name or path
567 # which contains forward slashes, into one that contains
568 # (escaped) backslashes.  A very naive implementation.
569 lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
570
571 # Re-`\' parameter expansions in output of double_quote_subst that were
572 # `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
573 # in input to double_quote_subst, that '$' was protected from expansion.
574 # Since each input `\' is now two `\'s, look for any number of runs of
575 # four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
576 bs='\\'
577 bs2='\\\\'
578 bs4='\\\\\\\\'
579 dollar='\$'
580 sed_double_backslash="\
581   s/$bs4/&\\
582 /g
583   s/^$bs2$dollar/$bs&/
584   s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
585   s/\n//g"
586
587 # Standard options:
588 opt_dry_run=false
589 opt_help=false
590 opt_quiet=false
591 opt_verbose=false
592 opt_warning=:
593
594 # func_echo arg...
595 # Echo program name prefixed message, along with the current mode
596 # name if it has been set yet.
597 func_echo ()
598 {
599     $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
600 }
601
602 # func_verbose arg...
603 # Echo program name prefixed message in verbose mode only.
604 func_verbose ()
605 {
606     $opt_verbose && func_echo ${1+"$@"}
607
608     # A bug in bash halts the script if the last line of a function
609     # fails when set -e is in force, so we need another command to
610     # work around that:
611     :
612 }
613
614 # func_echo_all arg...
615 # Invoke $ECHO with all args, space-separated.
616 func_echo_all ()
617 {
618     $ECHO "$*"
619 }
620
621 # func_error arg...
622 # Echo program name prefixed message to standard error.
623 func_error ()
624 {
625     $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
626 }
627
628 # func_warning arg...
629 # Echo program name prefixed warning message to standard error.
630 func_warning ()
631 {
632     $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
633
634     # bash bug again:
635     :
636 }
637
638 # func_fatal_error arg...
639 # Echo program name prefixed message to standard error, and exit.
640 func_fatal_error ()
641 {
642     func_error ${1+"$@"}
643     exit $EXIT_FAILURE
644 }
645
646 # func_fatal_help arg...
647 # Echo program name prefixed message to standard error, followed by
648 # a help hint, and exit.
649 func_fatal_help ()
650 {
651     func_error ${1+"$@"}
652     func_fatal_error "$help"
653 }
654 help="Try \`$progname --help' for more information."  ## default
655
656
657 # func_grep expression filename
658 # Check whether EXPRESSION matches any line of FILENAME, without output.
659 func_grep ()
660 {
661     $GREP "$1" "$2" >/dev/null 2>&1
662 }
663
664
665 # func_mkdir_p directory-path
666 # Make sure the entire path to DIRECTORY-PATH is available.
667 func_mkdir_p ()
668 {
669     my_directory_path="$1"
670     my_dir_list=
671
672     if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
673
674       # Protect directory names starting with `-'
675       case $my_directory_path in
676         -*) my_directory_path="./$my_directory_path" ;;
677       esac
678
679       # While some portion of DIR does not yet exist...
680       while test ! -d "$my_directory_path"; do
681         # ...make a list in topmost first order.  Use a colon delimited
682         # list incase some portion of path contains whitespace.
683         my_dir_list="$my_directory_path:$my_dir_list"
684
685         # If the last portion added has no slash in it, the list is done
686         case $my_directory_path in */*) ;; *) break ;; esac
687
688         # ...otherwise throw away the child directory and loop
689         my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
690       done
691       my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
692
693       save_mkdir_p_IFS="$IFS"; IFS=':'
694       for my_dir in $my_dir_list; do
695         IFS="$save_mkdir_p_IFS"
696         # mkdir can fail with a `File exist' error if two processes
697         # try to create one of the directories concurrently.  Don't
698         # stop in that case!
699         $MKDIR "$my_dir" 2>/dev/null || :
700       done
701       IFS="$save_mkdir_p_IFS"
702
703       # Bail out if we (or some other process) failed to create a directory.
704       test -d "$my_directory_path" || \
705         func_fatal_error "Failed to create \`$1'"
706     fi
707 }
708
709
710 # func_mktempdir [string]
711 # Make a temporary directory that won't clash with other running
712 # libtool processes, and avoids race conditions if possible.  If
713 # given, STRING is the basename for that directory.
714 func_mktempdir ()
715 {
716     my_template="${TMPDIR-/tmp}/${1-$progname}"
717
718     if test "$opt_dry_run" = ":"; then
719       # Return a directory name, but don't create it in dry-run mode
720       my_tmpdir="${my_template}-$$"
721     else
722
723       # If mktemp works, use that first and foremost
724       my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
725
726       if test ! -d "$my_tmpdir"; then
727         # Failing that, at least try and use $RANDOM to avoid a race
728         my_tmpdir="${my_template}-${RANDOM-0}$$"
729
730         save_mktempdir_umask=`umask`
731         umask 0077
732         $MKDIR "$my_tmpdir"
733         umask $save_mktempdir_umask
734       fi
735
736       # If we're not in dry-run mode, bomb out on failure
737       test -d "$my_tmpdir" || \
738         func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
739     fi
740
741     $ECHO "$my_tmpdir"
742 }
743
744
745 # func_quote_for_eval arg
746 # Aesthetically quote ARG to be evaled later.
747 # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
748 # is double-quoted, suitable for a subsequent eval, whereas
749 # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
750 # which are still active within double quotes backslashified.
751 func_quote_for_eval ()
752 {
753     case $1 in
754       *[\\\`\"\$]*)
755         func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
756       *)
757         func_quote_for_eval_unquoted_result="$1" ;;
758     esac
759
760     case $func_quote_for_eval_unquoted_result in
761       # Double-quote args containing shell metacharacters to delay
762       # word splitting, command substitution and and variable
763       # expansion for a subsequent eval.
764       # Many Bourne shells cannot handle close brackets correctly
765       # in scan sets, so we specify it separately.
766       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
767         func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
768         ;;
769       *)
770         func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
771     esac
772 }
773
774
775 # func_quote_for_expand arg
776 # Aesthetically quote ARG to be evaled later; same as above,
777 # but do not quote variable references.
778 func_quote_for_expand ()
779 {
780     case $1 in
781       *[\\\`\"]*)
782         my_arg=`$ECHO "$1" | $SED \
783             -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
784       *)
785         my_arg="$1" ;;
786     esac
787
788     case $my_arg in
789       # Double-quote args containing shell metacharacters to delay
790       # word splitting and command substitution for a subsequent eval.
791       # Many Bourne shells cannot handle close brackets correctly
792       # in scan sets, so we specify it separately.
793       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
794         my_arg="\"$my_arg\""
795         ;;
796     esac
797
798     func_quote_for_expand_result="$my_arg"
799 }
800
801
802 # func_show_eval cmd [fail_exp]
803 # Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
804 # not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
805 # is given, then evaluate it.
806 func_show_eval ()
807 {
808     my_cmd="$1"
809     my_fail_exp="${2-:}"
810
811     ${opt_silent-false} || {
812       func_quote_for_expand "$my_cmd"
813       eval "func_echo $func_quote_for_expand_result"
814     }
815
816     if ${opt_dry_run-false}; then :; else
817       eval "$my_cmd"
818       my_status=$?
819       if test "$my_status" -eq 0; then :; else
820         eval "(exit $my_status); $my_fail_exp"
821       fi
822     fi
823 }
824
825
826 # func_show_eval_locale cmd [fail_exp]
827 # Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
828 # not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
829 # is given, then evaluate it.  Use the saved locale for evaluation.
830 func_show_eval_locale ()
831 {
832     my_cmd="$1"
833     my_fail_exp="${2-:}"
834
835     ${opt_silent-false} || {
836       func_quote_for_expand "$my_cmd"
837       eval "func_echo $func_quote_for_expand_result"
838     }
839
840     if ${opt_dry_run-false}; then :; else
841       eval "$lt_user_locale
842             $my_cmd"
843       my_status=$?
844       eval "$lt_safe_locale"
845       if test "$my_status" -eq 0; then :; else
846         eval "(exit $my_status); $my_fail_exp"
847       fi
848     fi
849 }
850
851 # func_tr_sh
852 # Turn $1 into a string suitable for a shell variable name.
853 # Result is stored in $func_tr_sh_result.  All characters
854 # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
855 # if $1 begins with a digit, a '_' is prepended as well.
856 func_tr_sh ()
857 {
858   case $1 in
859   [0-9]* | *[!a-zA-Z0-9_]*)
860     func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
861     ;;
862   * )
863     func_tr_sh_result=$1
864     ;;
865   esac
866 }
867
868
869
870
871 : ${AUTOCONF="autoconf"}
872 : ${AUTORECONF="autoreconf"}
873 : ${LIBTOOL="./libtool"}
874
875 # Sed that helps us avoid accidentally triggering echo(1) options like -n.
876 Xsed="$SED -e 1s/^X//"
877
878 # Disable usage of config.site for autoconf, unless DJGPP is present.
879 # The DJGPP port of autoconf requires config.site, to work correctly.
880 if test -z "$DJGPP"; then
881     CONFIG_SITE=/nonexistent
882 fi
883
884 # How verbose should we be?  Default is test output in log file.
885 # Setting VERBOSE=debug puts the shell in debug mode.
886 opt_debug=:
887 case "$VERBOSE" in
888 DEBUG | debug )
889   opt_debug='set -x'
890   $opt_debug
891   ;;
892 esac
893
894 if test -z "$srcdir"; then
895   srcdir=`$ECHO "$0" | $SED "$dirname; s,/tests\$,,"`
896   test "$srcdir" = "$0" && srcdir=.
897 fi
898
899 # func_msg arg...
900 # Echo message with prefix.
901 func_msg ()
902 {
903     func_echo "=== " ${1+"$@"}
904 }
905
906 # func_skip arg...
907 # Echo message to standard error, and skip the rest of this test.
908 func_skip ()
909 {
910     func_error ${1+"$@"}
911     exit $EXIT_SKIP
912 }
913
914 # func_fail arg...
915 # Echo message to standard error, and fail this test.
916 func_fail ()
917 {
918     func_fatal_error ${1+"$@"}
919 }
920
921 # func_get_config varname_list src [failp] [regex]
922 func_get_config ()
923 {
924   $opt_debug
925   my_varname_list="$1"
926   my_src="$2"
927   my_failp="false";  test -z "$3" || my_failp=:
928   my_regex="$4"
929
930   my_exitp=false
931   if test -z "$my_regex"; then
932     my_regex="^("
933     my_build_regex=:
934   else
935     my_build_regex=false
936   fi
937   my_first=:
938
939   for my_varname in $my_varname_list; do
940     if $my_build_regex; then
941       $my_first || my_regex="$my_regex|"
942       my_first=false
943       my_regex="$my_regex$my_varname"
944     fi
945     eval $my_varname=NONE
946   done
947   $my_build_regex && my_regex="$my_regex)="
948   eval `eval "$my_src" | eval "$EGREP \"$my_regex\""`
949
950   for my_varname in $my_varname_list; do
951     if eval test x\"\$$my_varname\" = xNONE; then
952       func_error "$my_varname not set in \`$my_src'"
953       $my_failp && my_exitp=:
954     fi
955   done
956
957   $my_exitp && exit $EXIT_FAILURE
958 }
959
960
961 # Extract some variables from the libtool configuration.
962 func_get_config "objext
963 objdir
964 CC
965 host
966 host_os
967 host_alias
968 build
969 build_alias" "$LIBTOOL --config" ": fatal"
970
971
972 # func_mkprefixdir
973 func_mkprefixdir ()
974 {
975     $opt_debug
976     # An absolute path to a test installation directory.
977     func_mkdir_p "$prefix"
978     prefix=`cd $prefix && pwd`
979 }
980
981 # func_rmprefixdir
982 func_rmprefixdir ()
983 {
984     $opt_debug
985     test -d $prefix && rm -rf $prefix
986     prefix=NONE
987 }
988
989 # func_cd dir
990 # Make sure a directory exists, and then change to it.
991 func_cd ()
992 {
993     $opt_debug
994     my_dir="$1"
995
996     # Maybe we have a VPATH build, in which case, create a new subdir.
997     func_mkdir_p "$my_dir"
998
999     # Change to our build directory.
1000     cd "$my_dir" || func_fatal_error "couldn't cd to \`$my_dir'"
1001 }
1002
1003
1004 # func_require prereq file [...]
1005 # If FILE does not exist, give a fatal error regarding running PREREQ first.
1006 func_require ()
1007 {
1008     $opt_debug
1009     my_prereq="$1"; shift
1010     my_files=${1+"$@"}
1011
1012     for my_file in $my_files; do
1013       test -f "$my_file" \
1014         || func_skip "You must run ${my_prereq}.test before running $0"
1015     done
1016 }
1017
1018 # func_configure_nofail [args ...]
1019 # Configure the demonstration.
1020 func_configure_nofail ()
1021 {
1022     $opt_debug
1023     my_args=${1+"$@"}
1024     func_dirname_and_basename "`pwd`"
1025     my_dir=$func_basename_result
1026     my_testdir="$srcdir/tests/$my_dir"
1027     conf_status=$EXIT_FAILURE
1028
1029     test -n "$my_args" && my_args=" $my_args"
1030     my_args="--srcdir="\""$my_testdir"\"" --prefix="\""$prefix"\""$my_args"
1031     test -n "$host_alias" && my_args="$my_args --host=\"$host_alias\""
1032     test -n "$build_alias" && my_args="$my_args --build=\"$build_alias\""
1033
1034     func_msg "Configuring in $my_dir"
1035
1036     test -f "$my_testdir/configure" || ${AUTORECONF} --force --install $my_testdir
1037     if test -f "$my_testdir/configure"; then
1038
1039       eval func_msg $SHELL "$my_testdir/configure" $my_args
1040       if eval $SHELL "$my_testdir/configure" $my_args; then
1041         conf_status=$EXIT_SUCCESS
1042       else
1043         func_msg "FAILED: Configuring in $my_testdir"
1044         ls -ltr $my_testdir
1045       fi
1046     fi
1047 }
1048
1049 # func_configure [args ...]
1050 # Configure the demonstration, fail on error.
1051 func_configure ()
1052 {
1053     func_configure_nofail ${1+"$@"}
1054     if test "$conf_status" -eq "$EXIT_FAILURE"; then
1055       exit $EXIT_FAILURE
1056     fi
1057 }
1058
1059 # func_check_static_shared staticp sharedp
1060 # Determine whether the generated libtool script is configured properly
1061 # for the expected STATICP and SHAREDP library building
1062 func_check_static_shared ()
1063 {
1064     $opt_debug
1065     my_staticp="$1"
1066     my_sharedp="$2"
1067
1068     if func_grep "^build_old_libs=$staticp" libtool &&
1069        func_grep "^build_libtool_libs=$sharedp" libtool; then :
1070     else
1071       rm -f Makefile
1072       exit $EXIT_FAIL
1073     fi
1074 }
1075
1076
1077 # func_make [args ...]
1078 # Do the actual build.
1079 func_make ()
1080 {
1081     $opt_debug
1082     my_args=${1+"$@"}
1083     func_dirname_and_basename "`pwd`"
1084     func_msg "Running \`$MAKE $my_args' in $func_basename_result"
1085
1086     eval $MAKE $my_args || exit $EXIT_FAIL
1087 }
1088
1089
1090 # func_distclean
1091 # Possibly clean up the distribution.
1092 func_make_distclean ()
1093 {
1094     $opt_debug
1095     if test -f Makefile; then
1096       func_make distclean
1097     fi
1098     rm -rf autom4te.cache config.cache
1099 }
1100
1101
1102 # func_make_uninstall
1103 # See that there were no files leftover in $prefix.
1104 # Ignore dotfiles, so that .nfsXXX files don't screw up the test.
1105 func_make_uninstall ()
1106 {
1107     $opt_debug
1108     func_make uninstall
1109
1110     leftovers=`find $prefix ! -type d ! -name '.*' -print`
1111     if test -n "$leftovers"; then
1112       func_msg "Leftover after make uninstall:"
1113       ls -l $leftovers
1114       exit 1
1115     fi
1116 }
1117
1118
1119 # func_exec_init mode
1120 func_exec_init ()
1121 {
1122     $opt_debug
1123     func_dirname_and_basename "`pwd`"
1124     func_msg "Executing $1 programs in $func_basename_result"
1125
1126     # Windows hosts search for dlls in the command path
1127     PATH=$prefix/lib:$PATH
1128
1129     exec_status=$EXIT_SUCCESS
1130 }
1131
1132 # func_exec_check program [msg ...]
1133 # Check to see if PROGRAM was built. If not display MSG.
1134 func_exec_check ()
1135 {
1136     $opt_debug
1137     my_program="$1"
1138
1139     if test -f "$my_program"; then :
1140     else
1141       shift
1142       func_error "$0: $my_program did not build ${1+$@}"
1143       exec_status=$EXIT_FAILURE
1144     fi
1145 }
1146
1147 # func_exec program [exp_output] [msg ...]
1148 # Check to see if PROGRAM really runs, and produces EXP_OUTPUT if given.
1149 # If not display MSG.
1150 func_exec ()
1151 {
1152     $opt_debug
1153     my_program="$1"
1154     my_exp_output="$2"
1155     func_dirname_and_basename "`pwd`"
1156     my_dir=$func_basename_result
1157
1158     test -n "$my_exp_output" \
1159       && my_exp_output="| $EGREP -e "\""$my_exp_output"\"
1160
1161     if eval $my_program $my_exp_output; then :
1162     else
1163       shift
1164       test "x$1" = x || shift
1165       func_error "$0: cannot execute $my_program ${1+$@}"
1166
1167       if test "$build" != "$host"; then
1168         func_msg "This may be ok since you seem to be cross-compiling."
1169         exec_status=$EXIT_SKIP
1170       else
1171         # Simple check to see if they are superuser.
1172         if test $exec_status = $EXIT_FAILURE || test -w /; then :
1173         else
1174           func_msg "You may need to run $0 as the superuser."
1175         fi
1176         exec_status=$EXIT_FAILURE
1177       fi
1178     fi
1179 }
1180
1181 # Shared global variables for test scripts
1182 prefix=./_inst-`echo "$0" | sed 's,.*/,,; s,-.*,,'`
1183 srcdir=`cd $srcdir && pwd`
1184 m4dir=$srcdir/libltdl/m4
1185 auxdir=$srcdir/libltdl/config
1186 scripts="$auxdir/ltmain.m4sh $srcdir/libtoolize.m4sh"
1187
1188 # Unset some MAKE... variables that may cause $MAKE to act like a
1189 # recursively invoked sub-make.  Any $MAKE invocation in a test is
1190 # conceptually an independent invocation.
1191 unset MFLAGS MAKEFLAGS MAKELEVEL __MKLVL__ MAKE_JOBS_FIFO
1192
1193 # On AIX, shared libraries remain loaded in memory after use if they
1194 # are world-readable, until root issues slibclean.  On NFS, this causes
1195 # a testsuite rerun to fail to clean up test group directories.  Avoid
1196 # this with a suitable umask.  Do not do this on other systems, for
1197 # example HP-UX suffers unless shared libraries are mode 555.
1198 case $host_os in
1199 aix*) umask o-rwx ;;
1200 esac
1201
1202 func_msg "Running $progname"
1203
1204 # Local Variables:
1205 # mode:shell-script
1206 # sh-indentation:2
1207 # End:
1208