Free with free() and not g_free() what has been allocated with calloc().
[glib.git] / glib-gettextize.in
blob05642d7c24512695785a17f3948e714a4bf71959
1 #! /bin/sh
3 # Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc.
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.
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.
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.
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
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.
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=:
44 # Directory where the sources are stored.
45 prefix=@prefix@
46 case `uname` in
47 MINGW32*)
48 prefix="`dirname $0`/.."
50 esac
52 gettext_dir=$prefix/share/glib-2.0/gettext
54 while test $# -gt 0; do
55 case "$1" in
56 -c | --copy | --c* )
57 shift
58 try_ln_s=false ;;
59 -f | --force | --f* )
60 shift
61 force=1 ;;
62 -r | --run | --r* )
63 shift
64 configstatus=1 ;;
65 --help | --h* )
66 $echo "$usage"; exit 0 ;;
67 --version | --v* )
68 echo "$progname (GNU $package) $version"
69 $echo "Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc.
70 This is free software; see the source for copying conditions. There is NO
71 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
72 $echo "Written by" "Ulrich Drepper"
73 exit 0 ;;
74 -- ) # Stop option prcessing
75 shift; break ;;
76 -* )
77 $echo "glib-gettextize: unknown option $1"
78 $echo "Try \`glib-gettextize --help' for more information."; exit 1 ;;
79 * )
80 break ;;
81 esac
82 done
84 if test $# -gt 1; then
85 $echo "$usage"
86 exit 1
89 # Fill in the command line options value.
90 if test $# -eq 1; then
91 srcdir=$1
92 if cd "$srcdir"; then
93 srcdir=`pwd`
94 else
95 $echo "Cannot change directory to \`$srcdir'"
96 exit 1
98 else
99 srcdir=$origdir
102 test -f configure.in || test -f configure.ac || {
103 $echo "Missing configure.in or configure.ac, please cd to your package first."
104 exit 1
107 configure_in=NONE
108 if test -f configure.in; then
109 configure_in=configure.in
110 else
111 if test -f configure.ac; then
112 configure_in=configure.ac
115 # Check in which directory config.rpath, mkinstalldirs etc. belong.
116 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`
117 if test -n "$auxdir"; then
118 auxdir="$auxdir/"
121 if test -f po/Makefile.in.in && test $force -eq 0; then
122 $echo "\
123 po/Makefile.in.in exists: use option -f if you really want to delete it."
124 exit 1
127 test -d po || {
128 $echo "Creating po/ subdirectory"
129 mkdir po || {
130 $echo "failed to create po/ subdirectory"
131 exit 1
135 # For simplicity we changed to the gettext source directory.
136 cd $gettext_dir || {
137 $echo "gettext source directory '${gettext_dir}' doesn't exist"
138 exit 1
141 # Now copy all files. Take care for the destination directories.
142 for file in *; do
143 case $file in
144 intl | po)
146 mkinstalldirs)
147 rm -f "$srcdir/$auxdir$file"
148 ($try_ln_s && ln -s $gettext_dir/$file "$srcdir/$auxdir$file" && $echo "Symlinking file $file") 2>/dev/null ||
149 { $echo "Copying file $file"; cp $file "$srcdir/$auxdir$file"; }
152 rm -f "$srcdir/$file"
153 ($try_ln_s && ln -s $gettext_dir/$file "$srcdir/$file" && $echo "Symlinking file $file") 2>/dev/null ||
154 { $echo "Copying file $file"; cp $file "$srcdir/$file"; }
156 esac
157 done
159 # Copy files to po/ subdirectory.
160 cd po
161 for file in *; do
162 rm -f "$srcdir/po/$file"
163 ($try_ln_s && ln -s $gettext_dir/po/$file "$srcdir/po/$file" && $echo "Symlinking file po/$file") 2>/dev/null ||
164 { $echo "Copying file po/$file"; cp $file "$srcdir/po/$file"; }
165 done
166 if test -f "$srcdir/po/cat-id-tbl.c"; then
167 $echo "Removing po/cat-id-tbl.c"
168 rm -f "$srcdir/po/cat-id-tbl.c"
170 if test -f "$srcdir/po/stamp-cat-id"; then
171 $echo "Removing po/stamp-cat-id"
172 rm -f "$srcdir/po/stamp-cat-id"
175 echo
176 echo "Please add the files"
177 echo " codeset.m4 gettext.m4 glibc21.m4 iconv.m4 isc-posix.m4 lcmessage.m4"
178 echo " progtest.m4"
179 echo "from the @datadir@/aclocal directory to your autoconf macro directory"
180 echo "or directly to your aclocal.m4 file."
181 echo "You will also need config.guess and config.sub, which you can get from"
182 echo "ftp://ftp.gnu.org/pub/gnu/config/."
183 echo
185 exit 0