Support ifort on darwin.
[libtool.git] / libtoolize.m4sh
blob092cd25b73b28f9da4714280eaf122d8121326aa
1 m4_define([_m4_divert(SCRIPT)], 100)
2 m4_divert_push([SCRIPT])#! /bin/sh
3 # @configure_input@
5 # libtoolize (GNU @PACKAGE@@TIMESTAMP@) @VERSION@
6 # Written by Gary V. Vaughan <gary@gnu.org>, 2003
8 # Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
9 # This is free software; see the source for copying conditions.  There is NO
10 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 # Libtoolize is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
17 # Libtoolize is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with libtoolize; see the file COPYING.  If not, a copy
24 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
25 # or obtained by writing to the Free Software Foundation, Inc.,
26 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 # Usage: $progname [OPTION]...
30 # Prepare a package to use libtool.
32 # -c, --copy            copy files rather than symlinking them
33 #     --debug           enable verbose shell tracing
34 # -n, --dry-run         print commands rather than running them
35 # -f, --force           replace existing files
36 # -i, --install         copy missing auxiliary files
37 #     --ltdl[=DIR]      install libltdl sources [default: libltdl]
38 #     --no-warn         don't display warning messages
39 #     --nonrecursive    prepare ltdl for non-recursive make
40 # -q, --quiet           work silently
41 #     --recursive       prepare ltdl for recursive make
42 #     --subproject      prepare ltdl to configure and build independently
43 # -v, --verbose         verbosely report processing
44 #     --version         print version information and exit
45 # -h, --help            print short or long help message
47 # The following space or comma delimited options can be passed to $progname
48 # via the environment variable LIBTOOLIZE_OPTIONS, unknown environment
49 # options are ignored:
51 #     --debug           enable verbose shell tracing
52 #     --no-warn         don't display warning messages
53 #     --quiet           work silently
54 #     --verbose         verbosely report processing
56 # You must `cd' to the top directory of your package before you run
57 # `$progname'.
59 # When reporting a bug, please describe a test case to reproduce it and
60 # include the following information:
62 #       host-triplet:   @host_triplet@
63 #       $progname:      (GNU @PACKAGE@@TIMESTAMP@) @VERSION@
64 #       automake:               $automake_version
65 #       autoconf:               $autoconf_version
67 # Report bugs to <bug-libtool@gnu.org>.
69 : ${TAR=tar}
71 PROGRAM=libtoolize
73 AS_SHELL_SANITIZE
74 $as_unset CDPATH
76 m4_include([getopt.m4sh])
78 M4SH_VERBATIM([[
79 # test EBCDIC or ASCII
80 case `echo X|tr X '\101'` in
81  A) # ASCII based system
82     # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
83   SP2NL='tr \040 \012'
84   NL2SP='tr \015\012 \040\040'
85   ;;
86  *) # EBCDIC based system
87   SP2NL='tr \100 \n'
88   NL2SP='tr \r\n \100\100'
89   ;;
90 esac
93 # Command line options:
94 opt_debug=:
95 opt_force=false
96 opt_install=false
97 opt_link=:
98 opt_ltdl=false
100 seen_autoconf=false
101 seen_libtool=false
102 seen_ltdl=false
104 # ltdl can be installed to be self-contained (subproject, the default);
105 # or to be configured by a parent project, either with a recursive or
106 # nonrecursive automake driven make:
107 ltdl_mode=
109 # Locations for important files:
110 prefix=@prefix@
111 datadir=@datadir@
112 pkgdatadir=@pkgdatadir@
113 pkgltdldir=@pkgdatadir@
114 aclocaldir=@aclocaldir@
115 auxdir=
116 macrodir=
117 ltdldir=
118 configure_ac=configure.in
120 # Lists of all files libtoolize has ever installed.  These are removed
121 # before installing the latest files when --force was passed to help
122 # ensure a clean upgrade.
123 # Do not remove config.guess nor config.sub, we don't install them
124 # without --install, and the project may not be using Automake.
125 all_pkgconfig_files="ltmain.sh"
126 all_pkgmacro_files="argz.m4 libtool.m4 ltdl.m4 ltoptions.m4 ltsugar.m4 ltversion.in ltversion.m4 lt~obsolete.m4"
127 all_pkgltdl_files="COPYING.LIB Makefile Makefile.in Makefile.inc Makefile.am README acinclude.m4 aclocal.m4 argz_.h argz.c config.h.in config-h.in configure configure.ac configure.in libltdl/lt__alloc.h libltdl/lt__dirent.h libltdl/lt__glibc.h libltdl/lt__private.h libltdl/lt__strl.h libltdl/lt_dlloader.h libltdl/lt_error.h libltdl/lt_system.h libltdl/slist.h loaders/dld_link.c loaders/dlopen.c loaders/dyld.c loaders/load_add_on.c loaders/loadlibrary.c loaders/preopen.c loaders/shl_load.c lt__alloc.c lt__dirent.c lt__strl.c lt_dlloader.c lt_error.c ltdl.c ltdl.h slist.c"
129 # Parse environment options
131   my_sed_env_opt='1s/^\([^,:; ]*\).*$/\1/;q'
132   my_sed_env_rest='1s/^[^,:; ]*[,:; ]*\(.*\)$/\1/;q'
134   while test -n "$LIBTOOLIZE_OPTIONS"; do
135     opt=`echo "$LIBTOOLIZE_OPTIONS" | sed "$my_sed_env_opt"`
136     LIBTOOLIZE_OPTIONS=`echo "$LIBTOOLIZE_OPTIONS" | sed "$my_sed_env_rest"`
138     case $opt in
139       --debug)          opt_debug=:             ;;
140       --no-warn)        opt_warning=false       ;;
141       --quiet)          opt_quiet=:             ;;
142       --verbose)        opt_verbose=:           ;;
144       --*)      func_warning "unrecognized environment option \`$opt'"    ;;
145       *)        func_fatal_help "garbled LIBTOOLIZE_OPTIONS near \`$opt'" ;;
146     esac
147   done
151 # Parse options once, thoroughly.  This comes as soon as possible in
152 # the script to make things like `libtoolize --version' happen quickly.
154   # sed scripts:
155   my_sed_single_opt='1s/^\(..\).*$/\1/;q'
156   my_sed_single_rest='1s/^..\(.*\)$/\1/;q'
157   my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
158   my_sed_long_arg='1s/^--[^=]*=//'
160   while test "$#" -gt 0; do
161     opt="$1"
162     shift
163     case $opt in
164       --copy|-c)        opt_link=false ;;
166       --debug)          func_echo "enabling shell trace mode"
167                         opt_debug='set -x'
168                         $opt_debug
169                         ;;
171       --dry-run|-n)     if $opt_dry_run; then :; else
172                           opt_dry_run=:
173                           RM="$ECHO $RM"
174                           test -n "$LN_S" && LN_S="$ECHO $LN_S"
175                           CP="$ECHO $CP"
176                           MKDIR="$ECHO $MKDIR"
177                           TAR="$ECHO $TAR"
178                         fi
179                         ;;
181       --force|-f)       opt_force=: ;;
183       --install|-i)     opt_install=: ;;
185       --ltdl)           opt_ltdl=:
186                         if test "$#" -gt 0; then
187                           case $1 in
188                             -*) ;;
189                             *)  ltdldir=`$ECHO "X$1" | $Xsed -e 's,/*$,,'`
190                                 shift
191                                 ;;
192                           esac
193                         fi
194                         ;;
196       --no-warn)        opt_warning=false ;;
198       --nonrecursive|--non-recursive)
199                         ltdl_mode=nonrecursive
200                         ;;
202       --quiet|--automake|-q) # --automake is for 1.5 compatibility
203                         opt_quiet=:
204                         ;;
206       --recursive)      ltdl_mode=recursive ;;
208       --subproject)     ltdl_mode=subproject ;;
210       --verbose|-v)     opt_verbose=: ;;
212       # Separate optargs to long options:
213       --*=*)
214                         arg=`$ECHO "X$opt" | $Xsed -e "$my_sed_long_arg"`
215                         opt=`$ECHO "X$opt" | $Xsed -e "$my_sed_long_opt"`
216                         set dummy "$opt" "$arg" ${1+"$@"}
217                         shift
218                         ;;
220       # Separate optargs to short options:
221       #-X*)
222       #                 arg=`$ECHO "X$opt" | $Xsed -e "$my_sed_single_rest"`
223       #                 opt=`$ECHO "X$opt" | $Xsed -e "$my_sed_single_opt"`
224       #                 set dummy "$opt" "$arg" ${1+"$@"}
225       #                 shift
226       #                 ;;
228       # Separate non-argument short options:
229       -c*|-f*|-i*|-n*|-q*|-v*)
230                         rest=`$ECHO "X$opt" | $Xsed -e "$my_sed_single_rest"`
231                         opt=`$ECHO "X$opt" | $Xsed -e "$my_sed_single_opt"`
232                         set dummy "$opt" "-$rest" ${1+"$@"}
233                         shift
234                         ;;
236       -\?|-h)           func_usage                                      ;;
237       --help)           func_help                                       ;;
238       --version)        func_version                                    ;;
239       --)               break                                           ;;
240       -*)               func_fatal_help "unrecognized option \`$opt'"   ;;
241       *)                func_fatal_help "too many arguments"            ;;
242     esac
243   done
247 # func_echo_once msg_var
248 # Calls func_echo with the value of MSG_VAR, and then sets MSG_VAR="" so
249 # that subsequent calls have no effect.
250 func_echo_once ()
252     $opt_debug
253     if test -n "$1"; then
254       eval my_msg=\$$1
256       if test -n "$my_msg"; then
257         func_echo "$my_msg"
258         eval $1=""
259       fi
260     fi
264 # func_copy srcfile destfile [msg_var]
265 # A wrapper for func_copy_cb that accepts arguments in the same order
266 # as the cp(1) shell command.
267 func_copy ()
269     $opt_debug
271     test -f "$1" || \
272       { func_error "\`$1' not copied:  not a regular file"; return 1; }
274     my_f1=`$ECHO "X$1" | $Xsed -e "$basename"`
276     if test -d "$2"; then
278       func_copy_cb "$my_f1" \
279         `$ECHO "X$1" | $Xsed -e "$dirname"` "$2" "$3"
281     else
283       # Supporting this would mean changing the timestamp:
284       test "X$my_f1" = X`$ECHO "X$2" | $Xsed -e "$basename"` \
285         || func_fatal_error "func_copy() cannot change filename on copy"
287       func_copy_cb "$my_f1" \
288         `$ECHO "X$1" | $Xsed -e "$dirname"` \
289         `$ECHO "X$2" | $Xsed -e "$dirname"` \
290         "$3"
292     fi
294     return $copy_return_status # set in func_copy_cb
298 # func_copy_cb filename srcdir destdir [msg_var]
299 # If option `--copy' was specified, or soft-linking SRCFILE to DESTFILE fails,
300 # then try to copy SRCFILE to DESTFILE (without changing the timestamp if
301 # possible).
302 func_copy_cb ()
304     $opt_debug
305     my_file="$1"
306     my_srcdir="$2"
307     my_destdir="$3"
308     my_msg_var="$4"
309     copy_return_status=1
311     # Libtool is probably misinstalled if this happens:
312     test -f "$my_srcdir/$my_file" || 
313         func_fatal_error "\`$my_file' not found in \`$my_srcdir'"
315     case $opt_verbose in
316       false) my_copy_msg="file \`$my_destdir/$my_file'"     ;;
317       *)     my_copy_msg="file from \`$my_srcdir/$my_file'" ;;
318     esac
319     func_mkdir_p `$ECHO "X$my_destdir/$my_file" | $Xsed -e "$dirname"`
321     $RM "$my_destdir/$my_file"
322     if $opt_link; then
323       if test "$my_file" = "aclocal.m4"; then
324         if { ( cd "$my_srcdir" && $TAR chf - "$my_file" ) 2>/dev/null \
325              | ( umask 0 && cd "$my_destdir" && $TAR xf - ) >/dev/null 2>&1 ; }
326         then
327           $opt_quiet || func_echo_once "$my_msg_var"
328           $opt_quiet || func_echo "copying $my_copy_msg"
329           copy_return_status=0
330         fi
331       else
332         if $LN_S "$my_srcdir/$my_file" "$my_destdir/$my_file"; then
333           $opt_quiet || func_echo_once "$my_msg_var"
334           $opt_quiet || func_echo "linking $my_copy_msg"
335           copy_return_status=0
336         fi
337       fi
338     else
339       if { ( cd "$my_srcdir" && $TAR chf - "$my_file" ) 2>/dev/null \
340            | ( umask 0 && cd "$my_destdir" && $TAR xf - ) >/dev/null 2>&1; } \
341          && touch "$my_destdir/$my_file"; then
342         $opt_quiet || func_echo_once "$my_msg_var"
343         $opt_quiet || func_echo "copying $my_copy_msg"
344         copy_return_status=0
345       fi
346     fi
347     if test "$copy_return_status" != 0; then
348       $opt_quiet || func_echo_once "$my_msg_var"
349       func_error "can not copy \`$my_srcdir/$my_file' to \`$my_destdir/'"
350       exit_status=$EXIT_FAILURE
351     fi
355 # func_copy_some_files srcfile_spec srcdir destdir [msg_var] [cb=func_copy_cb]
356 # Call COPY_CB for each regular file in SRCDIR named by the ':' delimited
357 # names in SRCFILE_SPEC.  The odd calling convention is needed to allow
358 # spaces in file and directory names.
359 func_copy_some_files ()
361     $opt_debug
362     my_srcfile_spec="$1"
363     my_srcdir="$2"
364     my_destdir="$3"
365     my_msg_var="$4"
366     my_copy_cb="${5-func_copy_cb}"
368     my_save_IFS="$IFS"
369     IFS=:
370     for my_filename in $my_srcfile_spec; do
371       IFS="$my_save_IFS"
372       if test -f "$my_srcdir/$my_filename"; then
373         if test "X$my_copy_cb" = Xfunc_copy_cb; then
374           $opt_force || if test -f "$my_destdir/$my_filename"; then
375             $opt_quiet || func_echo_once "$my_msg_var"
376             $opt_quiet \
377               || func_error "\`$my_destdir/$my_filename' exists: use \`--force' to overwrite"
378             continue
379           fi
380         fi
381       else
382         func_echo_once "$my_msg_var"
383         func_fatal_error "\`$my_filename' not found in \`$my_srcdir'"
384       fi
386       $my_copy_cb "$my_filename" "$my_srcdir" "$my_destdir" "$my_msg_var"
387     done
388     IFS="$my_save_IFS"
392 # func_fixup_Makefile srcfile srcdir destdir
393 func_fixup_Makefile ()
395     $opt_debug
396     my_filename="$1"
397     my_srcdir="$2"
398     my_destdir="$3"
399     my_fixup_non_subpackage_script="\
400       s,(LIBOBJS),(ltdl_LIBOBJS),g
401       s,(LTLIBOBJS),(ltdl_LTLIBOBJS),g
402       s,libltdl/configure.ac,,
403       s,libltdl/configure,,
404       s,libltdl/aclocal.m4,,
405       s,libltdl/config-h.in,,
406       s,libltdl/Makefile.am,,
407       s,libltdl/Makefile.in,,
408       /^[        ]*\\\\\$/d"
409     case $my_filename in
410       Makefile.am)
411         my_fixup_non_subpackage_script=`echo "$my_fixup_non_subpackage_script" | \
412                 sed 's,libltdl/,,'`
413         my_fixup_inc_paths_script= ;;
414       Makefile.inc)
415         repl=$ltdldir
416         repl_uscore=`$ECHO "X$repl" | $Xsed -e 's,[/.+-],_,g'`
417         my_fixup_inc_paths_script="\
418           s,libltdl_,@repl_uscore@_,
419           s,libltdl/,@repl@/,
420           s,: libltdl/,: @repl@/,
421           s, -Ilibltdl , -I@repl@ ,
422           s,\\\$(libltdl_,\$(@repl_uscore@_,
423           s,)/libltdl ,)/@repl@ ,
424           s,@repl_uscore@,${repl_uscore},g
425           s,@repl@,${repl},g"
426         ;;
427     esac
429     $RM "$my_destdir/$my_filename" 2>/dev/null
430     $opt_quiet || func_echo "creating file \`$my_destdir/$my_filename'"
431     if $opt_dry_run; then :;
432     else
433       $SED "$my_fixup_non_subpackage_script
434             $my_fixup_inc_paths_script" \
435         < "$my_srcdir/$my_filename" > "$my_destdir/$my_filename" ||
436         func_fatal_error "cannot create $my_destdir/$my_filename"
437     fi
440 # func_scan_files
441 # Scan configure.(ac|in) and aclocal.m4 (if present) for use of libltdl
442 # and libtool.  Possibly running some of these tools if necessary.
443 # Libtoolize affects the contents of aclocal.m4, and should be run before
444 # aclocal, so we can't use configure --trace which relies on a consistent
445 # configure.(ac|in) and aclocal.m4.
446 func_scan_files ()
448     $opt_debug
449     # Prefer configure.ac to configure.in
450     test -f configure.ac && configure_ac=configure.ac
451     test -f "$configure_ac" || configure_ac=
453     # Set local variables to reflect contents of configure.ac
454     my_sed_scan_configure_ac='s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,;
455         /AC_INIT/ {
456             s,^.*$,seen_autoconf=:,
457             p
458         }
459         d'
460     test -z "$configure_ac" \
461         || eval `$SED "$my_sed_scan_configure_ac" "$configure_ac"`
463     $seen_autoconf || {
464         my_configure_ac=
465         test -n "$configure_ac" && my_configure_ac="$configure_ac: "
466         func_verbose "${my_configure_ac}not using Autoconf"
468         # Make sure ltdldir and ltdl_mode have sensible defaults
469         # since we return early here:
470         test -n "$ltdldir" || ltdldir=libltdl
471         test -n "$ltdl_mode" || ltdl_mode=subproject
473         return
474     }
476     # ---------------------------------------------------- #
477     # Probe macro usage in configure.ac and/or aclocal.m4. #
478     # ---------------------------------------------------- #
480     my_sed_traces='s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,
481         s,^.*AC_REQUIRE(.*$,,; s,^.*m4_require(.*$,,; s,^.*m4_define(.*$,,
482         s,^.*A[CU]_DEFUN(.*$,,; s,^.*m4_defun(.*$,,
483         /AC_CONFIG_AUX_DIR(/ {
484             s,^.*AC_CONFIG_AUX_DIR([[   ]*\([^])]*\).*$,ac_auxdir=\1,
485             p
486         }
487         /AC_CONFIG_MACRO_DIR(/ {
488             s,^.*AC_CONFIG_MACRO_DIR([[         ]*\([^])]*\).*$,ac_macrodir=\1,
489             p
490         }
491         /_LT_CONFIG_LTDL_DIR(/d
492         /LT_CONFIG_LTDL_DIR(/ {
493             s,^.*LT_CONFIG_LTDL_DIR([[   ]*\([^])]*\).*$,ac_ltdldir=\1,
494             p
495         }
496         /\@<:@A[CM]_PROG_LIBTOOL/d
497         /A[CM]_PROG_LIBTOOL/ {
498             s,^.*$,seen_libtool=:,
499             p
500         }
501         /the.*option into.*LT_INIT.*parameter/d
502         /\@<:@LT_INIT/d
503         /LT_INIT/                {
504             s,^.*$,seen_libtool=:,
505             p
506         }
507         /\@<:@LTDL_INIT/d
508         /LTDL_INIT/          {
509             s,^.*LTDL_INIT([[   ]*\([^])]*\).*$,ltdl_options="\1",
510             s,^.*LTDL_INIT[     ]*$,seen_ltdl=:,
511             p
512         }
513         /LT_WITH_LTDL/       {
514             s,^.*$,seen_ltdl=:,
515             p
516         }
517         /AC_LIB_LTDL/        {
518             s,^.*$,seen_ltdl=:,
519             p
520         }
521         /AC_WITH_LTDL/       {
522             s,^.*$,seen_ltdl=:,
523             p
524         }
525         d'
526     eval `cat aclocal.m4 "$configure_ac" 2>/dev/null | $SED "$my_sed_traces"`
529     # ----------------- #
530     # Validate ltdldir. #
531     # ----------------- #
533     ac_ltdldir=`$ECHO "X$ac_ltdldir" | $Xsed -e 's,/*$,,'`
535     # If $configure_ac contains AC_CONFIG_LTDL_DIR, check that its
536     # arguments were not given in terms of a shell variable!
537     case "$ac_ltdldir" in
538       *\$*)
539         func_fatal_error "can not handle variables in LT_CONFIG_LTDL_DIR"
540         ;;
541     esac
543     # If neither --ltdl nor LT_CONFIG_LTDL_DIR are specified, default to
544     # `libltdl'.  If both are specified, they must be the same.  Otherwise,
545     # take the one that is given! (If LT_CONFIG_LTDL_DIR is not specified
546     # we suggest adding it later in this code.)
547     case x$ac_ltdldir,x$ltdldir in
548       x,x)      ltdldir=libltdl         ;;
549       x*,x)     ltdldir=$ac_ltdldir     ;;
550       x,x*)     ltdldir=$ltdldir        ;;
551       *)
552         test x"$ac_ltdldir" = x"$ltdldir" || \
553             func_fatal_error "--ltdl='$ltdldir' does not match LT_CONFIG_LTDL_DIR($ac_ltdldir)"
554         ;;
555     esac
558     # ------------------- #
559     # Validate ltdl_mode. #
560     # ------------------- #
562     test -n "$ltdl_options" && seen_ltdl=:
564     # If $configure_ac contains LTDL_INIT, check that its
565     # arguments were not given in terms of a shell variable!
566     case "$ltdl_options" in
567       *\$*)
568         func_fatal_error "can not handle variables in LTDL_INIT"
569         ;;
570     esac
572     # Extract mode name from ltdl_options
573     # FIXME: Diagnose multiple conflicting modes in ltdl_options
574     ac_ltdl_mode=
575     case " $ltdl_options " in
576       *" nonrecursive "*)  ac_ltdl_mode=nonrecursive    ;;
577       *" recursive "*)     ac_ltdl_mode=recursive       ;;
578       *" subproject "*)    ac_ltdl_mode=subproject      ;;
579     esac
581     # If neither --ltdl nor an LTDL_INIT mode are specified, default to
582     # `subproject'.  If both are specified, they must be the same.  Otherwise,
583     # take the one that is given!
584     case x$ac_ltdl_mode,x$ltdl_mode in
585       x,x)      ltdl_mode=subproject    ;;
586       x*,x)     ltdl_mode=$ac_ltdl_mode ;;
587       x,x*)     ltdl_mode=$ltdl_mode    ;;
588       *)
589         test x"$ac_ltdl_mode" = x"$ltdl_mode" || \
590             func_fatal_error "--$ltdl_mode does not match LTDL_INIT($ac_ltdl_mode)"
591         ;;
592     esac
594     # ---------------- #
595     # Validate auxdir. #
596     # ---------------- #
598     if test -n "$ac_auxdir"; then
599       # If $configure_ac contains AC_CONFIG_AUX_DIR, check that it was
600       # not given in terms of a shell variable!
601       case "$ac_auxdir" in
602       *\$*)
603         func_fatal_error "can not handle variables in AC_CONFIG_AUX_DIR"
604         ;;
605       *)
606         auxdir=$ac_auxdir
607         ;;
608       esac
609     else
610       # Try to discover auxdir the same way it is discovered by configure.
611       # Note that we default to the current directory.
612       for dir in . .. ../..; do
613         if test -f "$dir/install-sh"; then
614           auxdir=$dir
615           break
616         elif test -f "$dir/install.sh"; then
617           auxdir="$dir"
618           break
619         fi
620       done
621     fi
623     # Just use the current directory if all else fails.
624     test -n "$auxdir" || auxdir=.
627     # ------------------------------ #
628     # Find local m4 macro directory. #
629     # ------------------------------ #
631     # Hunt for ACLOCAL_AMFLAGS in `Makefile.am' for a `-I' argument.
633     my_sed_aclocal_flags='
634         /^[     ]*ACLOCAL_[A-Z_]*FLAGS[         ]*=/ {
635             s,^[^=]*=[  ]*\(.*\), \1,
636             q
637         }
638         d'
639     if test -f Makefile.am; then
640       my_macrodir_is_next=false
641       for arg in `$SED "$my_sed_aclocal_flags" Makefile.am`; do
642         if $my_macrodir_is_next; then
643           am_macrodir="$arg"
644           break
645         else
646           if test "X$arg" = "X-I"; then
647             my_macrodir_is_next=:
648           else
649             my_macrodir_is_next=false
650           fi
651         fi
652       done
653     fi
655     macrodir="$ac_macrodir"
656     test -z "$macrodir" && macrodir="$am_macrodir"
658     if test -n "$am_macrodir" && test -n "$ac_macrodir"; then
659       test "$am_macrodir" = "$ac_macrodir" \
660         || func_fatal_error "AC_CONFIG_MACRO_DIR([$ac_macrodir]) conflicts with ACLOCAL_AMFLAGS=-I $am_macrodir."
661     fi
664 # func_included_files searchfile
665 # Output INCLUDEFILE if SEARCHFILE m4_includes it, else output SEARCHFILE.
666 func_included_files ()
668     $opt_debug
669     my_searchfile="$1"
671     my_include_regex=
672     my_sed_include='
673         /^m4_include(\[.*\])$/ {
674             s,^m4_include(\[\(.*\)\])$,\1,
675             p
676         }
677         d'
679     if test -f "$my_searchfile"; then
680       $ECHO "X$my_searchfile" | $Xsed
682       # Only recurse when we don't care if all the variables we use get
683       # trashed, since they are in global scope.
684       for my_filename in `$SED "$my_sed_include" "$my_searchfile"`; do
685         func_included_files $my_filename
686       done
687     fi
691 # func_serial filename [macro_regex]
692 # Output the value of the serial number comment in FILENAME, where the
693 # comment line must also match MACRO_REGEX, if given.
694 func_serial ()
696     $opt_debug
697     my_filename="$1"
698     my_macro_regex="$2"
699     my_sed_serial='
700         /^# serial [1-9][0-9.]*[        ]*'"$my_macro_regex"'[  ]*$/ {
701             s,^# serial \([1-9][0-9.]*\).*$,\1,
702             q
703         }
704         d'
706     # Search FILENAME and all the files it m4_includes for a serial number
707     # in the file that AC_DEFUNs MACRO_REGEX.
708     my_serial=
709     for my_file in `func_included_files "$my_filename"`; do
710       if test -z "$my_macro_regex" ||
711          test "$my_filename" = aclocal.m4 ||
712          test "$my_macro_regex" = `echo "$my_filename" | $SED "$basename"` ||
713          func_grep '^AC_DEFUN(\@<:@'"$my_macro_regex" "$my_file"
714       then
715         my_serial=`$SED -e "$my_sed_serial" "$my_file"`
716         break
717       fi
718     done
720     # If the file has no serial number, we assume it's ancient.
721     test -n "$my_serial" || my_serial=0
723     $ECHO $my_serial
727 # func_serial_max serial1 serial2
728 # Compare (possibly multi-part, '.' delimited) serial numbers, and
729 # return the largest in $func_serial_max_result.  If they are the
730 # same, func_serial_max_result will be empty.
731 func_serial_max ()
733     $opt_debug
734     my_serial1="$1"
735     my_serial2="$2"
737     my_sed_dot='s/\..*$//g'
738     my_sed_rest='s/^[0-9][1-9]*\.*//'
739     my_sed_digits='s/[^0-9.]//g'
741     # Incase they turn out to be the same, we'll set it to empty
742     func_serial_max_result=
744     test "X$1$2" = X`$ECHO "X$1$2" | $Xsed -e "$my_sed_digits"` || {
745       func_error "serial numbers \`$1' or \`$2' contain non-digit chars"
746       return
747     }
749     while test -n "$my_serial1$my_serial2"; do
750       my_serial1_part=`$ECHO "X$my_serial1" | $Xsed -e "$my_sed_dot"`
751       my_serial2_part=`$ECHO "X$my_serial2" | $Xsed -e "$my_sed_dot"`
753       test -z "$my_serial1_part$my_serial2_part" \
754         && break
756       test -z "$my_serial1_part" \
757         && { func_serial_max_result="$2"; break; }
759       test -z "$my_serial2_part" \
760         && { func_serial_max_result="$1"; break; }
762       test "$my_serial1_part" -gt "$my_serial2_part" \
763         && { func_serial_max_result="$1"; break; }
765       test "$my_serial2_part" -gt "$my_serial1_part" \
766         && { func_serial_max_result="$2"; break; }
768       my_serial1=`$ECHO "X$my_serial1" | $Xsed -e "$my_sed_rest"`
769       my_serial2=`$ECHO "X$my_serial2" | $Xsed -e "$my_sed_rest"`
770     done
774 # func_serial_update_check srcfile src_serial destfile dest_serial
775 # Unless SRC_SERIAL is newer than DEST_SERIAL set $func_serial_update_check
776 # to 'false'.
777 func_serial_update_check ()
779     $opt_debug
780     my_srcfile="$1"
781     my_src_serial="$2"
782     my_destfile="$3"
783     my_dest_serial="$4"
784     my_update_p=:
786     if test -f "$my_destfile"; then
787       test "X$my_src_serial" = "X0" && {
788         func_warning "no serial number on \`$my_srcfile', not copying."
789         return
790       }
792       # Determine whether the destination has an older serial.
793       func_serial_max "$my_src_serial" "$my_dest_serial"
794       test "X$my_src_serial" = "X$func_serial_max_result" || my_update_p=false
796       test "X$my_src_serial" = "X$func_serial_max_result" \
797         && func_verbose "\`$my_srcfile' is serial $my_src_serial, greater than $my_dest_serial in \`$my_destfile'"
799       if test "X$my_dest_serial" = "X$func_serial_max_result"; then
800         func_verbose "\`$my_srcfile' is serial $my_src_serial, less than $my_dest_serial in \`$my_destfile'"
801         $opt_force || if test -n "$ac_macrodir$ac_ltdldir"; then
802            func_error "\`$my_destfile' is newer: use \`--force' to overwrite"
803         fi
804       fi
805     fi
807     func_serial_update_check_result="$my_update_p"
811 # func_aclocal_update_check filename
812 # Unless serial number of FILENAME is newer than the matching serial number
813 # in aclocal.m4, set $func_aclocal_update_check to 'false'.
814 func_aclocal_update_check ()
816     $opt_debug
817     my_srcfile="$aclocaldir/$1"
818     my_destfile="aclocal.m4"
820     case $need in
821       libtool.m4)
822         my_src_serial=`func_serial "$my_srcfile" LT_INIT`
823         my_dest_serial=`func_serial "$my_destfile" LT_INIT`
825         # Strictly, this libtoolize ought not to have to deal with ancient
826         # serial formats, but we accept them here to be complete:
827         test "X$my_src_serial" = "X0" &&
828           my_src_serial=`func_serial "$my_srcfile" 'A[CM]_PROG_LIBTOOL'`
829         test "X$my_dest_serial" = "X0" &&
830           my_dest_serial=`func_serial "$my_destfile" 'A[CM]_PROG_LIBTOOL'`
831         ;;
832       ltdl.m4)
833         my_src_serial=`func_serial "$my_srcfile" LTDL_INIT`
834         my_dest_serial=`func_serial "$my_destfile" LTDL_INIT`
835         ;;
836       *)
837         my_src_serial=`func_serial "$my_srcfile" "$need"`
838         my_dest_serial=`func_serial "$my_destfile" "$need"`
839         ;;
840     esac
842     func_serial_update_check \
843       "$my_srcfile" "$my_src_serial" "$my_destfile" "$my_dest_serial"
845     func_aclocal_update_check_result="$func_serial_update_check_result"
849 # func_serial_update filename srcdir destdir [msg_var] [macro_re] [old_macro_re]
850 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
851 # has a newer serial number, or DESTFILE does not yet exist, or the user
852 # specified `--force' at the command line.  If given, MACRO_REGEX or
853 # OLD_MACRO_REGEX must match any text after "# serial N" in both files.
854 func_serial_update ()
856     $opt_debug
857     my_filename="$1"
858     my_srcdir="$2"
859     my_destdir="$3"
860     my_msg_var="$4"
861     my_macro_regex="$5"
862     my_old_macro_regex="$6"
864     my_serial_update_p=:
865     my_return_status=1
866     my_srcfile="$my_srcdir/$my_filename"
867     my_destfile="$my_destdir/$my_filename"
869     test -f "$my_srcfile" || func_fatal_error "\`$my_srcfile' does not exist."
871     if test -f "$my_destfile"; then
872       my_src_serial=`func_serial "$my_srcfile" "$my_macro_regex"`
873       my_dest_serial=`func_serial "$my_destfile" "$my_macro_regex"`
875       # Strictly, this libtoolize ought not to have to deal with ancient
876       # serial formats, but we accept them here to be complete:
877       test "X$my_src_serial" = "X0" &&
878         my_src_serial=`func_serial "$my_srcfile" "$my_old_macro_regex"`
880       test "X$my_dest_serial" = "X0" &&
881         my_dest_serial=`func_serial "$my_destfile" "$my_old_macro_regex"`
883       func_serial_update_check \
884         "$my_srcfile" "$my_src_serial" "$my_destfile" "$my_dest_serial"
885       my_serial_update_p="$func_serial_update_check_result"
886     fi
888     if $my_serial_update_p || $opt_force; then
889       func_copy "$my_srcfile" "$my_destfile" "$my_msg_var"
890       my_return_status=$?
891     elif $opt_force && test "X$my_dest_serial" = "X$my_src_serial"; then
892       $opt_quiet || func_echo_once "$my_msg_var"
893       $opt_quiet \
894         || func_echo "\`$my_destfile' is already up to date."
895     fi
897     # Do this after the copy for hand maintained `aclocal.m4', incase
898     # it has `m4_include([DESTFILE])', so the copy effectively already
899     # updated `aclocal.m4'.
900     my_included_files=`func_included_files aclocal.m4`
901     case `echo " $my_included_files " | $NL2SP` in
903       # Skip included files:
904       *" $my_destfile "*) ;;
906       # Otherwise compare to aclocal.m4 serial number (func_serial
907       # returns 0 for older macro serial numbers before we provided
908       # serial tags, so the update message will be correctly given
909       # if aclocal.m4 contains an untagged --i.e older-- macro file):
910       *)
911         if test -f aclocal.m4; then
912           func_serial_max \
913               "$my_src_serial" `func_serial aclocal.m4 "$my_macro_regex"`
914           if test "X$my_src_serial" = "X$func_serial_max_result"; then
915               func_echo_once "$my_msg_var"
916               func_echo "You should add the contents of \`$my_destfile' to \`aclocal.m4'."
917           fi
918         fi
919         ;;
920     esac
921     return $my_return_status
925 # func_keyword_update filename srcdir destdir sed_script [msg_var]
926 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
927 # has a newer revision according to the serial number extracted by
928 # SED_SCRIPT, or DESTFILE does not yet exist, or the user specified
929 # `--force' at the command line.
930 func_keyword_update ()
932     $opt_debug
933     my_filename="$1"
934     my_srcdir="$2"
935     my_destdir="$3"
936     my_sed_script="$4"
937     my_msg_var="$5"
939     my_srcfile="$my_srcdir/$my_filename"
940     my_destfile="$my_destdir/$my_filename"
942     my_keyword_update_p=:
944     test -f "$my_srcfile" || func_fatal_error "\`$my_srcfile' does not exist."
946     if test -f "$my_destfile"; then
947       my_src_serial=`$SED -e "$my_sed_script" "$my_srcfile"`
948       test -z "$my_src_serial" && {
949         func_warning "no serial number in \`$my_srcfile', not copying."
950         return
951       }
953       my_dest_serial=`$SED -e "$my_sed_script" "$my_destfile"`
954       test -n "$my_dest_serial" || my_dest_serial=0
956       func_serial_update_check \
957          "$my_srcfile" "$my_src_serial" "$my_destfile" "$my_dest_serial"
958       my_keyword_update_p="$func_serial_update_check_result"
959     fi
961     if $my_keyword_update_p || $opt_force; then
962       func_copy "$my_srcfile" "$my_destfile" "$my_msg_var"
963     elif $opt_verbose || $opt_force && test "X$my_dest_serial" = "X$my_src_serial"; then
964       func_echo_once "$my_msg_var"
965       func_echo "\`$my_destfile' is already up to date."
966     fi
970 # func_ltmain_update filename srcdir destdir [msg_var]
971 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
972 # has a newer revision, or DESTFILE does not yet exist, or the user
973 # specified `--force' at the command line.
974 func_ltmain_update ()
976     $opt_debug
977     my_sed_ltmain='
978         /^package_revision='\''*[0-9][1-9.]*'\''*/ {
979             s,^package_revision='\''*\([0-9.]*\)'\''*[  ]*$,\1,
980             p
981         }
982         d'
984     func_keyword_update "$1" "$2" "$3" "$my_sed_ltmain" "$4"
986     return $my_return_status
990 # func_config_update filename srcdir destdir [msg_var]
991 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
992 # has a newer timestamp, or DESTFILE does not yet exist, or the user
993 # specified `--force' at the command line.
994 func_config_update ()
996     $opt_debug
997     my_sed_config='
998         /^timestamp='\''*[0-9][1-9-]*'\''*/ {
999             s,^timestamp='\''*\([0-9-]*\)'\''*,\1,
1000             s/-/./g
1001             p
1002         }
1003         d'
1005     func_keyword_update "$1" "$2" "$3" "$my_sed_config" "$4"
1007     return $my_return_status
1011 # func_install_update filename srcdir destdir [msg_var]
1012 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
1013 # has a newer timestamp, or DESTFILE does not yet exist, or the user
1014 # specified `--force' at the command line.
1015 func_install_update ()
1017     $opt_debug
1018     my_sed_install='
1019         /^scriptversion='\''*[0-9][1-9.-]*'\''*/ {
1020             s,^scriptversion='\''*\([0-9.-]*\)'\''*,\1,
1021             s/-/./g
1022             p
1023         }
1024         d'
1026     func_keyword_update "$1" "$2" "$3" "$my_sed_install" "$4"
1028     return $my_return_status
1032 # func_massage_aclocal_DATA [glob_exclude]
1033 # @aclocal_DATA\@ is substituted as per its value in Makefile.am;
1034 # this function massages it into a suitable format for func_copy_some_files.
1035 func_massage_aclocal_DATA ()
1037     $opt_debug
1038     pkgmacro_files=     # GLOBAL VAR
1040     my_glob_exclude="$1"
1042     # Massage a value for pkgmacro_files from the value used in Makefile.am.
1043     for my_filename in @aclocal_DATA@; do
1044       my_filename=`$ECHO "X$my_filename" | $Xsed -e "$basename"`
1046       # ignore excluded filenames
1047       if test -n "$my_glob_exclude"; then
1048         my_cont=false
1049         eval 'case $my_filename in '$my_glob_exclude') my_cont=: ;; esac'
1050         $my_cont && continue
1051       fi
1053       pkgmacro_files="$pkgmacro_files:$my_filename"
1054     done
1056     # strip spurious leading `:'
1057     pkgmacro_files=`$ECHO "X$pkgmacro_files" | $Xsed -e 's,^:*,,'`
1061 # func_install_pkgmacro_subproject
1062 # Unless --quiet was passed, display a message. Then copy pkgmacro_files
1063 # from libtool installation tree to subproject libltdl tree.
1064 func_install_pkgmacro_subproject ()
1066     $opt_debug
1068     # Remove any lingering files that my have been installed by some
1069     # previous libtoolize release:
1070     $opt_force && for file in $all_pkgmacro_files; do
1071       test -f "$subproject_macrodir/$file" && func_verbose "rm -f '$subproject_macrodir/$file'"
1072       rm -f "$subproject_macrodir/$file"
1073     done
1075     # Copy all the files from installed libltdl to this project, if the
1076     # user specified a macrodir.
1077     $opt_quiet || if test "x$macrodir" != "x$subproject_macrodir"; then
1078       pkgmacro_header="putting macros in \`$subproject_macrodir'."
1079     elif test -n "$subproject_macrodir"; then
1080       pkgmacro_header="putting macros in AC_CONFIG_MACRO_DIR, \`$subproject_macrodir'."
1081     fi
1083     func_copy_some_files "argz.m4:libtool.m4:ltdl.m4:$pkgmacro_files" \
1084       "$aclocaldir" "$subproject_macrodir" pkgmacro_header
1088 # func_install_pkgmacro_parent
1089 # Unless --quiet was passed, or AC_CONFIG_MACRO_DIR was not seen, display
1090 # a message.  Then update appropriate macros if newer ones are available
1091 # from the libtool installation tree.
1092 func_install_pkgmacro_parent ()
1094     $opt_debug
1096     # Remove any lingering files that my have been installed by some
1097     # previous libtoolize release:
1098     $opt_force && for file in $all_pkgmacro_files; do
1099       test -f "$macrodir/$file" && func_verbose "rm -f '$macrodir/$file'"
1100       rm -f "$macrodir/$file"
1101     done
1103     # Copy all the files from installed libltdl to this project, if the
1104     # user specified a macrodir.
1105     $opt_quiet || if test -n "$ac_macrodir"; then
1106       my_pkgmacro_header="putting macros in AC_CONFIG_MACRO_DIR, \`$ac_macrodir'."
1107     elif test -n "$macrodir"; then
1108       my_pkgmacro_header="putting macros in \`$macrodir'."
1109     fi
1111     if $opt_ltdl; then
1112       func_serial_update argz.m4 "$aclocaldir" "$macrodir" \
1113         my_pkgmacro_header argz.m4
1114     else
1115       func_verbose "Not copying \`$macrodir/argz.m4', libltdl not used."
1116     fi
1118     func_serial_update  libtool.m4 "$aclocaldir" "$macrodir" \
1119       my_pkgmacro_header LT_INIT 'A[CM]_PROG_LIBTOOL'
1121     if $opt_ltdl; then
1122       func_serial_update ltdl.m4 "$aclocaldir" "$macrodir" \
1123         my_pkgmacro_header 'LTDL_INIT'
1124     else
1125       func_verbose "Not copying \`$macrodir/ltdl.m4', libltdl not used."
1126     fi
1128     my_save_IFS="$IFS"
1129     IFS=:
1130     for file in $pkgmacro_files; do
1131       IFS="$my_save_IFS"
1132       func_serial_update "$file" "$aclocaldir" "$macrodir" \
1133         my_pkgmacro_header "$file"
1134     done
1135     IFS="$my_save_IFS"
1139 # func_install_pkgmacro_files
1140 # Install copies of the libtool and libltdl m4 macros into this package.
1141 func_install_pkgmacro_files ()
1143     $opt_debug
1145     # argz.m4, libtool.m4 and ltdl.m4 are handled specially:
1146     func_massage_aclocal_DATA 'argz.m4|libtool.m4|ltdl.m4'
1148   # 1. Parent has separate macrodir to subproject ltdl:
1149     if $opt_ltdl && test "x$ltdl_mode" = "xsubproject" &&
1150        test -n "$macrodir" && test "x$macrodir" != "x$subproject_macrodir"
1151     then
1152       func_install_pkgmacro_parent
1153       func_install_pkgmacro_subproject
1155   # 2. Parent shares macrodir with subproject ltdl:
1156     elif $opt_ltdl && test "x$ltdl_mode" = "xsubproject"
1157        # && test "x$macrodir" = "x$subproject_macrodir"
1158     then
1159       func_install_pkgmacro_subproject
1161   # 3. Not a subproject, but macrodir was specified in parent:
1162     elif test -n "$macrodir"; then
1163       func_install_pkgmacro_parent
1165   # 4. AC_CONFIG_MACRO_DIR was not specified:
1166     else
1167       func_verbose "AC_CONFIG_MACRO_DIR not defined, not copying libtool macros."
1168     fi
1172 # func_massage_pkgltdl_files [glob_exclude]
1173 # @pkgltdl_files\@ is substituted as per its value in Makefile.am; this
1174 # function massages it into a suitable format for func_copy_some_files.
1175 func_massage_pkgltdl_files ()
1177     $opt_debug
1178     pkgltdl_files=      # GLOBAL VAR
1180     my_glob_exclude="$1"
1182     # Massage a value for pkgltdl_files from the value used in Makefile.am
1183     for my_filename in @pkgltdl_files@; do
1185       # Strip surplus leading 'libltdl/':
1186       my_filename=`expr "X$my_filename" : 'Xlibltdl/\(.*\)'`
1188       # ignore excluded filenames
1189       if test -n "$my_glob_exclude"; then
1190         my_cont=false
1191         eval 'case $my_filename in '$my_glob_exclude') my_cont=: ;; esac'
1192         $my_cont && continue
1193       fi
1195       # ignore duplicates
1196       case :$pkgltdl_files: in
1197         *:$my_filename:*) ;;
1198         *) pkgltdl_files="$pkgltdl_files:$my_filename" ;;
1199       esac
1200     done
1202     # strip spurious leading `:'
1203     pkgltdl_files=`$ECHO "X$pkgltdl_files" | $Xsed -e 's,^:*,,'`
1207 # func_install_pkgltdl_files
1208 # Install copies of the libltdl files into this package.  Any auxiliary
1209 # or m4 macro files needed in the libltdl tree will also be copied by
1210 # func_install_pkgconfig_files and func_install_pkgmacro_files resp.
1211 func_install_pkgltdl_files ()
1213     $opt_debug
1214     $opt_ltdl || return
1216     # Remove any lingering files that my have been installed by some
1217     # previous libtoolize release:
1218     $opt_force && for file in $all_pkgltdl_files; do
1219       test -f "$ltdldir/$file" && func_verbose "rm -f '$ltdldir/$file'"
1220       rm -f "$ltdldir/$file"
1221     done
1223     # Copy all the files from installed libltdl to this project, if the
1224     # user specified `--ltdl'.
1225     $opt_quiet || if test -n "$ac_ltdldir"; then
1226       pkgltdl_header="putting libltdl files in LT_CONFIG_LTDL_DIR, \`$ac_ltdldir'."
1227     elif test -n "$ltdldir"; then
1228       pkgltdl_header="putting libltdl files in \`$ltdldir'."
1229     fi
1231     # These files are handled specially, depending on ltdl_mode:
1232     if test "x$ltdl_mode" = "xsubproject"; then
1233       func_massage_pkgltdl_files 'Makefile.inc'
1234     else
1235       func_massage_pkgltdl_files 'Makefile.am|Makefile.in*|aclocal.m4|config*'
1236     fi
1238     func_copy_some_files "$pkgltdl_files" \
1239       "$pkgltdldir/libltdl" "$ltdldir" pkgltdl_header
1241     # For recursive ltdl modes, copy a suitable Makefile.{am,inc}:
1242     case $ltdl_mode in
1243       recursive)
1244         func_fixup_Makefile "Makefile.am" "$pkgltdldir/libltdl" "$ltdldir"
1245         ;;
1246       nonrecursive)
1247         func_fixup_Makefile "Makefile.inc" "$pkgltdldir/libltdl" "$ltdldir"
1248         ;;
1249     esac
1253 # func_massage_pkgconfig_files [glob_exclude]
1254 # @pkgconfig_files\@ is substituted as per its value in Makefile.am; this
1255 # function massages it into a suitable format for func_copy_some_files.
1256 func_massage_pkgconfig_files ()
1258     $opt_debug
1259     pkgconfig_files=    # GLOBAL VAR
1261     my_glob_exclude="$1"
1263     # Massage a value for pkgconfig_files from the value used in Makefile.am
1264     for my_filename in @pkgconfig_files@; do
1266       # ignore excluded filenames
1267       if test -n "$my_glob_exclude"; then
1268         my_cont=false
1269         eval 'case $my_filename in '$my_glob_exclude') my_cont=: ;; esac'
1270         $my_cont && continue
1271       fi
1273       # ignore duplicates
1274       case :$pkgconfig_files: in
1275         *:$my_filename:*) ;;
1276         *) pkgconfig_files="$pkgconfig_files:$my_filename" ;;
1277       esac
1278     done
1280     # strip spurious leading `:'
1281     pkgconfig_files=`$ECHO "X$pkgconfig_files" | $Xsed -e 's,^:*,,'`
1285 # func_install_pkgconfig_subproject
1286 # Unless --quiet was passed, display a message. Then copy pkgconfig_files
1287 # from libtool installation tree to subproject libltdl tree.
1288 func_install_pkgconfig_subproject ()
1290     $opt_debug
1292     # Remove any lingering files that my have been installed by some
1293     # previous libtoolize release:
1294     $opt_force && for file in $all_pkgconfig_files; do
1295       test -f "$subproject_auxdir/$file" && func_verbose "rm -f '$subproject_auxdir/$file'"
1296       rm -f "$subproject_auxdir/$file"
1297     done
1299     # Copy all the files from installed libltdl to this project, if the
1300     # user specified an auxdir.
1301     $opt_quiet || if test "x$ac_auxdir" = "x$subproject_auxdir"; then
1302       pkgconfig_header="putting auxiliary files in AC_CONFIG_AUX_DIR, \`$subproject_auxdir'."
1303     elif test -n "$auxdir"; then
1304       pkgconfig_header="putting auxiliary files in \`$auxdir'."
1305     fi
1307     func_copy_some_files "$pkgconfig_files" \
1308       "$pkgdatadir" "$ltdldir" pkgconfig_header
1312 # func_install_pkgconfig_parent
1313 # Unless --quiet was passed, or AC_CONFIG_AUX_DIR was not seen, display a
1314 # message.  Then update appropriate auxiliary files if newer ones are
1315 # available from the libtool installation tree.
1316 func_install_pkgconfig_parent ()
1318     $opt_debug
1320     # Remove any lingering files that my have been installed by some
1321     # previous libtoolize release:
1322     $opt_force && for file in $all_pkgconfig_files; do
1323       test -f "$auxdir/$file" && func_verbose "rm -f '$auxdir/$file'"
1324       rm -f "$auxdir/$file"
1325     done
1327     if test -n "$ac_auxdir"; then
1328       pkgconfig_header="putting auxiliary files in AC_CONFIG_AUX_DIR, \`$ac_auxdir'."
1329     elif test -n "$auxdir" || test "x$ltdldir" = "x."; then
1330       pkgconfig_header="putting auxiliary files in \`$auxdir'."
1331     fi
1333     if $opt_install; then
1334       func_config_update config.guess \
1335         "$pkgdatadir/config" "$auxdir" pkgconfig_header
1336       func_config_update config.sub \
1337         "$pkgdatadir/config" "$auxdir" pkgconfig_header
1338       func_install_update install-sh \
1339         "$pkgdatadir/config" "$auxdir" pkgconfig_header
1340     fi
1341     func_ltmain_update ltmain.sh \
1342       "$pkgdatadir/config" "$auxdir" pkgconfig_header
1346 # func_install_pkgconfig_files
1347 # Install copies of the auxiliary files into this package according to
1348 # the whether libltdl is included as a subproject, and whether the parent
1349 # shares the AC_CONFIG_AUX_DIR setting.
1350 func_install_pkgconfig_files ()
1352     $opt_debug
1353     func_massage_pkgconfig_files
1355   # 1. Parent shares auxdir with subproject ltdl:
1356     if $opt_ltdl && test "x$ltdl_mode" = "xsubproject" &&
1357        test "x$ac_auxdir" = "x$subproject_auxdir"
1358     then
1359       func_install_pkgconfig_subproject
1361   # 2. Parent has separate auxdir to subproject ltdl:
1362     elif $opt_ltdl && test "x$ltdl_mode" = "xsubproject"
1363        # && test "x$auxdir" != "x$subproject_auxdir" is implied
1364     then
1365       if $seen_autoconf; then
1366         func_install_pkgconfig_parent
1367       fi
1368       func_install_pkgconfig_subproject
1370   # 3. Not subproject, but AC_CONFIG_AUX_DIR was used in parent:
1371     elif test -n "$ac_auxdir" || test "x$auxdir" = "x."; then
1372       func_install_pkgconfig_parent
1374   # 4. AC_CONFIG_AUX_DIR was not specified:
1375     else
1376       func_verbose "AC_CONFIG_AUX_DIR not defined, not copying libtool auxiliary files."
1377     fi
1381 # func_nonemptydir_p dirvar
1382 # DIRVAR is the name of a variable to evaluate.  Unless DIRVAR names
1383 # a directory that exists and is non-empty abort with a diagnostic.
1384 func_nonemptydir_p ()
1386     $opt_debug
1387     my_dirvar="$1"
1388     my_dir=`eval echo "\\\$$my_dirvar"`
1390     # Is it a directory at all?
1391     test -d "$my_dir" \
1392       || func_fatal_error "\$$my_dirvar not a directory: \`$my_dir'"
1394     # check that the directories contents can be ls'ed
1395     test -n "`{ cd $my_dir && ls; } 2>/dev/null`" \
1396         || func_fatal_error "can not list files: \`$my_dir'"
1400 # func_check_macros
1401 # Sanity check macros from aclocal.m4 against installed versions.
1402 func_check_macros ()
1404     $opt_debug
1405     $opt_quiet && return
1406     $seen_autoconf || return
1408     ac_config_macro_dir_advised=false
1410     if test -n "$ac_macrodir$ltdldir" && test -z "$macrodir"; then
1411       my_ac_config_macro_srcdir="$aclocaldir"
1412       if $opt_ltdl && test "$macrodir" != "$subproject_macrodir"; then
1413         my_ac_config_macro_srcdir="$subproject_macrodir"
1414       fi
1416       my_needed="libtool.m4 ltoptions.m4 ltversion.m4 ltsugar.m4 lt~obsolete.m4"
1417       $opt_ltdl && my_needed="$my_needed argz.m4 ltdl.m4"
1419       if test -f "aclocal.m4"; then
1420         for need in $my_needed; do
1421           func_aclocal_update_check $need
1422           $func_aclocal_update_check_result && my_missing="$my_missing $need"
1423         done
1424       else
1425         my_missing="$my_needed"
1426       fi
1428       if test -n "$my_missing"; then
1429         func_echo "You should add the contents of the following files to \`aclocal.m4':"
1430         for need in $my_missing; do
1431           func_echo "  \`$my_ac_config_macro_srcdir/$need'"
1432         done
1434         if test "$my_ac_config_macro_srcdir" != "$aclocaldir"; then
1435           func_echo "or else add \`AC_CONFIG_MACRO_DIR([$subproject_macrodir])' to $configure_ac."
1436           ac_config_macro_dir_advised=:
1437         fi
1438       fi
1439     fi
1441     ## ---------------------------------------------------------- ##
1442     ## Since we return early here when --no-warn was given:       ##
1443     ## DO NOT PUT ANYTHING BUT UPGRADE ADVICE MESSAGES BELOW HERE ##
1444     ## ---------------------------------------------------------- ##
1446     $opt_warning || return
1448     $seen_libtool ||
1449       func_echo "Remember to add \`LT_INIT' to $configure_ac."
1451     # Suggest using LTDL_INIT if appropriate:
1452     $opt_ltdl && if test x$seen_ltdl != x:; then
1453       case $ltdl_mode in
1454         subproject) ltdl_init_args=""               ;;
1455         *)          ltdl_init_args="([$ltdl_mode])" ;;
1456       esac
1457       func_echo "Remember to add \`LTDL_INIT$ltdl_init_args' to $configure_ac."
1458     fi
1460     if $opt_ltdl; then
1461       # Remind the user to call LT_CONFIG_LTDL_DIR:
1462       test -n "$ac_ltdldir" ||
1463         func_echo "Remember to add \`LT_CONFIG_LTDL_DIR([$ltdldir])' to \`$configure_ac'."
1465       # For subproject mode, offer some suggestions for avoiding duplicate
1466       # files in a project that uses libltdl:
1467       if test "x$ltdl_mode" = "xsubproject"; then
1468         test "$subproject_auxdir" = "$auxdir" ||
1469           func_echo "Consider using \`AC_CONFIG_AUX_DIR([$subproject_auxdir])' in $configure_ac."
1470         $ac_config_macro_dir_advised || test "$subproject_macrodir" = "$macrodir" ||
1471           func_echo "Consider using \`AC_CONFIG_MACRO_DIR([$subproject_macrodir])' in $configure_ac."
1472         ac_config_macro_dir_advised=:
1473       fi
1474     fi
1476     # Suggest modern idioms for storing autoconf macros:
1477     $ac_config_macro_dir_advised || if test -z "$ac_macrodir" || test x"$macrodir" = x.; then
1478       func_echo "Consider adding \`AC_CONFIG_MACRO_DIR([m4])' to $configure_ac and"
1479       func_echo "rerunning libtoolize, to keep the correct libtool macros in-tree."
1480       ac_config_macro_dir_advised=:
1482     elif test -z "$ac_macrodir$ltdldir"; then
1483       func_echo "Consider adding \`AC_CONFIG_MACRO_DIR([$macrodir])' to $configure_ac,"
1484       func_echo "and rerunning libtoolize and aclocal."
1485       ac_config_macro_dir_advised=:
1486     fi
1488     if test -z "$am_macrodir$macrodir"; then
1489       func_echo "Consider adding \`-I m4' to ACLOCAL_AMFLAGS in Makefile.am."
1491     elif test -z "$am_macrodir"; then
1492       if $opt_ltdl && test "x$ltdl_mode" = "xsubproject" && test "$subproject_macrodir" != "$macrodir"; then
1493         func_echo "Consider adding \`-I $subproject_macrodir' to ACLOCAL_AMFLAGS in Makefile.am."
1494       else
1495         func_echo "Consider adding \`-I $macrodir' to ACLOCAL_AMFLAGS in Makefile.am."
1496       fi
1497     fi 
1499     # Don't trace for this, we're just checking the user didn't invoke it
1500     # directly from configure.ac.
1501     $SED 's,dnl .*$,,; s,# .*$,,' "$configure_ac" | grep AC_PROG_RANLIB >/dev/null &&
1502       func_echo "\`AC_PROG_RANLIB' is rendered obsolete by \`LT_INIT'"
1504     # FIXME: Ensure ltmain.sh, libtool.m4 and ltdl.m4 are from the same release
1508 ## ----------- ##
1509 ##    Main.    ##
1510 ## ----------- ##
1513   # Allow the user to override the master libtoolize repository:
1514   if test -n "$_lt_pkgdatadir"; then
1515     pkgltdldir="$_lt_pkgdatadir"
1516     pkgdatadir="$_lt_pkgdatadir/libltdl"
1517     aclocaldir="$_lt_pkgdatadir/libltdl/m4"
1518   fi
1519   func_nonemptydir_p pkgltdldir
1520   func_nonemptydir_p pkgdatadir
1521   func_nonemptydir_p aclocaldir
1523   func_scan_files
1525   case $ltdldir in
1526   .) ltdlprefix= ;;
1527   *) ltdlprefix=$ltdldir/ ;;
1528   esac
1529   subproject_auxdir=${ltdlprefix}config
1530   subproject_macrodir=${ltdlprefix}m4
1532   # :::BE CAREFUL HERE:::
1533   # func_check_macros needs to check whether --ltdl was specified when
1534   # LTDL_INIT was not seen, so we can't just use one variable for both
1535   # conditions, or that check will be impossible.   No need to clutter the
1536   # rest of the code with '$opt_ltdl || $seen_ltdl' though, because we CAN
1537   # safely set opt_ltdl to true if LTDL_INIT was seen:
1538   $seen_ltdl && opt_ltdl=:
1540   func_install_pkgconfig_files
1541   func_install_pkgmacro_files
1542   func_install_pkgltdl_files
1544   func_check_macros
1547 exit $exit_status
1549 # Local Variables:
1550 # mode:shell-script
1551 # sh-indentation:2
1552 # End: