Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / misc / gettextize.in
blob0bd377d841dc159b35278d73b94f337d521e49c0
1 #! /bin/sh
3 # Copyright (C) 1995-1998, 2000-2005 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 # This file is meant for authors or maintainers which want to
21 # internationalize their package with the help of GNU gettext. For
22 # further information how to use it consult the GNU gettext manual.
24 progname=$0
25 package=@PACKAGE@
26 version=@VERSION@
28 # Set variables
29 # - gettext_dir directory where the sources are stored.
30 prefix="@prefix@"
31 gettext_dir="@datadir@/gettext"
33 # func_tmpdir
34 # creates a temporary directory.
35 # Sets variable
36 # - tmp pathname of freshly created temporary directory
37 func_tmpdir ()
39 # Use the environment variable TMPDIR, falling back to /tmp. This allows
40 # users to specify a different temporary directory, for example, if their
41 # /tmp is filled up or too small.
42 : ${TMPDIR=/tmp}
44 # Use the mktemp program if available. If not available, hide the error
45 # message.
46 tmp=`(umask 077 && mktemp -d -q "$TMPDIR/gtXXXXXX") 2>/dev/null` &&
47 test -n "$tmp" && test -d "$tmp"
48 } ||
50 # Use a simple mkdir command. It is guaranteed to fail if the directory
51 # already exists. $RANDOM is bash specific and expands to empty in shells
52 # other than bash, ksh and zsh. Its use does not increase security;
53 # rather, it minimizes the probability of failure in a very cluttered /tmp
54 # directory.
55 tmp=$TMPDIR/gt$$-$RANDOM
56 (umask 077 && mkdir "$tmp")
57 } ||
59 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
60 { (exit 1); exit 1; }
64 # Support for relocatability.
65 func_find_curr_installdir ()
67 # Determine curr_installdir, even taking into account symlinks.
68 curr_executable="$0"
69 case "$curr_executable" in
70 */* | *\\*) ;;
71 *) # Need to look in the PATH.
72 if test "${PATH_SEPARATOR+set}" != set; then
73 func_tmpdir
74 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
75 chmod +x "$tmp"/conf.sh
76 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
77 PATH_SEPARATOR=';'
78 else
79 PATH_SEPARATOR=:
81 rm -f "$tmp"
83 save_IFS="$IFS"; IFS="$PATH_SEPARATOR"
84 for dir in $PATH; do
85 IFS="$save_IFS"
86 test -z "$dir" && dir=.
87 for exec_ext in ''; do
88 if test -f "$dir/$curr_executable$exec_ext"; then
89 curr_executable="$dir/$curr_executable$exec_ext"
90 break 2
92 done
93 done
94 IFS="$save_IFS"
96 esac
97 # Make absolute.
98 case "$curr_executable" in
99 /* | ?:/* | ?:\\*) ;;
100 *) curr_executable=`pwd`/"$curr_executable" ;;
101 esac
102 # Resolve symlinks.
103 while : ; do
104 lsline=`LC_ALL=C ls -l "$curr_executable"`
105 case "$lsline" in
106 *" -> "*)
107 curr_executable=`echo "$curr_executable" | sed -e 's,/[^/]*$,,'`/`echo "$lsline" | sed -n -e 's,^.* -> \(.*\),\1,p'` ;;
108 *) break ;;
109 esac
110 done
111 curr_installdir=`echo "$curr_executable" | sed -e 's,/[^/]*$,,'`
112 # Canonicalize.
113 curr_installdir=`cd "$curr_installdir" && pwd`
115 func_find_prefixes ()
117 # Compute the original/current installation prefixes by stripping the
118 # trailing directories off the original/current installation directories.
119 orig_installprefix="$orig_installdir"
120 curr_installprefix="$curr_installdir"
121 while true; do
122 orig_last=`echo "$orig_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'`
123 curr_last=`echo "$curr_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'`
124 if test -z "$orig_last" || test -z "$curr_last"; then
125 break
127 if test "$orig_last" != "$curr_last"; then
128 break
130 orig_installprefix=`echo "$orig_installprefix" | sed -e 's,/[^/]*$,,'`
131 curr_installprefix=`echo "$curr_installprefix" | sed -e 's,/[^/]*$,,'`
132 done
134 if test "@RELOCATABLE@" = yes; then
135 exec_prefix="@exec_prefix@"
136 bindir="@bindir@"
137 orig_installdir="$bindir" # see Makefile.am's *_SCRIPTS variables
138 func_find_curr_installdir # determine curr_installdir
139 func_find_prefixes
140 # Relocate the directory variables that we use.
141 gettext_dir=`echo "$gettext_dir/" | sed -e "s%^${orig_installprefix}/%${curr_installprefix}/%" | sed -e 's,/$,,'`
144 # func_usage
145 # outputs to stdout the --help usage message.
146 func_usage ()
148 echo "\
149 Usage: gettextize [OPTION]... [package-dir]
151 Prepares a source package to use gettext.
153 Options:
154 --help print this help and exit
155 --version print version information and exit
156 -c, --copy copy files instead of making symlinks
157 -f, --force force writing of new files even if old exist
158 --intl install libintl in a subdirectory
159 --no-changelog don't update or create ChangeLog files
160 -n, --dry-run print modifications but don't perform them
162 Report bugs to <bug-gnu-gettext@gnu.org>."
165 # func_version
166 # outputs to stdout the --version message.
167 func_version ()
169 echo "$progname (GNU $package) $version"
170 echo "Copyright (C) 1995-1998, 2000-2005 Free Software Foundation, Inc.
171 This is free software; see the source for copying conditions. There is NO
172 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
173 echo "Written by" "Ulrich Drepper"
176 # func_fatal_error message
177 # outputs to stderr a fatal error message, and terminates the program.
178 func_fatal_error ()
180 echo "gettextize: *** $1" 1>&2
181 echo "gettextize: *** Stop." 1>&2
182 exit 1
185 # Nuisances.
186 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
188 # Command-line option processing.
189 # Removes the OPTIONS from the arguments. Sets the variables:
190 # - force 1 if --force was given, 0 otherwise
191 # - intldir yes if --intl was given, empty otherwise
192 # - try_ln_s false if --copy was given, : otherwise
193 # - do_changelog false if --no-changelog was given, : otherwise
194 # - doit false if --dry-run was given, : otherwise
196 force=0
197 intldir=
198 try_ln_s=:
199 do_changelog=:
200 doit=:
202 while test $# -gt 0; do
203 case "$1" in
204 -c | --copy | --cop | --co | --c )
205 shift
206 try_ln_s=false ;;
207 -n | --dry-run | --dry-ru | --dry-r | --dry- | --dry | --dr | --d )
208 shift
209 doit=false ;;
210 -f | --force | --forc | --for | --fo | --f )
211 shift
212 force=1 ;;
213 --help | --hel | --he | --h )
214 func_usage; exit 0 ;;
215 --intl | --int | --in | --i )
216 shift
217 intldir=yes ;;
218 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
219 shift
220 do_changelog=false ;;
221 --version | --versio | --versi | --vers | --ver | --ve | --v )
222 func_version
223 exit 0 ;;
224 -- ) # Stop option prcessing
225 shift; break ;;
226 -* )
227 echo "gettextize: unknown option $1" 1>&2
228 echo "Try 'gettextize --help' for more information." 1>&2
229 exit 1 ;;
231 break ;;
232 esac
233 done
236 # Command-line argument processing.
237 # Analyzes the remaining arguments.
238 # Sets the variables
239 # - origdir to the original directory,
240 # - srcdir to the package directory, and cd-s into it.
242 if test $# -gt 1; then
243 func_usage 1>&2
244 exit 1
246 origdir=`pwd`
247 if test $# -eq 1; then
248 srcdir=$1
249 if cd "$srcdir"; then
250 srcdir=`pwd`
251 else
252 func_fatal_error "Cannot change directory to '$srcdir'."
254 else
255 srcdir=$origdir
259 # The current directory is now $srcdir.
261 # Check integrity of package: A configure.in/ac must be present. Sets variable
262 # - configure_in name of configure.in/ac file.
263 test -f configure.in || test -f configure.ac ||
264 func_fatal_error "Missing configure.in or configure.ac, please cd to your package first."
265 configure_in=NONE
266 if test -f configure.in; then
267 configure_in=configure.in
268 else
269 if test -f configure.ac; then
270 configure_in=configure.ac
274 # Check whether the --force option is needed but has not been specified.
275 if test $force -eq 0; then
276 if test -d intl; then
277 func_fatal_error "intl/ subdirectory exists: use option -f if you really want to delete it."
279 if test -f po/Makefile.in.in; then
280 func_fatal_error "po/Makefile.in.in exists: use option -f if you really want to delete it."
282 if test -f ABOUT-NLS; then
283 func_fatal_error "ABOUT-NLS exists: use option -f if you really want to delete it."
287 # Check in which directory config.rpath, mkinstalldirs etc. belong.
288 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`
289 if test -n "$auxdir"; then
290 auxdir="$auxdir/"
293 # For simplicity we change to the gettext source directory.
294 cd $gettext_dir ||
295 func_fatal_error "gettext source directory '${gettext_dir}' doesn't exist"
297 # Variables which keep track what has been modified.
298 added_directories=
299 removed_directory=
300 added_extradist=
301 added_acoutput=
302 removed_acoutput=" intl/intlh.inst"
304 # Variable:
305 # - please accumulates instructions for the user.
306 please=
308 # Variable:
309 # - date current date, for use in ChangeLog entries.
310 date=`date +%Y-%m-%d`
312 # func_copy from to
313 # copies a file.
314 # 'from' is a relative pathname, relative to the current directory.
315 # 'to' is a relative pathname, relative to $srcdir.
316 func_copy ()
318 if $doit; then
319 rm -f "$srcdir/$2"
320 echo "Copying file $2"
321 cp "$1" "$srcdir/$2"
322 else
323 echo "Copy file $2"
327 # func_linkorcopy from absfrom to
328 # links or copies a file.
329 # 'from' is a relative pathname, relative to the current directory.
330 # 'absfrom' is the corresponding absolute pathname.
331 # 'to' is a relative pathname, relative to $srcdir.
332 func_linkorcopy ()
334 if $doit; then
335 rm -f "$srcdir/$3"
336 ($try_ln_s && ln -s "$2" "$srcdir/$3" && echo "Symlinking file $3") 2>/dev/null ||
337 { echo "Copying file $3"; cp "$1" "$srcdir/$3"; }
338 else
339 if $try_ln_s; then
340 echo "Symlink file $3"
341 else
342 echo "Copy file $3"
347 # func_backup to
348 # makes a backup of a file that is about to be overwritten or replaced.
349 # 'to' is a relative pathname, relative to $srcdir.
350 func_backup ()
352 if $doit; then
353 if test -f "$srcdir/$1"; then
354 rm -f "$srcdir/$1~"
355 cp -p "$srcdir/$1" "$srcdir/$1~"
360 # func_remove to
361 # removes a file.
362 # 'to' is a relative pathname, relative to $srcdir.
363 func_remove ()
365 if $doit; then
366 echo "Removing $1"
367 rm -f "$srcdir/$1"
368 else
369 echo "Remove $1"
373 # func_ChangeLog_init
374 # func_ChangeLog_add_entry line
375 # func_ChangeLog_finish
376 # manage the ChangeLog file, relative to $srcdir.
377 func_ChangeLog_init ()
379 modified_ChangeLog=
381 func_ChangeLog_add_entry ()
383 if $doit; then
384 if test -z "$modified_ChangeLog"; then
385 echo "$date gettextize <bug-gnu-gettext@gnu.org>" > "$srcdir/ChangeLog.tmp"
386 echo >> "$srcdir/ChangeLog.tmp"
387 modified_ChangeLog=yes
389 echo "$1" >> "$srcdir/ChangeLog.tmp"
390 else
391 modified_ChangeLog=yes
394 func_ChangeLog_finish ()
396 if test -n "$modified_ChangeLog"; then
397 if $doit; then
398 echo >> "$srcdir/ChangeLog.tmp"
399 if test -f "$srcdir/ChangeLog"; then
400 echo "Adding an entry to ChangeLog (backup is in ChangeLog~)"
401 cat "$srcdir/ChangeLog" >> "$srcdir/ChangeLog.tmp"
402 rm -f "$srcdir/ChangeLog~"
403 cp -p "$srcdir/ChangeLog" "$srcdir/ChangeLog~"
404 else
405 echo "Creating ChangeLog"
407 cp "$srcdir/ChangeLog.tmp" "$srcdir/ChangeLog"
408 rm -f "$srcdir/ChangeLog.tmp"
409 else
410 if test -f "$srcdir/ChangeLog"; then
411 echo "Add an entry to ChangeLog"
412 else
413 echo "Create ChangeLog"
419 # func_poChangeLog_init
420 # func_poChangeLog_add_entry line
421 # func_poChangeLog_finish
422 # manage the po/ChangeLog file, relative to $srcdir.
423 func_poChangeLog_init ()
425 modified_poChangeLog=
427 func_poChangeLog_add_entry ()
429 if $doit; then
430 if test -z "$modified_poChangeLog"; then
431 echo "$date gettextize <bug-gnu-gettext@gnu.org>" > "$srcdir/po/ChangeLog.tmp"
432 echo >> "$srcdir/po/ChangeLog.tmp"
433 modified_poChangeLog=yes
435 echo "$1" >> "$srcdir/po/ChangeLog.tmp"
436 else
437 modified_poChangeLog=yes
440 func_poChangeLog_finish ()
442 if test -n "$modified_poChangeLog"; then
443 if $doit; then
444 echo >> "$srcdir/po/ChangeLog.tmp"
445 if test -f "$srcdir/po/ChangeLog"; then
446 echo "Adding an entry to po/ChangeLog (backup is in po/ChangeLog~)"
447 cat "$srcdir/po/ChangeLog" >> "$srcdir/po/ChangeLog.tmp"
448 rm -f "$srcdir/po/ChangeLog~"
449 cp -p "$srcdir/po/ChangeLog" "$srcdir/po/ChangeLog~"
450 else
451 echo "Creating po/ChangeLog"
453 cp "$srcdir/po/ChangeLog.tmp" "$srcdir/po/ChangeLog"
454 rm -f "$srcdir/po/ChangeLog.tmp"
455 else
456 if test -f "$srcdir/po/ChangeLog"; then
457 echo "Add an entry to po/ChangeLog"
458 else
459 echo "Create po/ChangeLog"
465 # func_m4ChangeLog_init
466 # func_m4ChangeLog_add_entry line
467 # func_m4ChangeLog_finish
468 # manage the $m4dir/ChangeLog file, relative to $srcdir.
469 func_m4ChangeLog_init ()
471 if test -n "$using_m4ChangeLog"; then
472 modified_m4ChangeLog=
473 created_m4ChangeLog=
476 func_m4ChangeLog_add_entry ()
478 if test -n "$using_m4ChangeLog"; then
479 if $doit; then
480 if test -z "$modified_m4ChangeLog"; then
481 echo "$date gettextize <bug-gnu-gettext@gnu.org>" > "$srcdir/$m4dir/ChangeLog.tmp"
482 echo >> "$srcdir/$m4dir/ChangeLog.tmp"
483 modified_m4ChangeLog=yes
485 echo "$1" >> "$srcdir/$m4dir/ChangeLog.tmp"
486 else
487 modified_m4ChangeLog=yes
489 else
490 line="$1"
491 line=`echo "$line" | sed -e "s%^ \\* % * $m4dir/%"`
492 func_ChangeLog_add_entry "$line"
495 func_m4ChangeLog_finish ()
497 if test -n "$using_m4ChangeLog"; then
498 if test -n "$modified_m4ChangeLog"; then
499 if $doit; then
500 echo >> "$srcdir/$m4dir/ChangeLog.tmp"
501 if test -f "$srcdir/$m4dir/ChangeLog"; then
502 echo "Adding an entry to $m4dir/ChangeLog (backup is in $m4dir/ChangeLog~)"
503 cat "$srcdir/$m4dir/ChangeLog" >> "$srcdir/$m4dir/ChangeLog.tmp"
504 rm -f "$srcdir/$m4dir/ChangeLog~"
505 cp -p "$srcdir/$m4dir/ChangeLog" "$srcdir/$m4dir/ChangeLog~"
506 else
507 echo "Creating $m4dir/ChangeLog"
508 created_m4ChangeLog=yes
510 cp "$srcdir/$m4dir/ChangeLog.tmp" "$srcdir/$m4dir/ChangeLog"
511 rm -f "$srcdir/$m4dir/ChangeLog.tmp"
512 else
513 if test -f "$srcdir/$m4dir/ChangeLog"; then
514 echo "Add an entry to $m4dir/ChangeLog"
515 else
516 echo "Create $m4dir/ChangeLog"
517 created_m4ChangeLog=yes
523 using_m4ChangeLog=yes
525 if test ! -f "$srcdir/intl/Makefile.in" && test -n "$intldir"; then
526 added_acoutput="$added_acoutput intl/Makefile"
528 if test -f "$srcdir/intl/Makefile.in" && test -z "$intldir"; then
529 removed_acoutput="$removed_acoutput intl/Makefile"
531 if test -d "$srcdir/intl"; then
532 # Remove everything inside intl except for RCS and CVS subdirs and invisible
533 # files.
534 if $doit; then
535 echo "Wiping out intl/ subdirectory"
536 (cd "$srcdir/intl" &&
537 for f in *; do
538 if test CVS != "$f" && test RCS != "$f"; then
539 rm -rf "$f"
541 done)
542 else
543 echo "Wipe out intl/ subdirectory"
545 if test -z "$intldir"; then
546 removed_directory=intl
548 else
549 if test -n "$intldir"; then
550 if $doit; then
551 echo "Creating intl/ subdirectory"
552 mkdir "$srcdir/intl" || func_fatal_error "failed to create intl/ subdirectory"
553 else
554 echo "Create intl/ subdirectory"
556 added_directories="$added_directories intl"
560 $do_changelog && func_ChangeLog_init
562 test -d "$srcdir/po" || {
563 if $doit; then
564 echo "Creating po/ subdirectory"
565 mkdir "$srcdir/po" || func_fatal_error "failed to create po/ subdirectory"
566 else
567 echo "Create po/ subdirectory"
569 added_directories="$added_directories po"
572 # Create the directory for config.rpath, mkinstalldirs, if needed.
573 # This is for consistency with autoreconf and automake.
574 # Note that $auxdir is either empty or ends in a slash.
575 test -d "$srcdir/$auxdir" || {
576 if $doit; then
577 echo "Creating $auxdir subdirectory"
578 mkdir "$srcdir/$auxdir" || func_fatal_error "failed to create $auxdir subdirectory"
579 else
580 echo "Create $auxdir subdirectory"
584 # Now copy all files. Take care for the destination directories.
585 for file in *; do
586 case $file in
587 ABOUT-NLS)
588 func_linkorcopy $file "$gettext_dir/$file" $file
590 config.rpath | mkinstalldirs)
591 if test -f "$srcdir/$auxdir$file"; then
593 else
594 added_extradist="$added_extradist $auxdir$file"
596 func_linkorcopy $file "$gettext_dir/$file" "$auxdir$file"
598 esac
599 done
601 # Copy files to intl/ subdirectory.
602 if test -n "$intldir"; then
603 cd intl
604 for file in *; do
605 if test $file != COPYING.LIB-2.0 && test $file != COPYING.LIB-2.1; then
606 if test $file != plural.c; then
607 func_linkorcopy $file "$gettext_dir/intl/$file" intl/$file
608 else
609 # plural.c is a generated file; it must be copied and touched.
610 func_copy $file intl/$file
611 if $doit; then
612 (sleep 2; touch "$srcdir/intl/$file") &
616 done
617 cd ..
618 else
619 echo "Not copying intl/ directory."
620 # Tell the user what to put into configure.ac, if it is not already there.
621 if grep '^AM_GNU_GETTEXT([[]\?external[]]\?[ ]*[,)]' "$srcdir/$configure_in" > /dev/null; then
623 else
624 please="$please
625 Please use AM_GNU_GETTEXT([external]) in order to cause autoconfiguration
626 to look for an external libintl.
631 # Copy files to po/ subdirectory.
632 $do_changelog && func_poChangeLog_init
633 cd po
634 for file in Makefile.in.in; do
635 same=no
636 if test -f "$srcdir/po/$file"; then
637 if cmp -s $file "$srcdir/po/$file"; then
638 same=yes
640 else
641 added_acoutput="$added_acoutput po/Makefile.in"
643 if $do_changelog && test $same = no; then
644 if test -f "$srcdir/po/$file"; then
645 func_poChangeLog_add_entry " * $file: Upgrade to gettext-${version}."
646 else
647 func_poChangeLog_add_entry " * $file: New file, from gettext-${version}."
650 func_backup po/$file
651 func_linkorcopy $file "$gettext_dir/po/$file" po/$file
652 done
653 for file in *; do
654 case $file in
655 Makefile.in.in)
656 # Already handled above.
658 Makevars.template)
659 func_linkorcopy Makevars.template "$gettext_dir/po/Makevars.template" po/Makevars.template
660 if test -f "$srcdir/po/Makevars"; then
661 LC_ALL=C sed -n -e 's/[ ]*\([A-Za-z0-9_]*\)[ ]*=.*/\1/p' < "$srcdir/po/Makevars" | LC_ALL=C sort > "$srcdir/po/Makevars.tmp1"
662 LC_ALL=C sed -n -e 's/[ ]*\([A-Za-z0-9_]*\)[ ]*=.*/\1/p' < "$srcdir/po/Makevars.template" | LC_ALL=C sort > "$srcdir/po/Makevars.tmp2"
663 missingvars=`LC_ALL=C comm -13 "$srcdir/po/Makevars.tmp1" "$srcdir/po/Makevars.tmp2"`
664 rm -f "$srcdir/po/Makevars.tmp1" "$srcdir/po/Makevars.tmp2"
665 if test -n "$missingvars"; then
666 please="$please
667 Please update po/Makevars so that it defines all the variables mentioned
668 in po/Makevars.template.
669 You can then remove po/Makevars.template.
672 else
673 please="$please
674 Please create po/Makevars from the template in po/Makevars.template.
675 You can then remove po/Makevars.template.
680 same=no
681 if test -f "$srcdir/po/$file"; then
682 if cmp -s $file "$srcdir/po/$file"; then
683 same=yes
686 if $do_changelog && test $same = no; then
687 if test -f "$srcdir/po/$file"; then
688 func_poChangeLog_add_entry " * $file: Upgrade to gettext-${version}."
689 else
690 func_poChangeLog_add_entry " * $file: New file, from gettext-${version}."
693 func_backup po/$file
694 func_linkorcopy $file $gettext_dir/po/$file po/$file
696 esac
697 done
698 if test -f "$srcdir/po/cat-id-tbl.c"; then
699 func_remove po/cat-id-tbl.c
700 $do_changelog && func_poChangeLog_add_entry " * cat-id-tbl.c: Remove file."
702 if test -f "$srcdir/po/stamp-cat-id"; then
703 func_remove po/stamp-cat-id
704 $do_changelog && func_poChangeLog_add_entry " * stamp-cat-id: Remove file."
706 if test ! -f "$srcdir/po/POTFILES.in"; then
707 if $doit; then
708 echo "Creating initial po/POTFILES.in"
709 echo '# List of source files which contain translatable strings.' > "$srcdir/po/POTFILES.in"
710 else
711 echo "Create initial po/POTFILES.in"
713 $do_changelog && func_poChangeLog_add_entry " * POTFILES.in: New file."
714 please="$please
715 Please fill po/POTFILES.in as described in the documentation.
718 $do_changelog && func_poChangeLog_finish
720 m4filelist=' codeset.m4 gettext.m4 glibc2.m4 glibc21.m4 iconv.m4 intdiv0.m4
721 intmax.m4 inttypes.m4 inttypes_h.m4 inttypes-pri.m4 isc-posix.m4 lcmessage.m4
722 lib-ld.m4 lib-link.m4 lib-prefix.m4 longdouble.m4 longlong.m4 nls.m4 po.m4
723 printf-posix.m4 progtest.m4 signed.m4 size_max.m4 stdint_h.m4 uintmax_t.m4
724 ulonglong.m4 wchar_t.m4 wint_t.m4 xsize.m4'
725 # We cannot omit codeset.m4, glibc2.m4, glibc21.m4, intdiv0.m4, intmax.m4,
726 # inttypes.m4, inttypes_h.m4, inttypes-pri.m4, isc-posix.m4, lcmessage.m4,
727 # longdouble.m4, longlong.m4, nls.m4, po.m4, printf-posix.m4, signed.m4,
728 # size_max.m4, stdint_h.m4, uintmax_t.m4, ulonglong.m4, wchar_t.m4, wint_t.m4,
729 # xsize.m4
730 # if test -z "$intldir", otherwise "aclocal -I m4" might give an error.
731 # (aclocal doesn't know which macros are really needed, it looks which macros
732 # are potentially needed.)
734 # All sorts of bugs could occur if the configure file was remade with the wrong
735 # version of gettext.m4 et al. (because then the configure and the po/Makefile.in.in
736 # don't fit together). It is therefore important that the package carries the
737 # right versions of gettext.m4 et al. with it.
738 if test -f "$srcdir/Makefile.am"; then
739 # A package using automake.
741 # Determine whether it's using automake 1.8 or newer.
742 have_automake18=
743 if (aclocal --version) >/dev/null 2>/dev/null; then
744 aclocal_version=`aclocal --version | sed -n -e 1p | sed -e 's/^[^0-9]*//'`
745 case $aclocal_version in
746 1.[8-9]* | 1.[1-9][0-9]* | [2-9]*) have_automake18=yes ;;
747 esac
750 # Extract the macro directory name from Makefile.am.
751 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$srcdir/Makefile.am" | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
752 m4dir=m4
753 m4dir_is_next=
754 for arg in $aclocal_amflags; do
755 if test -n "$m4dir_is_next"; then
756 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
757 case "$arg" in
758 /*) ;;
760 m4dir="$arg"
761 break
763 esac
764 else
765 if test "X$arg" = "X-I"; then
766 m4dir_is_next=yes
767 else
768 m4dir_is_next=
771 done
773 # Decide whether to use $m4dir/ChangeLog, or to use ChangeLog instead.
774 if test -d "$srcdir/$m4dir" && test -f "$srcdir/ChangeLog" && test ! -f "$srcdir/$m4dir/ChangeLog"; then
775 # The programmer has no $m4dir/ChangeLog so far. Don't introduce one.
776 using_m4ChangeLog=
779 # Update the *.m4 files and the corresponding Makefile.am.
780 $do_changelog && func_m4ChangeLog_init
781 added_m4dir=
782 added_m4files=
783 if test -d "$srcdir/$m4dir"; then
785 else
786 if $doit; then
787 echo "Creating directory $m4dir"
788 mkdir "$srcdir/$m4dir"
789 else
790 echo "Create directory $m4dir"
792 added_m4dir=yes
794 for file in $m4filelist; do
795 same=no
796 if test -f "$srcdir/$m4dir/$file"; then
797 if cmp -s "@datadir@/aclocal/$file" "$srcdir/$m4dir/$file"; then
798 same=yes
800 else
801 added_m4files="$added_m4files $file"
803 if $do_changelog && test $same = no; then
804 if test -f "$srcdir/$m4dir/$file"; then
805 func_m4ChangeLog_add_entry " * $file: Upgrade to gettext-${version}."
806 else
807 func_m4ChangeLog_add_entry " * $file: New file, from gettext-${version}."
810 func_backup "$m4dir/$file"
811 func_linkorcopy "@datadir@/aclocal/$file" "@datadir@/aclocal/$file" "$m4dir/$file"
812 done
813 missing_m4Makefileam=
814 if test -n "$added_m4files"; then
815 if test -f "$srcdir/$m4dir/Makefile.am"; then
816 if $doit; then
817 echo "Updating EXTRA_DIST in $m4dir/Makefile.am (backup is in $m4dir/Makefile.am~)"
818 func_backup "$m4dir/Makefile.am"
819 rm -f "$srcdir/$m4dir/Makefile.am"
820 if grep '^EXTRA_DIST[ ]*=' "$srcdir/$m4dir/Makefile.am~" > /dev/null; then
821 sed -e "s%^\(EXTRA_DIST[ ]*=\) \\?%\\1$added_m4files %" < "$srcdir/$m4dir/Makefile.am~" > "$srcdir/$m4dir/Makefile.am"
822 $do_changelog && func_m4ChangeLog_add_entry " * Makefile.am (EXTRA_DIST): Add the new files."
823 else
824 (cat "$srcdir/$m4dir/Makefile.am~"; echo; echo "EXTRA_DIST =$added_m4files") > "$srcdir/$m4dir/Makefile.am"
825 $do_changelog && func_m4ChangeLog_add_entry " * Makefile.am (EXTRA_DIST): New variable."
827 else
828 echo "Update EXTRA_DIST in $m4dir/Makefile.am"
829 $do_changelog && func_m4ChangeLog_add_entry " * Makefile.am (EXTRA_DIST)."
831 else
832 # $m4dir/Makefile.am is not needed any more when aclocal 1.8 or newer
833 # is used.
834 if test -z "$have_automake18"; then
835 if $doit; then
836 echo "Creating $m4dir/Makefile.am"
837 echo "EXTRA_DIST =$added_m4files" > "$srcdir/$m4dir/Makefile.am"
838 else
839 echo "Create $m4dir/Makefile.am"
841 $do_changelog && func_m4ChangeLog_add_entry " * Makefile.am: New file."
842 added_acoutput="$added_acoutput $m4dir/Makefile"
843 else
844 missing_m4Makefileam=yes
848 if test -n "$added_m4dir" && test -z "$missing_m4Makefileam"; then
849 added_directories="$added_directories $m4dir"
851 $do_changelog && func_m4ChangeLog_finish
852 # automake will arrange for $m4dir/ChangeLog to be distributed if a
853 # $m4dir/Makefile.am exists. If not, we need to add it to Makefile.am's
854 # EXTRA_DIST explicitly.
855 if test -n "$created_m4ChangeLog" && test -n "$missing_m4Makefileam"; then
856 added_extradist="$added_extradist $m4dir/ChangeLog"
859 # Update the top-level Makefile.am.
860 modified_Makefile_am=
861 # func_modify_Makefile_am changelog_comment
862 # assumes a modified copy of $srcdir/Makefile.am in $srcdir/Makefile.am.tmp
863 # and replaces the original Makefile.am file with the modified one if
864 # the two files differ. Then it removes the modified copy.
865 func_modify_Makefile_am ()
867 if cmp -s "$srcdir/Makefile.am" "$srcdir/Makefile.am.tmp"; then
869 else
870 if test -z "$modified_Makefile_am"; then
871 if $doit; then
872 echo "Updating Makefile.am (backup is in Makefile.am~)"
873 func_backup Makefile.am
874 else
875 echo "Update Makefile.am"
878 if $doit; then
879 rm -f "$srcdir/Makefile.am"
880 cp "$srcdir/Makefile.am.tmp" "$srcdir/Makefile.am"
882 if $do_changelog; then
883 if test -z "$modified_Makefile_am"; then
884 func_ChangeLog_add_entry " * Makefile.am $1"
885 else
886 func_ChangeLog_add_entry " $1"
889 modified_Makefile_am=yes
891 rm -f "$srcdir/Makefile.am.tmp"
894 if test -n "$added_directories"; then
895 if grep '^SUBDIRS[ ]*=' "$srcdir/Makefile.am" > /dev/null; then
896 sed -e "s%^\(SUBDIRS[ ]*=\) \\?%\\1$added_directories %" < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp"
897 added_directories_pretty=`echo $added_directories | sed -e 's/ /, /g'`
898 func_modify_Makefile_am "(SUBDIRS): Add $added_directories_pretty."
899 else
900 (cat "$srcdir/Makefile.am"; echo; echo "SUBDIRS =$added_directories") > "$srcdir/Makefile.am.tmp"
901 func_modify_Makefile_am "(SUBDIRS): New variable."
904 if test -n "$removed_directory"; then
905 sed -e '/^SUBDIRS[ ]*=/ {
907 s%\([ ]\)'"$removed_directory"'[ ]%\1%
908 s%[ ]'"$removed_directory"'$%%
911 s%\\$%\\%
918 }' < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp"
919 func_modify_Makefile_am "(SUBDIRS): Remove $removed_directory."
921 if test -n "$added_directories"; then
922 if grep '^DIST_SUBDIRS[ ]*=' "$srcdir/Makefile.am" > /dev/null; then
923 sed -e "s%^\(DIST_SUBDIRS[ ]*=\) \\?%\\1$added_directories %" < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp"
924 added_directories_pretty=`echo $added_directories | sed -e 's/ /, /g'`
925 func_modify_Makefile_am "(DIST_SUBDIRS): Add $added_directories_pretty."
928 if test -n "$removed_directory"; then
929 sed -e '/^DIST_SUBDIRS[ ]*=/ {
931 s%\([ ]\)'"$removed_directory"'[ ]%\1%
932 s%[ ]'"$removed_directory"'$%%
935 s%\\$%\\%
942 }' < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp"
943 func_modify_Makefile_am "(DIST_SUBDIRS): Remove $removed_directory."
945 if test -z "$m4dir_is_next"; then
946 if grep '^ACLOCAL_AMFLAGS[ ]*=' "$srcdir/Makefile.am" > /dev/null; then
947 sed -e "s%^\(ACLOCAL_AMFLAGS[ ]*=\) \\?%\\1 -I $m4dir %" < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp"
948 func_modify_Makefile_am "(ACLOCAL_AMFLAGS): Add -I $m4dir."
949 else
950 (cat "$srcdir/Makefile.am"; echo; echo "ACLOCAL_AMFLAGS = -I $m4dir") > "$srcdir/Makefile.am.tmp"
951 func_modify_Makefile_am "(ACLOCAL_AMFLAGS): New variable."
953 # Also update Makefile.in and, if existent, Makefile. Otherwise they
954 # would take into account the new flags only after a few rounds of
955 # "./configure", "make", "touch configure.in", "make distclean".
956 if $doit; then
957 for file in Makefile.in Makefile; do
958 if test -f "$srcdir/$file"; then
959 func_backup $file
960 rm -f "$srcdir/$file"
961 sed -e "s%(ACLOCAL)%(ACLOCAL) -I $m4dir%" < "$srcdir/$file~" > "$srcdir/$file"
963 done
966 if test -n "$added_extradist"; then
967 if grep '^EXTRA_DIST[ ]*=' "$srcdir/Makefile.am" > /dev/null; then
968 sed -e "s%^\(EXTRA_DIST[ ]*=\)%\\1$added_extradist %" < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp"
969 added_extradist_pretty=`echo $added_extradist | sed -e 's/ /, /g'`
970 func_modify_Makefile_am "(EXTRA_DIST): Add $added_extradist_pretty."
971 else
972 (cat "$srcdir/Makefile.am"; echo; echo "EXTRA_DIST =$added_extradist") > "$srcdir/Makefile.am.tmp"
973 func_modify_Makefile_am "(EXTRA_DIST): New variable."
976 please="$please
977 Please run 'aclocal -I $m4dir' to regenerate the aclocal.m4 file.
978 You need aclocal from GNU automake 1.5 (or newer) to do this.
979 Then run 'autoconf' to regenerate the configure file.
982 # Also create $m4dir/Makefile.in from $m4dir/Makefile.am, because automake
983 # doesn't do it by itself.
984 if $doit; then
985 case "$added_acoutput" in
986 *" $m4dir/Makefile")
987 (cd "$srcdir" && automake "$m4dir/Makefile") 2>/dev/null ||
988 please="$please
989 Please run 'automake $m4dir/Makefile' to create $m4dir/Makefile.in
992 esac
994 else
995 please="$please
996 Please add the files
997 $m4filelist
998 from the @datadir@/aclocal directory to your aclocal.m4 file.
1002 modified_configure_in=
1003 # func_modify_configure_in changelog_comment
1004 # assumes a modified copy of $srcdir/$configure_in in $srcdir/$configure_in.tmp
1005 # and replaces the original configure.in/ac file with the modified one if
1006 # the two files differ. Then it removes the modified copy.
1007 func_modify_configure_in ()
1009 if cmp -s "$srcdir/$configure_in" "$srcdir/$configure_in.tmp"; then
1011 else
1012 if test -z "$modified_configure_in"; then
1013 if $doit; then
1014 echo "Updating $configure_in (backup is in $configure_in~)"
1015 func_backup $configure_in
1016 else
1017 echo "Update $configure_in"
1020 if $doit; then
1021 rm -f "$srcdir/$configure_in"
1022 cp "$srcdir/$configure_in.tmp" "$srcdir/$configure_in"
1024 if $do_changelog; then
1025 if test -z "$modified_configure_in"; then
1026 func_ChangeLog_add_entry " * $configure_in $1"
1027 else
1028 func_ChangeLog_add_entry " $1"
1031 modified_configure_in=yes
1033 rm -f "$srcdir/$configure_in.tmp"
1036 if test -n "$added_acoutput"; then
1037 if grep '^AC_CONFIG_FILES(' "$srcdir/$configure_in" > /dev/null; then
1038 sedprog='
1044 sed -e "s%^\\(AC_CONFIG_FILES([^])\\,]*\\)%\\1$added_acoutput%$sedprog" < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp"
1045 added_acoutput_pretty=`echo $added_acoutput | sed -e 's/ /, /g'`
1046 func_modify_configure_in "(AC_CONFIG_FILES): Add $added_acoutput_pretty."
1047 else
1048 if grep '^AC_OUTPUT(' "$srcdir/$configure_in" > /dev/null; then
1049 sed -e "s%^\\(AC_OUTPUT([^])\\,]*\\)%\\1$added_acoutput%" < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp"
1050 added_acoutput_pretty=`echo $added_acoutput | sed -e 's/ /, /g'`
1051 func_modify_configure_in "(AC_OUTPUT): Add $added_acoutput_pretty."
1052 else
1053 please="$please
1054 Please add$added_acoutput to the AC_OUTPUT or AC_CONFIG_FILES invocation in the $configure_in file.
1059 if test -n "$removed_acoutput"; then
1060 for file in $removed_acoutput; do
1061 tag=
1062 sedprog='{
1063 s%\([[ ]\)'"$file"'[ ]%\1%
1064 s%\([[ ]\)'"$file"'\([]),]\)%\1\2%
1065 s%[[ ]'"$file"'$%%
1069 s%\\$%\\%
1074 s%\([ ]\)'"$file"'[ ]%\1%
1075 s%\([ ]\)'"$file"'\([]),]\)%\1\2%
1076 s%[ ]'"$file"'$%%
1080 sed -e '/^AC_CONFIG_FILES(/'"$sedprog" < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp"
1081 if cmp -s "$srcdir/$configure_in" "$srcdir/$configure_in.tmp"; then
1082 sed -e '/^AC_OUTPUT(/'"$sedprog" < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp"
1083 if cmp -s "$srcdir/$configure_in" "$srcdir/$configure_in.tmp"; then
1085 else
1086 tag=AC_OUTPUT
1088 else
1089 tag=AC_CONFIG_FILES
1091 if test -n "$tag"; then
1092 func_modify_configure_in "($tag): Remove $file."
1093 else
1094 rm -f "$srcdir/$configure_in.tmp"
1095 if test "$file" != intl/intlh.inst; then
1096 please="$please
1097 Please remove $file from the AC_OUTPUT or AC_CONFIG_FILES invocation
1098 in the $configure_in file.
1102 done
1104 sed -e 's%sed -e "/POTFILES =/r po/POTFILES" po/Makefile\.in > po/Makefile *;* *%%' < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp"
1105 func_modify_configure_in "(AC_OUTPUT): Remove command that created po/Makefile."
1106 sed -e '/^\(dnl \|\)AC_LINK_FILES(\$nls_cv_header_libgt, \$nls_cv_header_intl)$/d' < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp"
1107 func_modify_configure_in "(AC_LINK_FILES): Remove invocation."
1108 sed -e 's/^AM_GNU_GETTEXT_VERSION([^()]*)/AM_GNU_GETTEXT_VERSION(['"$version"'])/' < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp"
1109 func_modify_configure_in "(AM_GNU_GETTEXT_VERSION): Bump to $version."
1110 $do_changelog && func_ChangeLog_finish
1112 # Recommend replacement for deprecated Makefile variables.
1113 use_libtool=`cat "$srcdir/$configure_in" | grep '^A[CM]_PROG_LIBTOOL'`
1114 for file in `(cd "$srcdir"; find . -name Makefile.am -print; find . -name Makefile.in -print) | sed -e 's,^\./,,'`; do
1115 if test -f "$srcdir/$file"; then
1116 if test `echo "$file" | sed -e 's,^.*/,,'` = Makefile.in && grep automake "$srcdir/$file" >/dev/null 2>&1; then
1117 continue;
1119 # INTLLIBS is deprecated because it doesn't distinguish the two
1120 # cases: with libtool, without libtool.
1121 if grep '@''INTLLIBS''@' "$srcdir/$file" >/dev/null 2>&1; then
1122 if test -n "$use_libtool"; then
1123 please="$please
1124 Please change $file to use @""LTLIBINTL""@ or @""LIBINTL""@ instead of
1125 @""INTLLIBS""@. Which one, depends whether it is used with libtool or not.
1126 @""INTLLIBS""@ will go away.
1128 else
1129 please="$please
1130 Please change $file to use @""LIBINTL""@ instead of @""INTLLIBS""@.
1131 @""INTLLIBS""@ will go away.
1135 # DATADIRNAME is deprecated because we install only .gmo files nowadays,
1136 # which can be stored in the platform independent $prefix/share hierarchy.
1137 if grep '@''DATADIRNAME''@' "$srcdir/$file" >/dev/null 2>&1; then
1138 please="$please
1139 Please change $file to use the constant string \"share\" instead of
1140 @""DATADIRNAME""@. @""DATADIRNAME""@ will go away.
1143 # INSTOBJEXT is deprecated because we install only .gmo files nowadays,
1144 # no catgets .cat catalogs.
1145 if grep '@''INSTOBJEXT''@' "$srcdir/$file" >/dev/null 2>&1; then
1146 please="$please
1147 Please change $file to use the constant string \".mo\" instead of
1148 @""INSTOBJEXT""@. @""INSTOBJEXT""@ will go away.
1151 # GENCAT is deprecated because we install no catgets catalogs anymore.
1152 if grep '@''GENCAT''@' "$srcdir/$file" >/dev/null 2>&1; then
1153 please="$please
1154 Please change $file to use the constant string \"gencat\" instead of
1155 @""GENCAT""@. @""GENCAT""@ will go away. Maybe you don't even need it any more?
1158 # POSUB is deprecated because it causes "./configure --disable-nls", "make",
1159 # "make dist" to create a buggy tarfile.
1160 if grep '@''POSUB''@' "$srcdir/$file" >/dev/null 2>&1; then
1161 please="$please
1162 Please change $file to use the constant string \"po\" instead of
1163 @""POSUB""@. @""POSUB""@ will go away.
1167 done
1169 # Recommend replacement for deprecated configure variables.
1170 if grep '\$nls_cv_header_' "$srcdir/$configure_in" >/dev/null 2>&1; then
1171 please="$please
1172 Please stop using \$nls_cv_header_intl or \$nls_cv_header_libgt in the
1173 $configure_in file. Both will go away. Use <libintl.h> or \"gettext.h\" instead.
1177 # Recommend fetching config.guess and config.sub.
1178 if test -f "$srcdir/$auxdir"config.guess && test -f "$srcdir/$auxdir"config.sub; then
1180 else
1181 please="$please
1182 You will also need config.guess and config.sub, which you can get from the CVS
1183 of the 'config' project at http://savannah.gnu.org/. The commands to fetch them
1185 \$ wget 'http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess'
1186 \$ wget 'http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub'
1190 if $doit; then
1191 echo "$please"
1192 echo "You might also want to copy the convenience header file gettext.h"
1193 echo "from the $gettext_dir directory into your package."
1194 echo "It is a wrapper around <libintl.h> that implements the configure --disable-nls"
1195 echo "option."
1196 echo
1197 count=`echo "$please" | grep '^$' | wc -l`
1198 count=`echo "$count" | sed -e 's/[ ]//g'`
1199 case "$count" in
1200 1) count="paragraph";;
1201 2) count="two paragraphs";;
1202 3) count="three paragraphs";;
1203 4) count="four paragraphs";;
1204 5) count="five paragraphs";;
1205 *) count="$count paragraphs";;
1206 esac
1207 echo "Press Return to acknowledge the previous $count."
1208 # Read from /dev/tty, not stdin, so that gettextize cannot be abused by
1209 # non-interactive tools.
1210 read dummy < /dev/tty
1213 exit 0