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