xref: /netbsd-src/external/lgpl3/mpfr/dist/tools/ck-copyright-notice (revision d536862b7d93d77932ef5de7eebdc48d76921b77)
1#!/bin/sh
2
3# Copyright 2008-2020 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
14dir=`pwd`
15[ -d src ] || [ "`basename \"$dir\"`" != tools ] || cd ..
16
17err=0
18
19# Note: if paragraphs are reformatted, this may need to be updated.
20
21yrx="\([0-9][0-9][0-9][0-9]\)"
22
23lgpl=`sed -n "/version [0-9.]* or any later version/ {
24  s/.*version //
25  s/ or.*//
26  p
27  q
28  }" doc/mpfr.texi`
29
30clyr=`sed -n "/^r/ {
31  s/.* | $yrx-.*/\1/p
32  q
33  }" ChangeLog`
34
35# Do not use "find ... | while read file do ... done" because the "do"
36# part needs to be run in the current shell, and some shells behave in
37# a different way.
38srctests=`find examples src tests -name '*.[ch]' ! -name '.#*'`
39
40# Take the copyright notice last year of NEWS file as a reference.
41z=`sed -n "s/^Copyright 2000-$yrx Free Software Foundation.*/\1/p" NEWS`
42
43if [ $z -lt $clyr ]; then
44  echo "The copyright year of NEWS is out-of-date."
45  err=1
46fi
47
48# Note: mpfr.pc.in is not checked as it does not have a copyright notice
49# (it is distributed with MPFR, but regarded as trivial).
50
51for file in $srctests BUGS INSTALL README TODO configure.ac
52do
53  y=""
54  case $file in
55    tests/RRTest.c)
56      # This file doesn't have a copyright notice, but isn't distributed.
57      continue ;;
58    src/mini-gmp.[ch])
59      # These files may have been added by the user or 3rd party.
60      continue ;;
61    src/mpfr-longlong.h)
62      # This file (which comes from GMP) has a specific copyright notice.
63      continue ;;
64    src/get_patches.c)
65      file="tools/get_patches.sh" ;;
66    src/mparam.h)
67      file="src/mparam_h.in" ;;
68    */mparam.h)
69      y="2005-" ;;
70  esac
71  grep -q "Copyright $y.*$z Free Software Foundation" "$file" && \
72  grep -q "GNU MPFR Library" "$file" && \
73  grep -q "either version $lgpl of the License" "$file" && continue
74  echo "Possibly missing or incorrect copyright notice in $file"
75  err=1
76done
77
78exit $err
79