/[libtool]/libtool/libtoolize.m4sh
ViewVC logotype

Diff of /libtool/libtoolize.m4sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by gary, Mon Nov 15 01:03:14 2004 UTC revision 1.4 by gary, Mon Nov 29 13:50:46 2004 UTC
# Line 40  m4_divert_push([SCRIPT])#! /bin/sh Line 40  m4_divert_push([SCRIPT])#! /bin/sh
40  # -f, --force           replace existing files  # -f, --force           replace existing files
41  # -i, --install         copy missing auxiliary files  # -i, --install         copy missing auxiliary files
42  #     --ltdl[=DIR]      install libltdl in a subdirectory [default: libltdl]  #     --ltdl[=DIR]      install libltdl in a subdirectory [default: libltdl]
43    # -I DIR                search DIR for libtoolize master source files
44  # -q, --quiet           work silently  # -q, --quiet           work silently
45  # -v, --verbose         verbosely report processing  # -v, --verbose         verbosely report processing
46  #     --version         print version information and exit  #     --version         print version information and exit
# Line 79  libtoolize_flags= Line 80  libtoolize_flags=
80  # Locations for important files:  # Locations for important files:
81  prefix=@prefix@  prefix=@prefix@
82  datadir=@datadir@  datadir=@datadir@
83  pkgvdatadir=@pkgvdatadir@  pkgvdatadirs=@pkgvdatadir@
84  pkgvmacrodir=@pkgvmacrodir@  pkgvmacrodirs=@pkgvmacrodir@
85  auxdir=  auxdir=
86  m4dir=  m4dir=
87  ltdldir=  ltdldir=
# Line 135  configure_ac=configure.in Line 136  configure_ac=configure.in
136                          fi                          fi
137                          ;;                          ;;
138    
139          -I)               test "$#" = 0 && func_missing_arg $opt && break
140                            test -d "$1" \
141                              && pkgvdatadirs="`cd $1 && pwd`:$pkgvdatadirs"
142                            test -d "$1/m4" \
143                              && pkgvmacrodirs="`cd $1/m4 && pwd`:$pkgvmacrodirs"
144                            func_quote_for_eval "$1"
145                            libtoolize_flags="$libtoolize_flags -I $func_quote_for_eval_result"
146                            shift
147                            ;;
148    
149        --quiet|--automake|-q) # --automake is for 1.5 compatibility        --quiet|--automake|-q) # --automake is for 1.5 compatibility
150                          opt_quiet=:                          opt_quiet=:
151                          libtoolize_flags="${libtoolize_flags} --quiet"                          libtoolize_flags="${libtoolize_flags} --quiet"
# Line 145  configure_ac=configure.in Line 156  configure_ac=configure.in
156                          ;;                          ;;
157    
158        # Separate optargs to long options:        # Separate optargs to long options:
159        --ltdl=*)        --*=*)
160                          arg=`$ECHO "X$opt" | $Xsed -e "$my_sed_long_arg"`                          arg=`$ECHO "X$opt" | $Xsed -e "$my_sed_long_arg"`
161                          opt=`$ECHO "X$opt" | $Xsed -e "$my_sed_long_opt"`                          opt=`$ECHO "X$opt" | $Xsed -e "$my_sed_long_opt"`
162                          set -- "$opt" "$arg" ${1+"$@"}                          set -- "$opt" "$arg" ${1+"$@"}
# Line 195  func_copy () Line 206  func_copy ()
206      return $my_return_status      return $my_return_status
207  }  }
208    
209  # func_copy_all_files [-r] srcdir destdir [glob_exclude] [copy_cb=func_copy]  
210    # func_copy_cb filename srcdir destdir
211    # A wrapper for func_copy that accepts arguments in the order
212    # used by func_copy_all_files callbacks.
213    func_copy_cb ()
214    {
215        func_copy "$2/$1" "$3/$1"
216    }
217    
218    
219    # func_copy_all_from_path [-r] dirname srcpath destdir [glob_exclude]
220    # Search each : delimited directory in SRCPATH for a directory named
221    # DIRNAME.  Recursively copy the contents of the first match found
222    # to DESTDIR.
223    func_copy_all_from_path ()
224    {
225        if test "X$1" = X-r; then
226          my_args=-r
227          shift
228        fi
229    
230        my_dirname="$1"
231        my_srcpath="$2"
232        my_destdir="$3"
233        my_globexc="$4"
234    
235        save_IFS="$IFS"; IFS=:
236        for myvdir in $my_srcpath; do
237          IFS="$save_IFS"
238          test "X$my_dirname" = X. || myvdir="$myvdir/$my_dirname"
239          if test -d "$myvdir"; then
240            eval func_copy_all_files $my_args "$myvdir" "$my_destdir" "$my_globexc"
241            break
242          fi
243        done
244        IFS="$save_IFS"
245    }
246    
247    
248    # func_copy_all_files [-r] srcdir destdir [glob_exclude] [copy_cb=func_copy_cb]
249  # For each file in SRCDIR, then try to copy the file to DESTDIR by calling  # For each file in SRCDIR, then try to copy the file to DESTDIR by calling
250  # COPY_CB with the src and dest files.  With the `-r' option, recurse into  # COPY_CB with the src and dest files.  With the `-r' option, recurse into
251  # subdirectories of srcdir too.  If GLOB_EXCLUDE is given, exclude any  # subdirectories of srcdir too.  If GLOB_EXCLUDE is given, exclude any
# Line 214  func_copy_all_files () Line 264  func_copy_all_files ()
264      my_srcdir="$1"      my_srcdir="$1"
265      my_destdir="$2"      my_destdir="$2"
266      my_glob_exclude="$3"      my_glob_exclude="$3"
267      my_copy_cb="${4-func_copy}"      my_copy_cb="${4-func_copy_cb}"
268    
269      my_srcfiles=      my_srcfiles=
270      my_basedir="$my_srcdir"      my_basedir="$my_srcdir"
# Line 229  func_copy_all_files () Line 279  func_copy_all_files ()
279    
280        for my_filename in `cd "$my_srcdir" && ls`; do        for my_filename in `cd "$my_srcdir" && ls`; do
281    
282          # ignore excluded filenames           # ignore excluded filenames
283          if test -n "$my_glob_exclude"; then          if test -n "$my_glob_exclude"; then
284            eval 'case $my_filename in '$my_glob_exclude') continue ;; esac'            eval 'case $my_filename in '$my_glob_exclude') continue ;; esac'
285          fi          fi
# Line 247  func_copy_all_files () Line 297  func_copy_all_files ()
297      done      done
298      IFS="$my_save_IFS"      IFS="$my_save_IFS"
299    
300      func_copy_some_files "$my_basedir" "$my_srcfiles" \      func_copy_some_files "$my_srcfiles" "$my_basedir" \
301        "$my_destdir" "$my_copy_cb"        "$my_destdir" "$my_copy_cb"
302  }  }
303    
304    
305  # func_copy_some_files srcdir srcfile_spec destdir [copy_cb=func_copy]  # func_copy_some_files srcfile_spec srcdirs destdir [copy_cb=func_copy_cb]
306  # Call COPY_CB for each regular file in SRCDIR named by the ':' delimited  # Call COPY_CB for each regular file named by the ':' delimited names in
307  # names in SRCFILE_SPEC.  The odd calling convention is needed to allow  # SRCFILE_SPEC first found in a directory from SRCDIRS.  The odd calling
308  # spaces in file and directory names.  # convention is needed to allow spaces in file and directory names.
309  func_copy_some_files ()  func_copy_some_files ()
310  {  {
311      my_srcdir="$1"      my_srcfile_spec="$1"
312      my_srcfile_spec="$2"      my_srcdirs="$2"
313      my_destdir="$3"      my_destdir="$3"
314      my_copy_cb="${4-func_copy}"      my_copy_cb="${4-func_copy_cb}"
315    
316      my_save_IFS="$IFS"      my_save_IFS="$IFS"
317      IFS=:      IFS=:
318      for my_filename in $my_srcfile_spec; do      for my_filename in $my_srcfile_spec; do
319          for my_srcdir in $my_srcdirs; do
320        IFS="$my_save_IFS"          IFS="$my_save_IFS"
321        if test -f "$my_srcdir/$my_filename"; then          if test -f "$my_srcdir/$my_filename"; then
322          if test "X$my_copy_cb" = Xfunc_copy; then            if test "X$my_copy_cb" = Xfunc_copy_cb; then
323            $opt_force || if test -f "$my_destdir/$my_filename"; then              $opt_force || if test -f "$my_destdir/$my_filename"; then
324              $opt_quiet \                $opt_quiet \
325                || func_error "\`$my_destdir/$my_filename' exists: use \`--force' to overwrite"                  || func_error "\`$my_destdir/$my_filename' exists: use \`--force' to overwrite"
326              continue                continue
327            fi              fi
328              fi
329            else
330              # Not a regular file
331              continue
332          fi          fi
       else  
         # Not a regular file  
         continue  
       fi  
333    
334        $my_copy_cb "$my_srcdir/$my_filename" "$my_destdir/$my_filename"          $my_copy_cb "$my_filename" "$my_srcdir" "$my_destdir"
335          done
336          IFS="$my_save_IFS"
337      done      done
338      IFS="$my_save_IFS"      IFS="$my_save_IFS"
339  }  }
# Line 299  func_scan_files () Line 351  func_scan_files ()
351      test -f "$configure_ac" \      test -f "$configure_ac" \
352          || func_fatal_help "\`$configure_ac' does not exist"          || func_fatal_help "\`$configure_ac' does not exist"
353    
354      test -n "`cd $pkgvdatadir && ls`" \      # TODO: check that existing directories from the list can be ls'ed
355          || func_fatal_error "can not list files in \`$pkgvdatadir'"      #test -n "`{ cd $pkgvdatadir && ls; } 2>dev/null`" \
356        #    || func_fatal_error "can not list files in \`$pkgvdatadir'"
357    
358      # Set local variables to reflect contents of configure.ac      # Set local variables to reflect contents of configure.ac
359      my_uses_autoconf=false      my_uses_autoconf=false
# Line 415  func_included_files () Line 467  func_included_files ()
467      done      done
468  }  }
469    
470    
471    # func_filename_path_search filename dirs
472    func_filename_path_search ()
473    {
474        func_filename_path_search_result=
475    
476        my_save_IFS="$IFS"; IFS=:
477        for mydir in $2; do
478          IFS="$my_save_IFS"
479          test -f "$mydir/$1" && break
480        done
481        IFS="$my_save_IFS"
482    
483        test -f "$mydir/$1" && func_filename_path_search_result="$mydir/$1"
484    }
485    
486    
487  # func_serial filename [macro_regex]  # func_serial filename [macro_regex]
488  # Output the value of the serial number comment in FILENAME, where the  # Output the value of the serial number comment in FILENAME, where the
489  # comment line must also match MACRO_REGEX, if given.  # comment line must also match MACRO_REGEX, if given.
# Line 444  func_serial () Line 513  func_serial ()
513      $ECHO $my_serial      $ECHO $my_serial
514  }  }
515    
516  # func_serial_update srcfile destfile [macro_regex] [old_macro_regex]  # func_serial_update filename srcdirs destdir [macro_regex] [old_macro_regex]
517  # Copy SRCFILE to DESTFILE provided SRCFILE has a newer serial number, or  # Copy the first file named FILENAME from a directory listed in the
518  # DESTFILE does not yet exist, or the user specified `--force'.  If given,  # ':' delimited SRCDIRS to DESTFILE provided that either FILENAME has
519  # MACRO_REGEX or OLD_MACRO_REGEX must match any text after "# serial N" in  # a newer serial number, or DESTFILE does not yet exist, or the user
520  # both files.  # specified `--force' at the command line.  If given, MACRO_REGEX or
521    # OLD_MACRO_REGEX must match any text after "# serial N" in both files.
522  func_serial_update ()  func_serial_update ()
523  {  {
524      my_srcfile="$1"      my_filename="$1"
525      my_destfile="$2"      my_srcdirs="$2"
526      my_macro_regex="$3"      my_destdir="$3"
527      my_old_macro_regex="$4"      my_macro_regex="$4"
528        my_old_macro_regex="$5"
529    
530      my_return_status=1      my_return_status=1
531      my_update_p=:      my_update_p=:
532        func_filename_path_search "$my_filename" "$my_srcdirs"
533        my_srcfile="$func_filename_path_search_result"
534        my_destfile="$my_destdir/$my_filename"
535    
536        test -f "$my_srcfile" || \
537          { func_error "\`$my_filename' not found in \`$my_srcdirs'"; return; }
538    
539      if test -f "$my_destfile"; then      if test -f "$my_destfile"; then
540        my_src_serial=`func_serial "$my_srcfile" "$my_macro_regex"`        my_src_serial=`func_serial "$my_srcfile" "$my_macro_regex"`
# Line 522  func_check_macros () Line 599  func_check_macros ()
599      # FIXME: Ensure ltmain.sh, libtool.m4 and ltdl.m4 are from the same release      # FIXME: Ensure ltmain.sh, libtool.m4 and ltdl.m4 are from the same release
600  }  }
601    
602  # func_ltmain_update srcfile destfile  # func_ltmain_update filename srcdirs destdir
603  # Copy SRCFILE to DESTFILE provided SRCFILE has a newer VERSION/TIMESTAMP,  # Copy the first file named FILENAME from a directory listed in the
604  # or DESTFILE does not yet exist, or the user specified `--force'.  # ':' delimited SRCDIRS to DESTFILE provided that either FILENAME has
605    # a newer TIMESTAMP, or DESTFILE does not yet exist, or the user
606    # specified `--force' at the command line.
607  func_ltmain_update ()  func_ltmain_update ()
608  {  {
609      my_srcfile="$1"      my_filename="$1"
610      my_destfile="$2"      my_srcdirs="$2"
611        my_destdir="$3"
612    
613        func_filename_path_search "$my_filename" "$my_srcdirs"
614        my_srcfile="$func_filename_path_search_result"
615        my_destfile="$my_destdir/$my_filename"
616      my_sed_ltmain='      my_sed_ltmain='
617          s,^VERSION=[[^0-9]]*\(.*\)[[    ]]*$,\1,; t          s,^VERSION=[[^0-9]]*\(.*\)[[    ]]*$,\1,; t
618          s,^TIMESTAMP=[[^0-9]]*\([[.0-9]]*\) .*$,\1,; t          s,^TIMESTAMP=[[^0-9]]*\([[.0-9]]*\) .*$,\1,; t
619          d'          d'
620    
621      if test -f "$my_srcfile"; then :      if test -n "$my_srcfile"; then
622      else  
623        func_error "\`$my_srcfile' does not exist."        # FIXME:  check versions, and only downgrade with --force
624        return        cmp -s  "$my_srcfile" "$my_destfile"
625      fi        if test "$?" -ne 0 || $opt_force; then
626            func_copy "$my_srcfile" "$my_destfile"
627          else
628            $opt_quiet \
629              || func_echo "\`$my_destfile' is already up to date."
630          fi
631    
     # FIXME:  check versions, and only downgrade with --force  
     cmp -s  "$my_srcfile" "$my_destfile"  
     if test "$?" -ne 0 || $opt_force; then  
       func_copy "$my_srcfile" "$my_destfile"  
632      else      else
633        $opt_quiet \        func_error "\`$my_filename' not found in \`$my_srcdirs'."
         || func_echo "\`$my_destfile' is already up to date."  
634      fi      fi
635  }  }
636    
637  # func_config_update srcfile destfile  # func_config_update filename srcdirs destdir
638  # Copy SRCFILE to DESTFILE provided SRCFILE has a newer TIMESTAMP,  # Copy the first file named FILENAME from a directory listed in the
639  # or DESTFILE does not yet exist, or the user specified `--force'.  # ':' delimited SRCDIRS to DESTFILE provided that either FILENAME has
640    # a newer TIMESTAMP, or DESTFILE does not yet exist, or the user
641    # specified `--force' at the command line.
642  func_config_update ()  func_config_update ()
643  {  {
644      my_srcfile="$1"      my_filename="$1"
645      my_destfile="$2"      my_srcdirs="$2"
646        my_destdir="$3"
647    
648        func_filename_path_search "$my_filename" "$my_srcdirs"
649        my_srcfile="$func_filename_path_search_result"
650        my_destfile="$my_destdir/$my_filename"
651      my_sed_config='s,^timestamp=[[^0-9]]*\([[.0-9-]]*\)[[^0-9]].*$,\1,; t; d'      my_sed_config='s,^timestamp=[[^0-9]]*\([[.0-9-]]*\)[[^0-9]].*$,\1,; t; d'
652    
653      if test -f "$my_srcfile"; then :      if test -n "$my_srcfile"; then
654      else  
655        func_error "\`$my_srcfile' does not exist."        # FIXME:  check versions, and only downgrade with --force
656        return        cmp -s  "$my_srcfile" "$my_destfile"
657      fi        if test "$?" -ne 0 || $opt_force; then
658            func_copy "$my_srcfile" "$my_destfile"
659          else
660            $opt_quiet \
661              || func_echo "\`$my_destfile' is already up to date."
662          fi
663    
     # FIXME:  check versions, and only downgrade with --force  
     cmp -s  "$my_srcfile" "$my_destfile"  
     if test "$?" -ne 0 || $opt_force; then  
       func_copy "$my_srcfile" "$my_destfile"  
664      else      else
665        $opt_quiet \        func_error "\`$my_filename' not found in \`$my_srcdirs'."
         || func_echo "\`$my_destfile' is already up to date."  
666      fi      fi
667  }  }
668    
# Line 594  func_config_update () Line 685  func_config_update ()
685    func_scan_files    func_scan_files
686    $opt_quiet || func_check_macros    $opt_quiet || func_check_macros
687    
688    # Copy all the files from installed libltdl to this project, if the    # Copy all the files from installed (or specified, if `-I' was used)
689    # user specified `--ltdl'.    # libltdl to this project, if the user specified `--ltdl'.
690    if test -n "$ltdldir"; then    if test -n "$ltdldir"; then
691      eval func_copy_all_files -r "$pkgvdatadir/libltdl" "$ltdldir"      func_copy_all_from_path -r libltdl "$pkgvdatadirs" "$ltdldir"
692    
693      # libtoolize the newly copied libltdl tree      # libtoolize the newly copied libltdl tree
694      ( cd "$ltdldir" && "$progpath" $libtoolize_flags ) || exit $EXIT_FAILURE      ( cd "$ltdldir" && eval "$progpath" $libtoolize_flags ) \
695          || exit $EXIT_FAILURE
696    fi    fi
697    
698    # Copy all the installed utility files to the auxiliary directory if    # Copy all the installed utility files to the auxiliary directory if
# Line 609  func_config_update () Line 701  func_config_update ()
701      func_echo "putting files in AC_CONFIG_AUX_DIR, \`$auxdir'."      func_echo "putting files in AC_CONFIG_AUX_DIR, \`$auxdir'."
702    fi    fi
703    if $opt_install || $opt_force; then    if $opt_install || $opt_force; then
704      func_copy_all_files "$pkgvdatadir" "$auxdir" "$glob_exclude_pkgaux_files"      func_copy_all_from_path . "$pkgvdatadirs" \
705      func_config_update "$pkgvdatadir/config.guess" "$auxdir/config.guess"        "$auxdir" "$glob_exclude_pkgaux_files"
706      test -f "$pkgvdatadir/config.sub" \      func_config_update config.guess "$pkgvdatadirs" "$auxdir"
707        && func_config_update "$pkgvdatadir/config.sub" "$auxdir/config.sub"      func_config_update config.sub   "$pkgvdatadirs" "$auxdir"
708    fi    fi
709    func_ltmain_update "$pkgvdatadir/ltmain.sh" "$auxdir/ltmain.sh"    func_ltmain_update ltmain.sh "$pkgvdatadirs" "$auxdir"
710    
711    # Copy libtool's m4 macros to the macro directory, if they are newer.    # Copy libtool's m4 macros to the macro directory, if they are newer.
712    if test -n "$m4dir"; then    if test -n "$m4dir"; then
     libtool_m4="$pkgvmacrodir/libtool.m4"  
     ltdl_m4="$pkgvmacrodir/ltdl.m4"  
   
