-
Notifications
You must be signed in to change notification settings - Fork 11
/
make-copyright.sh
executable file
·130 lines (106 loc) · 3.4 KB
/
make-copyright.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/sh
#
# Basic idea is shamelessly ripped from gtk+/makecopyright.
#
# Naofumi Yasufuku <[email protected]>
#
exclude_files="config.h glext.h glxext.h wglext.h docs examples"
header_files=`find . -name '*.h' -print`
source_files=`find . -name '*.c' -print`
target_files="$header_files $source_files"
copyright_gdk ()
{
cat << EOF
/* GdkGLExt - OpenGL Extension to GDK
* Copyright (C) 2002-2004 Naofumi Yasufuku
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
EOF
}
copyright_gdk_glext ()
{
copyright_gdk
}
copyright_gdk_x11 ()
{
copyright_gdk
}
copyright_gdk_win32 ()
{
copyright_gdk
}
copyright_gtk ()
{
cat << EOF
/* GtkGLExt - OpenGL Extension to GTK+
* Copyright (C) 2002-2004 Naofumi Yasufuku
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
EOF
}
for file in $target_files; do
exclude=""
for file_exclude in bak $exclude_files; do
exclude=`echo $file | grep $file_exclude`
if test -n "$exclude"; then
continue 2
fi
done
dir=`dirname $file`
subdir=`echo ${dir#*/} | sed -e 's/\//_/g'`
if test -z "$subdir"; then
continue
fi
src_header=`copyright_$subdir | head -1`
dst_header=`cat $file | grep "$src_header" | head -1`
src_copyright=`copyright_$subdir | grep Copyright | head -1 | \
sed -e 's/^.*Copyright/Copyright/'`
dst_copyright=`cat $file | grep Copyright | head -1 | \
sed -e 's/^.*Copyright/Copyright/'`
if test "x$dst_header" != "x$src_header" -o \
"x$dst_copyright" != "x$src_copyright"; then
backup_dir="$dir/bak"
if test ! -d $backup_dir; then
echo -n "Making directory ... "
mkdir $backup_dir
echo "$backup_dir"
fi
filename=`basename $file`
echo "Copying $file to $backup_dir/$filename ..."
cp $file $backup_dir/$filename
if test "x$dst_header" != "x$src_header"; then
copyright_$subdir > $file
cat $backup_dir/$filename >> $file
else
cat $backup_dir/$filename | \
sed -e "s/$dst_copyright/$src_copyright/" > $file
fi
echo "$file is updated"
fi
done