1 m4_define([_m4_divert(SCRIPT)], 100)
2 m4_divert_push([SCRIPT])#! /bin/sh
5 # libtoolize (GNU @PACKAGE@@TIMESTAMP@) @VERSION@
6 # Written by Gary V. Vaughan <gary@gnu.org>, 2003
8 # Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
9 # This is free software; see the source for copying conditions. There is NO
10 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 # Libtoolize is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
17 # Libtoolize is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with libtoolize; see the file COPYING. If not, a copy
24 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
25 # or obtained by writing to the Free Software Foundation, Inc.,
26 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 # Usage: $progname [OPTION]...
30 # Prepare a package to use libtool.
32 # -c, --copy copy files rather than symlinking them
33 # --debug enable verbose shell tracing
34 # -n, --dry-run print commands rather than running them
35 # -f, --force replace existing files
36 # -i, --install copy missing auxiliary files
37 # --ltdl[=DIR] install libltdl sources [default: libltdl]
38 # --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
46 # You must `cd' to the top directory of your package before you run
49 # When reporting a bug, please describe a test case to reproduce it and
50 # include the following information:
52 # host-triplet: @host_triplet@
53 # $progname: (GNU @PACKAGE@@TIMESTAMP@) @VERSION@
54 # automake: $automake_version
55 # autoconf: $autoconf_version
57 # Report bugs to <bug-libtool@gnu.org>.
66 m4_include([getopt.m4sh])
69 # test EBCDIC or ASCII
70 case `echo X|tr X '\101'` in
71 A) # ASCII based system
72 # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
74 NL2SP='tr \015\012 \040\040'
76 *) # EBCDIC based system
78 NL2SP='tr \r\n \100\100'
83 # Command line options:
94 # ltdl can be installed to be self-contained (subproject, the default);
95 # or to be configured by a parent project, either with a recursive or
96 # nonrecursive automake driven make:
99 # Locations for important files:
102 pkgdatadir=@pkgdatadir@
103 pkgltdldir=@pkgdatadir@
104 aclocaldir=@aclocaldir@
108 configure_ac=configure.in
111 # Parse options once, thoroughly. This comes as soon as possible in
112 # the script to make things like `libtoolize --version' happen quickly.
115 my_sed_single_opt='1s/^\(..\).*$/\1/;q'
116 my_sed_single_rest='1s/^..\(.*\)$/\1/;q'
117 my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
118 my_sed_long_arg='1s/^--[^=]*=//'
120 while test "$#" -gt 0; do
124 --copy|-c) opt_link=false ;;
126 --debug) func_echo "enabling shell trace mode"
131 --dry-run|-n) if $opt_dry_run; then :; else
134 test -n "$LN_S" && LN_S="$ECHO $LN_S"
141 --force|-f) opt_force=: ;;
143 --install|-i) opt_install=: ;;
146 if test "$#" -gt 0; then
149 *) ltdldir=`$ECHO "X$1" | $Xsed -e 's,/*$,,'`
156 --nonrecursive|--non-recursive)
157 ltdl_mode=nonrecursive
160 --quiet|--automake|-q) # --automake is for 1.5 compatibility
164 --recursive) ltdl_mode=recursive ;;
166 --subproject) ltdl_mode=subproject ;;
168 --verbose|-v) opt_verbose=: ;;
170 # Separate optargs to long options:
172 arg=`$ECHO "X$opt" | $Xsed -e "$my_sed_long_arg"`
173 opt=`$ECHO "X$opt" | $Xsed -e "$my_sed_long_opt"`
174 set dummy "$opt" "$arg" ${1+"$@"}
178 # Separate optargs to short options:
180 # arg=`$ECHO "X$opt" | $Xsed -e "$my_sed_single_rest"`
181 # opt=`$ECHO "X$opt" | $Xsed -e "$my_sed_single_opt"`
182 # set dummy "$opt" "$arg" ${1+"$@"}
186 # Separate non-argument short options:
187 -c*|-f*|-i*|-n*|-q*|-v*)
188 rest=`$ECHO "X$opt" | $Xsed -e "$my_sed_single_rest"`
189 opt=`$ECHO "X$opt" | $Xsed -e "$my_sed_single_opt"`
190 set dummy "$opt" "-$rest" ${1+"$@"}
194 -\?|-h) func_usage ;;
196 --version) func_version ;;
198 -*) func_fatal_help "unrecognized option \`$opt'" ;;
199 *) func_fatal_help "too many arguments" ;;
205 # func_copy srcfile destfile
206 # A wrapper for func_copy_cb that accepts arguments in the same order
207 # as the cp(1) shell command.
213 { func_error "\`$1' not copied: not a regular file"; return 1; }
215 my_f1=`$ECHO "X$1" | $Xsed -e "$basename"`
217 if test -d "$2"; then
219 func_copy_cb "$my_f1" \
220 `$ECHO "X$1" | $Xsed -e "$dirname"` "$2"
224 # Supporting this would mean changing the timestamp:
225 test "X$my_f1" = X`$ECHO "X$2" | $Xsed -e "$basename"` \
226 || func_fatal_error "func_copy() cannot change filename on copy"
228 func_copy_cb "$my_f1" \
229 `$ECHO "X$1" | $Xsed -e "$dirname"` \
230 `$ECHO "X$2" | $Xsed -e "$dirname"`
234 return $copy_return_status # set in func_copy_cb
238 # func_copy_cb filename srcdir destdir
239 # If option `--copy' was specified, or soft-linking SRCFILE to DESTFILE fails,
240 # then try to copy SRCFILE to DESTFILE (without changing the timestamp if
250 # Libtool is probably misinstalled if this happens:
251 test -f "$my_srcdir/$my_file" ||
252 func_fatal_error "\`$my_file' not found in \`$my_srcdir'"
255 false) my_copy_msg="file \`$my_destdir/$my_file'" ;;
256 *) my_copy_msg="file from \`$my_srcdir/$my_file'" ;;
258 func_mkdir_p `$ECHO "X$my_destdir/$my_file" | $Xsed -e "$dirname"`
260 $RM "$my_destdir/$my_file"
262 if test "$my_file" = "aclocal.m4"; then
263 if { ( cd "$my_srcdir" && $TAR chf - "$my_file" ) 2>/dev/null \
264 | ( umask 0 && cd "$my_destdir" && $TAR xf - ) >/dev/null 2>&1 ; }
266 $opt_quiet || func_echo "copying $my_copy_msg"
270 if $LN_S "$my_srcdir/$my_file" "$my_destdir/$my_file"; then
271 $opt_quiet || func_echo "linking $my_copy_msg"
276 if { ( cd "$my_srcdir" && $TAR chf - "$my_file" ) 2>/dev/null \
277 | ( umask 0 && cd "$my_destdir" && $TAR xf - ) >/dev/null 2>&1; } \
278 && touch "$my_destdir/$my_file"; then
279 $opt_quiet || func_echo "copying $my_copy_msg"
283 if test "$copy_return_status" != 0; then
284 func_error "can not copy \`$my_srcdir/$my_file' to \`$my_destdir/'"
285 exit_status=$EXIT_FAILURE
290 # func_copy_some_files srcfile_spec srcdir destdir [copy_cb=func_copy_cb]
291 # Call COPY_CB for each regular file in SRCDIR named by the ':' delimited
292 # names in SRCFILE_SPEC. The odd calling convention is needed to allow
293 # spaces in file and directory names.
294 func_copy_some_files ()
300 my_copy_cb="${4-func_copy_cb}"
304 for my_filename in $my_srcfile_spec; do
306 if test -f "$my_srcdir/$my_filename"; then
307 if test "X$my_copy_cb" = Xfunc_copy_cb; then
308 $opt_force || if test -f "$my_destdir/$my_filename"; then
310 || func_error "\`$my_destdir/$my_filename' exists: use \`--force' to overwrite"
315 func_fatal_error "\`$my_filename' not found in \`$my_srcdir'"
318 $my_copy_cb "$my_filename" "$my_srcdir" "$my_destdir"
324 # func_fixup_Makefile srcfile srcdir destdir
325 func_fixup_Makefile ()
331 my_fixup_non_subpackage_script="\
332 s,(LIBOBJS),(ltdl_LIBOBJS),g
333 s,(LTLIBOBJS),(ltdl_LTLIBOBJS),g
334 s,libltdl/configure.ac,,
335 s,libltdl/configure,,
336 s,libltdl/aclocal.m4,,
337 s,libltdl/config-h.in,,
338 s,libltdl/Makefile.am,,
339 s,libltdl/Makefile.in,,
343 my_fixup_non_subpackage_script=`echo "$my_fixup_non_subpackage_script" | \
345 my_fixup_inc_paths_script= ;;
348 repl_uscore=`$ECHO "X$repl" | $Xsed -e 's,[/.+-],_,g'`
349 my_fixup_inc_paths_script="\
350 s,libltdl_,@repl_uscore@_,
352 s,: libltdl/,: @repl@/,
353 s, -Ilibltdl , -I@repl@ ,
354 s,\\\$(libltdl_,\$(@repl_uscore@_,
355 s,)/libltdl ,)/@repl@ ,
356 s,@repl_uscore@,${repl_uscore},g
361 $RM "$my_destdir/$my_filename" 2>/dev/null
362 $opt_quiet || func_echo "creating file \`$my_destdir/$my_filename'"
363 if $opt_dry_run; then :;
365 $SED "$my_fixup_non_subpackage_script
366 $my_fixup_inc_paths_script" \
367 < "$my_srcdir/$my_filename" > "$my_destdir/$my_filename" ||
368 func_fatal_error "cannot create $my_destdir/$my_filename"
373 # Scan configure.(ac|in) and aclocal.m4 (if present) for use of libltdl
374 # and libtool. Possibly running some of these tools if necessary.
375 # Libtoolize affects the contents of aclocal.m4, and should be run before
376 # aclocal, so we can't use configure --trace which relies on a consistent
377 # configure.(ac|in) and aclocal.m4.
381 # Prefer configure.ac to configure.in
382 test -f configure.ac && configure_ac=configure.ac
383 test -f "$configure_ac" || configure_ac=
385 # Set local variables to reflect contents of configure.ac
386 my_sed_scan_configure_ac='s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,;
388 s,^.*$,seen_autoconf=:,
392 test -z "$configure_ac" \
393 || eval `$SED "$my_sed_scan_configure_ac" "$configure_ac"`
397 test -n "$configure_ac" && my_configure_ac="$configure_ac: "
398 func_verbose "${my_configure_ac}not using Autoconf"
400 # Make sure ltdldir and ltdl_mode have sensible defaults
401 # since we return early here:
402 test -n "$ltdldir" || ltdldir=libltdl
403 test -n "$ltdl_mode" || ltdl_mode=subproject
408 # ---------------------------------------------------- #
409 # Probe macro usage in configure.ac and/or aclocal.m4. #
410 # ---------------------------------------------------- #
412 my_sed_traces='s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,
413 s,^.*AC_REQUIRE(.*$,,; s,^.*m4_require(.*$,,; s,^.*m4_define(.*$,,
414 s,^.*A[CU]_DEFUN(.*$,,; s,^.*m4_defun(.*$,,
415 /AC_CONFIG_AUX_DIR(/ {
416 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,ac_auxdir=\1,
419 /AC_CONFIG_MACRO_DIR(/ {
420 s,^.*AC_CONFIG_MACRO_DIR([[ ]*\([^])]*\).*$,ac_macrodir=\1,
423 /_LT_CONFIG_LTDL_DIR(/d
424 /LT_CONFIG_LTDL_DIR(/ {
425 s,^.*LT_CONFIG_LTDL_DIR([[ ]*\([^])]*\).*$,ac_ltdldir=\1,
428 /\@<:@A[CM]_PROG_LIBTOOL/d
429 /A[CM]_PROG_LIBTOOL/ {
430 s,^.*$,seen_libtool=:,
433 /the.*option into.*LT_INIT.*parameter/d
436 s,^.*$,seen_libtool=:,
441 s,^.*LTDL_INIT([[ ]*\([^])]*\).*$,ltdl_options="\1",
442 s,^.*LTDL_INIT[ ]*$,seen_ltdl=:,
458 eval `cat aclocal.m4 "$configure_ac" 2>/dev/null | $SED "$my_sed_traces"`
461 # ----------------- #
462 # Validate ltdldir. #
463 # ----------------- #
465 ac_ltdldir=`$ECHO "X$ac_ltdldir" | $Xsed -e 's,/*$,,'`
467 # If $configure_ac contains AC_CONFIG_LTDL_DIR, check that its
468 # arguments were not given in terms of a shell variable!
469 case "$ac_ltdldir" in
471 func_fatal_error "can not handle variables in LT_CONFIG_LTDL_DIR"
475 # If neither --ltdl nor LT_CONFIG_LTDL_DIR are specified, default to
476 # `libltdl'. If both are specified, they must be the same. Otherwise,
477 # take the one that is given! (If LT_CONFIG_LTDL_DIR is not specified
478 # we suggest adding it later in this code.)
479 case x$ac_ltdldir,x$ltdldir in
480 x,x) ltdldir=libltdl ;;
481 x*,x) ltdldir=$ac_ltdldir ;;
482 x,x*) ltdldir=$ltdldir ;;
484 test x"$ac_ltdldir" = x"$ltdldir" || \
485 func_fatal_error "--ltdl='$ltdldir' does not match LT_CONFIG_LTDL_DIR($ac_ltdldir)"
490 # ------------------- #
491 # Validate ltdl_mode. #
492 # ------------------- #
494 test -n "$ltdl_options" && seen_ltdl=:
496 # If $configure_ac contains LTDL_INIT, check that its
497 # arguments were not given in terms of a shell variable!
498 case "$ltdl_options" in
500 func_fatal_error "can not handle variables in LTDL_INIT"
504 # Extract mode name from ltdl_options
505 # FIXME: Diagnose multiple conflicting modes in ltdl_options
507 case " $ltdl_options " in
508 *" nonrecursive "*) ac_ltdl_mode=nonrecursive ;;
509 *" recursive "*) ac_ltdl_mode=recursive ;;
510 *" subproject "*) ac_ltdl_mode=subproject ;;
513 # If neither --ltdl nor an LTDL_INIT mode are specified, default to
514 # `subproject'. If both are specified, they must be the same. Otherwise,
515 # take the one that is given!
516 case x$ac_ltdl_mode,x$ltdl_mode in
517 x,x) ltdl_mode=subproject ;;
518 x*,x) ltdl_mode=$ac_ltdl_mode ;;
519 x,x*) ltdl_mode=$ltdl_mode ;;
521 test x"$ac_ltdl_mode" = x"$ltdl_mode" || \
522 func_fatal_error "--$ltdl_mode does not match LTDL_INIT($ac_ltdl_mode)"
530 if test -n "$ac_auxdir"; then
531 # If $configure_ac contains AC_CONFIG_AUX_DIR, check that it was
532 # not given in terms of a shell variable!
535 func_fatal_error "can not handle variables in AC_CONFIG_AUX_DIR"
542 # Try to discover auxdir the same way it is discovered by configure.
543 # Note that we default to the current directory.
544 for dir in . .. ../..; do
545 if test -f "$dir/install-sh"; then
548 elif test -f "$dir/install.sh"; then
555 # Just use the current directory if all else fails.
556 test -n "$auxdir" || auxdir=.
559 # ------------------------------ #
560 # Find local m4 macro directory. #
561 # ------------------------------ #
563 # If AC_CONFIG_MACRO_DIR turned nothing up, we hunt for ACLOCAL_AMFLAGS
564 # in `Makefile.am' for a `-I' argument.
566 my_sed_aclocal_flags='
567 /^[ ]*ACLOCAL_[A-Z_]*FLAGS[ ]*=/ {
568 s,^[^=]*=[ ]*\(.*\), \1,
572 macrodir="$ac_macrodir"
573 if test ! -n "$macrodir" && test -f Makefile.am; then
574 my_macrodir_is_next=false
575 for arg in `$SED "$my_sed_aclocal_flags" Makefile.am`; do
576 if $my_macrodir_is_next; then
580 if test "X$arg" = "X-I"; then
581 my_macrodir_is_next=:
583 my_macrodir_is_next=false
590 # func_included_files searchfile
591 # Output INCLUDEFILE if SEARCHFILE m4_includes it, else output SEARCHFILE.
592 func_included_files ()
599 /^m4_include(\[.*\])$/ {
600 s,^m4_include(\[\(.*\)\])$,\1,
605 if test -f "$my_searchfile"; then
606 $ECHO "X$my_searchfile" | $Xsed
608 # Only recurse when we don't care if all the variables we use get
609 # trashed, since they are in global scope.
610 for my_filename in `$SED "$my_sed_include" "$my_searchfile"`; do
611 func_included_files $my_filename
617 # func_serial filename [macro_regex]
618 # Output the value of the serial number comment in FILENAME, where the
619 # comment line must also match MACRO_REGEX, if given.
626 /^# serial [1-9][0-9.]*[ ]*'"$my_macro_regex"'[ ]*$/ {
627 s,^# serial \([1-9][0-9.]*\).*$,\1,
632 # Search FILENAME and all the files it m4_includes for a serial number
633 # in the file that AC_DEFUNs MACRO_REGEX.
635 for my_file in `func_included_files "$my_filename"`; do
636 if test -z "$my_macro_regex" ||
637 test "$my_filename" = aclocal.m4 ||
638 test "$my_macro_regex" = `echo "$my_filename" | $SED "$basename"` ||
639 func_grep '^AC_DEFUN(\@<:@'"$my_macro_regex" "$my_file"
641 my_serial=`$SED -e "$my_sed_serial" "$my_file"`
646 # If the file has no serial number, we assume it's ancient.
647 test -n "$my_serial" || my_serial=0
653 # func_serial_max serial1 serial2
654 # Compare (possibly multi-part, '.' delimited) serial numbers, and
655 # return the largest in $func_serial_max_result. If they are the
656 # same, func_serial_max_result will be empty.
663 my_sed_dot='s/\..*$//g'
664 my_sed_rest='s/^[0-9][1-9]*\.*//'
665 my_sed_digits='s/[^0-9.]//g'
667 # Incase they turn out to be the same, we'll set it to empty
668 func_serial_max_result=
670 test "X$1$2" = X`$ECHO "X$1$2" | $Xsed -e "$my_sed_digits"` || {
671 func_error "serial numbers \`$1' or \`$2' contain non-digit chars"
675 while test -n "$my_serial1$my_serial2"; do
676 my_serial1_part=`$ECHO "X$my_serial1" | $Xsed -e "$my_sed_dot"`
677 my_serial2_part=`$ECHO "X$my_serial2" | $Xsed -e "$my_sed_dot"`
679 test -z "$my_serial1_part$my_serial2_part" \
682 test -z "$my_serial1_part" \
683 && { func_serial_max_result="$2"; break; }
685 test -z "$my_serial2_part" \
686 && { func_serial_max_result="$1"; break; }
688 test "$my_serial1_part" -gt "$my_serial2_part" \
689 && { func_serial_max_result="$1"; break; }
691 test "$my_serial2_part" -gt "$my_serial1_part" \
692 && { func_serial_max_result="$2"; break; }
694 my_serial1=`$ECHO "X$my_serial1" | $Xsed -e "$my_sed_rest"`
695 my_serial2=`$ECHO "X$my_serial2" | $Xsed -e "$my_sed_rest"`
700 # func_serial_update_check srcfile src_serial destfile dest_serial
701 # Unless SRC_SERIAL is newer than DEST_SERIAL set $func_serial_update_check
703 func_serial_update_check ()
712 if test -f "$my_destfile"; then
713 test "X$my_src_serial" = "X0" && {
714 func_error "warning: no serial number on \`$my_srcfile', not copying."
718 # Determine whether the destination has an older serial.
719 func_serial_max "$my_src_serial" "$my_dest_serial"
720 test "X$my_src_serial" = "X$func_serial_max_result" || my_update_p=false
722 test "X$my_src_serial" = "X$func_serial_max_result" \
723 && func_verbose "\`$my_srcfile' is serial $my_src_serial, greater than $my_dest_serial in \`$my_destfile'"
725 if test "X$my_dest_serial" = "X$func_serial_max_result"; then
726 func_verbose "\`$my_srcfile' is serial $my_src_serial, less than $my_dest_serial in \`$my_destfile'"
728 || func_error "\`$my_destfile' is newer: use \`--force' to overwrite"
732 func_serial_update_check_result="$my_update_p"
736 # func_serial_update filename srcdir destdir [macro_regex] [old_macro_regex]
737 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
738 # has a newer serial number, or DESTFILE does not yet exist, or the user
739 # specified `--force' at the command line. If given, MACRO_REGEX or
740 # OLD_MACRO_REGEX must match any text after "# serial N" in both files.
741 func_serial_update ()
748 my_old_macro_regex="$5"
752 my_srcfile="$my_srcdir/$my_filename"
753 my_destfile="$my_destdir/$my_filename"
755 test -f "$my_srcfile" || func_fatal_error "\`$my_srcfile' does not exist."
757 if test -f "$my_destfile"; then
758 my_src_serial=`func_serial "$my_srcfile" "$my_macro_regex"`
759 my_dest_serial=`func_serial "$my_destfile" "$my_macro_regex"`
761 # Strictly, this libtoolize ought not to have to deal with ancient
762 # serial formats, but we accept them here to be complete:
763 test "X$my_src_serial" = "X0" &&
764 my_src_serial=`func_serial "$my_srcfile" "$my_old_macro_regex"`
766 test "X$my_dest_serial" = "X0" &&
767 my_dest_serial=`func_serial "$my_destfile" "$my_old_macro_regex"`
769 func_serial_update_check \
770 "$my_srcfile" "$my_src_serial" "$my_destfile" "$my_dest_serial"
771 my_serial_update_p="$func_serial_update_check_result"
774 if $my_serial_update_p || $opt_force; then
775 func_copy "$my_srcfile" "$my_destfile"
777 elif test "X$my_dest_serial" = "X$my_src_serial"; then
779 || func_echo "\`$my_destfile' is already up to date."
782 # Do this after the copy for hand maintained `aclocal.m4', incase
783 # it has `m4_include([DESTFILE])', so the copy effectively already
784 # updated `aclocal.m4'.
785 my_included_files=`func_included_files aclocal.m4`
786 case `echo " $my_included_files " | $NL2SP` in
788 # Skip included files:
789 *" $my_destfile "*) ;;
791 # Otherwise compare to aclocal.m4 serial number (func_serial
792 # returns 0 for older macro serial numbers before we provided
793 # serial tags, so the update message will be correctly given
794 # if aclocal.m4 contains an untagged --i.e older-- macro file):
796 if test -f aclocal.m4; then
798 "$my_src_serial" `func_serial aclocal.m4 "$my_macro_regex"`
799 test "X$my_src_serial" = "X$func_serial_max_result" \
800 && func_echo "You should add the contents of \`$my_destfile' to \`aclocal.m4'."
804 return $my_return_status
808 # func_keyword_update filename srcdir destdir sed_script
809 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
810 # has a newer revision according to the serial number extracted by
811 # SED_SCRIPT, or DESTFILE does not yet exist, or the user specified
812 # `--force' at the command line.
813 func_keyword_update ()
821 my_srcfile="$my_srcdir/$my_filename"
822 my_destfile="$my_destdir/$my_filename"
824 my_keyword_update_p=:
826 test -f "$my_srcfile" || func_fatal_error "\`$my_srcfile' does not exist."
828 if test -f "$my_destfile"; then
829 my_src_serial=`$SED -e "$my_sed_script" "$my_srcfile"`
830 test -z "$my_src_serial" && {
831 func_error "warning: no serial number in \`$my_srcfile', not copying."
835 my_dest_serial=`$SED -e "$my_sed_script" "$my_destfile"`
836 test -n "$my_dest_serial" || my_dest_serial=0
838 func_serial_update_check \
839 "$my_srcfile" "$my_src_serial" "$my_destfile" "$my_dest_serial"
840 my_keyword_update_p="$func_serial_update_check_result"
843 if $my_keyword_update_p || $opt_force; then
844 func_copy "$my_srcfile" "$my_destfile"
845 elif test "X$my_dest_serial" = "X$my_src_serial"; then
847 || func_echo "\`$my_destfile' is already up to date."
852 # func_ltmain_update filename srcdir destdir
853 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
854 # has a newer revision, or DESTFILE does not yet exist, or the user
855 # specified `--force' at the command line.
856 func_ltmain_update ()
860 /^package_revision='\''*[0-9][1-9.]*'\''*/ {
861 s,^package_revision='\''*\([0-9.]*\)'\''*[ ]*$,\1,
866 func_keyword_update "$1" "$2" "$3" "$my_sed_ltmain"
868 return $my_return_status
872 # func_config_update filename srcdir destdir
873 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
874 # has a newer timestamp, or DESTFILE does not yet exist, or the user
875 # specified `--force' at the command line.
876 func_config_update ()
880 /^timestamp='\''*[0-9][1-9-]*'\''*/ {
881 s,^timestamp='\''*\([0-9-]*\)'\''*,\1,
887 func_keyword_update "$1" "$2" "$3" "$my_sed_config"
889 return $my_return_status
893 # func_install_update filename srcdir destdir
894 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
895 # has a newer timestamp, or DESTFILE does not yet exist, or the user
896 # specified `--force' at the command line.
897 func_install_update ()
901 /^scriptversion='\''*[0-9][1-9.-]*'\''*/ {
902 s,^scriptversion='\''*\([0-9.-]*\)'\''*,\1,
908 func_keyword_update "$1" "$2" "$3" "$my_sed_install"
910 return $my_return_status
914 # func_massage_aclocal_DATA [glob_exclude]
915 # @aclocal_DATA\@ is substituted as per its value in Makefile.am;
916 # this function massages it into a suitable format for func_copy_some_files.
917 func_massage_aclocal_DATA ()
920 pkgmacro_files= # GLOBAL VAR
924 # Massage a value for pkgmacro_files from the value used in Makefile.am.
925 for my_filename in @aclocal_DATA@; do
926 my_filename=`$ECHO "X$my_filename" | $Xsed -e "$basename"`
928 # ignore excluded filenames
929 if test -n "$my_glob_exclude"; then
931 eval 'case $my_filename in '$my_glob_exclude') my_cont=: ;; esac'
935 pkgmacro_files="$pkgmacro_files:$my_filename"
938 # strip spurious leading `:'
939 pkgmacro_files=`$ECHO "X$pkgmacro_files" | $Xsed -e 's,^:*,,'`
943 # func_install_pkgmacro_subproject
944 # Unless --quiet was passed, display a message. Then copy pkgmacro_files
945 # from libtool installation tree to subproject libltdl tree.
946 func_install_pkgmacro_subproject ()
950 # Copy all the files from installed libltdl to this project, if the
951 # user specified a macrodir.
952 $opt_quiet || if test "x$macrodir" != "x$subproject_macrodir"; then
953 func_echo "putting macros in \`$subproject_macrodir'."
954 elif test -n "$subproject_macrodir"; then
955 func_echo "putting macros in AC_CONFIG_MACRO_DIR, \`$subproject_macrodir'."
958 func_copy_some_files "argz.m4:libtool.m4:ltdl.m4:$pkgmacro_files" \
959 "$aclocaldir" "$subproject_macrodir"
963 # func_install_pkgmacro_parent
964 # Unless --quiet was passed, or AC_CONFIG_MACRO_DIR was not seen, display
965 # a message. Then update appropriate macros if newer ones are available
966 # from the libtool installation tree.
967 func_install_pkgmacro_parent ()
971 # Copy all the files from installed libltdl to this project, if the
972 # user specified a macrodir.
973 $opt_quiet || if test -n "$ac_macrodir"; then
974 func_echo "putting macros in AC_CONFIG_MACRO_DIR, \`$ac_macrodir'."
975 elif test -n "$macrodir"; then
976 func_echo "putting macros in \`$macrodir'."
980 func_serial_update argz.m4 "$aclocaldir" "$macrodir" argz.m4
982 func_verbose "Not copying \`$macrodir/argz.m4', libltdl not used."
985 func_serial_update libtool.m4 "$aclocaldir" "$macrodir" \
986 LT_INIT 'A[CM]_PROG_LIBTOOL'
989 func_serial_update ltdl.m4 "$aclocaldir" "$macrodir" 'LTDL_INIT'
991 func_verbose "Not copying \`$macrodir/ltdl.m4', libltdl not used."
996 for file in $pkgmacro_files; do
998 func_serial_update $file "$aclocaldir" "$macrodir" "$file"
1004 # func_install_pkgmacro_files
1005 # Install copies of the libtool and libltdl m4 macros into this package.
1006 func_install_pkgmacro_files ()
1010 # argz.m4, libtool.m4 and ltdl.m4 are handled specially:
1011 func_massage_aclocal_DATA 'argz.m4|libtool.m4|ltdl.m4'
1013 # 1. Parent has separate macrodir to subproject ltdl:
1014 if $opt_ltdl && test "x$ltdl_mode" = "xsubproject" &&
1015 test -n "$macrodir" && test "x$macrodir" != "x$subproject_macrodir"
1017 func_install_pkgmacro_parent
1018 func_install_pkgmacro_subproject
1020 # 2. Parent shares macrodir with subproject ltdl:
1021 elif $opt_ltdl && test "x$ltdl_mode" = "xsubproject"
1022 # && test "x$macrodir" = "x$subproject_macrodir"
1024 func_install_pkgmacro_subproject
1026 # 3. Not a subproject, but macrodir was specified in parent:
1027 elif test -n "$macrodir"; then
1028 func_install_pkgmacro_parent
1030 # 4. AC_CONFIG_MACRO_DIR was not specified:
1032 func_verbose "AC_CONFIG_MACRO_DIR not defined, not copying libtool macros."
1037 # func_massage_pkgltdl_files [glob_exclude]
1038 # @pkgltdl_files\@ is substituted as per its value in Makefile.am; this
1039 # function massages it into a suitable format for func_copy_some_files.
1040 func_massage_pkgltdl_files ()
1043 pkgltdl_files= # GLOBAL VAR
1045 my_glob_exclude="$1"
1047 # Massage a value for pkgltdl_files from the value used in Makefile.am
1048 for my_filename in @pkgltdl_files@; do
1050 # Strip surplus leading 'libltdl/':
1051 my_filename=`expr "X$my_filename" : 'Xlibltdl/\(.*\)'`
1053 # ignore excluded filenames
1054 if test -n "$my_glob_exclude"; then
1056 eval 'case $my_filename in '$my_glob_exclude') my_cont=: ;; esac'
1057 $my_cont && continue
1061 case :$pkgltdl_files: in
1062 *:$my_filename:*) ;;
1063 *) pkgltdl_files="$pkgltdl_files:$my_filename" ;;
1067 # strip spurious leading `:'
1068 pkgltdl_files=`$ECHO "X$pkgltdl_files" | $Xsed -e 's,^:*,,'`
1072 # func_install_pkgltdl_files
1073 # Install copies of the libltdl files into this package. Any auxiliary
1074 # or m4 macro files needed in the libltdl tree will also be copied by
1075 # func_install_pkgconfig_files and func_install_pkgmacro_files resp.
1076 func_install_pkgltdl_files ()
1081 # Copy all the files from installed libltdl to this project, if the
1082 # user specified `--ltdl'.
1083 $opt_quiet || if test -n "$ac_ltdldir"; then
1084 func_echo "putting libltdl files in LT_CONFIG_LTDL_DIR, \`$ac_ltdldir'."
1085 elif test -n "$ltdldir"; then
1086 func_echo "putting libltdl files in \`$ltdldir'."
1089 # These files are handled specially, depending on ltdl_mode:
1090 if test "x$ltdl_mode" = "xsubproject"; then
1091 func_massage_pkgltdl_files 'Makefile.inc'
1093 func_massage_pkgltdl_files 'Makefile.am|Makefile.in*|aclocal.m4|config*'
1096 func_copy_some_files "$pkgltdl_files" "$pkgltdldir/libltdl" "$ltdldir"
1098 # For recursive ltdl modes, copy a suitable Makefile.{am,inc}:
1101 func_fixup_Makefile "Makefile.am" "$pkgltdldir/libltdl" "$ltdldir"
1104 func_fixup_Makefile "Makefile.inc" "$pkgltdldir/libltdl" "$ltdldir"
1110 # func_massage_pkgconfig_files [glob_exclude]
1111 # @pkgconfig_files\@ is substituted as per its value in Makefile.am; this
1112 # function massages it into a suitable format for func_copy_some_files.
1113 func_massage_pkgconfig_files ()
1116 pkgconfig_files= # GLOBAL VAR
1118 my_glob_exclude="$1"
1120 # Massage a value for pkgconfig_files from the value used in Makefile.am
1121 for my_filename in @pkgconfig_files@; do
1123 # ignore excluded filenames
1124 if test -n "$my_glob_exclude"; then
1126 eval 'case $my_filename in '$my_glob_exclude') my_cont=: ;; esac'
1127 $my_cont && continue
1131 case :$pkgconfig_files: in
1132 *:$my_filename:*) ;;
1133 *) pkgconfig_files="$pkgconfig_files:$my_filename" ;;
1137 # strip spurious leading `:'
1138 pkgconfig_files=`$ECHO "X$pkgconfig_files" | $Xsed -e 's,^:*,,'`
1142 # func_install_pkgconfig_subproject
1143 # Unless --quiet was passed, display a message. Then copy pkgconfig_files
1144 # from libtool installation tree to subproject libltdl tree.
1145 func_install_pkgconfig_subproject ()
1149 # Copy all the files from installed libltdl to this project, if the
1150 # user specified an auxdir.
1151 $opt_quiet || if test "x$ac_auxdir" = "x$subproject_auxdir"; then
1152 func_echo "putting auxiliary files in AC_CONFIG_AUX_DIR, \`$subproject_auxdir'."
1153 elif test -n "$auxdir"; then
1154 func_echo "putting auxiliary files in \`$auxdir'."
1157 func_copy_some_files "$pkgconfig_files" "$pkgdatadir" "$ltdldir"
1161 # func_install_pkgconfig_parent
1162 # Unless --quiet was passed, or AC_CONFIG_AUX_DIR was not seen, display a
1163 # message. Then update appropriate auxiliary files if newer ones are
1164 # available from the libtool installation tree.
1165 func_install_pkgconfig_parent ()
1169 # Copy all the files from installed libltdl to this project, if the
1170 # user specified an auxdir.
1171 $opt_quiet || if test -n "$ac_auxdir"; then
1172 func_echo "putting auxiliary files in AC_CONFIG_AUX_DIR, \`$ac_auxdir'."
1173 elif test -n "$auxdir" || test "x$ltdldir" = "x."; then
1174 func_echo "putting auxiliary files in \`$auxdir'."
1177 if $opt_install; then
1178 func_config_update config.guess "$pkgdatadir/config" "$auxdir"
1179 func_config_update config.sub "$pkgdatadir/config" "$auxdir"
1180 func_install_update install-sh "$pkgdatadir/config" "$auxdir"
1182 func_ltmain_update ltmain.sh "$pkgdatadir/config" "$auxdir"
1186 # func_install_pkgconfig_files
1187 # Install copies of the auxiliary files into this package according to
1188 # the whether libltdl is included as a subproject, and whether the parent
1189 # shares the AC_CONFIG_AUX_DIR setting.
1190 func_install_pkgconfig_files ()
1193 func_massage_pkgconfig_files
1195 # 1. Parent shares auxdir with subproject ltdl:
1196 if $opt_ltdl && test "x$ltdl_mode" = "xsubproject" &&
1197 test "x$ac_auxdir" = "x$subproject_auxdir"
1199 func_install_pkgconfig_subproject
1201 # 2. Parent has separate auxdir to subproject ltdl:
1202 elif $opt_ltdl && test "x$ltdl_mode" = "xsubproject"
1203 # && test "x$auxdir" != "x$subproject_auxdir" is implied
1205 if $seen_autoconf; then
1206 func_install_pkgconfig_parent
1208 func_install_pkgconfig_subproject
1210 # 3. Not subproject, but AC_CONFIG_AUX_DIR was used in parent:
1211 elif test -n "$ac_auxdir" || test "x$auxdir" = "x."; then
1212 func_install_pkgconfig_parent
1214 # 4. AC_CONFIG_AUX_DIR was not specified:
1216 func_verbose "AC_CONFIG_AUX_DIR not defined, not copying libtool auxiliary files."
1221 # func_nonemptydir_p dirvar
1222 # DIRVAR is the name of a variable to evaluate. Unless DIRVAR names
1223 # a directory that exists and is non-empty abort with a diagnostic.
1224 func_nonemptydir_p ()
1228 my_dir=`eval echo "\\\$$my_dirvar"`
1230 # Is it a directory at all?
1232 || func_fatal_error "\$$my_dirvar not a directory: \`$my_dir'"
1234 # check that the directories contents can be ls'ed
1235 test -n "`{ cd $my_dir && ls; } 2>/dev/null`" \
1236 || func_fatal_error "can not list files: \`$my_dir'"
1241 # Sanity check macros from aclocal.m4 against installed versions.
1242 func_check_macros ()
1245 $opt_quiet && return
1246 $seen_autoconf || return
1248 ac_config_macro_dir_advised=false
1251 # Suggest modern idioms for storing autoconf macros:
1252 if test -z "$ac_macrodir$ltdldir"; then
1253 if test x"$macrodir" = x.; then
1254 func_echo "Consider adding \`AC_CONFIG_MACRO_DIR([m4])' to $configure_ac and rerunning"
1255 func_echo " libtoolize, to keep the correct libtool macros in-tree."
1257 func_echo "Consider adding \`AC_CONFIG_MACRO_DIR([$macrodir])'to $configure.ac,"
1258 func_echo "and rerunning libtoolize."
1261 elif test -z "$macrodir"; then
1262 my_ac_config_macro_srcdir="$aclocaldir"
1263 if $opt_ltdl && test "$macrodir" != "$subproject_macrodir"; then
1264 my_ac_config_macro_srcdir="$subproject_macrodir"
1267 my_needed="libtool.m4 ltoptions.m4 ltversion.m4 ltsugar.m4 lt~obsolete.m4"
1268 $opt_ltdl && my_needed="$my_needed argz.m4 ltdl.m4"
1270 func_echo "You should add the contents of the following files to \`aclocal.m4':"
1271 for need in $my_needed; do
1272 func_echo " \`$my_ac_config_macro_srcdir/$need'"
1275 if test "$my_ac_config_macro_srcdir" != "$aclocaldir"; then
1276 func_echo "or else add \`AC_CONFIG_MACRO_DIR([$subproject_macrodir])' to $configure_ac."
1277 ac_config_macro_dir_advised=:
1282 func_echo "Remember to add \`LT_INIT' to $configure_ac."
1284 # Suggest using LTDL_INIT if appropriate:
1285 $opt_ltdl && if test x$seen_ltdl != x:; then
1287 subproject) ltdl_init_args="" ;;
1288 *) ltdl_init_args="([$ltdl_mode])" ;;
1290 func_echo "Remember to add \`LTDL_INIT$ltdl_init_args' to $configure_ac."
1294 # Remind the user to call LT_CONFIG_LTDL_DIR:
1295 test -n "$ac_ltdldir" ||
1296 func_echo "Remember to add \`LT_CONFIG_LTDL_DIR([$ltdldir])' to \`$configure_ac'."
1298 # For subproject mode, offer some suggestions for avoiding duplicate
1299 # files in a project that uses libltdl:
1300 if test "x$ltdl_mode" = "xsubproject"; then
1301 test "$subproject_auxdir" = "$auxdir" ||
1302 func_echo "Consider using \`AC_CONFIG_AUX_DIR([$subproject_auxdir])' in $configure_ac."
1303 $ac_config_macro_dir_advised || test "$subproject_macrodir" = "$macrodir" ||
1304 func_echo "Consider using \`AC_CONFIG_MACRO_DIR([$subproject_macrodir])' in $configure_ac."
1308 # Don't trace for this, we're just checking the user didn't invoke it
1309 # directly from configure.ac.
1310 $SED 's,dnl .*$,,; s,# .*$,,' "$configure_ac" | grep AC_PROG_RANLIB >/dev/null &&
1311 func_echo "\`AC_PROG_RANLIB' is rendered obsolete by \`LT_INIT'"
1313 # FIXME: Ensure ltmain.sh, libtool.m4 and ltdl.m4 are from the same release
1324 # Allow the user to override the master libtoolize repository:
1325 if test -n "$_lt_pkgdatadir"; then
1326 pkgltdldir="$_lt_pkgdatadir"
1327 pkgdatadir="$_lt_pkgdatadir/libltdl"
1328 aclocaldir="$_lt_pkgdatadir/libltdl/m4"
1330 func_nonemptydir_p pkgltdldir
1331 func_nonemptydir_p pkgdatadir
1332 func_nonemptydir_p aclocaldir
1338 *) ltdlprefix=$ltdldir/ ;;
1340 subproject_auxdir=${ltdlprefix}config
1341 subproject_macrodir=${ltdlprefix}m4
1343 # :::BE CAREFUL HERE:::
1344 # func_check_macros needs to check whether --ltdl was specified when
1345 # LTDL_INIT was not seen, so we can't just use one variable for both
1346 # conditions, or that check will be impossible. No need to clutter the
1347 # rest of the code with '$opt_ltdl || $seen_ltdl' though, because we CAN
1348 # safely set opt_ltdl to true if LTDL_INIT was seen:
1349 $seen_ltdl && opt_ltdl=:
1351 func_install_pkgconfig_files
1352 func_install_pkgmacro_files
1353 func_install_pkgltdl_files