BugĀ 598712 - can't detect text file with backspace
[dana/cg-glib.git] / glib-gettextize.in
1 #! /bin/sh
2 #
3 # Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 #
19
20 # - Modified in October 2001 by jacob berkman <jacob@ximian.com> to
21 # work with glib's Makefile.in.in and po2tbl.sed.in, to not copy in
22 # intl/, and to not add ChangeLog entries to po/ChangeLog
23
24 # This file is meant for authors or maintainers which want to
25 # internationalize their package with the help of GNU gettext.  For
26 # further information how to use it consult the GNU gettext manual.
27
28 echo=echo
29 progname=$0
30 force=0
31 configstatus=0
32 origdir=`pwd`
33 usage="\
34 Usage: glib-gettextize [OPTION]... [package-dir]
35       --help           print this help and exit
36       --version        print version information and exit
37   -c, --copy           copy files instead of making symlinks
38   -f, --force          force writing of new files even if old exist
39 Report bugs to http://bugzilla.gnome.org/."
40 package=@PACKAGE@
41 version=@VERSION@
42 try_ln_s=:
43
44 # Directory where the sources are stored.
45 prefix=@prefix@
46 case `uname` in
47 MINGW32*)
48     prefix="`dirname $0`/.."
49     ;;
50 esac
51
52 datadir=@datadir@
53 datarootdir=@datarootdir@
54
55 gettext_dir=$prefix/share/glib-2.0/gettext
56
57 while test $# -gt 0; do
58   case "$1" in
59     -c | --copy | --c* )
60       shift
61       try_ln_s=false ;;
62     -f | --force | --f* )
63       shift
64       force=1 ;;
65     -r | --run | --r* )
66       shift
67       configstatus=1 ;;
68     --help | --h* )
69       $echo "$usage"; exit 0 ;;
70     --version | --v* )
71       echo "$progname (GNU $package) $version"
72       $echo "Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc.
73 This is free software; see the source for copying conditions.  There is NO
74 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
75       $echo "Written by" "Ulrich Drepper"
76       exit 0 ;;
77     -- )        # Stop option prcessing
78       shift; break ;;
79     -* )
80       $echo "glib-gettextize: unknown option $1"
81       $echo "Try \`glib-gettextize --help' for more information."; exit 1 ;;
82     * )
83       break ;;
84   esac
85 done
86
87 if test $# -gt 1; then
88   $echo "$usage"
89   exit 1
90 fi
91
92 # Fill in the command line options value.
93 if test $# -eq 1; then
94   srcdir=$1
95   if cd "$srcdir"; then
96     srcdir=`pwd`
97   else
98     $echo "Cannot change directory to \`$srcdir'"
99     exit 1
100   fi
101 else
102   srcdir=$origdir
103 fi
104
105 test -f configure.in || test -f configure.ac || {
106   $echo "Missing configure.in or configure.ac, please cd to your package first."
107   exit 1
108 }
109
110 configure_in=NONE
111 if test -f configure.in; then
112   configure_in=configure.in
113 else
114   if test -f configure.ac; then
115     configure_in=configure.ac
116   fi
117 fi
118 # Check in which directory config.rpath, mkinstalldirs etc. belong.
119 auxdir=`cat "$configure_in" | grep '^AC_CONFIG_AUX_DIR' | sed -n -e 's/AC_CONFIG_AUX_DIR(\([^()]*\))/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q`
120 if test -n "$auxdir"; then
121   auxdir="$auxdir/"
122 fi
123
124 if test -f po/Makefile.in.in && test $force -eq 0; then
125   $echo "\
126 po/Makefile.in.in exists: use option -f if you really want to delete it."
127   exit 1
128 fi
129
130 test -d po || {
131   $echo "Creating po/ subdirectory"
132   mkdir po || {
133     $echo "failed to create po/ subdirectory"
134     exit 1
135   }
136 }
137
138 # For simplicity we changed to the gettext source directory.
139 cd $gettext_dir || {
140    $echo "gettext source directory '${gettext_dir}' doesn't exist"
141    exit 1
142 }
143
144 # Now copy all files.  Take care for the destination directories.
145 for file in *; do
146   case $file in
147     intl | po)
148       ;;
149     mkinstalldirs)
150       rm -f "$srcdir/$auxdir$file"
151       ($try_ln_s && ln -s $gettext_dir/$file "$srcdir/$auxdir$file" && $echo "Symlinking file $file") 2>/dev/null ||
152       { $echo "Copying file $file"; cp $file "$srcdir/$auxdir$file"; }
153       ;;
154     *)
155       rm -f "$srcdir/$file"
156       ($try_ln_s && ln -s $gettext_dir/$file "$srcdir/$file" && $echo "Symlinking file $file") 2>/dev/null ||
157       { $echo "Copying file $file"; cp $file "$srcdir/$file"; }
158       ;;
159   esac
160 done
161
162 # Copy files to po/ subdirectory.
163 cd po
164 for file in *; do
165   rm -f "$srcdir/po/$file"
166   ($try_ln_s && ln -s $gettext_dir/po/$file "$srcdir/po/$file" && $echo "Symlinking file po/$file") 2>/dev/null ||
167   { $echo "Copying file po/$file"; cp $file "$srcdir/po/$file"; }
168 done
169 if test -f "$srcdir/po/cat-id-tbl.c"; then
170   $echo "Removing po/cat-id-tbl.c"
171   rm -f "$srcdir/po/cat-id-tbl.c"
172 fi
173 if test -f "$srcdir/po/stamp-cat-id"; then
174   $echo "Removing po/stamp-cat-id"
175   rm -f "$srcdir/po/stamp-cat-id"
176 fi
177
178 echo
179 echo "Please add the files"
180 echo "  codeset.m4 gettext.m4 glibc21.m4 iconv.m4 isc-posix.m4 lcmessage.m4"
181 echo "  progtest.m4"
182 echo "from the $datadir/aclocal directory to your autoconf macro directory"
183 echo "or directly to your aclocal.m4 file."
184 echo "You will also need config.guess and config.sub, which you can get from"
185 echo "ftp://ftp.gnu.org/pub/gnu/config/."
186 echo
187
188 exit 0