fixed recent bug with CUDA texture objects
[gromacs.git] / admin / changecopyright.pl
blob6e302057741f79e289f0960735d8d338173dad9d
1 #!/usr/bin/perl -w
3 # This file is part of the GROMACS molecular simulation package.
5 # Copyright (c) 2012, by the GROMACS development team, led by
6 # David van der Spoel, Berk Hess, Erik Lindahl, and including many
7 # others, as listed in the AUTHORS file in the top-level source
8 # directory and at http://www.gromacs.org.
10 # GROMACS is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU Lesser General Public License
12 # as published by the Free Software Foundation; either version 2.1
13 # of the License, or (at your option) any later version.
15 # GROMACS is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # Lesser General Public License for more details.
20 # You should have received a copy of the GNU Lesser General Public
21 # License along with GROMACS; if not, see
22 # http://www.gnu.org/licenses, or write to the Free Software Foundation,
23 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 # If you want to redistribute modifications to GROMACS, please
26 # consider that scientific software is very special. Version
27 # control is crucial - bugs must be traceable. We will be happy to
28 # consider code for inclusion in the official distribution, but
29 # derived work must not be called official GROMACS. Details are found
30 # in the README & COPYING files - if they are missing, get the
31 # official version at http://www.gromacs.org.
33 # To help us fund GROMACS development, we humbly ask that you cite
34 # the research papers on the package. Check out http://www.gromacs.org
36 # Use with
38 # changecopyright.pl your_file_name_here
40 # Files with C-style comments and CMake files are more-or-less supported
42 use strict;
43 use Regexp::Common qw /comment RE_comment_C/;
44 use File::Slurp;
46 my $file_name = shift @ARGV;
47 my $gromacs_copyright_notice = <<END;
49 * This file is part of the GROMACS molecular simulation package.
51 * Copyright (c) 2012, by the GROMACS development team, led by
52 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
53 * others, as listed in the AUTHORS file in the top-level source
54 * directory and at http://www.gromacs.org.
56 * GROMACS is free software; you can redistribute it and/or
57 * modify it under the terms of the GNU Lesser General Public License
58 * as published by the Free Software Foundation; either version 2.1
59 * of the License, or (at your option) any later version.
61 * GROMACS is distributed in the hope that it will be useful,
62 * but WITHOUT ANY WARRANTY; without even the implied warranty of
63 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
64 * Lesser General Public License for more details.
66 * You should have received a copy of the GNU Lesser General Public
67 * License along with GROMACS; if not, see
68 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
69 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
71 * If you want to redistribute modifications to GROMACS, please
72 * consider that scientific software is very special. Version
73 * control is crucial - bugs must be traceable. We will be happy to
74 * consider code for inclusion in the official distribution, but
75 * derived work must not be called official GROMACS. Details are found
76 * in the README & COPYING files - if they are missing, get the
77 * official version at http://www.gromacs.org.
79 * To help us fund GROMACS development, we humbly ask that you cite
80 * the research papers on the package. Check out http://www.gromacs.org.
82 END
83 chop $gromacs_copyright_notice;
85 my %filetypes = (
86 [ 'extension' => qr/.*\.(?:[chyl]|[ch]pp)|cuh?$|/,
87 'commentchar' => ''
90 [ 'extension' => qr/.*\.f$/,
91 'commentchar' => 'C'
94 [ 'extension' => qr/.*\.(?:py|pl|sh|)$/,
95 'commentchar' => '#'
98 [ 'extension' => qr/CMakeLists.txt/,
99 'commentchar' => '#'
102 [ 'extension' => qr/.pre/,
103 'commentchar' => ''
106 [ 'extension' => qr//,
107 'commentchar' => ''
111 # since the new copyright notice is not included here, we magically
112 # can't duplicate the 4.6 copyright notice by re-applying the script
113 my $multi_line_authors = qr/ \* BIOSON Research Institute, Dept. of Biophysical Chemistry\n \* University of Groningen, The Netherlands\n| \* check out http:\/\/www.gromacs.org for more information.\n| \* Erik Lindahl, David van der Spoel, University of Groningen.\n| \* David van der Spoel, Erik Lindahl, University of Groningen.\n|\* David van der Spoel, Erik Lindahl, University of Groningen.\n| \* David van der Spoel, Erik Lindahl, Berk Hess, University of Groningen.\n/;
115 my $year = qr/[0-9]{4}/;
116 my $year_range = qr/$year(?:-$year)?/;
117 my $noncopyright_line = qr/ \* (?![Cc]opyright)[^\n]*\n/;
118 my $empty_line = qr/ ?\*\n/;
119 my $text = qr/[^\n]/;
120 my $comma_and_more_lines = qr/,\n${multi_line_authors}/;
121 my $nothing_and_possible_multi_line_authors = qr/ *\n${multi_line_authors}?/;
122 my $period_and_end_of_line = qr/\.\s*?\n/;
123 my $copyright_notice = qr/(?:This file is part of Gromacs |Gromacs 4.0 )?[Cc]opyright.*\s(${year_range}(?:,${year_range})*)(?:${text}+${period_and_end_of_line}|${text}+${comma_and_more_lines}|${nothing_and_possible_multi_line_authors}|${text}+\n(?=${empty_line}))/;
125 my $slurped_text = read_file($file_name);
126 my $result = "";
127 my $remaining = $slurped_text;
128 my $found_copyright_notice = 0;
130 while ($remaining =~ /$RE{comment}{C}/) {
131 # These variables are ugly, but so is the purpose of this script
132 $result .= ${^PREMATCH};
133 my $comment = ${^MATCH};
134 $remaining = ${^POSTMATCH};
136 # Accept this comment unmodified, and later prepend the GROMACS
137 # one because found_copyright_notice is still 0
138 if ($comment =~ /This source code file is part of thread_mpi|Aladdin Enterprises/) {
139 $result .= $comment;
140 next;
142 if ($comment =~ $copyright_notice && 0 == $found_copyright_notice) {
143 my $this_copyright_notice = $gromacs_copyright_notice;
144 my @old_copyrights = ();
145 my $remaining_comment;
146 do {
147 push @old_copyrights, ${^MATCH};
148 $remaining_comment = ${^POSTMATCH};
149 } while ($remaining_comment =~ /${copyright_notice}/m);
151 # Prepend old copyrights to the new GROMACS copyright notice
152 map {
153 (my $old_copyright = $_) =~ s/,$/./;
154 # Remove temporary open-ended copyright assertions
155 unless ($old_copyright =~ /Copyright \(c\) 2012- */) {
156 $this_copyright_notice =~ s/^( \* Copyright)/ * ${old_copyright}$1/m;
158 } reverse(@old_copyrights);
160 $result .= $this_copyright_notice;
161 } else {
162 $result .= $comment;
164 if ($comment =~ /[Cc]opyright/) {
165 # Make sure we don't duplicate copyright statements when the first
166 # one was made in 2012, but can still insert that statement when
167 # there has never been one before.
168 $found_copyright_notice = 1;
171 $result .= $remaining;
173 # Deal with CMake files first
174 if ($file_name =~ /CMakeLists.txt$|.cmake$/) {
175 if ( $result !~ /[Cc]opyright.*by the GROMACS development team/) {
176 (my $this_copyright_notice = $gromacs_copyright_notice) =~ s/^[\/ ]\*\/?/#/gm;
177 $result = "${this_copyright_notice}\n$result";
179 } elsif (0 == $found_copyright_notice) {
180 # Prepare output for files with C-style comments
181 $result = "${gromacs_copyright_notice}\n$result";
184 # Write output
185 open FILE, ">$file_name" or die "Couldn't open file $file_name for writing";
186 print FILE $result;
187 close FILE;
189 # Review the changes before they get added! Some files need manual tweaking
190 # because they have licensing external to GROMACS.
191 system("git add --interactive --patch $file_name");