Home | History | Annotate | Line # | Download | only in tools
      1 #!/bin/sh
      2 
      3 # Copyright 2008-2023 Free Software Foundation, Inc.
      4 # This script is free software; the Free Software Foundation
      5 # gives unlimited permission to copy and/or distribute it,
      6 # with or without modifications, as long as this notice is preserved.
      7 
      8 # This program is distributed in the hope that it will be useful,
      9 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
     10 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
     11 # PARTICULAR PURPOSE.
     12 
     13 # ck-copyright-notice can be run from the tools directory
     14 dir=`pwd`
     15 [ -d src ] || [ "`basename \"$dir\"`" != tools ] || cd ..
     16 
     17 err=0
     18 
     19 # Note: if paragraphs are reformatted, this may need to be updated.
     20 
     21 yrx="\([0-9][0-9][0-9][0-9]\)"
     22 
     23 lgpl=`sed -n "/version [0-9.]* or any later version/ {
     24     s/.*version //
     25     s/ or.*//
     26     p
     27     q
     28   }" doc/mpfr.texi`
     29 
     30 clyr=`sed -n "/^r/ {
     31     s/.* | $yrx-.*/\1/p
     32     q
     33   }
     34   /^$yrx-/ {
     35     s/^$yrx-.*/\1/p
     36     q
     37   }" ChangeLog`
     38 
     39 # Do not use "find ... | while read file do ... done" because the "do"
     40 # part needs to be run in the current shell, and some shells behave in
     41 # a different way.
     42 srctests=`find examples src tests -name '*.[ch]' ! -name '.#*'`
     43 
     44 # Take the copyright notice last year of NEWS file as a reference.
     45 z=`sed -n "s/^Copyright 2000-$yrx Free Software Foundation.*/\1/p" NEWS`
     46 
     47 if [ $z -ge $clyr ]; then
     48   : no errors and up-to-date NEWS file
     49 else
     50   # The condition may be false due to an error when getting years.
     51   # The following two lines avoid an incorrect message in such a case.
     52   set -e
     53   [ $z -lt $clyr ] 2> /dev/null
     54   echo "The copyright year of NEWS is out-of-date."
     55   err=1
     56 fi
     57 
     58 # Note: mpfr.pc.in is not checked as it does not have a copyright notice
     59 # (it is distributed with MPFR, but regarded as trivial).
     60 
     61 for file in $srctests BUGS INSTALL README TODO configure.ac
     62 do
     63   y=""
     64   case $file in
     65     tests/RRTest.c)
     66       # This file doesn't have a copyright notice, but isn't distributed.
     67       continue ;;
     68     src/mini-gmp.[ch])
     69       # These files may have been added by the user or 3rd party.
     70       continue ;;
     71     src/mpfr-longlong.h)
     72       # This file (which comes from GMP) has a specific copyright notice.
     73       continue ;;
     74     src/get_patches.c)
     75       file="tools/get_patches.sh" ;;
     76     src/mparam.h)
     77       file="src/mparam_h.in" ;;
     78     */mparam.h)
     79       y="2005-" ;;
     80   esac
     81   grep -q "Copyright $y.*$z Free Software Foundation" "$file" && \
     82   grep -q "GNU MPFR Library" "$file" && \
     83   grep -q "either version $lgpl of the License" "$file" && continue
     84   echo "Possibly missing or incorrect copyright notice in $file"
     85   err=1
     86 done
     87 
     88 exit $err
     89