If g_convert fails, set bytes_written to 0 and close the iconv descriptor
[platform/upstream/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 gettext_dir=@prefix@/share/glib-2.0/gettext
47
48 while test $# -gt 0; do
49   case "$1" in
50     -c | --copy | --c* )
51       shift
52       try_ln_s=false ;;
53     -f | --force | --f* )
54       shift
55       force=1 ;;
56     -r | --run | --r* )
57       shift
58       configstatus=1 ;;
59     --help | --h* )
60       $echo "$usage"; exit 0 ;;
61     --version | --v* )
62       echo "$progname (GNU $package) $version"
63       $echo "Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc.
64 This is free software; see the source for copying conditions.  There is NO
65 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
66       $echo "Written by" "Ulrich Drepper"
67       exit 0 ;;
68     -- )        # Stop option prcessing
69       shift; break ;;
70     -* )
71       $echo "glib-gettextize: unknown option $1"
72       $echo "Try \`glib-gettextize --help' for more information."; exit 1 ;;
73     * )
74       break ;;
75   esac
76 done
77
78 if test $# -gt 1; then
79   $echo "$usage"
80   exit 1
81 fi
82
83 # Fill in the command line options value.
84 if test $# -eq 1; then
85   srcdir=$1
86   if cd $srcdir; then
87     srcdir=`pwd`
88   else
89     $echo "Cannot change directory to \`$srcdir'"
90     exit 1
91   fi
92 else
93   srcdir=$origdir
94 fi
95
96 test -f configure.in || test -f configure.ac || {
97   $echo "Missing configure.in or configure.ac, please cd to your package first."
98   exit 1
99 }
100
101 if test -f po/Makefile.in.in && test $force -eq 0; then
102   $echo "\
103 po/Makefile.in.in exists: use option -f if you really want to delete it."
104   exit 1
105 fi
106
107 if test -f po/po2tbl.sed.in && test $force -eq 0; then
108   $echo "\
109 po/po2tbl.sed.in exists: use option -f if you really want to delete it."
110   exit 1
111 fi
112
113 test -d po || {
114   $echo "Creating po/ subdirectory"
115   mkdir po || {
116     $echo "failed to create po/ subdirectory"
117     exit 1
118   }
119 }
120
121 # For simplicity we changed to the gettext source directory.
122 cd $gettext_dir || {
123    $echo "gettext source directory '${gettext_dir}' doesn't exist"
124    exit 1
125 }
126
127 # Now copy all files.  Take care for the destination directories.
128 for file in *; do
129   case $file in
130     intl | po)
131       ;;
132     *)
133       rm -f $srcdir/$file
134       ($try_ln_s && ln -s $gettext_dir/$file $srcdir/$file && $echo "Symlinking file $file") 2>/dev/null ||
135       { $echo "Copying file $file"; cp $file $srcdir/$file; }
136       ;;
137   esac
138 done
139
140 # Copy files to po/ subdirectory.
141 cd po
142 for file in *; do
143   rm -f $srcdir/po/$file
144   ($try_ln_s && ln -s $gettext_dir/po/$file $srcdir/po/$file && $echo "Symlinking file po/$file") 2>/dev/null ||
145   { $echo "Copying file po/$file"; cp $file $srcdir/po/$file; }
146 done
147 if test -f $srcdir/po/cat-id-tbl.c; then
148   $echo "Removing po/cat-id-tbl.c"
149   rm -f $srcdir/po/cat-id-tbl.c
150 fi
151 if test -f $srcdir/po/stamp-cat-id; then
152   $echo "Removing po/stamp-cat-id"
153   rm -f $srcdir/po/stamp-cat-id
154 fi
155
156 echo
157 echo "Please add the files"
158 echo "  codeset.m4 gettext.m4 glibc21.m4 iconv.m4 isc-posix.m4 lcmessage.m4"
159 echo "  progtest.m4"
160 echo "from the @datadir@/aclocal directory to your autoconf macro directory"
161 echo "or directly to your aclocal.m4 file."
162 echo "You will also need config.guess and config.sub, which you can get from"
163 echo "ftp://ftp.gnu.org/pub/gnu/config/."
164 echo
165
166 exit 0