Don't abort if the 'long double' type has excess precision.
[gnulib.git] / gnulib-tool
index ceca16a..5d3a785 100755 (executable)
@@ -2,10 +2,10 @@
 #
 # Copyright (C) 2002-2007 Free Software Foundation, Inc.
 #
-# This program is free software; you can redistribute it and/or modify
+# This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -13,8 +13,7 @@
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
 # This program is meant for authors or maintainers which want to import
@@ -170,8 +169,10 @@ Options for --import:
       --avoid=MODULE        Avoid including the given MODULE. Useful if you
                             have code that provides equivalent functionality.
                             This option can be repeated.
-      --lgpl                Abort if modules aren't available under the LGPL.
+      --lgpl[=2|=3]         Abort if modules aren't available under the LGPL.
                             Also modify license template from GPL to LGPL.
+                            The version number of the LGPL can be specified;
+                            the default is currently LGPLv3.
       --makefile-name=NAME  Name of makefile in automake syntax in the
                             source-base and tests-base directories
                             (default \"Makefile.am\").
@@ -595,7 +596,7 @@ fi
 # - auxdir          from --aux-dir
 # - inctests        true if --with-tests was given, blank otherwise
 # - avoidlist       list of modules to avoid, from --avoid
-# - lgpl            true if --lgpl was given, blank otherwise
+# - lgpl            yes or a number if --lgpl was given, blank otherwise
 # - makefile_name   from --makefile-name
 # - libtool         true if --libtool was given, false if --no-libtool was
 #                   given, blank otherwise
@@ -775,7 +776,15 @@ fi
         func_append avoidlist " $arg"
         shift ;;
       --lgpl )
-        lgpl=true
+        lgpl=yes
+        shift ;;
+      --lgpl=* )
+        arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
+        case "$arg" in
+          2 | 3) ;;
+          *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
+        esac
+        lgpl=$arg
         shift ;;
       --makefile-name )
         shift
@@ -1213,7 +1222,7 @@ func_get_filelist ()
 func_get_dependencies ()
 {
   # ${module}-tests always implicitly depends on ${module}.
-  echo "$1" | sed -n -e 's/-tests//p'
+  echo "$1" | sed -n -e 's/-tests$//p'
   # Then the explicit dependencies listed in the module description.
   func_lookup_file "modules/$1"
   sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
@@ -1991,7 +2000,8 @@ func_emit_initmacro_done ()
 # - auxdir          directory relative to destdir where to place build aux files
 # - inctests        true if --with-tests was given, blank otherwise
 # - avoidlist       list of modules to avoid, from --avoid
-# - lgpl            true if library's license shall be LGPL, blank otherwise
+# - lgpl            yes or a number if library's license shall be LGPL,
+#                   blank otherwise
 # - makefile_name   from --makefile-name
 # - libtool         true if --libtool was given, false if --no-libtool was
 #                   given, blank otherwise
@@ -2060,8 +2070,11 @@ func_import ()
       /gl_LIB(/ {
         s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
       }
+      /gl_LGPL(/ {
+        s,^.*gl_LGPL([[ ]*\([^])]*\).*$,cached_lgpl="\1",p
+      }
       /gl_LGPL/ {
-        s,^.*$,cached_lgpl=true,p
+        s,^.*$,cached_lgpl=yes,p
       }
       /gl_MAKEFILE_NAME(/ {
         s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
@@ -2212,9 +2225,25 @@ func_import ()
     for module in $modules; do
       license=`func_get_license $module`
       case $license in
-        LGPL | LGPLv2+ | 'GPLed build tool') ;;
+        'GPLed build tool') ;;
         'public domain' | 'unlimited' | 'unmodifiable license text') ;;
-        *) func_fatal_error "incompatible license on module $module: $license" ;;
+        *)
+          case "$lgpl" in
+            yes | 3)
+              case $license in
+                LGPL | LGPLv2+) ;;
+                *) func_fatal_error "incompatible license on module $module: $license" ;;
+              esac
+              ;;
+            2)
+              case $license in
+                LGPLv2+) ;;
+                *) func_fatal_error "incompatible license on module $module: $license" ;;
+              esac
+              ;;
+            *) func_fatal_error "invalid value lgpl=$lgpl" ;;
+          esac
+          ;;
       esac
     done
   fi
@@ -2236,9 +2265,26 @@ func_import ()
   if test -n "$do_copyrights"; then
     if test -n "$lgpl"; then
       # Update license.
+      case "$lgpl" in
+        yes | 3)
+          sed_transform_lib_file=$sed_transform_lib_file'
+            s/GNU General/GNU Lesser General/g
+          '
+          ;;
+        2)
+          sed_transform_lib_file=$sed_transform_lib_file'
+            s/GNU General/GNU Lesser General/g
+            s/version [23]\([ ,]\)/version 2.1\1/g
+          '
+          ;;
+        *) func_fatal_error "invalid value lgpl=$lgpl" ;;
+      esac
+    else
+      # Update license.
       sed_transform_lib_file=$sed_transform_lib_file'
-        s/GNU General/GNU Lesser General/g
-        s/version 2\([ ,]\)/version 2.1\1/g
+        s/GNU Lesser General/GNU General/g
+        s/GNU Library General/GNU General/g
+        s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
       '
     fi
   fi
@@ -2474,7 +2520,11 @@ func_import ()
     func_append actioncmd " --avoid=$module"
   done
   if test -n "$lgpl"; then
-    func_append actioncmd " --lgpl"
+    if test "$lgpl" = yes; then
+      func_append actioncmd " --lgpl"
+    else
+      func_append actioncmd " --lgpl=$lgpl"
+    fi
   fi
   if test -n "$makefile_name"; then
     func_append actioncmd " --makefile-name=$makefile_name"
@@ -2696,7 +2746,13 @@ func_import ()
     echo "gl_TESTS_BASE([$testsbase])"
     test -z "$inctests" || echo "gl_WITH_TESTS"
     echo "gl_LIB([$libname])"
-    test -z "$lgpl" || echo "gl_LGPL"
+    if test -n "$lgpl"; then
+      if test "$lgpl" = yes; then
+        echo "gl_LGPL"
+      else
+        echo "gl_LGPL([$lgpl])"
+      fi
+    fi
     echo "gl_MAKEFILE_NAME([$makefile_name])"
     if test "$libtool" = true; then
       echo "gl_LIBTOOL"
@@ -3539,7 +3595,12 @@ func_create_megatestdir ()
   func_append megasubdirs "ALL"
 
   # Create autobuild.
-  cvsdate=`sh "$gnulib_dir/build-aux/mdate-sh" "$gnulib_dir/CVS/Entries" \
+  cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
+             vc_witness="$gnulib_dir/CVS/Entries"; \
+           else \
+             vc_witness="$gnulib_dir/.git/refs/heads/master"; \
+           fi; \
+           sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
              | sed -e 's,January,01,'   -e 's,Jan,01,' \
                    -e 's,February,02,'  -e 's,Feb,02,' \
                    -e 's,March,03,'     -e 's,Mar,03,' \