* lib/inttypes_.h: Undo previous change, since it was fixed
[gnulib.git] / gnulib-tool
index 5bc39c4..c9029ca 100755 (executable)
@@ -22,7 +22,7 @@
 
 progname=$0
 package=gnulib
-cvsdatestamp='$Date: 2007-07-01 11:02:15 $'
+cvsdatestamp='$Date: 2007-07-13 01:17:00 $'
 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
 nl='
@@ -887,24 +887,57 @@ case "$0" in
   /*) self_abspathname="$0" ;;
   */*) self_abspathname=`pwd`/"$0" ;;
   *)
+    # Look in $PATH.
+    # Iterate through the elements of $PATH.
+    # We use IFS=: instead of
+    #   for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
+    # because the latter does not work when some PATH element contains spaces.
+    # We use a canonicalized $pathx instead of $PATH, because empty PATH
+    # elements are by definition equivalent to '.', however field splitting
+    # according to IFS=: loses empty fields in many shells:
+    #   - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
+    #     beginning, at the end, and in the middle),
+    #   - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
+    #     at the beginning and at the end,
+    #   - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
+    #     Solaris lose empty fields at the end.
+    # The 'case' statement is an optimization, to avoid evaluating the
+    # explicit canonicalization command when $PATH contains no empty fields.
     self_abspathname=
-    pathx=$PATH
-    case :$PATH: in
-      *::*)
-        pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
-       ;;
-    esac
-    save_IFS=$IFS
-    IFS=:
+    if test "${PATH_SEPARATOR+set}" != set; then
+      func_tmpdir
+      { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
+      chmod +x "$tmp"/conf.sh
+      if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
+        PATH_SEPARATOR=';'
+      else
+        PATH_SEPARATOR=:
+      fi
+      rm -rf "$tmp"
+    fi
+    if test "$PATH_SEPARATOR" = ";"; then
+      # On Windows, programs are searched in "." before $PATH.
+      pathx=".;$PATH"
+    else
+      # On Unix, we have to convert empty PATH elements to ".".
+      pathx="$PATH"
+      case :$PATH: in
+        *::*)
+          pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
+          ;;
+      esac
+    fi
+    save_IFS="$IFS"
+    IFS="$PATH_SEPARATOR"
     for d in $pathx; do
-      IFS=$save_IFS
+      IFS="$save_IFS"
       test -z "$d" && d=.
       if test -x "$d/$0" && test ! -d "$d/$0"; then
-       self_abspathname=$d/$0
-       break
+        self_abspathname="$d/$0"
+        break
       fi
     done
-    IFS=$save_IFS
+    IFS="$save_IFS"
     if test -z "$self_abspathname"; then
       func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
     fi
@@ -1831,8 +1864,10 @@ func_import ()
   specified_modules="$cached_specified_modules $1"
   # Append the cached and the specified avoidlist. This is probably better
   # than dropping the cached one when --avoid is specified at least once.
-  avoidlist=`echo $cached_avoidlist $avoidlist`
-  # The sourcebase defaults to the cached one.
+  avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
+  avoidlist=`echo $avoidlist`
+
+    # The sourcebase defaults to the cached one.
   if test -z "$sourcebase"; then
     sourcebase="$cached_sourcebase"
     if test -z "$sourcebase"; then
@@ -1905,7 +1940,7 @@ func_import ()
     for module in $modules; do
       license=`func_get_license $module`
       case $license in
-        LGPL | 'GPLed build tool') ;;
+        LGPL | LGPLv2+ | 'GPLed build tool') ;;
         'public domain' | 'unlimited' | 'unmodifiable license text') ;;
         *) func_fatal_error "incompatible license on module $module: $license" ;;
       esac
@@ -2357,7 +2392,7 @@ func_import ()
     # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
     # created using libtool, because libtool already handles the dependencies.
     if test "$libtool" != true; then
-      libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
+      libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
       echo "  ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
       echo "  AC_SUBST([${libname_upper}_LIBDEPS])"
       echo "  ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
@@ -2620,10 +2655,31 @@ func_create_testdir ()
       func_modules_transitive_closure
       for module in $modules; do
         license=`func_get_license "$module"`
-        case $license in
-          LGPL | 'GPLed build tool') ;;
+        case "$license" in
+          'GPLed build tool') ;;
           'public domain' | 'unlimited' | 'unmodifiable license text') ;;
-          *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
+          *)
+            case "$requested_license" in
+              GPLv2+)
+                case "$license" in
+                  GPLv2+ | LGPLv2+) ;;
+                  *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
+                esac
+                ;;
+              LGPL)
+                case "$license" in
+                  LGPL | LGPLv2+) ;;
+                  *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
+                esac
+                ;;
+              LGPLv2+)
+                case "$license" in
+                  LGPLv2+) ;;
+                  *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
+                esac
+                ;;
+            esac
+            ;;
         esac
       done
     fi
@@ -2806,7 +2862,7 @@ func_create_testdir ()
      # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
      # created using libtool, because libtool already handles the dependencies.
      if test "$libtool" != true; then
-       libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
+       libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
        echo "  ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
        echo "  AC_SUBST([${libname_upper}_LIBDEPS])"
        echo "  ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
@@ -2917,7 +2973,7 @@ func_create_testdir ()
    # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
    # created using libtool, because libtool already handles the dependencies.
    if test "$libtool" != true; then
-     libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
+     libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
      echo "  ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
      echo "  AC_SUBST([${libname_upper}_LIBDEPS])"
      echo "  ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""