riscv64: update config.sub and config.guess
[platform/upstream/libtool.git] / libtoolize.in
1 #! /bin/sh
2
3 # Prepare a package to use libtool.
4 # Written by Gary V. Vaughan <gary@gnu.org>, 2003
5
6 # Copyright (C) 2003-2015 Free Software Foundation, Inc.
7 # This is free software; see the source for copying conditions.  There is NO
8 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9
10 # Libtoolize is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
14 #
15 # Libtoolize is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
23
24 ## ------ ##
25 ## Usage. ##
26 ## ------ ##
27
28 # Run './libtoolize --help' for help with using this script from the
29 # command line.
30
31
32 ## ------------------------------- ##
33 ## User overridable command paths. ##
34 ## ------------------------------- ##
35
36 # After configure completes, it has a better idea of some of the
37 # shell tools we need than the defaults used by the functions shared
38 # with bootstrap, so set those here where they can still be over-
39 # ridden by the user, but otherwise take precedence.
40
41 : ${AUTOCONF="autoconf"}
42 : ${AUTOMAKE="automake"}
43 : ${EGREP="@EGREP@"}
44 : ${FGREP="@FGREP@"}
45 : ${GREP="@GREP@"}
46 : ${LN_S="@LN_S@"}
47 : ${SED="@SED@"}
48
49
50 ## -------------------------- ##
51 ## Source external libraries. ##
52 ## -------------------------- ##
53
54 # Much of our low-level functionality needs to be sourced from external
55 # libraries, which are installed to $pkgauxdir under normal use, though
56 # we also need to be able to find them in $srcdir during testing, or if
57 # executed directly from the build tree.
58
59 . "@auxscriptsdir@/funclib.sh"
60 . "@auxscriptsdir@/options-parser"
61 . "@auxscriptsdir@/extract-trace"
62
63 # Set a version string.
64 scriptversion='(GNU @PACKAGE@) @VERSION@'
65
66
67 ## ---------------- ##
68 ## Options parsing. ##
69 ## ---------------- ##
70
71 # Hook in the functions to make sure our own options are parsed during
72 # the option parsing loop.
73
74 usage='$progpath [OPTION]...'
75
76 # Short help message in response to '-h'.
77 usage_message="Options:
78    -c, --copy          copy files rather than symlinking them
79        --debug         enable verbose shell tracing
80    -n, --dry-run       print commands rather than running them
81    -f, --force         replace existing files
82    -i, --install       copy missing auxiliary files
83        --ltdl[=DIR]    install libltdl sources [default: libltdl]
84        --no-warnings   equivalent to '-Wnone'
85        --nonrecursive  prepare ltdl for non-recursive make
86    -q, --quiet         work silently
87        --recursive     prepare ltdl for recursive make
88        --subproject    prepare ltdl to configure and build independently
89    -v, --verbose       verbosely report processing
90        --version       print version information and exit
91    -W, --warnings=CATEGORY
92                        report the warnings falling in CATEGORY [all]
93    -h, --help          print short or long help message
94 "
95
96 # Additional text appended to 'usage_message' in response to '--help'.
97 long_help_message=$long_help_message"
98        'environment'   show warnings about LIBTOOLIZE_OPTIONS content
99        'file'          show warnings about file copying and linking
100
101 The following space or comma delimited options can be passed to $progname
102 via the environment variable LIBTOOLIZE_OPTIONS, unknown environment
103 options are ignored:
104
105        --debug         enable verbose shell tracing
106        --no-warnings   don't display warning messages
107        --quiet         work silently
108        --verbose       verbosely report processing
109
110 You must 'cd' to the top directory of your package before you run
111 '$progname'.
112
113 When reporting a bug, please describe a test case to reproduce it and
114 include the following information:
115
116        host-triplet:   @host_triplet@
117        version:        $progname (GNU @PACKAGE@) @VERSION@
118        automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
119        autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
120
121 Report bugs to <@PACKAGE_BUGREPORT@>.
122 GNU @PACKAGE@ home page: <@PACKAGE_URL@>.
123 General help using GNU software: <http://www.gnu.org/gethelp/>.
124 "
125
126 warning_categories='environment file'
127
128
129 # libtoolize_environment_options [ARG]...
130 # ---------------------------------------
131 # Parse environment options.
132 libtoolize_environment_options ()
133 {
134     $debug_mode
135
136     my_sed_env_opt='1s/^\([^,:; ]*\).*$/\1/;q'
137     my_sed_env_rest='1s/^[^,:; ]*[,:; ]*\(.*\)$/\1/;q'
138
139     while test -n "$LIBTOOLIZE_OPTIONS"; do
140       opt=`echo "$LIBTOOLIZE_OPTIONS" | $SED "$my_sed_env_opt"`
141       LIBTOOLIZE_OPTIONS=`echo "$LIBTOOLIZE_OPTIONS" | $SED "$my_sed_env_rest"`
142
143       case $opt in
144         --debug|--no-warn|--no-warning|--no-warnings|--quiet|--verbose)
145                 envopts="${envopts+$envopts }$opt"                        ;;
146         --*)    env_warning="${env_warning+$env_warning
147 }unrecognized environment option '$opt'"                                  ;;
148         *)      func_fatal_help "garbled LIBTOOLIZE_OPTIONS near '$opt'"  ;;
149       esac
150     done
151
152     # Pass back the updated list of options.
153     if test -n "$envopts"; then
154       func_quote_for_eval "$envopts" ${1+"$@"}
155     else
156       func_quote_for_eval ${1+"$@"}
157     fi
158     libtoolize_environment_options_result=$func_quote_for_eval_result
159 }
160 func_add_hook func_options_prep libtoolize_environment_options
161
162
163 # libtoolize_options_prep [ARG]...
164 # --------------------------------
165 # Preparation for options parsed by libtoolize.
166 libtoolize_options_prep ()
167 {
168     $debug_cmd
169
170     # Option defaults:
171     opt_copy=false
172     opt_dry_run=false
173     opt_force=false
174     opt_install=false
175     opt_ltdl=false
176     opt_nonrecursive=false
177     opt_quiet=false
178     opt_recursive=false
179     opt_subproject=false
180
181     ltdl_mode=
182
183     # Pass back the list of options.
184     func_quote_for_eval ${1+"$@"}
185     libtoolize_options_prep_result=$func_quote_for_eval_result
186 }
187 func_add_hook func_options_prep libtoolize_options_prep
188
189
190 # libtoolize_parse_options [ARG]...
191 # ---------------------------------
192 # Provide handling for libtoolize specific options.
193 libtoolize_parse_options ()
194 {
195     $debug_cmd
196
197     # Perform our own loop to consume as many options as possible in
198     # each iteration.
199     while test $# -gt 0; do
200       _G_opt=$1
201       shift
202       case $_G_opt in
203         --copy|-c)      opt_copy=: ;;
204
205         --dry-run|--dryrun|-n)
206                         $opt_dry_run || {
207                           opt_dry_run=:
208                           CP="func_echo_all $CP"
209                           test -n "$LN_S" && LN_S="func_echo_all $LN_S"
210                           MKDIR="func_echo_all $MKDIR"
211                           RM="func_echo_all $RM"
212                         }
213                         ;;
214
215         --force|-f)     opt_force=: ;;
216
217         --install|-i)   opt_install=: ;;
218
219         --ltdl)         opt_ltdl=:
220                         if test 0 -lt $#; then
221                           case $1 in
222                             -*) ;;
223                             *)  ltdl_dir=`$ECHO "$1" | $SED 's|/*$||'`
224                                 shift
225                                 ;;
226                           esac
227                         fi
228                         ;;
229
230         --nonrecursive|--non-recursive)
231                         opt_nonrecursive=:
232                         ;;
233
234         --quiet|--automake|-q) # --automake is for 1.5 compatibility
235                         opt_quiet=: ;;
236
237         --recursive)    opt_recursive=: ;;
238
239         --subproject)   opt_subproject=: ;;
240
241         # Separate non-argument short options:
242         -c*|-f*|-i*|-n*|-q*)
243                         func_split_short_opt "$_G_opt"
244                         set dummy "$func_split_short_opt_name" \
245                             "-$func_split_short_opt_arg" ${1+"$@"}
246                         shift
247                         ;;
248
249         # An option not handled by this hook function:
250         *)              set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
251       esac
252     done
253
254     # save modified positional parameters for caller
255     func_quote_for_eval ${1+"$@"}
256     libtoolize_parse_options_result=$func_quote_for_eval_result
257 }
258 func_add_hook func_parse_options libtoolize_parse_options
259
260
261 # libtoolize_validate_options [ARG]...
262 # ------------------------------------
263 # Perform any sanity checks on option settings and/or unconsumed
264 # arguments.
265 libtoolize_validate_options ()
266 {
267     # show any warnings saved by LIBTOOLIZE_OPTIONS parsing
268     test -n "$env_warning" && func_warning environment "$env_warning"
269
270     # validate $opt_nonrecursive, $opt_recursive and $opt_subproject
271     if $opt_nonrecursive; then
272       if $opt_recursive || $opt_subproject; then
273         func_error "you can have at most one of --non-recursive, --recursive and --subproject"
274       fi
275       ltdl_mode=nonrecursive
276     elif $opt_recursive; then
277       $opt_subproject &&
278         func_error "you can have at most one of --non-recursive, --recursive and --subproject"
279       ltdl_mode=recursive
280     elif $opt_subproject; then
281       ltdl_mode=subproject
282     fi
283
284     # any remaining arguments are an error
285     test 0 -lt $# &&
286       func_fatal_help "unknown additional arguments: '${1+$@}'"
287
288     # Pass back the empty argument list
289     func_quote_for_eval ${1+"$@"}
290     libtoolize_validate_options_result=$func_quote_for_eval_result
291 }
292 func_add_hook func_validate_options libtoolize_validate_options
293
294
295 # Process options as early as possible so that --help and --version
296 # can return quickly.
297 func_options ${1+"$@"}
298 eval set dummy "$func_options_result"; shift
299
300
301 # func_notquiet_once MSG_VAR
302 # --------------------------
303 # Call func_notquiet with the value of MSG_VAR, and then set MSG_VAR='' so
304 # that subsequent calls will have no effect.
305 func_notquiet_once ()
306 {
307     $debug_cmd
308
309     if test -n "$1"; then
310       eval my_msg=\$$1
311
312       if test -n "$my_msg"; then
313         func_notquiet "$my_msg"
314         eval $1=
315       fi
316     fi
317 }
318
319
320 # func_notquiet_hdr MSG_VAR ARG...
321 # --------------------------------
322 # With at least 1 non-empty ARG, call func_notquiet_once with MSG_VAR,
323 # and then func_notquiet with the remaining arguments.
324 func_notquiet_hdr ()
325 {
326     $debug_cmd
327
328     my_msg_var=$1; shift
329     test -n "$*" || return
330
331     func_notquiet_once "$my_msg_var"
332     func_notquiet "$*"
333 }
334
335
336 # func_notquiet_error_hdr MSG_VAR ARG...
337 # --------------------------------------
338 # Much the same as func_notquiet_header, but for (non-fatal) error
339 # messages.
340 func_notquiet_error_hdr ()
341 {
342     $debug_cmd
343
344     my_msg_var=$1; shift
345     test -n "$*" || return
346
347     func_notquiet_once "$my_msg_var"
348     func_error "$*"
349
350     exit_status=$EXIT_FAILURE
351 }
352
353
354 # func_copy FILENAME SRCDIR DESTDIR [MSG_VAR [FILTER]]
355 # ----------------------------------------------------
356 # If option '--copy' was specified, or soft-linking SRCFILE to DESTFILE
357 # fails, then try to copy SRCFILE to DESTFILE (making sure to update the
358 # timestamp so that a series of files with dependencies can be copied
359 # in the right order that their timestamps won't trigger rebuilds). If
360 # FILTER is non-empty, it is a sed script to apply to SRCFILE as it is
361 # copied.  MSG_VAR names a variable for use with func_notquiet_hdr.
362 func_copy ()
363 {
364     $debug_cmd
365
366     my_filename=$1
367     my_srcdir=$2
368     my_destdir=$3
369     my_msg_var=$4
370     my_filter=$5
371
372     my_srcfile=$my_srcdir/$my_filename
373     my_destfile=$my_destdir/$my_filename
374
375     # Libtool is probably misinstalled if this happens:
376     test -f "$my_srcfile" || {
377       func_notquiet_error_hdr "$my_msg_var" "'$my_srcfile' not found"
378       return 1
379     }
380
381     # Require --force to remove existing $my_destfile.
382     $opt_force && $RM "$my_destfile"
383     test -f "$my_destfile" && {
384       func_notquiet_error_hdr "$my_msg_var" \
385         "'$my_destfile' exists: use '--force' to overwrite"
386       return 1
387     }
388
389     # Be careful to support 'func_copy dir/target srcbase destbase'.
390     func_dirname "$my_destfile"
391     func_mkdir_p "$func_dirname_result"
392
393     # Filters always take priority.
394     if test -n "$my_filter"; then
395       if $opt_dry_run || $SED -e "$my_filter" "$my_srcfile" > "$my_destfile" 2>/dev/null
396       then
397         func_notquiet_once "$my_msg_var"
398         if $opt_verbose; then
399           func_notquiet "$SED -e '$my_filter' $my_srcfile > $my_destfile"
400          else
401           func_notquiet "creating file '$my_destfile'"
402          fi
403       else
404         func_notquiet_error_hdr "$my_msg_var" "creating '$my_destfile' from '$my_srcfile' failed"
405         return 1
406       fi
407       return 0
408     fi
409
410     # Otherwise copy or link according to '--copy' option.
411     if $opt_copy; then
412       my_copycmd=$CP
413       my_copy_type=copying
414     else
415       my_copycmd=$LN_S
416       my_copy_type=linking
417     fi
418     my_copy_msg="$my_copy_type file '$my_destfile'"
419     $opt_verbose && my_copy_msg="$my_copycmd $my_srcfile $my_destdir"
420
421     if $opt_dry_run || $my_copycmd "$my_srcfile" "$my_destfile" 2>/dev/null
422     then
423       func_notquiet_hdr "$my_msg_var" "$my_copy_msg"
424     else
425       func_notquiet_error_hdr "$my_msg_var" \
426         "$my_copy_type '$my_srcdir/$my_filename' to '$my_destdir/' failed"
427       return 1
428     fi
429 }
430
431
432 # func_included_files SEARCHFILE
433 # ------------------------------
434 # Output INCLUDEFILE if SEARCHFILE m4_includes it, else output SEARCHFILE.
435 func_included_files ()
436 {
437     $debug_cmd
438
439     my_searchfile=$1
440
441     my_include_regex=
442     my_sed_include='
443         /^m4_include(\[.*\])$/ {
444             s|^m4_include(\[\(.*\)\])$|\1|
445             p
446         }
447         d'
448
449     if test -f "$my_searchfile"; then
450       $ECHO "$my_searchfile"
451
452       # Only recurse when we don't care if all the variables we use get
453       # trashed, since they are in global scope.
454       for my_filename in `$SED "$my_sed_include" "$my_searchfile"`; do
455         func_included_files $my_filename
456       done
457     fi
458 }
459
460
461 # func_serial FILENAME [MACRO_REGEX]
462 # ----------------------------------
463 # Output the value of the serial number comment in FILENAME, where the
464 # comment line must also match MACRO_REGEX, if given.
465 func_serial ()
466 {
467     $debug_cmd
468
469     my_filename=$1
470     my_macro_regex=$2
471     my_sed_serial='
472         /^# serial [1-9][0-9.]*[         ]*'"$my_macro_regex"'[  ]*$/ {
473             s|^# serial \([1-9][0-9.]*\).*$|\1|
474             q
475         }
476         d'
477
478     # Search FILENAME and all the files it m4_includes for a serial number
479     # in the file that AC_DEFUNs MACRO_REGEX.
480     my_serial=
481     func_dirname_and_basename "$my_filename"
482     my_filebase=$func_basename_result
483     for my_file in `func_included_files "$my_filename"`; do
484       if test -z "$my_macro_regex" ||
485          test aclocal.m4 = "$my_filename" ||
486          test "X$my_macro_regex" = "X$my_filebase" ||
487          func_grep '^AC_DEFUN(\['"$my_macro_regex" "$my_file"
488       then
489         my_serial=`$SED -e "$my_sed_serial" "$my_file"`
490         break
491       fi
492     done
493
494     # If the file has no serial number, we assume it's ancient.
495     test -n "$my_serial" || my_serial=0
496
497     $ECHO "$my_serial"
498 }
499
500
501 # func_serial_max SERIAL1 SERIAL2
502 # -------------------------------
503 # Compare (possibly multi-part, '.' delimited) serial numbers, and
504 # return the largest in $func_serial_max_result.  If they are the
505 # same, func_serial_max_result will be empty.
506 func_serial_max ()
507 {
508     $debug_cmd
509
510     my_serial1=$1
511     my_serial2=$2
512
513     my_sed_dot='s/\..*$//g'
514     my_sed_rest='s/^[0-9][1-9]*\.*//'
515     my_sed_digits='s/[^0-9.]//g'
516
517     # Incase they turn out to be the same, we'll set it to empty
518     func_serial_max_result=
519
520     test "X$1$2" = X`$ECHO "$1$2" | $SED "$my_sed_digits"` || {
521       func_error "serial numbers '$1' or '$2' contain non-digit chars"
522       return
523     }
524
525     while test -n "$my_serial1$my_serial2"; do
526       my_serial1_part=`$ECHO "$my_serial1" | $SED "$my_sed_dot"`
527       my_serial2_part=`$ECHO "$my_serial2" | $SED "$my_sed_dot"`
528
529       test -z "$my_serial1_part$my_serial2_part" \
530         && break
531
532       test -z "$my_serial1_part" \
533         && { func_serial_max_result=$2; break; }
534
535       test -z "$my_serial2_part" \
536         && { func_serial_max_result=$1; break; }
537
538       test "$my_serial1_part" -gt "$my_serial2_part" \
539         && { func_serial_max_result=$1; break; }
540
541       test "$my_serial2_part" -gt "$my_serial1_part" \
542         && { func_serial_max_result=$2; break; }
543
544       my_serial1=`$ECHO "$my_serial1" | $SED "$my_sed_rest"`
545       my_serial2=`$ECHO "$my_serial2" | $SED "$my_sed_rest"`
546     done
547 }
548
549
550 # func_serial_update_check SRCFILE SRC_SERIAL DESTFILE DEST_SERIAL
551 # ----------------------------------------------------------------
552 # Unless SRC_SERIAL is newer than DEST_SERIAL set $func_serial_update_check
553 # to 'false'.
554 func_serial_update_check ()
555 {
556     $debug_cmd
557
558     $require_ac_ltdl_dir
559     $require_ac_macro_dir
560
561     my_srcfile=$1
562     my_src_serial=$2
563     my_destfile=$3
564     my_dest_serial=$4
565     my_update_p=:
566
567     if test -f "$my_destfile"; then
568       test 0 = "$my_src_serial" && {
569         func_warning file "no serial number on '$my_srcfile', not copying."
570         return
571       }
572
573       # Determine whether the destination has an older serial.
574       func_serial_max "$my_src_serial" "$my_dest_serial"
575       test "X$my_src_serial" = "X$func_serial_max_result" || my_update_p=false
576
577       test "X$my_src_serial" = "X$func_serial_max_result" \
578         && func_verbose "'$my_srcfile' is serial $my_src_serial, greater than $my_dest_serial in '$my_destfile'"
579
580       if test "X$my_dest_serial" = "X$func_serial_max_result"; then
581         func_verbose "'$my_srcfile' is serial $my_src_serial, less than $my_dest_serial in '$my_destfile'"
582         $opt_force || if test -n "$ac_macro_dir$ac_ltdl_dir"; then
583            func_error "'$my_destfile' is newer: use '--force' to overwrite"
584         fi
585       fi
586     fi
587
588     func_serial_update_check_result=$my_update_p
589 }
590
591
592 # func_aclocal_update_check FILENAME
593 # ----------------------------------
594 # Unless serial number of FILENAME is newer than the matching serial number
595 # in aclocal.m4, set $func_aclocal_update_check to 'false'.
596 func_aclocal_update_check ()
597 {
598     $debug_cmd
599
600     my_filename=$1
601
602     my_srcfile=$aclocaldir/$1
603     my_destfile=aclocal.m4
604
605     case $my_filename in
606       libtool.m4)
607         my_src_serial=`func_serial "$my_srcfile" LT_INIT`
608         my_dest_serial=`func_serial "$my_destfile" LT_INIT`
609
610         # Strictly, this libtoolize ought not to have to deal with ancient
611         # serial formats, but we accept them here to be complete:
612         test 0 = "$my_src_serial" &&
613           my_src_serial=`func_serial "$my_srcfile" 'A[CM]_PROG_LIBTOOL'`
614         test 0 = "$my_dest_serial" &&
615           my_dest_serial=`func_serial "$my_destfile" 'A[CM]_PROG_LIBTOOL'`
616         ;;
617       ltdl.m4)
618         my_src_serial=`func_serial "$my_srcfile" LTDL_INIT`
619         my_dest_serial=`func_serial "$my_destfile" LTDL_INIT`
620         ;;
621       *)
622         my_src_serial=`func_serial "$my_srcfile" "$my_filename"`
623         my_dest_serial=`func_serial "$my_destfile" "$my_filename"`
624         ;;
625     esac
626
627     func_serial_update_check \
628       "$my_srcfile" "$my_src_serial" "$my_destfile" "$my_dest_serial"
629
630     func_aclocal_update_check_result=$func_serial_update_check_result
631 }
632
633
634 # func_serial_update FILENAME SRCDIR DESTDIR [MSG_VAR] [MACRO_RE] [OLD_MACRO_RE]
635 # ------------------------------------------------------------------------------
636 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
637 # has a newer serial number, or DESTFILE does not yet exist, or the user
638 # specified '--force' at the command line.  If given, MACRO_REGEX or
639 # OLD_MACRO_REGEX must match any text after "# serial N" in both files.
640 func_serial_update ()
641 {
642     $debug_cmd
643
644     my_filename=$1
645     my_srcdir=$2
646     my_destdir=$3
647     my_msg_var=$4
648     my_macro_regex=$5
649     my_old_macro_regex=$6
650
651     my_serial_update_p=:
652     my_return_status=1
653     my_srcfile=$my_srcdir/$my_filename
654     my_destfile=$my_destdir/$my_filename
655
656     test -f "$my_srcfile" || func_fatal_error "'$my_srcfile' does not exist."
657
658     if test -f "$my_destfile"; then
659       my_src_serial=`func_serial "$my_srcfile" "$my_macro_regex"`
660       my_dest_serial=`func_serial "$my_destfile" "$my_macro_regex"`
661
662       # Strictly, this libtoolize ought not to have to deal with ancient
663       # serial formats, but we accept them here to be complete:
664       test 0 = "$my_src_serial" &&
665         my_src_serial=`func_serial "$my_srcfile" "$my_old_macro_regex"`
666
667       test 0 = "$my_dest_serial" &&
668         my_dest_serial=`func_serial "$my_destfile" "$my_old_macro_regex"`
669
670       func_serial_update_check \
671         "$my_srcfile" "$my_src_serial" "$my_destfile" "$my_dest_serial"
672       my_serial_update_p=$func_serial_update_check_result
673     fi
674
675     if $my_serial_update_p || $opt_force; then
676       $RM "$my_destfile"
677       func_copy "$my_filename" "$my_srcdir" "$my_destdir" "$my_msg_var"
678       my_return_status=$?
679     elif $opt_force && test "X$my_dest_serial" = "X$my_src_serial"; then
680       func_notquiet_hdr "$my_msg_var" "'$my_destfile' is already up to date."
681     fi
682
683     # Do this after the copy for hand maintained 'aclocal.m4', incase
684     # it has 'm4_include([DESTFILE])', so the copy effectively already
685     # updated 'aclocal.m4'.
686     my_included_files=`func_included_files aclocal.m4`
687     case `echo " "$my_included_files" "` in
688
689       # Skip included files:
690       *" $my_destfile "*) ;;
691
692       # Otherwise compare to aclocal.m4 serial number (func_serial
693       # returns 0 for older macro serial numbers before we provided
694       # serial tags, so the update message will be correctly given
695       # if aclocal.m4 contains an untagged --i.e older-- macro file):
696       *)
697         if test -f aclocal.m4; then
698           func_serial_max \
699               "$my_src_serial" `func_serial aclocal.m4 "$my_macro_regex"`
700           if test "X$my_src_serial" = "X$func_serial_max_result"; then
701               func_notquiet_hdr "$my_msg_var" \
702                 "You should add the contents of '$my_destfile' to 'aclocal.m4'."
703           fi
704         fi
705         ;;
706     esac
707     return $my_return_status
708 }
709
710
711 # func_keyword_update FILENAME SRCDIR DESTDIR SED_SCRIPT [MSG_VAR]
712 # ----------------------------------------------------------------
713 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
714 # has a newer revision according to the serial number extracted by
715 # SED_SCRIPT, or DESTFILE does not yet exist, or the user specified
716 # '--force' at the command line.
717 func_keyword_update ()
718 {
719     $debug_cmd
720
721     my_filename=$1
722     my_srcdir=$2
723     my_destdir=$3
724     my_sed_script=$4
725     my_msg_var=$5
726
727     my_srcfile=$my_srcdir/$my_filename
728     my_destfile=$my_destdir/$my_filename
729
730     my_keyword_update_p=:
731
732     test -f "$my_srcfile" || func_fatal_error "'$my_srcfile' does not exist."
733
734     if test -f "$my_destfile"; then
735       my_src_serial=`$SED -e "$my_sed_script" "$my_srcfile"`
736       test -z "$my_src_serial" && {
737         func_warning file "no serial number in '$my_srcfile', not copying."
738         return
739       }
740
741       my_dest_serial=`$SED -e "$my_sed_script" "$my_destfile"`
742       test -n "$my_dest_serial" || my_dest_serial=0
743
744       func_serial_update_check \
745          "$my_srcfile" "$my_src_serial" "$my_destfile" "$my_dest_serial"
746       my_keyword_update_p=$func_serial_update_check_result
747     fi
748
749     if $my_keyword_update_p || $opt_force; then
750       $RM "$my_destfile"
751       func_copy "$my_filename" "$my_srcdir" "$my_destdir" "$my_msg_var"
752     elif $opt_verbose || $opt_force && test "X$my_dest_serial" = "X$my_src_serial"; then
753       func_notquiet_hdr "$my_msg_var" "'$my_destfile' is already up to date."
754     fi
755 }
756
757
758 # func_ltmain_update FILENAME SRCDIR DESTDIR [MSG_VAR]
759 # ----------------------------------------------------
760 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
761 # has a newer revision, or DESTFILE does not yet exist, or the user
762 # specified '--force' at the command line.
763 func_ltmain_update ()
764 {
765     $debug_cmd
766
767     my_sed_ltmain='
768         /^package_revision='\''*[0-9][1-9.]*'\''*/ {
769             s|^package_revision='\''*\([0-9.]*\)'\''*[   ]*$|\1|
770             p
771         }
772         d'
773
774     func_keyword_update "$1" "$2" "$3" "$my_sed_ltmain" "$4"
775
776     return $my_return_status
777 }
778
779
780 # func_config_update FILENAME SRCDIR DESTDIR [MSG_VAR]
781 # ----------------------------------------------------
782 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
783 # has a newer timestamp, or DESTFILE does not yet exist, or the user
784 # specified '--force' at the command line.
785 func_config_update ()
786 {
787     $debug_cmd
788
789     my_sed_config='
790         /^timestamp='\''*[0-9][1-9-]*'\''*/ {
791             s|^timestamp='\''*\([0-9-]*\)'\''*|\1|
792             s|-|.|g
793             p
794         }
795         d'
796
797     func_keyword_update "$1" "$2" "$3" "$my_sed_config" "$4"
798
799     return $my_return_status
800 }
801
802
803 # func_install_update FILENAME SRCDIR DESTDIR [MSG_VAR]
804 # -----------------------------------------------------
805 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
806 # has a newer timestamp, or DESTFILE does not yet exist, or the user
807 # specified '--force' at the command line.
808 func_install_update ()
809 {
810     $debug_cmd
811
812     my_sed_install='
813         /^scriptversion='\''*[0-9][1-9.-]*'\''*/ {
814             s|[#;].*||
815             s|^scriptversion='\''*\([0-9.-]*\)'\''*|\1|
816             s|-|.|g
817             p
818         }
819         d'
820
821     func_keyword_update "$1" "$2" "$3" "$my_sed_install" "$4"
822
823     return $my_return_status
824 }
825
826
827 # func_install_pkgmacro_files
828 # ---------------------------
829 # Install copies of the libtool and libltdl m4 macros into this package.
830 func_install_pkgmacro_files ()
831 {
832     $debug_cmd
833
834     $require_ac_macro_dir
835     $require_am_macro_dir
836     $require_ltdl_mode
837     $require_macro_dir
838
839     $opt_ltdl || test -n "$ac_macro_dir$am_macro_dir" || return
840
841     # Remove any lingering files that my have been installed by some
842     # previous libtoolize release:
843     $opt_force && for file in $all_pkgmacro_files; do
844       test -f "$macro_dir/$file" && func_verbose "rm -f '$macro_dir/$file'"
845       rm -f "$macro_dir/$file"
846     done
847
848     # Install the libltdl autoconf macros to this project's source tree.
849     $opt_quiet || if test -n "$ac_macro_dir"; then
850       my_pkgmacro_header="putting macros in AC_CONFIG_MACRO_DIRS, '$ac_macro_dir'."
851     else
852       my_pkgmacro_header="putting macros in '$macro_dir'."
853     fi
854
855     for file in $pkgmacro_files; do
856       case $file in
857         libtool.m4)
858           func_serial_update "$file" "$aclocaldir" "$macro_dir" \
859             my_pkgmacro_header LT_INIT 'A[CM]_PROG_LIBTOOL'
860           ;;
861         ltdl.m4)
862           if $opt_ltdl; then
863             func_serial_update "$file" "$aclocaldir" "$macro_dir" \
864               my_pkgmacro_header 'LTDL_INIT'
865           else
866             func_verbose "Not copying '$macro_dir/$file', libltdl not used."
867           fi
868           ;;
869         ltoptions.m4|ltsugar.m4|ltversion.m4|lt~obsolete.m4)
870           func_serial_update "$file" "$aclocaldir" "$macro_dir" \
871             my_pkgmacro_header "$file"
872           ;;
873         *)
874           if $opt_ltdl; then
875             func_serial_update "$file" "$aclocaldir" "$macro_dir" \
876               my_pkgmacro_header "$file"
877           else
878             func_verbose "Not copying '$macro_dir/$file', libltdl not used."
879           fi
880           ;;
881       esac
882     done
883 }
884
885
886 # func_install_pkgltdl_files
887 # --------------------------
888 # Install copies of the libltdl files into this package.  Any auxiliary
889 # or m4 macro files needed in the libltdl tree will also be copied by
890 # func_install_pkgaux_files and func_install_pkgmacro_files resp.
891 func_install_pkgltdl_files ()
892 {
893     $debug_cmd
894
895     $opt_ltdl || return
896
897     $require_ac_ltdl_dir
898     $require_ltdl_dir
899     $require_ltdl_mode
900
901     # Remove any lingering files that my have been installed by some
902     # previous libtoolize release:
903     $opt_force && for file in $all_pkgltdl_files; do
904       test -f "$ltdl_dir/$file" && func_verbose "rm -f '$ltdl_dir/$file'"
905       rm -f "$ltdl_dir/$file"
906     done
907
908     # Copy all the files from installed libltdl to this project, if the
909     # user specified '--ltdl'.
910     $opt_quiet || if test -n "$ac_ltdl_dir"; then
911       pkgltdl_header="putting libltdl files in LT_CONFIG_LTDL_DIR, '$ac_ltdl_dir'."
912     else
913       pkgltdl_header="putting libltdl files in '$ltdl_dir'."
914     fi
915
916     $require_filter_Makefile_am
917     $require_filter_ltdl_mk
918
919     # Copy ltdl sources appropriate to the requested ltdl_mode.
920     for file in $pkgltdl_files; do
921       my_copy_filter=
922       case $file in
923         Makefile.am|Makefile.in)
924           test nonrecursive = "$ltdl_mode" && continue
925           my_copy_filter=$filter_Makefile_am
926           ;;
927
928         ltdl.mk)
929           test nonrecursive = "$ltdl_mode" || continue
930           my_copy_filter=$filter_ltdl_mk
931           ;;
932
933         aclocal.m4)
934           test subproject = "$ltdl_mode" && {
935             $require_filter_aclocal_m4
936
937             # Always copy aclocal.m4, otherwise regenerating it can
938             # overwrite the destination if it is symlinked.
939             ( opt_copy=:
940               func_copy "$file" "$pkgltdldir" "$ltdl_dir" \
941                 pkgltdl_header "$filter_aclocal_m4"
942             )
943           }
944           continue
945           ;;
946
947         config-h.in)
948           test subproject = "$ltdl_mode" || continue
949           ;;
950
951         configure)
952           test subproject = "$ltdl_mode" && {
953             $require_filter_configure_ac
954
955             # Always copy configure, otherwise regenerating it can
956             # overwrite the destination if it is symlinked.
957             ( opt_copy=:
958               func_copy "$file" "$pkgltdldir" "$ltdl_dir" \
959                 pkgltdl_header "$filter_configure_ac"
960             )
961           }
962           continue
963           ;;
964
965         configure.ac)
966           test subproject = "$ltdl_mode" || continue
967           $require_filter_configure_ac
968           my_copy_filter=$filter_configure_ac
969           ;;
970       esac
971
972       # Still here?  Copy the file then, with selected filters.
973       func_copy "$file" "$pkgltdldir" "$ltdl_dir" \
974         pkgltdl_header "$my_copy_filter"
975
976       # FIXME: Remove in 2013
977       #        (along with deprecation warning in func_check_macros)
978       test ltdl.mk = "$file" \
979         && func_grep "^-\?include $ltdl_dir/Makefile.inc\$" Makefile.am \
980         && mv "$ltdl_dir/$file" "$ltdl_dir/Makefile.inc" \
981         && func_notquiet "renaming file '$ltdl_dir/Makefile.inc'"
982     done
983 }
984
985
986 # func_install_pkgaux_files
987 # -------------------------
988 # Install copies of the auxiliary files into this package according to
989 # the whether libltdl is included as a subproject, and whether the parent
990 # shares the AC_CONFIG_AUX_DIR setting.
991 func_install_pkgaux_files ()
992 {
993     $debug_cmd
994
995     $require_ac_aux_dir
996     $require_aux_dir
997     $require_configure_ac
998     $require_ltdl_mode
999
1000     # Remove any lingering files that my have been installed by some
1001     # previous libtoolize release:
1002     $opt_force && for file in $all_pkgaux_files; do
1003       test -f "$aux_dir/$file" && func_verbose "rm -f '$aux_dir/$file'"
1004       rm -f "$aux_dir/$file"
1005     done
1006
1007     if test -n "$ac_aux_dir"; then
1008       pkgaux_header="putting auxiliary files in AC_CONFIG_AUX_DIR, '$ac_aux_dir'."
1009     else
1010       pkgaux_header="putting auxiliary files in '$aux_dir'."
1011     fi
1012
1013     for file in $pkgaux_files; do
1014       case $file in
1015         config.guess|config.sub)
1016           $opt_install || test subproject = "$ltdl_mode" || continue
1017           func_config_update "$file" "$pkgauxdir" "$aux_dir" pkgaux_header
1018           ;;
1019         install-sh)
1020           $opt_install || test subproject = "$ltdl_mode" || continue
1021           func_install_update "$file" "$pkgauxdir" "$aux_dir" pkgaux_header
1022           ;;
1023         ltmain.sh)
1024           func_ltmain_update "$file" "$pkgauxdir" "$aux_dir" pkgaux_header
1025           ;;
1026         *)
1027           test subproject = "$ltdl_mode" || continue
1028           func_copy "$file" "$pkgauxdir" "$aux_dir" pkgaux_header
1029           ;;
1030       esac
1031     done
1032
1033     # If the parent project is using Autoconf and linking with Libtool,
1034     # even if subproject libltdl already has a copy, the parent project
1035     # will still need to build libtool for its own purposes, and might
1036     # need another copy of ltmain.sh if the parent didn't declare an
1037     # AC_CONFIG_AUX_DIR.
1038     pkgaux_hdr="putting another copy of auxiliary files in '.'"
1039     test -f "$configure_ac" \
1040       && test -z "$ac_aux_dir" \
1041       && test subproject = "$ltdl_mode" \
1042       && test "$aux_dir" = "$ltdl_dir" \
1043       && func_ltmain_update "$file" "$pkgauxdir" . pkgaux_hdr
1044
1045     # FIXME: Remove in 2013.
1046     # Very old parent projects using 'libtoolize --install --ltdl', and
1047     # a top-level $configure_ac to build the ltdl subproject, but not
1048     # using Automake themselves, might still be relying on the old
1049     # behaviour of libtoolize to put a second copy of some 'Auxiliary
1050     # Programs' needed by the top-level configure (instead of using
1051     # the recommended method: 'automake --add-missing').
1052     test -f "$configure_ac" \
1053       && test subproject = "$ltdl_mode" \
1054       && test "$aux_dir" = "$ltdl_dir" \
1055       && func_config_update config.guess "$pkgauxdir" . pkgaux_hdr \
1056       && func_config_update config.sub "$pkgauxdir" . pkgaux_hdr \
1057       && func_install_update install-sh "$pkgauxdir" . pkgaux_hdr
1058 }
1059
1060
1061 # func_nonemptydir_p DIRVAR
1062 # -------------------------
1063 # DIRVAR is the name of a variable to evaluate.  Unless DIRVAR names
1064 # a directory that exists and is non-empty abort with a diagnostic.
1065 func_nonemptydir_p ()
1066 {
1067     $debug_cmd
1068
1069     my_dirvar=$1
1070     my_dir=`eval echo "\\\$$my_dirvar"`
1071
1072     # Is it a directory at all?
1073     test -d "$my_dir" \
1074       || func_fatal_error "\$$my_dirvar is not a directory: '$my_dir'"
1075
1076     # check that the directories contents can be ls'ed
1077     test -n "`{ cd $my_dir && ls; } 2>/dev/null`" \
1078         || func_fatal_error "cannot list files: '$my_dir'"
1079 }
1080
1081
1082 # func_check_macros
1083 # -----------------
1084 # Sanity check macros from aclocal.m4 against installed versions.
1085 func_check_macros ()
1086 {
1087     $debug_cmd
1088
1089     $require_ac_ltdl_dir
1090     $require_ac_macro_dir
1091     $require_am_macro_dir
1092     $require_aux_dir
1093     $require_configure_ac
1094     $require_ltdl_dir
1095     $require_ltdl_mode
1096     $require_macro_dir
1097     $require_seen_ltdl
1098     $require_seen_libtool
1099
1100     $opt_quiet && return
1101     test -n "$configure_ac" || return
1102
1103     ac_config_macro_dir_advised=false
1104
1105     if test -z "$ac_macro_dir$am_macro_dir"; then
1106       my_missing=
1107       for file in $pkgmacro_files; do
1108         case $file in
1109           ltargz.m4|ltdl.m4) $opt_ltdl || continue ;;
1110         esac
1111         if test -f "aclocal.m4"; then
1112           func_aclocal_update_check $file
1113           $func_aclocal_update_check_result || continue
1114         fi
1115         my_missing="$my_missing $file"
1116       done
1117
1118       if test -n "$my_missing"; then
1119         func_echo "You should add the contents of the following files to 'aclocal.m4':"
1120         for need in $my_missing; do
1121           func_echo "  '$aclocaldir/$need'"
1122         done
1123       fi
1124     fi
1125
1126     ## ---------------------------------------------------------- ##
1127     ## Since we return early here when --no-warn was given:       ##
1128     ## DO NOT PUT ANYTHING BUT UPGRADE ADVICE MESSAGES BELOW HERE ##
1129     ## ---------------------------------------------------------- ##
1130
1131     test " none" = "$opt_warning_types" && return
1132
1133     $seen_libtool ||
1134       func_echo "Remember to add 'LT_INIT' to $configure_ac."
1135
1136     # Suggest using LTDL_INIT if appropriate:
1137     $opt_ltdl && if test : != "$seen_ltdl"; then
1138       case $ltdl_mode in
1139         subproject) ltdl_init_args=                 ;;
1140         *)          ltdl_init_args="([$ltdl_mode])" ;;
1141       esac
1142       func_echo "Remember to add 'LTDL_INIT$ltdl_init_args' to $configure_ac."
1143     fi
1144
1145     if $opt_ltdl; then
1146       # Remind the user to call LT_CONFIG_LTDL_DIR:
1147       test -n "$ac_ltdl_dir" ||
1148         func_echo "Remember to add 'LT_CONFIG_LTDL_DIR([$ltdl_dir])' to '$configure_ac'."
1149
1150       # For nonrecursive mode, warn about continued use of Makefile.inc:
1151       # FIXME: Remove in 2013
1152       #        (along with last minute rename in func_install_pkgltdl_files)
1153       if test nonrecursive = "$ltdl_mode"; then
1154         if func_grep "^-\?include $ltdl_dir/Makefile.inc\$" Makefile.am;
1155         then
1156           func_error "Use of 'include $ltdl_dir/Makefile.inc' is deprecated!"
1157           func_echo "Consider updating to use of 'include $ltdl_dir/ltdl.mk' in Makefile.am."
1158         fi
1159       fi
1160     fi
1161
1162     # Suggest modern idioms for storing autoconf macros:
1163     $ac_config_macro_dir_advised || if test -z "$macro_dir" || test . = "$macro_dir"; then
1164       func_echo "Consider adding 'AC_CONFIG_MACRO_DIRS([m4])' to $configure_ac and"
1165       func_echo "rerunning $progname, to keep the correct libtool macros in-tree."
1166       ac_config_macro_dir_advised=:
1167
1168     elif test -z "$ac_macro_dir"; then
1169       func_echo "Consider adding 'AC_CONFIG_MACRO_DIRS([$macro_dir])' to $configure_ac,"
1170       func_echo "and rerunning $progname and aclocal."
1171       ac_config_macro_dir_advised=:
1172     fi
1173
1174     if test -z "$am_macro_dir$ac_macro_dir"; then
1175       func_echo "Consider adding '-I m4' to ACLOCAL_AMFLAGS in Makefile.am."
1176
1177     elif test -z "$am_macro_dir"; then
1178       func_echo "Consider adding '-I $macro_dir' to ACLOCAL_AMFLAGS in Makefile.am."
1179     fi
1180
1181     # Don't trace for this, we're just checking the user didn't invoke it
1182     # directly from configure.ac.
1183     $SED 's|dnl .*$||; s|# .*$||' "$configure_ac" | $GREP AC_PROG_RANLIB >/dev/null &&
1184       func_echo "'AC_PROG_RANLIB' is rendered obsolete by 'LT_INIT'"
1185
1186     # FIXME: Ensure ltmain.sh, libtool.m4 and ltdl.m4 are from the same release
1187 }
1188
1189
1190
1191 ## ------------------##
1192 ## Helper functions. ##
1193 ## ------------------##
1194
1195 # This section contains the helper functions used by the rest of
1196 # this script.
1197
1198
1199 # func_autoconf_configure MAYBE-CONFIGURE-FILE
1200 # --------------------------------------------
1201 # Ensure that MAYBE-CONFIGURE-FILE is the name of a file in the current
1202 # directory that contains an uncommented call to AC_INIT.
1203 func_autoconf_configure ()
1204 {
1205     $debug_cmd
1206
1207     _G_sed_no_comment='s|#.*$||; s|^dnl .*$||; s| dnl .*$||;'
1208     _G_ac_init=
1209
1210     # If we were passed a genuine file, make sure it calls AC_INIT.
1211     test -f "$1" \
1212       && _G_ac_init=`$SED "$_G_sed_no_comment" "$1" |$GREP AC_INIT`
1213
1214     # Otherwise it is not a genuine Autoconf input file.
1215     test -n "$_G_ac_init"
1216     _G_status=$?
1217
1218     test 0 -ne "$_G_status" \
1219       && func_verbose "'$1' not using Autoconf"
1220
1221     (exit $_G_status)
1222 }
1223
1224
1225 # func_make_relative_dir_filter CURRDIR SRCDIR DESTDIR [PREFIX [SUFFIX]]
1226 # ----------------------------------------------------------------------
1227 # Make a sed script suitable for appending to a copy filter, which will
1228 # replace occurrences of CURRDIR with the relative path from SRCDIR to
1229 # DESTDIR if they are different, otherwise the result is the empty
1230 # string:
1231 #
1232 #    func_make_relative_dir_filter ltdl config ../build-aux
1233 #      => 's|\.\./build-aux|../config|g'
1234 #    func_make_relative_dir_filter ltdl ltdl/m4 ../m4
1235 #      => 's|\.\./m4|m4|g'
1236 #    func_make_relative_dir_filter libltdl build-aux ../build-aux
1237 #      => ''
1238 #
1239 # If PREFIX (and SUFFIX) are passed they are prepended (and appended)
1240 # to the match and replacement expressions literally:
1241 #
1242 #    func_make_relative_dir_filter ltdl ltdl/m4 ../m4 '-I ' ' '
1243 #      => 's|-I \.\./m4 |-I m4 |g'
1244 func_make_relative_dir_filter ()
1245 {
1246     $debug_cmd
1247
1248     my_currdir=$1
1249     my_srcdir=$2
1250     my_destdir=$3
1251
1252     func_relative_path "$my_srcdir" "$my_destdir"
1253
1254     if test "$my_currdir" = "$func_relative_path_result"; then
1255       func_make_relative_dir_filter_result=
1256     else
1257       my_match_currdir=`$ECHO "$my_currdir" |$SED "$sed_make_literal_regex"`
1258
1259       # Avoid substituting with 'dir/./file' when current dir is '.'.
1260       if test . = "$my_currdir"; then
1261         func_make_relative_dir_filter_result="
1262           s|$4$my_match_currdir/$5|$4$5|g"
1263       else
1264         func_make_relative_dir_filter_result="
1265           s|$4$my_match_currdir$5|$4$func_relative_path_result$5|g"
1266       fi
1267     fi
1268 }
1269
1270 # func_make_relative_ltdl_filter CURRDIR DESTDIR [PREFIX [SUFFIX]]
1271 # ----------------------------------------------------------------
1272 # As 'func_make_relative_dir_filter' optimised for the common case where
1273 # SRCDIR is '$ltdl_dir'.
1274 func_make_relative_ltdl_filter ()
1275 {
1276     $debug_cmd
1277
1278     $require_ltdl_dir
1279
1280     func_make_relative_dir_filter "$1" "$ltdl_dir" "$2" "$3" "$4"
1281     func_make_relative_ltdl_filter_result=$func_make_relative_dir_filter_result
1282 }
1283
1284
1285 ## -------------------- ##
1286 ## Resource management. ##
1287 ## -------------------- ##
1288
1289 # This section contains definitions for functions that each ensure a
1290 # particular resource (a file, or a non-empty configuration variable for
1291 # example) is available, and if appropriate to extract default values
1292 # from pertinent package files.  Where a variable already has a non-
1293 # empty value (as set by the package's 'bootstrap.conf'), that value is
1294 # used in preference to deriving the default. Call them using their
1295 # associated 'require_*' variable to ensure that they are executed, at
1296 # most, once.
1297 #
1298 # Some of the require functions are very similar, so we generate those
1299 # as this file is sourced. They look complicated, but they are the same
1300 # as normal function declarations wrapped in "eval '<definition>'", so
1301 # that embedded single quotes need to be escaped, and wherever a symbol
1302 # is generated, we drop out of the single quotes and expand a variable
1303 # that holds the symbol.
1304 #
1305 # After that, the rest appear in asciibetical order.
1306
1307 for base in '' ltdl_; do
1308   if test ltdl_ = "$base"; then p='$pkgltdldir/'; else p=; fi
1309
1310   # require_Makefile_am
1311   # require_ltdl_Makefile_am
1312   # ------------------------
1313   # If not already set, set Makefile_am to 'Makefile.am' if that file is
1314   # present in the current directory, and similarly for
1315   # '$pkgltdldir/Makefile.am'.
1316   r=${base}Makefile_am
1317   v=require_$r
1318   f=func_$v
1319   eval $v'='$f'
1320   '$f' ()
1321   {
1322     $debug_cmd
1323
1324     test -n "$'$r'" || '$r'='$p'Makefile.am
1325
1326     if test -f "$'$r'"; then
1327       func_verbose "found '\'\$$r\''"
1328     else
1329       '$r'=
1330     fi
1331
1332     '$v'=:
1333   }'
1334   o=$r
1335
1336
1337   # require_aclocal_amflags
1338   # require_ltdl_aclocal_amflags
1339   # ----------------------------
1340   # Extract '$aclocal_amflags' from 'Makefile.am' if present, and
1341   # similarly for 'libltdl/Makefile.am'.
1342   r=${base}aclocal_amflags
1343   v=require_$r
1344   f=func_$v
1345   eval $v'='$f'
1346   '$f' ()
1347   {
1348     $debug_cmd
1349
1350     $require_'$o'
1351
1352     test -n "$'$o'" && {
1353       _G_sed_extract_aclocal_amflags='\''s|#.*$||
1354         /^[      ]*ACLOCAL_AMFLAGS[      ]*=/ {
1355             s|^.*=[      ]*\(.*\)|'$r'="\1"|
1356             p
1357         }'\''
1358
1359       _G_aclocal_flags_cmd=`$SED -n "$_G_sed_extract_aclocal_amflags" \
1360           "$'$o'"`
1361       eval "$_G_aclocal_flags_cmd"
1362
1363       test -n "$'$r'" && func_verbose "'$r'='\$$r\''"
1364     }
1365
1366     '$v'=:
1367   }'
1368   o=$r
1369
1370
1371   # require_am_macro_dir
1372   # require_ltdl_am_macro_dir
1373   # -------------------------
1374   # Set am_macro_dir to the first directory specified in
1375   # ACLOCAL_AMFLAGS from 'Makefile.am', and similarly for
1376   # 'libltdl/Makefile.am'.
1377   r=${base}am_macro_dir
1378   v=require_$r
1379   f=func_$v
1380   eval $v'='$f'
1381   '$f' ()
1382   {
1383     $debug_cmd
1384
1385     $require_'$o'
1386
1387     _G_minus_I_seen=false
1388     for _G_arg in $'$o'; do
1389       case $_G_minus_I_seen,$_G_arg in
1390         :,*)   '$r'=$_G_arg; break ;;
1391         *,-I)  _G_minus_I_seen=: ;;
1392         *,-I*) '$r'=`expr x$_G_arg : '\''x-I\(.*\)$'\''`; break ;;
1393       esac
1394     done
1395
1396     test -n "$'$r'" && func_verbose "'$r'='\'\$$r\''"
1397
1398     '$v'=:
1399   }'
1400   o=$r
1401
1402 done
1403
1404
1405 # require_ac_aux_dir
1406 # ------------------
1407 # Extract ac_aux_dir from AC_CONFIG_AUX_DIR.
1408 require_ac_aux_dir=func_require_ac_aux_dir
1409 func_require_ac_aux_dir ()
1410 {
1411     $debug_cmd
1412
1413     $require_configure_ac
1414
1415     test -n "$configure_ac" && {
1416       func_extract_trace_first AC_CONFIG_AUX_DIR
1417       ac_aux_dir=$func_extract_trace_first_result
1418
1419       case $ac_aux_dir in
1420         *\$*)
1421           func_fatal_error "\
1422 cannot expand unknown variable in AC_CONFIG_AUX_DIR argument."
1423           ;;
1424       esac
1425     }
1426
1427     test -n "$ac_aux_dir" && func_verbose "ac_aux_dir='$ac_aux_dir'"
1428
1429     require_ac_aux_dir=:
1430 }
1431
1432
1433 # require_ac_ltdl_dir
1434 # -------------------
1435 # Extract ac_ltdl_dir from LT_CONFIG_LTDL_DIR.
1436 require_ac_ltdl_dir=func_require_ac_ltdl_dir
1437 func_require_ac_ltdl_dir ()
1438 {
1439     $debug_cmd
1440
1441     $require_configure_ac
1442
1443     if test -n "$configure_ac"; then
1444       func_extract_trace_first LT_CONFIG_LTDL_DIR
1445       ac_ltdl_dir=$func_extract_trace_first_result
1446
1447       case $ac_ltdl_dir in
1448         *\$*)
1449           func_fatal_error "\
1450 cannot expand unknown variable in LT_CONFIG_LTDL_DIR argument."
1451           ;;
1452       esac
1453     fi
1454
1455     # Strip trailing slashes.
1456     ac_ltdl_dir=`echo "$ac_ltdl_dir" |$SED 's|/*$||'`
1457
1458     require_ac_ltdl_dir=:
1459 }
1460
1461
1462 # require_ac_ltdl_mode
1463 # --------------------
1464 # Extract mode name from LTDL_INIT options.
1465 require_ac_ltdl_mode=func_require_ac_ltdl_mode
1466 func_require_ac_ltdl_mode ()
1467 {
1468     $debug_cmd
1469
1470     $require_ac_ltdl_options
1471
1472     case " $ac_ltdl_options " in
1473       *" nonrecursive "*) ac_ltdl_mode=nonrecursive ;;
1474       *" recursive "*)    ac_ltdl_mode=recursive    ;;
1475       *" subproject "*)   ac_ltdl_mode=subproject   ;;
1476     esac
1477
1478     require_ac_ltdl_mode=:
1479 }
1480
1481
1482 # require_ac_ltdl_options
1483 # -----------------------
1484 # Extract ac_ltdl_options from LTDL_INIT.
1485 require_ac_ltdl_options=func_require_ac_ltdl_options
1486 func_require_ac_ltdl_options ()
1487 {
1488     $debug_cmd
1489
1490     $require_configure_ac
1491
1492     if test -n "$configure_ac"; then
1493       func_extract_trace_first LTDL_INIT
1494       ac_ltdl_options=$func_extract_trace_first_result
1495
1496       case $ac_ltdl_options in
1497         *\$*)
1498           func_fatal_error "\
1499 cannot expand unknown variable in LTDL_INIT argument."
1500           ;;
1501       esac
1502     fi
1503
1504     require_ac_ltdl_mode=:
1505 }
1506
1507
1508 # require_ac_macro_dir
1509 # --------------------
1510 # Extract ac_macro_dir from AC_CONFIG_MACRO_DIRS.
1511 require_ac_macro_dir=func_require_ac_macro_dir
1512 func_require_ac_macro_dir ()
1513 {
1514     $debug_cmd
1515
1516     $require_configure_ac
1517
1518     if test -n "$configure_ac"; then
1519       func_extract_trace_first AC_CONFIG_MACRO_DIRS
1520       ac_macro_dir=`expr "x$func_extract_trace_first_result" : 'x\([^    ]*\)'`
1521
1522       test -n "$ac_macro_dir" || {
1523         func_extract_trace_first AC_CONFIG_MACRO_DIR
1524         ac_macro_dir=$func_extract_trace_first_result
1525       }
1526     fi
1527
1528     require_ac_macro_dir=:
1529 }
1530
1531
1532 # require_aux_dir
1533 # ---------------
1534 # Set aux_dir according to AC_CONFIG_AUX_DIR or else use the same
1535 # heuristics as Autoconf to intuit an appropriate setting.
1536 require_aux_dir=func_require_aux_dir
1537 func_require_aux_dir ()
1538 {
1539     $debug_cmd
1540
1541     $require_ac_aux_dir
1542
1543     test -z "$aux_dir" && aux_dir=$ac_aux_dir
1544
1545     # Subproject ltdl without $configure_ac keeps pkgauxfiles in
1546     # specified --ltdl optarg directory.
1547     test -z "$aux_dir" && $opt_ltdl && {
1548       $require_configure_ac
1549
1550       test -n "$configure_ac" || {
1551         $require_ltdl_dir
1552         $require_ltdl_mode
1553
1554         test subproject = "$ltdl_mode" && aux_dir=$ltdl_dir
1555       }
1556     }
1557
1558     test -z "$aux_dir" && {
1559       # Try to intuit aux_dir using the same heuristic as Autoconf.
1560       for _G_dir in . .. ../..; do
1561         if test -f "$_G_dir/install-sh" || test -f "$_G_dir/install.sh"
1562         then
1563           aux_dir=$_G_dir
1564           break
1565         fi
1566       done
1567     }
1568
1569     # Use the current directory if all else fails.
1570     test -z "$aux_dir" && aux_dir=.
1571
1572     require_aux_dir=:
1573 }
1574
1575
1576 # require_configure_ac
1577 # --------------------
1578 # Ensure that there is a 'configure.ac' or 'configure.in' file in this
1579 # directory, and that '$configure_ac' contains its name.
1580 require_configure_ac=func_require_configure_ac
1581 func_require_configure_ac ()
1582 {
1583     $debug_cmd
1584
1585     test -z "$configure_ac" \
1586       && func_autoconf_configure configure.ac && configure_ac=configure.ac
1587     test -z "$configure_ac" \
1588       && func_autoconf_configure configure.in && configure_ac=configure.in
1589     test -z "$configure_ac" \
1590       || func_verbose "found '$configure_ac'"
1591
1592     require_configure_ac=:
1593 }
1594
1595
1596 # require_filter_Makefile_am
1597 # --------------------------
1598 # Set 'filter_Makefile_am' ready for passing to func_copy when libltdl's
1599 # stock Makefile.am contents need to be filtered to work in recursive
1600 # mode.
1601 require_filter_Makefile_am=func_require_filter_Makefile_am
1602 func_require_filter_Makefile_am ()
1603 {
1604     $debug_cmd
1605
1606     $require_ltdl_mode
1607
1608     case $ltdl_mode in
1609       recursive)
1610         filter_Makefile_am='
1611             /^[^#]/{
1612               s|(LIBOBJS)|(ltdl_LIBOBJS)|g
1613               s|(LTLIBOBJS)|(ltdl_LTLIBOBJS)|g
1614             }'
1615         ;;
1616
1617       subproject)
1618         # Adjust default relative macro_dir paths.
1619         $require_ltdl_am_macro_dir
1620
1621         func_make_relative_ltdl_filter "$ltdl_am_macro_dir" "$macro_dir" '-I '
1622         test -z "$func_make_relative_ltdl_filter_result" || {
1623           func_append filter_Makefile_am "
1624               /^ACLOCAL_AMFLAGS = /{
1625                 $func_make_relative_ltdl_filter_result
1626               }"
1627         }
1628         func_make_relative_ltdl_filter "$ltdl_am_macro_dir" "$macro_dir" 'dir)'
1629         func_append filter_Makefile_am "$func_make_relative_ltdl_filter_result"
1630
1631         # Adjust default relative aux_dir paths.
1632         $require_ltdl_ac_aux_dir
1633         func_make_relative_ltdl_filter "$ltdl_ac_aux_dir" "$aux_dir"
1634         func_append filter_Makefile_am "$func_make_relative_ltdl_filter_result"
1635         ;;
1636     esac
1637
1638     require_filter_Makefile_am=:
1639 }
1640
1641
1642 # require_filter_aclocal_m4
1643 # -------------------------
1644 # Set 'filter_aclocal_m4' ready for passing to func_copy when libltdl's
1645 # stock aclocal.m4 contents need to be filtered to work in recursive
1646 # mode.
1647 require_filter_aclocal_m4=func_require_filter_aclocal_m4
1648 func_require_filter_aclocal_m4 ()
1649 {
1650     $debug_cmd
1651
1652     $require_ltdl_am_macro_dir
1653
1654     func_make_relative_ltdl_filter "$ltdl_am_macro_dir" "$macro_dir"
1655
1656     test -z "$func_make_relative_ltdl_filter_result" || {
1657       func_append filter_aclocal_m4 "
1658           /^[m]4_include(/{
1659             $func_make_relative_ltdl_filter_result
1660           }"
1661     }
1662
1663     require_filter_aclocal_m4=:
1664 }
1665
1666
1667 # require_filter_configure_ac
1668 # ---------------------------
1669 # Set 'filter_configure_ac' ready for passing to func_copy when
1670 # libltdl's stock configure.ac contents need to be filtered to work in
1671 # subproject mode.
1672 require_filter_configure_ac=func_require_filter_configure_ac
1673 func_require_filter_configure_ac ()
1674 {
1675     $debug_cmd
1676
1677     $require_ltdl_ac_aux_dir
1678
1679     func_make_relative_ltdl_filter "$ltdl_ac_aux_dir" "$aux_dir"
1680     func_append filter_configure_ac "$func_make_relative_ltdl_filter_result"
1681
1682     require_filter_configure_ac=:
1683 }
1684
1685
1686 # require_filter_ltdl_mk
1687 # ----------------------
1688 # Set 'filter_ltdl_mk' ready for passing to func_copy in order for the
1689 # contents of ltdl.mk to match the nonrecursive libltdl directory into
1690 # which it is copied.
1691 require_filter_ltdl_mk=func_require_filter_ltdl_mk
1692 func_require_filter_ltdl_mk ()
1693 {
1694     $debug_cmd
1695
1696     $require_ltdl_dir
1697
1698     # Note that we strip comments right here, rather than rely on
1699     # using a $SED that allows comments.
1700     my_uscore=`$ECHO "$ltdl_dir" | $SED 's|[/.+-]|_|g'`
1701     filter_ltdl_mk=`$ECHO '
1702       /^[^#]/{
1703
1704         # Use only libltdl conditional objects.
1705         s|(LIBOBJS)|(ltdl_LIBOBJS)|g
1706         s|(LTLIBOBJS)|(ltdl_LTLIBOBJS)|g
1707
1708         # Convert libltdl path and variable sections to $ltdl_dir.
1709         s|libltdl_|@my_uscore@_|
1710         s|libltdl/|@ltdl_dir@/|
1711         s|: libltdl/|: @ltdl_dir@/|
1712         s| -Ilibltdl | -I@ltdl_dir@ |
1713         s|\$(libltdl_|\$(@my_uscore@_|
1714         s|)/libltdl |)/@ltdl_dir@ |
1715         s|@my_uscore@|'"$my_uscore"'|g
1716         s|@ltdl_dir@|'"$ltdl_dir"'|g
1717
1718       }' | $SED '/^[     ]*#/d;/^$/d'`
1719
1720     require_filter_ltdl_mk=:
1721 }
1722
1723
1724 # require_ltdl_ac_aux_dir
1725 # -----------------------
1726 # This needs to work in subproject mode, when GNU M4 may not be
1727 # available and hence extract-trace can't be used.  But since we
1728 # installed libltdl/configure.ac, then we already know what value
1729 # we used.
1730 require_ltdl_ac_aux_dir=func_require_ltdl_ac_aux_dir
1731 func_require_ltdl_ac_aux_dir ()
1732 {
1733     $debug_cmd
1734
1735     ltdl_ac_aux_dir="@ltdl_ac_aux_dir@"
1736     func_verbose "ltdl_ac_aux_dir='$ltdl_ac_aux_dir'"
1737
1738     require_ltdl_ac_aux_dir=:
1739 }
1740
1741
1742 # require_ltdl_dir
1743 # ----------------
1744 # If both are specified, ensure both --ltdl=LTDL_DIR and
1745 # LT_CONFIG_LTDL_DIR agree, and set ltdl_dir to the value of either.
1746 require_ltdl_dir=func_require_ltdl_dir
1747 func_require_ltdl_dir ()
1748 {
1749     $debug_cmd
1750
1751     $require_ac_ltdl_dir
1752
1753     test -z "$ltdl_dir" && ltdl_dir=$ac_ltdl_dir
1754     test -z "$ltdl_dir" && $opt_ltdl && ltdl_dir=libltdl
1755
1756     if test -n "$ac_ltdl_dir"; then
1757       test "$ac_ltdl_dir" = "$ltdl_dir" || func_fatal_error "\
1758 --ltdl='$ltdl_dir' does not match LT_CONFIG_LTDL_DIR($ac_ltdl_dir)"
1759     fi
1760
1761     require_ltdl_dir=:
1762 }
1763
1764
1765 # require_ltdl_mode
1766 # -----------------
1767 # If both are specified, ensure both command line setting and LTDL_INIT
1768 # option agree, and set ltdl_mode to the value of either.
1769 require_ltdl_mode=func_require_ltdl_mode
1770 func_require_ltdl_mode ()
1771 {
1772     $debug_cmd
1773
1774     $require_ac_ltdl_mode
1775
1776     test -z "$ltdl_mode" && ltdl_mode=$ac_ltdl_mode
1777     test -z "$ltdl_mode" && {
1778       $require_ltdl_dir
1779
1780       test -n "$ltdl_dir" && ltdl_mode=subproject
1781     }
1782
1783     if test -n "$ac_ltdl_mode"; then
1784       test "$ac_ltdl_mode" = "$ltdl_mode" || func_fatal_error "\
1785 --$ltdl_mode does not match LTDL_INIT($ac_ltdl_mode)"
1786     fi
1787
1788     func_verbose "ltdl mode='$ltdl_mode'"
1789
1790     require_ltdl_mode=:
1791 }
1792
1793
1794 # require_macro_dir
1795 # -----------------
1796 # If both are specified, ensure both ACLOCAL_AMFLAGS and
1797 # AC_CONFIG_MACRO_DIRS agree, and set macro_dir to the value of either.
1798 require_macro_dir=func_require_macro_dir
1799 func_require_macro_dir ()
1800 {
1801     $debug_cmd
1802
1803     $require_ac_macro_dir
1804     $require_am_macro_dir
1805
1806     # AC_CONFIG_MACRO_DIRS takes precedence.
1807     macro_dir=$ac_macro_dir
1808
1809     # Followed by first -I optarg from ACLOCAL_AMFLAGS.
1810     test -z "$macro_dir" && macro_dir=$am_macro_dir
1811
1812     # Subproject ltdl without either of the above keeps macros in
1813     # specified --ltdl optarg subdirectory.
1814     test -z "$macro_dir" && $opt_ltdl && {
1815       $require_ltdl_dir
1816       $require_ltdl_mode
1817
1818       test subproject = "$ltdl_mode" && macro_dir=$ltdl_dir/m4
1819     }
1820
1821     # Use ./m4 as the last resort.
1822     test -z "$macro_dir" && macro_dir=m4
1823
1824     # Diagnose conflicts.
1825     if test -n "$ac_macro_dir" && test -n "$am_macro_dir"; then
1826       test "$ac_macro_dir" = "$am_macro_dir" || func_fatal_error "\
1827 AC_CONFIG_MACRO_DIRS([$ac_macro_dir]) conflicts with ACLOCAL_AMFLAGS=-I $am_macro_dir."
1828     fi
1829
1830     require_macro_dir=:
1831 }
1832
1833
1834 # require_seen_ltdl
1835 # -----------------
1836 # Determine from contents of $configure_ac whether this project contains
1837 # libltdl.
1838 require_seen_ltdl=func_require_seen_ltdl
1839 func_require_seen_ltdl ()
1840 {
1841     $debug_cmd
1842
1843     $require_configure_ac
1844
1845     if test -n "$configure_ac"; then
1846       func_extract_trace AC_LIB_LTDL,AC_WITH_LTDL,LT_WITH_LTDL,LTDL_INIT
1847       test -n "$func_extract_trace_result" && seen_ltdl=:
1848     fi
1849     test -n "$seen_ltdl" || seen_ltdl=false
1850
1851     $seen_ltdl && func_verbose "found LTDL_INIT invocation"
1852
1853     require_seen_ltdl=:
1854 }
1855
1856
1857 # require_seen_libtool
1858 # --------------------
1859 # Determine from contents of $configure_ac whether this project is using
1860 # Libtool to compile (some of) its objects.
1861 require_seen_libtool=func_require_seen_libtool
1862 func_require_seen_libtool ()
1863 {
1864     $debug_cmd
1865
1866     $require_configure_ac
1867
1868     if test -n "$configure_ac"; then
1869       func_extract_trace AM_PROG_LIBTOOL,AC_PROG_LIBTOOL,LT_INIT
1870       test -n "$func_extract_trace_result" && seen_libtool=:
1871     fi
1872     test -n "$seen_libtool" || seen_libtool=false
1873
1874     $seen_libtool && func_verbose "found LT_INIT invocation"
1875
1876     require_seen_libtool=:
1877 }
1878
1879
1880
1881 ## ----------- ##
1882 ##    Main.    ##
1883 ## ----------- ##
1884
1885 {
1886   # Lists of all files libtoolize has ever installed.  These are removed
1887   # before installing the latest files when --force was passed to help
1888   # ensure a clean upgrade.
1889   # Do not remove config.guess, config.sub or install-sh, we don't
1890   # install them without --install, and the project may not be using
1891   # Automake.  Similarly, do not remove Gnulib files.
1892   all_pkgaux_files="compile depcomp missing ltmain.sh"
1893   all_pkgmacro_files="libtool.m4 ltargz.m4 ltdl.m4 ltoptions.m4 ltsugar.m4 ltversion.in ltversion.m4 lt~obsolete.m4"
1894   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__argz.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__argz.c lt__dirent.c lt__strl.c lt_dlloader.c lt_error.c ltdl.c ltdl.h ltdl.mk slist.c"
1895
1896   # Files installed by func_install_*, some files are missing from these
1897   # lists deliberately because their respective func_install has to handle
1898   # the missing filenames specially.
1899   pkgaux_files="@pkgaux_files@"
1900   pkgltdl_files="@pkgltdl_files@"
1901   pkgmacro_files="@pkgmacro_files@"
1902
1903   # Locations for important files:
1904   prefix="@prefix@"
1905   datadir="@datadir@"
1906   pkgauxdir="@pkgauxdir@"
1907   pkgltdldir="@pkgdatadir@"
1908   aclocaldir="@aclocaldir@"
1909
1910   # Allow the user to override the master libtoolize repository:
1911   if test -n "$_lt_pkgdatadir"; then
1912     pkgauxdir=$_lt_pkgdatadir/build-aux
1913     pkgltdldir=$_lt_pkgdatadir/libltdl
1914     aclocaldir=$_lt_pkgdatadir/m4
1915   fi
1916   func_nonemptydir_p pkgauxdir
1917   func_nonemptydir_p pkgltdldir
1918   func_nonemptydir_p aclocaldir
1919
1920   extract_trace=$pkgauxdir/extract-trace
1921
1922   # :::BE CAREFUL HERE:::
1923   # func_check_macros needs to check whether --ltdl was specified when
1924   # LTDL_INIT was not seen, so we can't just use one variable for both
1925   # conditions, or that check will be impossible.   No need to clutter the
1926   # rest of the code with '$opt_ltdl || $seen_ltdl' though, because we CAN
1927   # safely set opt_ltdl to true if LTDL_INIT was seen:
1928   $require_seen_ltdl
1929   $seen_ltdl && opt_ltdl=:
1930
1931   func_install_pkgaux_files
1932   func_install_pkgmacro_files
1933   func_install_pkgltdl_files
1934
1935   func_check_macros
1936 }
1937
1938 exit $exit_status
1939
1940 # Local Variables:
1941 # mode:shell-script
1942 # sh-indentation:2
1943 # End: