xref: /netbsd-src/external/lgpl3/mpfr/dist/tools/ck-copyright-notice (revision d90047b5d07facf36e6c01dcc0bded8997ce9cc2)
1#!/bin/sh
2
3# Copyright 2008-2018 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
48for file in $srctests BUGS INSTALL README TODO configure.ac
49do
50  y=""
51  case $file in
52    tests/RRTest.c)
53      # This file doesn't have a copyright notice, but isn't distributed.
54      continue ;;
55    src/mini-gmp.[ch])
56      # These files may have been added by the user or 3rd party.
57      continue ;;
58    src/mpfr-longlong.h)
59      # This file (which comes from GMP) has a specific copyright notice.
60      continue ;;
61    src/get_patches.c)
62      file="tools/get_patches.sh" ;;
63    src/mparam.h)
64      file="src/mparam_h.in" ;;
65    */mparam.h)
66      y="2005-" ;;
67  esac
68  grep -q "Copyright $y.*$z Free Software Foundation" "$file" && \
69  grep -q "GNU MPFR Library" "$file" && \
70  grep -q "either version $lgpl of the License" "$file" && continue
71  echo "Possibly missing or incorrect copyright notice in $file"
72  err=1
73done
74
75exit $err
76