X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=gnulib-tool;h=757ad7c8e8fcbfa3e5b75634b4027c4451732a1a;hb=569c14694b09263fe3238b3a68b6a48535e1599f;hp=b043a9618c1c24c92321986b32f0d6d10d6e4c94;hpb=7539f3f0c8fb8121c4c73b389816a6b05268eb8f;p=gnulib.git diff --git a/gnulib-tool b/gnulib-tool index b043a9618..757ad7c8e 100755 --- a/gnulib-tool +++ b/gnulib-tool @@ -22,7 +22,7 @@ progname=$0 package=gnulib -cvsdatestamp='$Date: 2005-08-31 20:55:19 $' +cvsdatestamp='$Date: 2005-09-05 11:40:42 $' last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'` version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'` @@ -746,6 +746,7 @@ func_emit_tests_Makefile_am () # - avoidlist list of modules to avoid, from --avoid # - lgpl true if library's license shall be LGPL, blank otherwise # - libtool true if libtool will be used, blank otherwise +# - guessed_libtool true if the configure.ac file uses libtool, blank otherwise # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use # - dry_run true if actions shall only be printed, blank otherwise # - symbolic true if files should be symlinked, copied otherwise @@ -832,7 +833,7 @@ func_import () fi fi # The libname defaults to the cached one. - if test -z "$libname"; then + if test -z "$supplied_libname"; then libname="$cached_libname" if test -z "$libname"; then func_fatal_error "missing --lib option" @@ -842,9 +843,13 @@ func_import () if test -z "$lgpl"; then lgpl="$cached_lgpl" fi - # Use libtool if specified either way. + # Use libtool if specified either way, or if guessed. if test -z "$libtool"; then - libtool="$cached_libtool" + if test -n "$cached_m4base"; then + libtool="$cached_libtool" + else + libtool="$guessed_libtool" + fi fi # The macro_prefix defaults to the cached one. if test -z "$macro_prefix"; then @@ -889,6 +894,14 @@ func_import () old_files="$old_files m4/gnulib-tool.m4" fi + # Create directories. + test -d "$destdir/$sourcebase" \ + || { test -n "$dry_run" || mkdir "$destdir/$sourcebase" || func_fatal_error "failed"; } + test -d "$destdir/$m4base" \ + || { test -n "$dry_run" || mkdir "$destdir/$m4base" || func_fatal_error "failed"; } + test -d "$destdir/$auxdir" \ + || { test -n "$dry_run" || mkdir "$destdir/$auxdir" || func_fatal_error "failed"; } + # Copy files or make symbolic links. Remove obsolete files. for f1 in $old_files; do case "$f1" in @@ -963,7 +976,7 @@ func_import () fi test -n "$dry_run" && dry=echo $dry mv -f "$destdir/$g2" "$destdir/${g2}~" || func_fatal_error "failed" - if test -z "$symbolic" && cmp "$gnulib_dir/$f2" "$destdir/$g2.tmp"; then + if test -n "$symbolic" && cmp "$gnulib_dir/$f2" "$destdir/$g2.tmp" > /dev/null; then func_ln_if_changed "$gnulib_dir/$f2" "$destdir/$g2" else $dry mv -f "$destdir/$g2.tmp" "$destdir/${g2}" || func_fatal_error "failed" @@ -975,12 +988,13 @@ func_import () # frequently that developers don't put autogenerated files into CVS. echo "Copying file $g2" test -n "$dry_run" && dry=echo - if test -z "$symbolic" && cmp "$gnulib_dir/$f2" "$destdir/$g2.tmp"; then + if test -n "$symbolic" && cmp "$gnulib_dir/$f2" "$destdir/$g2.tmp" > /dev/null; then func_ln_if_changed "$gnulib_dir/$f2" "$destdir/$g2" else $dry mv -f "$destdir/$g2.tmp" "$destdir/${g2}" || func_fatal_error "failed" fi fi + rm -f "$destdir/$g2.tmp" done # Command-line invocation printed in a comment in generated gnulib-cache.m4. @@ -999,7 +1013,7 @@ func_import () if test -n "$libtool"; then actioncmd="$actioncmd --libtool" fi - actioncmd="$actioncmd -macro-prefix=$macro_prefix" + actioncmd="$actioncmd --macro-prefix=$macro_prefix" actioncmd="$actioncmd `echo $specified_modules`" # Create lib/Makefile.am. @@ -1434,93 +1448,108 @@ case $mode in test -d "$destdir" \ || func_fatal_error "destination directory does not exist: $destdir" - # Prefer configure.ac to configure.in - test -f "$destdir"/configure.in && configure_ac="$destdir/configure.in" - test -f "$destdir"/configure.ac && configure_ac="$destdir/configure.ac" - test -f "$configure_ac" \ - || func_fatal_error "cannot find $destdir/configure.ac" - - # Get settings. - my_sed_traces='s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,; - /gl_MODULES[^_]/ { - s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_modules="\1",; p; - }; - /gl_AVOID[^_]/ { - s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",; p; - }; - /gl_SOURCE_BASE/ { - s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",; p; - }; - /gl_M4_BASE/ { - s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",; p; - }; - /gl_LIB/ { - s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",; p; - }; - /AC_CONFIG_AUX_DIR/ { - s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,ac_auxdir="\1",; p; - } - /A[CM]_PROG_LIBTOOL/ { s,^.*$,seen_libtool=:,; p; }; - /LT_INIT/ { s,^.*$,seen_libtool=:,; p; }; - /gl_LGPL/ { s,^.*$,cached_lgpl=true,; p; }; - /gl_LIBTOOL/ { s,^.*$,cached_libtool=:,; p; }; - /gl_MACRO_PREFIX/ { - s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",; p; - }; - d;' - eval `cat $configure_ac | sed "$my_sed_traces"` - - # Override libname? - if test -z "$supplied_libname" && test -n "$cached_libname"; then - libname="$cached_libname" + # Prefer configure.ac to configure.in. + if test -f "$destdir"/configure.ac; then + configure_ac="$destdir/configure.ac" + else + if test -f "$destdir"/configure.in; then + configure_ac="$destdir/configure.in" + else + func_fatal_error "cannot find $destdir/configure.ac" + fi fi - # Set up source base. - test -z "$sourcebase" && sourcebase="$cached_sourcebase" - test -z "$sourcebase" && sourcebase="lib" - test -d "$destdir/$sourcebase" \ - || { test -z "$dry_run" && mkdir "$destdir/$sourcebase"; } \ - || func_fatal_error "source base $destdir/$sourcebase doesn't exist" - - # Set up m4 base. - test -z "$m4base" && m4base="$cached_m4base" - test -z "$m4base" && m4base="m4" - test -d "$destdir/$m4base" \ - || { test -z "$dry_run" && mkdir "$destdir/$m4base"; } \ - || func_fatal_error "m4 base $destdir/$m4base doesn't exist" - - # Set up auxiliary directory. - test -z "$auxdir" && auxdir="$ac_auxdir" - test -z "$auxdir" && auxdir="build-aux" - test -d "$destdir/$auxdir" \ - || { test -z "$dry_run" && mkdir "$destdir/$auxdir"; } \ - || func_fatal_error "aux directory $destdir/$auxdir doesn't exist" - - # Require LGPL? - if test -n "$cached_lgpl"; then - lgpl=true - fi + test -f "$destdir"/Makefile.am \ + || func_fatal_error "cannot find $destdir/Makefile.am" - # Using libtool? - if test -n "$seen_libtool" || test -n "$cached_libtool"; then - libtool=true - fi + # Analyze configure.ac. + guessed_auxdir="." + guessed_libtool= + my_sed_traces=' + s,#.*$,, + s,^dnl .*$,, + s, dnl .*$,, + /AC_CONFIG_AUX_DIR/ { + s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p + } + /A[CM]_PROG_LIBTOOL/ { + s,^.*$,guessed_libtool=true,p + }' + eval `sed -n -e "$my_sed_traces" < "$configure_ac"` - # Macro prefix - test -z "$macro_prefix" && macro_prefix="$cached_macro_prefix" - test -z "$macro_prefix" && macro_prefix="gl" + if test -z "$auxdir"; then + auxdir="$guessed_auxdir" + fi - # What modules to extract. - if test $# = 0; then - modules="$cached_modules" + # Determine where to apply func_import. + if test -n "$m4base"; then + # Apply func_import to a particular gnulib directory. + # Any number of additional modules can be given. + if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then + # First use of gnulib in the given m4base. + test -n "$supplied_libname" || supplied_libname=true + test -n "$sourcebase" || sourcebase="lib" + test -n "$macro_prefix" || macro_prefix="gl" + fi + func_import "$*" else - modules="$*" + # Apply func_import to all gnulib directories. + # To get this list of directories, look at Makefile.am. (Not at + # configure, because it may be omitted from CVS. Also, don't run + # "find $destdir -name gnulib-cache.m4", as it might be too expensive.) + aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'` + m4dirs= + m4dirs_count=0 + m4dir_is_next= + for arg in $aclocal_amflags; do + if test -n "$m4dir_is_next"; then + # Ignore absolute directory pathnames, like /usr/local/share/aclocal. + case "$arg" in + /*) ;; + *) + if test -f "$destdir/$arg"/gnulib-cache.m4; then + m4dirs="$m4dirs $arg" + m4dirs_count=`expr $m4dirs_count + 1` + fi + ;; + esac + else + if test "X$arg" = "X-I"; then + m4dir_is_next=yes + else + m4dir_is_next= + fi + fi + done + if test $m4dirs_count = 0; then + # First use of gnulib in a package. + # Any number of additional modules can be given. + test -n "$supplied_libname" || supplied_libname=true + test -n "$sourcebase" || sourcebase="lib" + m4base="m4" + test -n "$macro_prefix" || macro_prefix="gl" + func_import "$*" + else + if test $m4dirs_count = 1; then + # There's only one use of gnulib here. Assume the user means it. + # Any number of additional modules can be given. + for m4base in $m4dirs; do + func_import "$*" + done + else + # Ambiguous - guess what the user meant. + if test $# = 0; then + # No further arguments. Guess the user wants to update all of them. + for m4base in $m4dirs; do + func_import + done + else + # Really ambiguous. + func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..." + fi + fi + fi fi - - # Which modules to avoid? - avoidlist=`echo $avoidlist $cached_avoidlist` - - func_import "$modules" ;; create-testdir )