]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - locale/update-makefile.sh
Don't use 'find ... -printf ...'. MacOSX doesn't like it.
[SourceForge/phpwiki.git] / locale / update-makefile.sh
1 #!/bin/sh
2 #
3 # $Id: update-makefile.sh,v 1.2 2002-01-14 00:05:41 dairiki Exp $
4 #
5 # This shell script is used to update the list of .po files and the
6 # dependencies for phpwiki.pot in the Makefile.
7 #
8 # Do not invoke this script directly, rather run:
9 #
10 #    make dep
11 #
12 # to update the Makefile.
13 #
14
15 # Generate the head (manually-edited part) of the new Makefile
16 #
17 makefile_head () {
18     sed '/^# DO NOT DELETE THIS LINE$/,$ d' Makefile && cat <<'EOF'
19 # DO NOT DELETE THIS LINE
20 #
21 # The remainder of this file is auto-generated
22 #
23 # (Run 'make dep' to regenerate this section.)
24 #
25 EOF
26 }
27
28 # Find all .po files in po/.
29 #
30 po_files () {
31     find po -name "*.po" |
32         sed 's/^/PO_FILES += /;' |
33         sort
34 }
35
36 # Find all .php and .html source code which should be scanned
37 # by xgettext() for localizeable strings.
38 #
39 pot_file_deps () {
40     find ../lib ../templates ../themes                                  \
41             \( -name "*.php" -o -name "*.html" \) |
42         sed 's/^/${POT_FILE}: /;' |
43         sort
44 }
45
46 # Generate the new Makefile
47 { makefile_head &&
48     po_files &&
49     echo "#" &&
50     pot_file_deps; } > Makefile.new || exit 1
51
52 if diff -q Makefile Makefile.new > /dev/null
53 then
54     # Don't touch the Makefile if unchanged.
55     # (This avoids updating the timestamp)
56     rm Makefile.new
57     echo "Makefile unchanged" 1>&2
58     exit 0
59 fi
60
61 mv Makefile.new Makefile && echo "Makefile updated" 1>&2