713      $opt_quiet || func_echo "putting macros in AC_CONFIG_MACRO_DIR, \`$m4dir'."      $opt_quiet || func_echo "putting macros in AC_CONFIG_MACRO_DIR, \`$m4dir'."
714    
715      func_serial_update  "$libtool_m4" "$m4dir/libtool.m4" \      func_serial_update  libtool.m4 "$pkgvmacrodirs" "$m4dir" \
716        LT_INIT 'A[[CM]]_PROG_LIBTOOL'        LT_INIT 'A[[CM]]_PROG_LIBTOOL'
717    
718      if $seen_ltdl; then      if $seen_ltdl; then
719        func_serial_update "$ltdl_m4" "$m4dir/ltdl.m4" 'LTDL_INIT'        func_serial_update ltdl.m4 "$pkgvmacrodirs" "$m4dir" 'LTDL_INIT'
720      else      else
721        func_verbose "Not copying \`$ltdl_m4', libltdl not used."        func_verbose "Not copying \`$m4dir/ltdl.m4', libltdl not used."
722      fi      fi
723    
724      func_copy_some_files "$pkgvmacrodir" "$pkgvmacro_files" \      func_copy_some_files "$pkgvmacro_files" "$pkgvmacrodirs" \
725        "$m4dir" func_serial_update        "$m4dir" func_serial_update
726    fi    fi
727  }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26