* m4/libtool.m4 (CXX, archive_cmds) [sun]: Add -lCstd, -lCrun
[libtool.git] / libtoolize.m4sh
blob089bde6be7846a6199a6df40b3942366f9aa733e
1 m4_define([_m4_divert(SCRIPT)], 100)
2 m4_divert_push([SCRIPT])#! /bin/sh
3 # @configure_input@
5 # libtoolize (GNU @PACKAGE@@TIMESTAMP@) @VERSION@
6 # Written by Gary V. Vaughan <gary@gnu.org>, 2003
8 # Copyright (C) 2003, 2004, 2005 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 # This program 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 # This program 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 GNU
20 # General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, a copy can be downloaded from
24 # http://www.gnu.org/copyleft/gpl.html, or by writing to the Free
25 # Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26 # MA 02110-1301, USA.
28 # As a special exception to the GNU General Public License, if you
29 # distribute this file as part of a program that contains a
30 # configuration script generated by Autoconf, you may include it under
31 # the same distribution terms that you use for the rest of that program.
33 # Usage: $progname [OPTION]...
35 # Prepare a package to use libtool.
37 # -c, --copy            copy files rather than symlinking them
38 #     --debug           enable verbose shell tracing
39 # -n, --dry-run         print commands rather than running them
40 # -f, --force           replace existing files
41 # -i, --install         copy missing auxiliary files
42 #     --ltdl[=DIR]      install libltdl in a subdirectory [default: libltdl]
43 # -q, --quiet           work silently
44 # -v, --verbose         verbosely report processing
45 #     --version         print version information and exit
46 # -h, --help            print short or long help message
48 # You must `cd' to the top directory of your package before you run
49 # `$progname'.
51 # When reporting a bug, please describe a test case to reproduce it and
52 # include the following information:
54 #       host-triplet:   @host_triplet@
55 #       $progname:      (GNU @PACKAGE@@TIMESTAMP@) @VERSION@
56 #       automake:               $automake_version
57 #       autoconf:               $autoconf_version
59 # Report bugs to <bug-libtool@gnu.org>.
61 PROGRAM=libtoolize
63 AS_SHELL_SANITIZE
64 $as_unset CDPATH
66 m4_include([getopt.m4sh])
68 TAR=tar
70 # Command line options:
71 opt_force=false
72 opt_install=false
73 opt_link=:
74 opt_debug=:
76 seen_libtool=false
77 seen_ltdl=false
79 # Collect flags to pass into libltdl libtoolize
80 libtoolize_flags=
82 # Locations for important files:
83 prefix=@prefix@
84 datadir=@datadir@
85 pkgdatadir=@pkgdatadir@
86 aclocaldir=@aclocaldir@
87 auxdir=
88 m4dir=
89 ltdldir=
90 configure_ac=configure.in
93 # Parse options once, thoroughly.  This comes as soon as possible in
94 # the script to make things like `libtoolize --version' happen quickly.
96   # sed scripts:
97   my_sed_single_opt='1s/^\(..\).*$/\1/;q'
98   my_sed_single_rest='1s/^..\(.*\)$/\1/;q'
99   my_sed_long_opt='1s/^\(--[[^=]]*\)=.*/\1/;q'
100   my_sed_long_arg='1s/^--[[^=]]*=//'
102   while test "$#" -gt 0; do
103     opt="$1"
104     shift
105     case $opt in
106       --copy|-c)        opt_link=false
107                         libtoolize_flags="$libtoolize_flags --copy"
108                         ;;
110       --debug)          func_echo "enabling shell trace mode"
111                         libtoolize_flags="$libtoolize_flags --debug"
112                         opt_debug='set -x'
113                         $opt_debug
114                         ;;
116       --dry-run|-n)     if $opt_dry_run; then :; else
117                           opt_dry_run=:
118                           RM="$ECHO $RM"
119                           test -n "$LN_S" && LN_S="$ECHO $LN_S"
120                           CP="$ECHO $CP"
121                           MKDIR="$ECHO $MKDIR"
122                           TAR="$ECHO $TAR"
123                         fi
124                         libtoolize_flags="${libtoolize_flags} --dry-run"
125                         ;;
127       --force|-f)       opt_force=:
128                         libtoolize_flags="${libtoolize_flags} --force"
129                         ;;
131       --install|-i)     opt_install=:
132                         libtoolize_flags="${libtoolize_flags} --install"
133                         ;;
135       --ltdl)           ltdldir=libltdl
136                         if test "$#" -gt 0; then
137                           case $1 in
138                             -*)                         ;;
139                             *)  ltdldir="$1"; shift     ;;
140                           esac
141                         fi
142                         ;;
144       --quiet|--automake|-q) # --automake is for 1.5 compatibility
145                         opt_quiet=:
146                         libtoolize_flags="${libtoolize_flags} --quiet"
147                         ;;
149       --verbose|-v)     opt_verbose=:
150                         libtoolize_flags="${libtoolize_flags} --verbose"
151                         ;;
153       # Separate optargs to long options:
154       --*=*)
155                         arg=`$ECHO "X$opt" | $Xsed -e "$my_sed_long_arg"`
156                         opt=`$ECHO "X$opt" | $Xsed -e "$my_sed_long_opt"`
157                         set dummy "$opt" "$arg" ${1+"$@"}
158                         shift
159                         ;;
161       # Separate non-argument short options:
162       -c*|-i*|-f*|-n*|-q*|-v*)
163                         rest=`$ECHO "X$opt" | $Xsed -e "$my_sed_single_rest"`
164                         opt=`$ECHO "X$opt" | $Xsed -e "$my_sed_single_opt"`
165                         set dummy "$opt" "-$rest" ${1+"$@"}
166                         shift
167                         ;;
169       -\?|-h)           func_usage                                      ;;
170       --help)           func_help                                       ;;
171       --version)        func_version                                    ;;
172       --)               break                                           ;;
173       -*)               func_fatal_help "unrecognized option \`$opt'"   ;;
174       *)                func_fatal_help "too many arguments"            ;;
175     esac
176   done
180 # func_copy srcfile destfile
181 # A wrapper for func_copy_cb that accepts arguments in the same order
182 # as the cp(1) shell command.
183 func_copy ()
185     $opt_debug
187     test -f "$1" || \
188       { func_error "\`$1' not copied:  not a regular file"; return 1; }
190     my_f1=`$ECHO "X$1" | $Xsed -e "$basename"`
192     if test -d "$2"; then
194       func_copy_cb "$my_f1" \
195         `$ECHO "X$1" | $Xsed -e "$dirname"` "$2"
197     else
199       # Supporting this would mean changing the timestamp:
200       test "X$my_f1" = X`$ECHO "X$2" | $Xsed -e "$basename"` \
201         || func_fatal_error "func_copy() cannot change filename on copy"
203       func_copy_cb "$my_f1" \
204         `$ECHO "X$1" | $Xsed -e "$dirname"` \
205         `$ECHO "X$2" | $Xsed -e "$dirname"`
207     fi
209     return $copy_return_status # set in func_copy_cb
213 # func_copy_cb filename srcdir destdir
214 # If option `--copy' was specified, or soft-linking SRCFILE to DESTFILE fails,
215 # then try to copy SRCFILE to DESTFILE (without changing the timestamp if
216 # possible).
217 func_copy_cb ()
219     $opt_debug
220     my_file="$1"
221     my_srcdir="$2"
222     my_destdir="$3"
223     copy_return_status=1
225     # Libtool is probably misinstalled if this happens:
226     test -f "$my_srcdir/$my_file" || \
227       { func_error "\`$my_file' not found in \`$my_srcdir'"; return; }
229     func_mkdir_p "$my_destdir"
231     $RM "$my_destdir/$my_file"
232     if $opt_link && $LN_S "$my_srcdir/$my_file" "$my_destdir/$my_file"; then
233       $opt_quiet || func_echo "copying file \`$my_destdir/$my_file'"
234       copy_return_status=0
235     elif { ( cd "$my_srcdir" 2>/dev/null && $TAR chf - "$my_file" 2>/dev/null; ) \
236         | ( umask 0 && cd "$my_destdir" 2>/dev/null && "$TAR" xf - >/dev/null 2>&1; ); } ; then
237       $opt_quiet || func_echo "copying file \`$my_destdir/$my_file'"
238       copy_return_status=0
239     elif $CP -p "$my_srcdir/$my_file" "$my_destdir/$my_file"; then
240       $opt_quiet || func_echo "copying file \`$my_destdir/$my_file'"
241       copy_return_status=0
242     else
243       func_error "can not copy \`$my_srcdir/$my_file' to \`$my_destdir/'"
244       exit_status=$EXIT_FAILURE
245     fi
249 # func_copy_all_files [-r] srcdir destdir [glob_exclude] [copy_cb=func_copy_cb]
250 # For each file in SRCDIR, then try to copy the file to DESTDIR by calling
251 # COPY_CB with the src and dest files.  With the `-r' option, recurse into
252 # subdirectories of srcdir too.  If GLOB_EXCLUDE is given, exclude any
253 # matching filenames from the copy.  If COPY_CB is passed, then the check
254 # for overwriting without opt_force is the callbacks responsibility:  This
255 # allows using callbacks like func_serial_update, which perform their own
256 # checks to decide whether to overwrite the dest file.
257 func_copy_all_files ()
259     $opt_debug
260     my_opt_recurse=false
261     if test "X$1" = X-r; then
262       my_opt_recurse=:
263       shift
264     fi
266     my_srcdir="$1"
267     my_destdir="$2"
268     my_glob_exclude="$3"
269     my_copy_cb="${4-func_copy_cb}"
271     my_srcfiles=
272     my_basedir="$my_srcdir"
273     my_srcdirs="$my_srcdir"
274     my_save_IFS="$IFS"
275     IFS=:
276     while test -n "$my_srcdirs"; do
278       IFS="$my_save_IFS"
279       my_srcdir=`$ECHO "X$my_srcdirs" | $Xsed -e 's,:.*,,g'`
280       my_srcdirs=`$ECHO "X$my_srcdirs" | $Xsed -e 's,:*[[^:]][[^:]]*:*,,'`
282       for my_filename in `cd "$my_srcdir" && ls`; do
284         # ignore excluded filenames
285         if test -n "$my_glob_exclude"; then
286           eval 'case $my_filename in '$my_glob_exclude') continue ;; esac'
287         fi
289         # Add to the appropriate list
290         if test -f "$my_srcdir/$my_filename"; then
291           my_srcfile=`$ECHO "X$my_srcdir/$my_filename" | $Xsed \
292               -e "s,^$my_basedir/*,,"`
293           my_srcfiles="$my_srcfiles${my_srcfiles:+:}$my_srcfile"
294         elif $my_opt_recurse && test -d "$my_srcdir/$my_filename"; then
295           my_srcdirs="$my_srcdirs${my_srcdirs:+:}$my_srcdir/$my_filename"
296         fi
298       done
299     done
300     IFS="$my_save_IFS"
302     func_copy_some_files "$my_srcfiles" "$my_basedir" \
303       "$my_destdir" "$my_copy_cb"
307 # func_copy_some_files srcfile_spec srcdir destdir [copy_cb=func_copy_cb]
308 # Call COPY_CB for each regular file in SRCDIR named by the ':' delimited
309 # names in SRCFILE_SPEC.  The odd calling convention is needed to allow
310 # spaces in file and directory names.
311 func_copy_some_files ()
313     $opt_debug
314     my_srcfile_spec="$1"
315     my_srcdir="$2"
316     my_destdir="$3"
317     my_copy_cb="${4-func_copy_cb}"
319     my_save_IFS="$IFS"
320     IFS=:
321     for my_filename in $my_srcfile_spec; do
322       IFS="$my_save_IFS"
323       if test -f "$my_srcdir/$my_filename"; then
324         if test "X$my_copy_cb" = Xfunc_copy_cb; then
325           $opt_force || if test -f "$my_destdir/$my_filename"; then
326             $opt_quiet \
327               || func_error "\`$my_destdir/$my_filename' exists: use \`--force' to overwrite"
328             continue
329           fi
330         fi
331       else
332         # Not a regular file
333         continue
334       fi
336       $my_copy_cb "$my_filename" "$my_srcdir" "$my_destdir"
337     done
338     IFS="$my_save_IFS"
341 # func_scan_files
342 # Scan configure.(ac|in) and aclocal.m4 (if present) for use of libltdl
343 # and libtool.  Possibly running some of these tools if necessary.
344 # Libtoolize affects the contents of aclocal.m4, and should be run before
345 # aclocal, so we can't use configure --trace which relies on a consistent
346 # configure.(ac|in) and aclocal.m4.
347 func_scan_files ()
349     $opt_debug
350     # Prefer configure.ac to configure.in
351     test -f configure.ac && configure_ac=configure.ac
352     test -f "$configure_ac" \
353         || func_fatal_help "\`$configure_ac' does not exist"
355     # Set local variables to reflect contents of configure.ac
356     my_uses_autoconf=false
357     my_sed_scan_configure_ac='s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,;
358         /AC_INIT/ { s,^.*$,my_uses_autoconf=:,; p; };
359         d'
360     eval `$SED "$my_sed_scan_configure_ac" "$configure_ac"`
362     $my_uses_autoconf || {
363         func_verbose "$configure_ac: not using Autoconf"
364         return
365     }
367     # ---------------------------------------------------- #
368     # Probe macro usage in configure.ac and/or aclocal.m4. #
369     # ---------------------------------------------------- #
371     my_sed_traces='s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,;
372         /AC_CONFIG_AUX_DIR[[^_]]/  {
373             s,^.*AC_CONFIG_AUX_DIR([[[  ]*\([^])]]*\).*$,auxdir=\1,; p;
374         };
375         /AC_CONFIG_MACRO_DIR/   {
376             s,^.*AC_CONFIG_MACRO_DIR([[[        ]*\([^])]]*\).*$,m4dir=\1,; p;
377         };
378         /A[[CM]]_PROG_LIBTOOL/ { s,^.*$,seen_libtool=:,; p; };
379         /LT_INIT/            { s,^.*$,seen_libtool=:,; p; };
380         /LTDL_INIT/          { s,^.*$,seen_ltdl=:,; p; };
381         /LT_WITH_LTDL/       { s,^.*$,seen_ltdl=:,; p; };
382         /AC_LIB_LTDL/        { s,^.*$,seen_ltdl=:,; p; };
383         /AC_WITH_LTDL/       { s,^.*$,seen_ltdl=:,; p; };
384         d;'
385     eval `cat aclocal.m4 "$configure_ac" 2>/dev/null | $SED "$my_sed_traces"`
388     # ---------------- #
389     # Validate auxdir. #
390     # ---------------- #
392     if test -n "$auxdir"; then
393       # If $configure_ac contains AC_CONFIG_AUX_DIR, check that it was
394       # not given in terms of a shell variable!
395       case "$auxdir" in
396       *\$*)
397         func_fatal_error "can not handle variables in AC_CONFIG_AUX_DIR"
398         ;;
399       *);;
400       esac
401     else
402       # Try to discover auxdir the same way it is discovered by configure.
403       # Note that we default to the current directory.
404       for dir in . .. ../..; do
405         if test -f "$dir/install-sh"; then
406           auxdir=$dir
407           break
408         elif test -f "$dir/install.sh"; then
409           auxdir="$dir"
410           break
411         fi
412       done
413     fi
415     # Just use the current directory if all else fails.
416     test -n "$auxdir" || auxdir=.
419     # ------------------------------ #
420     # Find local m4 macro directory. #
421     # ------------------------------ #
423     # If AC_CONFIG_MACRO_DIR turned nothing up, we hunt for ACLOCAL_AMFLAGS
424     # in `Makefile.am' for a `-I' argument.
426     my_sed_aclocal_flags='/^[[  ]]*ACLOCAL_[[A-Z_]]*FLAGS[[     ]]*=/ {
427         s,^[[^=]]*=[[   ]]*\(.*\), \1,; q; };
428         d'
429     if test ! -n "$m4dir" && test -f Makefile.am; then
430       my_m4dir_is_next=false
431       for arg in `$SED "$my_sed_aclocal_flags" Makefile.am`; do
432         if $my_m4dir_is_next; then
433           m4dir="$arg"
434           break
435         else
436           if test "X$arg" = "X-I"; then
437             my_m4dir_is_next=:
438           else
439             my_m4dir_is_next=false
440           fi
441         fi
442       done
443     fi
446 # func_included_files searchfile
447 # Output INCLUDEFILE if SEARCHFILE m4_includes it, else output SEARCHFILE.
448 func_included_files ()
450     $opt_debug
451     my_searchfile="$1"
453     my_include_regex=
454     my_sed_include='
455         /^[m4]_include(\[[.*\]])$/ { s,^[m4]_include(\[[\(.*\)\]])$,\1,; p; };
456         d'
458     if test -f "$my_searchfile"; then
459       $ECHO "X$my_searchfile" | $Xsed
460     fi
462     # Only recurse when we don't care if all the variables we use get
463     # trashed, since they are in global scope.
464     for my_filename in `$SED "$my_sed_include" "$my_searchfile"`; do
465       func_included_files $my_filename
466     done
470 # func_serial filename [macro_regex]
471 # Output the value of the serial number comment in FILENAME, where the
472 # comment line must also match MACRO_REGEX, if given.
473 func_serial ()
475     $opt_debug
476     my_filename="$1"
477     my_macro_regex="$2"
478     my_sed_serial=['/^# serial [1-9][0-9.]*[    ]*'"$my_macro_regex"'[  ]*$/ {
479           s,^# serial \([1-9][0-9.]*\).*$,\1,; q;
480         };
481         d']
483     # Search FILENAME and all the files it m4_includes for a serial number
484     # in the file that AC_DEFUNs MACRO_REGEX.
485     my_serial=
486     for my_file in `func_included_files "$my_filename"`; do
487       if test -z "$my_macro_regex" ||
488          func_grep '^AC_DEFUN(\@<:@'"$my_macro_regex" "$my_file"
489       then
490         my_serial=`$SED -e "$my_sed_serial" "$my_file"`
491         break
492       fi
493     done
495     # If the file has no serial number, we assume it's ancient.
496     test -n "$my_serial" || my_serial=0
498     $ECHO $my_serial
502 # func_serial_max serial1 serial2
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 ()
508     $opt_debug
509     my_serial1="$1"
510     my_serial2="$2"
512     my_sed_dot='s/\..*$//g'
513     my_sed_rest='s/^[[0-9]][[1-9]]*\.*//'
514     my_sed_digits='s/[[^0-9.]]//g'
516     # Incase they turn out to be the same, we'll set it to empty
517     func_serial_max_result=
519     test "X$1$2" = X`$ECHO "X$1$2" | $Xsed -e "$my_sed_digits"` || {
520       func_error "serial numbers \`$1' or \`$2' contain non-digit chars"
521       return
522     }
524     while test -n "$my_serial1$my_serial2"; do
525       my_serial1_part=`$ECHO "X$my_serial1" | $Xsed -e "$my_sed_dot"`
526       my_serial2_part=`$ECHO "X$my_serial2" | $Xsed -e "$my_sed_dot"`
528       test -z "$my_serial1_part$my_serial2_part" \
529         && break
531       test -z "$my_serial1_part" \
532         && { func_serial_max_result="$2"; break; }
534       test -z "$my_serial2_part" \
535         && { func_serial_max_result="$1"; break; }
537       test "$my_serial1_part" -gt "$my_serial2_part" \
538         && { func_serial_max_result="$1"; break; }
540       test "$my_serial2_part" -gt "$my_serial1_part" \
541         && { func_serial_max_result="$2"; break; }
543       my_serial1=`$ECHO "X$my_serial1" | $Xsed -e "$my_sed_rest"`
544       my_serial2=`$ECHO "X$my_serial2" | $Xsed -e "$my_sed_rest"`
545     done
549 # func_serial_update_check srcfile src_serial destfile dest_serial
550 # Unless SRC_SERIAL is newer than DEST_SERIAL set $func_serial_update_check
551 # to 'false'.
552 func_serial_update_check ()
554     $opt_debug
555     my_srcfile="$1"
556     my_src_serial="$2"
557     my_destfile="$3"
558     my_dest_serial="$4"
559     my_update_p=:
561     if test -f "$my_destfile"; then
562       test "X$my_src_serial" = "X0" && {
563         func_error "warning: no serial number on \`$my_srcfile', not copying."
564         return
565       }
567       # Determine whether the destination has an older serial.
568       func_serial_max "$my_src_serial" "$my_dest_serial"
569       test "X$my_src_serial" = "X$func_serial_max_result" || my_update_p=false
571       test "X$my_src_serial" = "X$func_serial_max_result" \
572         && func_verbose "\`$my_srcfile' is serial $my_src_serial, greater than $my_dest_serial in \`$my_destfile'"
574       if test "X$my_dest_serial" = "X$func_serial_max_result"; then
575         func_verbose "\`$my_srcfile' is serial $my_src_serial, less than $my_dest_serial in \`$my_destfile'"
576         $opt_force \
577           || func_error "\`$my_destfile' is newer: use \`--force' to overwrite"
578       fi
579     fi
581     func_serial_update_check_result="$my_update_p"
585 # func_serial_update filename srcdir destdir [macro_regex] [old_macro_regex]
586 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
587 # has a newer serial number, or DESTFILE does not yet exist, or the user
588 # specified `--force' at the command line.  If given, MACRO_REGEX or
589 # OLD_MACRO_REGEX must match any text after "# serial N" in both files.
590 func_serial_update ()
592     $opt_debug
593     my_filename="$1"
594     my_srcdir="$2"
595     my_destdir="$3"
596     my_macro_regex="$4"
597     my_old_macro_regex="$5"
599     my_serial_update_p=:
600     my_return_status=1
601     my_srcfile="$my_srcdir/$my_filename"
602     my_destfile="$my_destdir/$my_filename"
604     test -f "$my_srcfile" || {
605       func_error "\`$my_srcfile' does not exist."
606       return
607     }
609     if test -f "$my_destfile"; then
610       my_src_serial=`func_serial "$my_srcfile" "$my_macro_regex"`
611       my_dest_serial=`func_serial "$my_destfile" "$my_macro_regex"`
613       # Strictly, this libtoolize ought not to have to deal with ancient
614       # serial formats, but we accept them here to be complete:
615       test "X$my_src_serial" = "X0" &&
616         my_src_serial=`func_serial "$my_srcfile" "$my_old_macro_regex"`
618       test "X$my_dest_serial" = "X0" &&
619         my_dest_serial=`func_serial "$my_destfile" "$my_old_macro_regex"`
621       func_serial_update_check \
622         "$my_srcfile" "$my_src_serial" "$my_destfile" "$my_dest_serial"
623       my_serial_update_p="$func_serial_update_check_result"
624     fi
626     if $my_serial_update_p || $opt_force; then
627       func_copy "$my_srcfile" "$my_destfile"
628       my_return_status=$?
629     elif test "X$my_dest_serial" = "X$my_src_serial"; then
630       $opt_quiet \
631         || func_echo "\`$my_destfile' is already up to date."
632     fi
634     # Do this after the copy for hand maintained `aclocal.m4', incase
635     # it has `m4_include([DESTFILE])', so the copy effectively already
636     # updated `aclocal.m4'.
637     $use_aclocal || if test -f aclocal.m4; then
638       func_serial_max \
639           "$my_src_serial" `func_serial aclocal.m4 "$my_macro_regex"`
640       test "X$my_src_serial" = "X$func_serial_max_result" \
641           && func_echo "You should add the contents of \'$my_destfile' to \`aclocal.m4'."
642     fi
644     return $my_return_status
648 # func_keyword_update filename srcdir destdir sed_script
649 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
650 # has a newer revision according to the serial number extracted by
651 # SED_SCRIPT, or DESTFILE does not yet exist, or the user specified
652 # `--force' at the command line.
653 func_keyword_update ()
655     $opt_debug
656     my_filename="$1"
657     my_srcdir="$2"
658     my_destdir="$3"
659     my_sed_script="$4"
661     my_srcfile="$my_srcdir/$my_filename"
662     my_destfile="$my_destdir/$my_filename"
664     my_keyword_update_p=:
666     test -f "$my_srcfile" || {
667       func_error "\`$my_srcfile' does not exist."
668       return
669     }
671     if test -f "$my_destfile"; then
672       my_src_serial=`$SED -e "$my_sed_script" "$my_srcfile"`
673       test -z "$my_src_serial" && {
674         func_error "warning: no serial number in \`$my_srcfile', not copying."
675         return
676       }
678       my_dest_serial=`$SED -e "$my_sed_script" "$my_destfile"`
679       test -n "$my_dest_serial" || my_dest_serial=0
681       func_serial_update_check \
682          "$my_srcfile" "$my_src_serial" "$my_destfile" "$my_dest_serial"
683       my_keyword_update_p="$func_serial_update_check_result"
684     fi
686     if $my_keyword_update_p || $opt_force; then
687       func_copy "$my_srcfile" "$my_destfile"
688     elif test "X$my_dest_serial" = "X$my_src_serial"; then
689       $opt_quiet \
690         || func_echo "\`$my_destfile' is already up to date."
691     fi
695 # func_ltmain_update filename srcdir destdir
696 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
697 # has a newer revision, or DESTFILE does not yet exist, or the user
698 # specified `--force' at the command line.
699 func_ltmain_update ()
701     $opt_debug
702     my_sed_ltmain=['/^package_revision='\''*[0-9][1-9.]*'\''*/ {
703       s,^package_revision='\''*\([0-9.]*\)'\''*[        ]*$,\1,; p;
704     };
705     d']
707     func_keyword_update "$1" "$2" "$3" "$my_sed_ltmain"
709     return $my_return_status
713 # func_config_update filename srcdir destdir
714 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
715 # has a newer timestamp, or DESTFILE does not yet exist, or the user
716 # specified `--force' at the command line.
717 func_config_update ()
719     $opt_debug
720     my_sed_config=['/^timestamp='\''*[0-9][1-9-]*'\''*/ {
721       s,^timestamp='\''*\([0-9-]*\)'\''*,\1,; s/-/./g; p;
722     };
723     d']
725     func_keyword_update "$1" "$2" "$3" "$my_sed_config"
727     return $my_return_status
731 # func_install_update filename srcdir destdir
732 # Copy the FILENAME from a SRCDIR to DESTDIR provided that either FILENAME
733 # has a newer timestamp, or DESTFILE does not yet exist, or the user
734 # specified `--force' at the command line.
735 func_install_update ()
737     $opt_debug
738     my_sed_install=['/^scriptversion='\''*[0-9][1-9.-]*'\''*/ {
739       s,^scriptversion='\''*\([0-9.-]*\)'\''*,\1,; s/-/./g; p;
740     };
741     d']
743     func_keyword_update "$1" "$2" "$3" "$my_sed_install"
745     return $my_return_status
749 # func_check_macros
750 # Sanity check macros from aclocal.m4 against installed versions.
751 func_check_macros ()
753     $opt_debug
754     # Don't trace for this, we're just checking the user didn't invoke it
755     # directly from configure.ac.
756     $SED 's,[d]nl .*$,,; s,# .*$,,' "$configure_ac" | grep AC_PROG_RANLIB \
757       && func_echo "\`AC_PROG_RANLIB' is rendered obsolete by \`LT_INIT'"
759     $seen_libtool \
760       || func_echo "Remember to add \`LT_INIT' to \`$configure_ac'."
762     # FIXME: Ensure ltmain.sh, libtool.m4 and ltdl.m4 are from the same release
766 # func_massage_aclocal_DATA [glob_exclude]
767 # @aclocal_DATA\@ is substituted as per its value in Makefile.am;
768 # this function massages it into a suitable format for func_copy_some_files.
769 func_massage_aclocal_DATA ()
771     pkgmacro_files=     # GLOBAL VAR
773     my_glob_exclude="$1"
775     # Massage a value for pkgmacro_files from the value used in Makefile.am.
776     for my_filename in @aclocal_DATA@; do
777       my_filename=`$ECHO "X$my_filename" | $Xsed -e "$basename"`
779       # ignore excluded filenames
780       if test -n "$my_glob_exclude"; then
781         eval 'case $my_filename in '$my_glob_exclude') continue ;; esac'
782       fi
784       pkgmacro_files="$pkgmacro_files:$my_filename"
785     done
787     # strip spurious leading `:'
788     pkgmacro_files=`$ECHO "X$pkgmacro_files" | $Xsed -e 's,^:*,,'`
792 # func_massage_pkgltdl_files [glob_exclude]
793 # @pkgltdl_files\@ is substituted as per its value in Makefile.am; this
794 # function massages it into a suitable format for func_copy_some_files.
795 func_massage_pkgltdl_files ()
797     pkgltdl_files=      # GLOBAL VAR
799     my_glob_exclude="$1"
801     # Massage a value for pkgltdl_files from the value used in Makefile.am
802     for my_filename in @pkgltdl_files@; do
804       # ignore excluded filenames
805       if test -n "$my_glob_exclude"; then
806         eval 'case $my_filename in '$my_glob_exclude') continue ;; esac'
807       fi
809       # ignore duplicates
810       case :$pkgltdl_files: in
811         *:$my_filename:*) ;;
812         *) pkgltdl_files="$pkgltdl_files:$my_filename" ;;
813       esac
814     done
816     # strip spurious leading `:'
817     pkgltdl_files=`$ECHO "X$pkgltdl_files" | $Xsed -e 's,^:*,,'`
821 # func_nonemptydir_p dirvar
822 # DIRVAR is the name of a variable to evaluate.  Unless DIRVAR names
823 # a directory that exists and is non-empty abort with a diagnostic.
824 func_nonemptydir_p ()
826     $opt_debug
827     my_dirvar="$1"
828     my_dir=`eval echo "\\\$$my_dirvar"`
830     # Is it a directory at all?
831     test -d "$my_dir" \
832       || func_fatal_error "\$$my_dirvar not a directory: \`$my_dir'"
834     # check that the directories contents can be ls'ed
835     test -n "`{ cd $my_dir && ls; } 2>/dev/null`" \
836         || func_fatal_error "can not list files: \`$my_dir'"
840 ## ----------- ##
841 ##    Main.    ##
842 ## ----------- ##
845   rerun_aclocal=false
847   # Allow the user to override the master libtoolize repository:
848   if test -n "$_lt_pkgdatadir"; then
849     pkgdatadir="$_lt_pkgdatadir"
850     aclocaldir="$_lt_pkgdatadir/m4"
851   fi
852   func_nonemptydir_p pkgdatadir
853   func_nonemptydir_p aclocaldir
855   func_massage_pkgltdl_files
857   # libtool.m4 and ltdl.m4 are handled specially below
858   func_massage_aclocal_DATA 'libtool.m4|ltdl.m4'
860   glob_exclude_pkgaux_files='config.guess|config.sub|install-sh|ltmain.sh'
862   func_scan_files
863   $opt_quiet || func_check_macros
865   # Copy all the files from installed libltdl to this project, if the
866   # user specified `--ltdl'.
867   if test -n "$ltdldir"; then
868     func_copy_some_files "$pkgltdl_files" "$pkgdatadir/libltdl" "$ltdldir"
870     # libtoolize the newly copied libltdl tree
871     ( cd "$ltdldir" && eval "$progpath" $libtoolize_flags ) \
872       || exit $EXIT_FAILURE
873   fi
875   # Copy all the installed utility files to the auxiliary directory if
876   # `--install' was passed, or else copy just ltmain.sh.
877   $opt_quiet || if test "$auxdir" != .; then
878     func_echo "putting files in AC_CONFIG_AUX_DIR, \`$auxdir'."
879   fi
880   if $opt_install; then
881     func_config_update config.guess "$pkgdatadir/config" "$auxdir"
882     func_config_update config.sub   "$pkgdatadir/config" "$auxdir"
883     func_install_update install-sh  "$pkgdatadir/config" "$auxdir"
884   fi
885   func_ltmain_update ltmain.sh "$pkgdatadir/config" "$auxdir"
887   # Copy libtool's m4 macros to the macro directory, if they are newer.
888   if test -n "$m4dir"; then
889     $opt_quiet || func_echo "putting macros in AC_CONFIG_MACRO_DIR, \`$m4dir'."
891     func_serial_update  libtool.m4 "$aclocaldir" "$m4dir" \
892       LT_INIT 'A[[CM]]_PROG_LIBTOOL'
894     if $seen_ltdl; then
895       func_serial_update ltdl.m4 "$aclocaldir" "$m4dir" 'LTDL_INIT'
896     else
897       func_verbose "Not copying \`$m4dir/ltdl.m4', libltdl not used."
898     fi
900     func_copy_some_files "$pkgmacro_files" "$aclocaldir" \
901       "$m4dir" func_serial_update
902   else
903     func_verbose "AC_CONFIG_MACRO_DIR not defined, not copying libtool macro files."
904   fi
907 exit $exit_status
909 # Local Variables:
910 # mode:shell-script
911 # sh-indentation:2
912 # End: