3 # Copyright (C) 1995-1998, 2000-2015 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 3 of the License, or
8 # (at your option) 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, see <http://www.gnu.org/licenses/>.
19 # This file is meant for authors or maintainers which want to
20 # internationalize their package with the help of GNU gettext. For
21 # further information how to use it consult the GNU gettext manual.
26 archive_version=@ARCHIVE_VERSION@
29 # - gettext_datadir directory where the data files are stored.
31 datarootdir="@datarootdir@"
32 : ${gettext_datadir="@datadir@/gettext"}
33 : ${AUTOM4TE=autom4te}
36 # creates a temporary directory.
38 # - tmp pathname of freshly created temporary directory
41 # Use the environment variable TMPDIR, falling back to /tmp. This allows
42 # users to specify a different temporary directory, for example, if their
43 # /tmp is filled up or too small.
46 # Use the mktemp program if available. If not available, hide the error
48 tmp=`(umask 077 && mktemp -d "$TMPDIR/gtXXXXXX") 2>/dev/null` &&
49 test -n "$tmp" && test -d "$tmp"
52 # Use a simple mkdir command. It is guaranteed to fail if the directory
53 # already exists. $RANDOM is bash specific and expands to empty in shells
54 # other than bash, ksh and zsh. Its use does not increase security;
55 # rather, it minimizes the probability of failure in a very cluttered /tmp
57 tmp=$TMPDIR/gt$$-$RANDOM
58 (umask 077 && mkdir "$tmp")
61 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
66 # Support for relocatability.
67 func_find_curr_installdir ()
69 # Determine curr_installdir, even taking into account symlinks.
71 case "$curr_executable" in
73 *) # Need to look in the PATH.
74 save_IFS="$IFS"; IFS="${PATH_SEPARATOR='@PATH_SEPARATOR@'}"
77 test -z "$dir" && dir=.
78 for exec_ext in ''; do
79 if test -f "$dir/$curr_executable$exec_ext"; then
80 curr_executable="$dir/$curr_executable$exec_ext"
89 case "$curr_executable" in
91 *) curr_executable=`pwd`/"$curr_executable" ;;
94 sed_dirname='s,/[^/]*$,,'
95 sed_linkdest='s,^.* -> \(.*\),\1,p'
97 lsline=`LC_ALL=C ls -l "$curr_executable"`
100 linkdest=`echo "$lsline" | sed -n -e "$sed_linkdest"`
102 /* | ?:/* | ?:\\*) curr_executable="$linkdest" ;;
103 *) curr_executable=`echo "$curr_executable" | sed -e "$sed_dirname"`/"$linkdest" ;;
108 curr_installdir=`echo "$curr_executable" | sed -e 's,/[^/]*$,,'`
110 curr_installdir=`cd "$curr_installdir" && pwd`
112 func_find_prefixes ()
114 # Compute the original/current installation prefixes by stripping the
115 # trailing directories off the original/current installation directories.
116 orig_installprefix="$orig_installdir"
117 curr_installprefix="$curr_installdir"
119 orig_last=`echo "$orig_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'`
120 curr_last=`echo "$curr_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'`
121 if test -z "$orig_last" || test -z "$curr_last"; then
124 if test "$orig_last" != "$curr_last"; then
127 orig_installprefix=`echo "$orig_installprefix" | sed -e 's,/[^/]*$,,'`
128 curr_installprefix=`echo "$curr_installprefix" | sed -e 's,/[^/]*$,,'`
131 if test "@RELOCATABLE@" = yes; then
132 exec_prefix="@exec_prefix@"
134 orig_installdir="$bindir" # see Makefile.am's *_SCRIPTS variables
135 func_find_curr_installdir # determine curr_installdir
137 # Relocate the directory variables that we use.
138 gettext_datadir=`echo "$gettext_datadir/" | sed -e "s%^${orig_installprefix}/%${curr_installprefix}/%" | sed -e 's,/$,,'`
141 # func_trace_autoconf macro configure.ac
142 # traces an Autoconf macro call and outputs the arguments to stdout,
144 func_trace_autoconf ()
147 dnl replace macros which may abort autom4te with a no-op variant
148 m4_pushdef([m4_assert])
149 m4_pushdef([m4_fatal])
150 m4_pushdef([m4_warn])
151 m4_pushdef([m4_errprintn])
152 m4_pushdef([m4_exit])
153 m4_pushdef([m4_include])
154 m4_pushdef([m4_esyscmd])
156 | "$AUTOM4TE" --no-cache --language=Autoconf-without-aclocal-m4 \
157 --trace="$1":\$% - "$2" 2>/dev/null
160 # func_trace_sed macro configure.ac
161 # traces an Autoconf macro call and outputs the arguments to stdout,
165 sed_extract_arguments='
166 s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,;
176 s,^.*'"$1"'([[ ]*\([^]"$`\\)]*\).*$,\1,p
179 sed -e "$sed_extract_arguments" "$2"
183 # outputs to stdout the --help usage message.
187 Usage: gettextize [OPTION]... [package-dir]
189 Prepares a source package to use gettext.
192 --help print this help and exit
193 --version print version information and exit
194 -f, --force force writing of new files even if old exist
195 --intl install libintl in a subdirectory (deprecated)
196 --po-dir=DIR specify directory with PO files
197 --no-changelog don't update or create ChangeLog files
198 --symlink make symbolic links instead of copying files
199 -n, --dry-run print modifications but don't perform them
201 Report bugs to <bug-gnu-gettext@gnu.org>."
205 # outputs to stdout the --version message.
208 echo "$progname (GNU $package) $version"
209 echo "Copyright (C) 1995-1998, 2000-2013 Free Software Foundation, Inc.
210 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
211 This is free software: you are free to change and redistribute it.
212 There is NO WARRANTY, to the extent permitted by law."
213 echo "Written by" "Ulrich Drepper"
216 # func_fatal_error message
217 # outputs to stderr a fatal error message, and terminates the program.
220 echo "gettextize: *** $1" 1>&2
221 echo "gettextize: *** Stop." 1>&2
226 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
228 # Unset more variables known to interfere with behavior of common tools.
229 CLICOLOR_FORCE= GREP_OPTIONS=
230 unset CLICOLOR_FORCE GREP_OPTIONS
232 # Command-line option processing.
233 # Removes the OPTIONS from the arguments. Sets the variables:
234 # - force 1 if --force was given, 0 otherwise
235 # - intldir yes if --intl was given, empty otherwise
236 # - podirs list of directories specified with --po-dir
237 # - try_ln_s : if --symlink was given, false otherwise
238 # - do_changelog false if --no-changelog was given, : otherwise
239 # - doit false if --dry-run was given, : otherwise
248 while test $# -gt 0; do
250 -c | --copy | --cop | --co | --c ) # accepted for backward compatibility
252 -n | --dry-run | --dry-ru | --dry-r | --dry- | --dry | --dr | --d )
255 -f | --force | --forc | --for | --fo | --f )
258 --help | --hel | --he | --h )
259 func_usage; exit 0 ;;
260 --intl | --int | --in | --i )
263 --po-dir | --po-di | --po-d | --po- | --po | --p )
266 func_fatal_error "missing argument for --po-dir"
269 -*) func_fatal_error "missing argument for --po-dir" ;;
274 arg=`echo "X$1" | sed -e 's/^X--po-dir=//'`
275 podirs="$podirs $arg"
277 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
279 do_changelog=false ;;
280 --symlink | --symlin | --symli | --syml | --sym | --sy | --s )
283 --version | --versio | --versi | --vers | --ver | --ve | --v )
286 -- ) # Stop option prcessing
289 echo "gettextize: unknown option $1" 1>&2
290 echo "Try 'gettextize --help' for more information." 1>&2
296 # podirs defaults to "po".
297 test -n "$podirs" || podirs="po"
300 # Warn about deprecated options.
301 if test -n "$intldir"; then
302 echo "gettextize: warning: the option '--intl' is deprecated and will be removed" 1>&2
305 # Command-line argument processing.
306 # Analyzes the remaining arguments.
308 # - origdir to the original directory,
309 # - srcdir to the package directory, and cd-s into it.
311 if test $# -gt 1; then
316 if test $# -eq 1; then
318 if cd "$srcdir"; then
321 func_fatal_error "Cannot change directory to '$srcdir'."
328 # The current directory is now $srcdir.
330 # Check integrity of package: A configure.in/ac must be present. Sets variable
331 # - configure_in name of configure.in/ac file.
332 test -f configure.in || test -f configure.ac ||
333 func_fatal_error "Missing configure.in or configure.ac, please cd to your package first."
335 if test -f configure.in; then
336 configure_in=configure.in
338 if test -f configure.ac; then
339 configure_in=configure.ac
343 # Check whether the --force option is needed but has not been specified.
344 if test $force -eq 0; then
345 if test -d intl; then
346 func_fatal_error "intl/ subdirectory exists: use option -f if you really want to delete it."
348 for podir in $podirs; do
349 if test -f "$podir/Makefile.in.in"; then
350 func_fatal_error "$podir/Makefile.in.in exists: use option -f if you really want to delete it."
353 if test -f ABOUT-NLS; then
354 func_fatal_error "ABOUT-NLS exists: use option -f if you really want to delete it."
358 # Select the method for Autoconf macro tracing. func_trace_autoconf
359 # is more accurate than func_trace_sed, but it only works with
361 if echo "AC_PREREQ([2.69])" \
362 | "$AUTOM4TE" --no-cache --language=Autoconf-without-aclocal-m4 - 2>&1; then
363 func_trace=func_trace_autoconf
365 func_trace=func_trace_sed
368 # Check in which directory config.rpath etc. belong.
369 auxdir=`"$func_trace" AC_CONFIG_AUX_DIR "$configure_in"`
370 if test -n "$auxdir"; then
374 # Check in which directory gettext.m4 etc. belong.
375 macrodirs=`"$func_trace" AC_CONFIG_MACRO_DIR_TRACE "$configure_in"`
376 if test -z "$macrodirs"; then
377 macrodirs=`"$func_trace" AC_CONFIG_MACRO_DIR "$configure_in"`
379 for arg in $macrodirs; do
384 # For simplicity we change to the gettext source directory.
385 cd "$gettext_datadir" ||
386 func_fatal_error "gettext source directory '${gettext_datadir}' doesn't exist"
388 # Variables which keep track what has been modified.
393 removed_acoutput=" intl/intlh.inst"
396 # - please accumulates instructions for the user.
400 # - date current date, for use in ChangeLog entries.
401 date=`date +%Y-%m-%d`
405 # 'from' is a relative pathname, relative to the current directory.
406 # 'to' is a relative pathname, relative to $srcdir.
411 echo "Copying file $2"
418 # func_linkorcopy from absfrom to
419 # links or copies a file.
420 # 'from' is a relative pathname, relative to the current directory.
421 # 'absfrom' is the corresponding absolute pathname.
422 # 'to' is a relative pathname, relative to $srcdir.
427 ($try_ln_s && ln -s "$2" "$srcdir/$3" && echo "Symlinking file $3") 2>/dev/null ||
428 { echo "Copying file $3"; cp "$1" "$srcdir/$3"; }
431 echo "Symlink file $3"
439 # makes a backup of a file that is about to be overwritten or replaced.
440 # 'to' is a relative pathname, relative to $srcdir.
444 if test -f "$srcdir/$1"; then
446 cp -p "$srcdir/$1" "$srcdir/$1~"
453 # 'to' is a relative pathname, relative to $srcdir.
464 # func_ChangeLog_init
465 # func_ChangeLog_add_entry line
466 # func_ChangeLog_finish
467 # manage the ChangeLog file, relative to $srcdir.
468 func_ChangeLog_init ()
472 func_ChangeLog_add_entry ()
475 if test -z "$modified_ChangeLog"; then
476 echo "$date gettextize <bug-gnu-gettext@gnu.org>" > "$srcdir/ChangeLog.tmp"
477 echo >> "$srcdir/ChangeLog.tmp"
478 modified_ChangeLog=yes
480 echo "$1" >> "$srcdir/ChangeLog.tmp"
482 modified_ChangeLog=yes
485 func_ChangeLog_finish ()
487 if test -n "$modified_ChangeLog"; then
489 echo >> "$srcdir/ChangeLog.tmp"
490 if test -f "$srcdir/ChangeLog"; then
491 echo "Adding an entry to ChangeLog (backup is in ChangeLog~)"
492 cat "$srcdir/ChangeLog" >> "$srcdir/ChangeLog.tmp"
493 rm -f "$srcdir/ChangeLog~"
494 cp -p "$srcdir/ChangeLog" "$srcdir/ChangeLog~"
496 echo "Creating ChangeLog"
498 cp "$srcdir/ChangeLog.tmp" "$srcdir/ChangeLog"
499 rm -f "$srcdir/ChangeLog.tmp"
501 if test -f "$srcdir/ChangeLog"; then
502 echo "Add an entry to ChangeLog"
504 echo "Create ChangeLog"
510 # func_poChangeLog_init
511 # func_poChangeLog_add_entry line
512 # func_poChangeLog_finish
513 # manage the $podir/ChangeLog file, relative to $srcdir.
514 func_poChangeLog_init ()
516 modified_poChangeLog=
518 func_poChangeLog_add_entry ()
521 if test -z "$modified_poChangeLog"; then
522 echo "$date gettextize <bug-gnu-gettext@gnu.org>" > "$srcdir/$podir/ChangeLog.tmp"
523 echo >> "$srcdir/$podir/ChangeLog.tmp"
524 modified_poChangeLog=yes
526 echo "$1" >> "$srcdir/$podir/ChangeLog.tmp"
528 modified_poChangeLog=yes
531 func_poChangeLog_finish ()
533 if test -n "$modified_poChangeLog"; then
535 echo >> "$srcdir/$podir/ChangeLog.tmp"
536 if test -f "$srcdir/$podir/ChangeLog"; then
537 echo "Adding an entry to $podir/ChangeLog (backup is in $podir/ChangeLog~)"
538 cat "$srcdir/$podir/ChangeLog" >> "$srcdir/$podir/ChangeLog.tmp"
539 rm -f "$srcdir/$podir/ChangeLog~"
540 cp -p "$srcdir/$podir/ChangeLog" "$srcdir/$podir/ChangeLog~"
542 echo "Creating $podir/ChangeLog"
544 cp "$srcdir/$podir/ChangeLog.tmp" "$srcdir/$podir/ChangeLog"
545 rm -f "$srcdir/$podir/ChangeLog.tmp"
547 if test -f "$srcdir/$podir/ChangeLog"; then
548 echo "Add an entry to $podir/ChangeLog"
550 echo "Create $podir/ChangeLog"
556 # func_m4ChangeLog_init
557 # func_m4ChangeLog_add_entry line
558 # func_m4ChangeLog_finish
559 # manage the $m4dir/ChangeLog file, relative to $srcdir.
560 func_m4ChangeLog_init ()
562 if test -n "$using_m4ChangeLog"; then
563 modified_m4ChangeLog=
567 func_m4ChangeLog_add_entry ()
569 if test -n "$using_m4ChangeLog"; then
571 if test -z "$modified_m4ChangeLog"; then
572 echo "$date gettextize <bug-gnu-gettext@gnu.org>" > "$srcdir/$m4dir/ChangeLog.tmp"
573 echo >> "$srcdir/$m4dir/ChangeLog.tmp"
574 modified_m4ChangeLog=yes
576 echo "$1" >> "$srcdir/$m4dir/ChangeLog.tmp"
578 modified_m4ChangeLog=yes
582 line=`echo "$line" | sed -e "s%^ \\* % * $m4dir/%"`
583 func_ChangeLog_add_entry "$line"
586 func_m4ChangeLog_finish ()
588 if test -n "$using_m4ChangeLog"; then
589 if test -n "$modified_m4ChangeLog"; then
591 echo >> "$srcdir/$m4dir/ChangeLog.tmp"
592 if test -f "$srcdir/$m4dir/ChangeLog"; then
593 echo "Adding an entry to $m4dir/ChangeLog (backup is in $m4dir/ChangeLog~)"
594 cat "$srcdir/$m4dir/ChangeLog" >> "$srcdir/$m4dir/ChangeLog.tmp"
595 rm -f "$srcdir/$m4dir/ChangeLog~"
596 cp -p "$srcdir/$m4dir/ChangeLog" "$srcdir/$m4dir/ChangeLog~"
598 echo "Creating $m4dir/ChangeLog"
599 created_m4ChangeLog=yes
601 cp "$srcdir/$m4dir/ChangeLog.tmp" "$srcdir/$m4dir/ChangeLog"
602 rm -f "$srcdir/$m4dir/ChangeLog.tmp"
604 if test -f "$srcdir/$m4dir/ChangeLog"; then
605 echo "Add an entry to $m4dir/ChangeLog"
607 echo "Create $m4dir/ChangeLog"
608 created_m4ChangeLog=yes
614 using_m4ChangeLog=yes
616 if test ! -f "$srcdir/intl/Makefile.in" && test -n "$intldir"; then
617 added_acoutput="$added_acoutput intl/Makefile"
619 if test -f "$srcdir/intl/Makefile.in" && test -z "$intldir"; then
620 removed_acoutput="$removed_acoutput intl/Makefile"
622 if test -d "$srcdir/intl"; then
623 # Remove everything inside intl except for RCS and CVS subdirs and invisible
626 echo "Wiping out intl/ subdirectory"
627 (cd "$srcdir/intl" &&
629 if test CVS != "$f" && test RCS != "$f"; then
634 echo "Wipe out intl/ subdirectory"
636 if test -z "$intldir"; then
637 removed_directory=intl
640 if test -n "$intldir"; then
642 echo "Creating intl/ subdirectory"
643 mkdir "$srcdir/intl" || func_fatal_error "failed to create intl/ subdirectory"
645 echo "Create intl/ subdirectory"
647 added_directories="$added_directories intl"
651 $do_changelog && func_ChangeLog_init
653 for podir in $podirs; do
654 test -d "$srcdir/$podir" || {
656 echo "Creating $podir/ subdirectory"
657 mkdir "$srcdir/$podir" || func_fatal_error "failed to create $podir/ subdirectory"
659 echo "Create $podir/ subdirectory"
661 added_directories="$added_directories $podir"
665 # Create the directory for config.rpath, if needed.
666 # This is for consistency with autoreconf and automake.
667 # Note that $auxdir is either empty or ends in a slash.
668 test -d "$srcdir/$auxdir" || {
670 echo "Creating $auxdir subdirectory"
671 mkdir "$srcdir/$auxdir" || func_fatal_error "failed to create $auxdir subdirectory"
673 echo "Create $auxdir subdirectory"
677 # Now copy all files. Take care for the destination directories.
681 func_linkorcopy $file "$gettext_datadir/$file" $file
684 if test -f "$srcdir/$auxdir$file"; then
687 added_extradist="$added_extradist $auxdir$file"
689 func_linkorcopy $file "$gettext_datadir/$file" "$auxdir$file"
694 # Copy files to intl/ subdirectory.
695 if test -n "$intldir"; then
698 if test $file != COPYING.LIB-2.0 && test $file != COPYING.LIB-2.1; then
699 if test $file != plural.c; then
700 func_linkorcopy $file "$gettext_datadir/intl/$file" intl/$file
702 # plural.c is a generated file; it must be copied and touched.
703 func_copy $file intl/$file
705 (sleep 2; touch "$srcdir/intl/$file") &
712 echo "Not copying intl/ directory."
713 # Tell the user what to put into configure.ac, if it is not already there.
715 # Need to use func_trace_sed instead of $func_trace, since
716 # AM_GNU_GETTEXT is not a standard Autoconf trace.
717 xargs=`func_trace_sed AM_GNU_GETTEXT "$srcdir/$configure_in"`
718 save_IFS="$IFS"; IFS=:
719 for arg in $xargs; do
720 if test 'external' = "$arg"; then
726 if test -z "$external"; then
728 Please use AM_GNU_GETTEXT([external]) in order to cause autoconfiguration
729 to look for an external libintl.
734 # Copy files to po/ subdirectory.
736 for podir in $podirs; do
737 $do_changelog && func_poChangeLog_init
738 for file in Makefile.in.in; do
740 if test -f "$srcdir/$podir/$file"; then
741 if cmp -s $file "$srcdir/$podir/$file"; then
745 added_acoutput="$added_acoutput $podir/Makefile.in"
747 if $do_changelog && test $same = no; then
748 if test -f "$srcdir/$podir/$file"; then
749 func_poChangeLog_add_entry " * $file: Upgrade to gettext-${version}."
751 func_poChangeLog_add_entry " * $file: New file, from gettext-${version}."
754 func_backup "$podir/$file"
755 func_linkorcopy $file "$gettext_datadir/po/$file" "$podir/$file"
760 # Already handled above.
763 func_linkorcopy Makevars.template "$gettext_datadir/po/Makevars.template" "$podir/Makevars.template"
764 if test -f "$srcdir/po/Makevars"; then
765 LC_ALL=C sed -n -e 's/[ ]*\([A-Za-z0-9_]*\)[ ]*=.*/\1/p' < "$srcdir/$podir/Makevars" | LC_ALL=C sort > "$srcdir/$podir/Makevars.tmp1"
766 LC_ALL=C sed -n -e 's/[ ]*\([A-Za-z0-9_]*\)[ ]*=.*/\1/p' < "$srcdir/$podir/Makevars.template" | LC_ALL=C sort > "$srcdir/$podir/Makevars.tmp2"
767 missingvars=`LC_ALL=C comm -13 "$srcdir/$podir/Makevars.tmp1" "$srcdir/$podir/Makevars.tmp2"`
768 rm -f "$srcdir/$podir/Makevars.tmp1" "$srcdir/$podir/Makevars.tmp2"
769 if test -n "$missingvars"; then
771 Please update $podir/Makevars so that it defines all the variables mentioned
772 in $podir/Makevars.template.
773 You can then remove $podir/Makevars.template.
778 Please create $podir/Makevars from the template in $podir/Makevars.template.
779 You can then remove $podir/Makevars.template.
785 if test -f "$srcdir/$podir/$file"; then
786 if cmp -s $file "$srcdir/$podir/$file"; then
790 if $do_changelog && test $same = no; then
791 if test -f "$srcdir/$podir/$file"; then
792 func_poChangeLog_add_entry " * $file: Upgrade to gettext-${version}."
794 func_poChangeLog_add_entry " * $file: New file, from gettext-${version}."
797 func_backup "$podir/$file"
798 func_linkorcopy $file "$gettext_datadir/po/$file" "$podir/$file"
802 if test -f "$srcdir/$podir/cat-id-tbl.c"; then
803 func_remove "$podir/cat-id-tbl.c"
804 $do_changelog && func_poChangeLog_add_entry " * cat-id-tbl.c: Remove file."
806 if test -f "$srcdir/$podir/stamp-cat-id"; then
807 func_remove "$podir/stamp-cat-id"
808 $do_changelog && func_poChangeLog_add_entry " * stamp-cat-id: Remove file."
810 if test ! -f "$srcdir/$podir/POTFILES.in"; then
812 echo "Creating initial $podir/POTFILES.in"
813 echo '# List of source files which contain translatable strings.' > "$srcdir/$podir/POTFILES.in"
815 echo "Create initial $podir/POTFILES.in"
817 $do_changelog && func_poChangeLog_add_entry " * POTFILES.in: New file."
819 Please fill $podir/POTFILES.in as described in the documentation.
822 $do_changelog && func_poChangeLog_finish
825 # Determine whether we can assume automake 1.9 or newer.
827 if (aclocal --version) >/dev/null 2>/dev/null; then
828 aclocal_version=`aclocal --version | sed -n -e 1p | sed -e 's/^[^0-9]*//'`
829 case $aclocal_version in
830 1.9* | 1.[1-9][0-9]* | [2-9]*) have_automake19=yes ;;
834 m4filelist='gettext.m4 iconv.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 nls.m4
836 # With aclocal versions < 1.9 we need all m4 files, otherwise "aclocal -I m4"
837 # might give an error. (aclocal < 1.9 didn't know which macros are really
838 # needed, it looked which macros are potentially needed.)
839 min_automake_version=1.9
840 if test -n "$intldir" || test -z "$have_automake19"; then
841 # Add intldir.m4, intl.m4 and its dependencies.
842 m4filelist=$m4filelist' codeset.m4 fcntl-o.m4 glibc2.m4 glibc21.m4 intdiv0.m4
843 intl.m4 intldir.m4 intlmacosx.m4 intmax.m4 inttypes_h.m4 inttypes-pri.m4
844 lcmessage.m4 lock.m4 longlong.m4 printf-posix.m4 size_max.m4 stdint_h.m4
845 threadlib.m4 uintmax_t.m4 visibility.m4 wchar_t.m4 wint_t.m4 xsize.m4'
846 min_automake_version=1.8
849 # All sorts of bugs could occur if the configure file was remade with the wrong
850 # version of gettext.m4 et al. (because then the configure and the po/Makefile.in.in
851 # don't fit together). It is therefore important that the package carries the
852 # right versions of gettext.m4 et al. with it.
853 if test -f "$srcdir/Makefile.am"; then
854 # A package using automake.
856 # Determine whether it's using automake 1.8 or newer.
858 if (aclocal --version) >/dev/null 2>/dev/null; then
859 aclocal_version=`aclocal --version | sed -n -e 1p | sed -e 's/^[^0-9]*//'`
860 case $aclocal_version in
861 1.[8-9]* | 1.[1-9][0-9]* | [2-9]*) have_automake18=yes ;;
865 if test -z "$m4dir"; then
866 # Extract the macro directory name from Makefile.am.
867 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$srcdir/Makefile.am" | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
869 for arg in $aclocal_amflags; do
870 if test -n "$m4dir_is_next"; then
871 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
875 test -z "$m4dir" || m4dir="$arg"
876 macrodirs="$macrodirs $arg"
881 if test "X$arg" = "X-I"; then
888 for arg in $macrodirs; do
894 if test -z "$m4dir"; then
899 # Decide whether to use $m4dir/ChangeLog, or to use ChangeLog instead.
900 if test -d "$srcdir/$m4dir" && test -f "$srcdir/ChangeLog" && test ! -f "$srcdir/$m4dir/ChangeLog"; then
901 # The programmer has no $m4dir/ChangeLog so far. Don't introduce one.
905 # Update the *.m4 files and the corresponding Makefile.am.
906 $do_changelog && func_m4ChangeLog_init
909 if test -d "$srcdir/$m4dir"; then
913 echo "Creating directory $m4dir"
914 mkdir "$srcdir/$m4dir"
916 echo "Create directory $m4dir"
920 for file in $m4filelist; do
922 if test -f "$srcdir/$m4dir/$file"; then
923 if cmp -s "@datadir@/aclocal/$file" "$srcdir/$m4dir/$file"; then
927 added_m4files="$added_m4files $file"
929 if $do_changelog && test $same = no; then
930 if test -f "$srcdir/$m4dir/$file"; then
931 func_m4ChangeLog_add_entry " * $file: Upgrade to gettext-${version}."
933 func_m4ChangeLog_add_entry " * $file: New file, from gettext-${version}."
936 func_backup "$m4dir/$file"
937 func_linkorcopy "@datadir@/aclocal/$file" "@datadir@/aclocal/$file" "$m4dir/$file"
939 missing_m4Makefileam=
940 if test -n "$added_m4files"; then
941 if test -f "$srcdir/$m4dir/Makefile.am"; then
943 echo "Updating EXTRA_DIST in $m4dir/Makefile.am (backup is in $m4dir/Makefile.am~)"
944 func_backup "$m4dir/Makefile.am"
945 rm -f "$srcdir/$m4dir/Makefile.am"
946 if grep '^EXTRA_DIST[ ]*=' "$srcdir/$m4dir/Makefile.am~" > /dev/null; then
947 sed -e "s%^\(EXTRA_DIST[ ]*=\) \\?%\\1$added_m4files %" < "$srcdir/$m4dir/Makefile.am~" > "$srcdir/$m4dir/Makefile.am"
948 $do_changelog && func_m4ChangeLog_add_entry " * Makefile.am (EXTRA_DIST): Add the new files."
950 (cat "$srcdir/$m4dir/Makefile.am~"; echo; echo "EXTRA_DIST =$added_m4files") > "$srcdir/$m4dir/Makefile.am"
951 $do_changelog && func_m4ChangeLog_add_entry " * Makefile.am (EXTRA_DIST): New variable."
954 echo "Update EXTRA_DIST in $m4dir/Makefile.am"
955 $do_changelog && func_m4ChangeLog_add_entry " * Makefile.am (EXTRA_DIST)."
958 # $m4dir/Makefile.am is not needed any more when aclocal 1.8 or newer
960 if test -z "$have_automake18"; then
962 echo "Creating $m4dir/Makefile.am"
963 echo "EXTRA_DIST =$added_m4files" > "$srcdir/$m4dir/Makefile.am"
965 echo "Create $m4dir/Makefile.am"
967 $do_changelog && func_m4ChangeLog_add_entry " * Makefile.am: New file."
968 added_acoutput="$added_acoutput $m4dir/Makefile"
970 missing_m4Makefileam=yes
974 if test -n "$added_m4dir" && test -z "$missing_m4Makefileam"; then
975 added_directories="$added_directories $m4dir"
977 $do_changelog && func_m4ChangeLog_finish
978 # automake will arrange for $m4dir/ChangeLog to be distributed if a
979 # $m4dir/Makefile.am exists. If not, we need to add it to Makefile.am's
980 # EXTRA_DIST explicitly.
981 if test -n "$created_m4ChangeLog" && test -n "$missing_m4Makefileam"; then
982 added_extradist="$added_extradist $m4dir/ChangeLog"
985 # Update the top-level Makefile.am.
986 modified_Makefile_am=
987 # func_modify_Makefile_am changelog_comment
988 # assumes a modified copy of $srcdir/Makefile.am in $srcdir/Makefile.am.tmp
989 # and replaces the original Makefile.am file with the modified one if
990 # the two files differ. Then it removes the modified copy.
991 func_modify_Makefile_am ()
993 if cmp -s "$srcdir/Makefile.am" "$srcdir/Makefile.am.tmp"; then
996 if test -z "$modified_Makefile_am"; then
998 echo "Updating Makefile.am (backup is in Makefile.am~)"
999 func_backup Makefile.am
1001 echo "Update Makefile.am"
1005 rm -f "$srcdir/Makefile.am"
1006 cp "$srcdir/Makefile.am.tmp" "$srcdir/Makefile.am"
1008 if $do_changelog; then
1009 if test -z "$modified_Makefile_am"; then
1010 func_ChangeLog_add_entry " * Makefile.am $1"
1012 func_ChangeLog_add_entry " $1"
1015 modified_Makefile_am=yes
1017 rm -f "$srcdir/Makefile.am.tmp"
1020 if test -n "$added_directories"; then
1021 if grep '^SUBDIRS[ ]*=' "$srcdir/Makefile.am" > /dev/null; then
1022 sed -e "s%^\(SUBDIRS[ ]*=\) \\?%\\1$added_directories %" < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp"
1023 added_directories_pretty=`echo $added_directories | sed -e 's/ /, /g'`
1024 func_modify_Makefile_am "(SUBDIRS): Add $added_directories_pretty."
1026 (cat "$srcdir/Makefile.am"; echo; echo "SUBDIRS =$added_directories") > "$srcdir/Makefile.am.tmp"
1027 func_modify_Makefile_am "(SUBDIRS): New variable."
1030 if test -n "$removed_directory"; then
1031 sed -e '/^SUBDIRS[ ]*=/ {
1033 s%\([ ]\)'"$removed_directory"'[ ]%\1%
1034 s%[ ]'"$removed_directory"'$%%
1044 }' < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp"
1045 func_modify_Makefile_am "(SUBDIRS): Remove $removed_directory."
1047 if test -n "$added_directories"; then
1048 if grep '^DIST_SUBDIRS[ ]*=' "$srcdir/Makefile.am" > /dev/null; then
1049 sed -e "s%^\(DIST_SUBDIRS[ ]*=\) \\?%\\1$added_directories %" < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp"
1050 added_directories_pretty=`echo $added_directories | sed -e 's/ /, /g'`
1051 func_modify_Makefile_am "(DIST_SUBDIRS): Add $added_directories_pretty."
1054 if test -n "$removed_directory"; then
1055 sed -e '/^DIST_SUBDIRS[ ]*=/ {
1057 s%\([ ]\)'"$removed_directory"'[ ]%\1%
1058 s%[ ]'"$removed_directory"'$%%
1068 }' < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp"
1069 func_modify_Makefile_am "(DIST_SUBDIRS): Remove $removed_directory."
1071 if test -n "$m4dir_defaulted"; then
1072 if grep '^ACLOCAL_AMFLAGS[ ]*=' "$srcdir/Makefile.am" > /dev/null; then
1073 sed -e "s%^\(ACLOCAL_AMFLAGS[ ]*=\) \\?%\\1 -I $m4dir %" < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp"
1074 func_modify_Makefile_am "(ACLOCAL_AMFLAGS): Add -I $m4dir."
1076 (cat "$srcdir/Makefile.am"; echo; echo "ACLOCAL_AMFLAGS = -I $m4dir") > "$srcdir/Makefile.am.tmp"
1077 func_modify_Makefile_am "(ACLOCAL_AMFLAGS): New variable."
1079 # Also update Makefile.in and, if existent, Makefile. Otherwise they
1080 # would take into account the new flags only after a few rounds of
1081 # "./configure", "make", "touch configure.in", "make distclean".
1083 for file in Makefile.in Makefile; do
1084 if test -f "$srcdir/$file"; then
1086 rm -f "$srcdir/$file"
1087 sed -e "s%(ACLOCAL)%(ACLOCAL) -I $m4dir%" < "$srcdir/$file~" > "$srcdir/$file"
1092 if test -n "$added_extradist"; then
1093 if grep '^EXTRA_DIST[ ]*=' "$srcdir/Makefile.am" > /dev/null; then
1094 sed -e "s%^\(EXTRA_DIST[ ]*=\)%\\1$added_extradist %" < "$srcdir/Makefile.am" > "$srcdir/Makefile.am.tmp"
1095 added_extradist_pretty=`echo $added_extradist | sed -e 's/ /, /g'`
1096 func_modify_Makefile_am "(EXTRA_DIST): Add $added_extradist_pretty."
1098 (cat "$srcdir/Makefile.am"; echo; echo "EXTRA_DIST =$added_extradist") > "$srcdir/Makefile.am.tmp"
1099 func_modify_Makefile_am "(EXTRA_DIST): New variable."
1102 # Extract the aclocal options name from Makefile.am.
1104 for arg in $macrodirs; do
1105 aclocal_options="$aclocal_options -I $arg"
1108 Please run 'aclocal$aclocal_options' to regenerate the aclocal.m4 file.
1109 You need aclocal from GNU automake $min_automake_version (or newer) to do this.
1110 Then run 'autoconf' to regenerate the configure file.
1113 # Also create $m4dir/Makefile.in from $m4dir/Makefile.am, because automake
1114 # doesn't do it by itself.
1116 case "$added_acoutput" in
1117 *" $m4dir/Makefile")
1118 (cd "$srcdir" && automake "$m4dir/Makefile") 2>/dev/null ||
1120 Please run 'automake $m4dir/Makefile' to create $m4dir/Makefile.in
1127 Please add the files
1129 from the @datadir@/aclocal directory to your aclocal.m4 file.
1133 modified_configure_in=
1134 # func_modify_configure_in changelog_comment
1135 # assumes a modified copy of $srcdir/$configure_in in $srcdir/$configure_in.tmp
1136 # and replaces the original configure.in/ac file with the modified one if
1137 # the two files differ. Then it removes the modified copy.
1138 func_modify_configure_in ()
1140 if cmp -s "$srcdir/$configure_in" "$srcdir/$configure_in.tmp"; then
1143 if test -z "$modified_configure_in"; then
1145 echo "Updating $configure_in (backup is in $configure_in~)"
1146 func_backup $configure_in
1148 echo "Update $configure_in"
1152 rm -f "$srcdir/$configure_in"
1153 cp "$srcdir/$configure_in.tmp" "$srcdir/$configure_in"
1155 if $do_changelog; then
1156 if test -z "$modified_configure_in"; then
1157 func_ChangeLog_add_entry " * $configure_in $1"
1159 func_ChangeLog_add_entry " $1"
1162 modified_configure_in=yes
1164 rm -f "$srcdir/$configure_in.tmp"
1167 if test -n "$added_acoutput"; then
1168 if grep '^AC_CONFIG_FILES(' "$srcdir/$configure_in" > /dev/null; then
1175 sed -e "s%^\\(AC_CONFIG_FILES([^])\\,]*\\)%\\1$added_acoutput%$sedprog" < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp"
1176 added_acoutput_pretty=`echo $added_acoutput | sed -e 's/ /, /g'`
1177 func_modify_configure_in "(AC_CONFIG_FILES): Add $added_acoutput_pretty."
1179 if grep '^AC_OUTPUT(' "$srcdir/$configure_in" > /dev/null; then
1180 sed -e "s%^\\(AC_OUTPUT([^])\\,]*\\)%\\1$added_acoutput%" < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp"
1181 added_acoutput_pretty=`echo $added_acoutput | sed -e 's/ /, /g'`
1182 func_modify_configure_in "(AC_OUTPUT): Add $added_acoutput_pretty."
1185 Please add$added_acoutput to the AC_OUTPUT or AC_CONFIG_FILES invocation in the $configure_in file.
1190 if test -n "$removed_acoutput"; then
1191 for file in $removed_acoutput; do
1194 s%\([[ ]\)'"$file"'[ ]%\1%
1195 s%\([[ ]\)'"$file"'\([]),]\)%\1\2%
1205 s%\([ ]\)'"$file"'[ ]%\1%
1206 s%\([ ]\)'"$file"'\([]),]\)%\1\2%
1211 sed -e '/^AC_CONFIG_FILES(/'"$sedprog" < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp"
1212 if cmp -s "$srcdir/$configure_in" "$srcdir/$configure_in.tmp"; then
1213 sed -e '/^AC_OUTPUT(/'"$sedprog" < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp"
1214 if cmp -s "$srcdir/$configure_in" "$srcdir/$configure_in.tmp"; then
1222 if test -n "$tag"; then
1223 func_modify_configure_in "($tag): Remove $file."
1225 rm -f "$srcdir/$configure_in.tmp"
1226 if test "$file" != intl/intlh.inst; then
1228 Please remove $file from the AC_OUTPUT or AC_CONFIG_FILES invocation
1229 in the $configure_in file.
1235 sed -e 's%sed -e "/POTFILES =/r po/POTFILES" po/Makefile\.in > po/Makefile *;* *%%' < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp"
1236 func_modify_configure_in "(AC_OUTPUT): Remove command that created po/Makefile."
1237 sed -e '/^\(dnl \|\)AC_LINK_FILES(\$nls_cv_header_libgt, \$nls_cv_header_intl)$/d' < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp"
1238 func_modify_configure_in "(AC_LINK_FILES): Remove invocation."
1239 # AM_GNU_GETTEXT_VERSION may not be present, when AM_GNU_GETTEXT_REQUIRE_VERSION is used.
1240 if grep '^AM_GNU_GETTEXT_VERSION(' "$srcdir/$configure_in" 2>&1 >/dev/null; then
1241 sed -e 's/^AM_GNU_GETTEXT_VERSION([^()]*)/AM_GNU_GETTEXT_VERSION(['"$archive_version"'])/' < "$srcdir/$configure_in" > "$srcdir/$configure_in.tmp"
1242 func_modify_configure_in "(AM_GNU_GETTEXT_VERSION): Bump to $archive_version."
1244 $do_changelog && func_ChangeLog_finish
1246 # Recommend replacement for deprecated Makefile variables.
1247 use_libtool=`cat "$srcdir/$configure_in" | grep '^A[CM]_PROG_LIBTOOL'`
1248 for file in `(cd "$srcdir"; find . -name Makefile.am -print; find . -name Makefile.in -print) | sed -e 's,^\./,,'`; do
1249 if test -f "$srcdir/$file"; then
1250 if test `echo "$file" | sed -e 's,^.*/,,'` = Makefile.in && grep automake "$srcdir/$file" >/dev/null 2>&1; then
1253 # INTLLIBS is deprecated because it doesn't distinguish the two
1254 # cases: with libtool, without libtool.
1255 if grep '@''INTLLIBS''@' "$srcdir/$file" >/dev/null 2>&1; then
1256 if test -n "$use_libtool"; then
1258 Please change $file to use @""LTLIBINTL""@ or @""LIBINTL""@ instead of
1259 @""INTLLIBS""@. Which one, depends whether it is used with libtool or not.
1260 @""INTLLIBS""@ will go away.
1264 Please change $file to use @""LIBINTL""@ instead of @""INTLLIBS""@.
1265 @""INTLLIBS""@ will go away.
1269 # DATADIRNAME is deprecated because we install only .gmo files nowadays,
1270 # which can be stored in the platform independent $prefix/share hierarchy.
1271 if grep '@''DATADIRNAME''@' "$srcdir/$file" >/dev/null 2>&1; then
1273 Please change $file to use the constant string \"share\" instead of
1274 @""DATADIRNAME""@. @""DATADIRNAME""@ will go away.
1277 # INSTOBJEXT is deprecated because we install only .gmo files nowadays,
1278 # no catgets .cat catalogs.
1279 if grep '@''INSTOBJEXT''@' "$srcdir/$file" >/dev/null 2>&1; then
1281 Please change $file to use the constant string \".mo\" instead of
1282 @""INSTOBJEXT""@. @""INSTOBJEXT""@ will go away.
1285 # GENCAT is deprecated because we install no catgets catalogs anymore.
1286 if grep '@''GENCAT''@' "$srcdir/$file" >/dev/null 2>&1; then
1288 Please change $file to use the constant string \"gencat\" instead of
1289 @""GENCAT""@. @""GENCAT""@ will go away. Maybe you don't even need it any more?
1292 # POSUB is deprecated because it causes "./configure --disable-nls", "make",
1293 # "make dist" to create a buggy tarfile.
1294 if grep '@''POSUB''@' "$srcdir/$file" >/dev/null 2>&1; then
1296 Please change $file to use the constant string \"po\" instead of
1297 @""POSUB""@. @""POSUB""@ will go away.
1303 # Recommend replacement for deprecated configure variables.
1304 if grep '\$nls_cv_header_' "$srcdir/$configure_in" >/dev/null 2>&1; then
1306 Please stop using \$nls_cv_header_intl or \$nls_cv_header_libgt in the
1307 $configure_in file. Both will go away. Use <libintl.h> or \"gettext.h\" instead.
1311 # Recommend fetching config.guess and config.sub.
1312 if test -f "$srcdir/$auxdir"config.guess && test -f "$srcdir/$auxdir"config.sub; then
1316 You will also need config.guess and config.sub, which you can get from the CVS
1317 of the 'config' project at http://savannah.gnu.org/. The commands to fetch them
1319 \$ wget 'http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess'
1320 \$ wget 'http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub'
1326 echo "You might also want to copy the convenience header file gettext.h"
1327 echo "from the $gettext_datadir directory into your package."
1328 echo "It is a wrapper around <libintl.h> that implements the configure --disable-nls"
1331 count=`echo "$please" | grep '^$' | wc -l`
1332 count=`echo "$count" | sed -e 's/[ ]//g'`
1334 1) count="paragraph";;
1335 2) count="two paragraphs";;
1336 3) count="three paragraphs";;
1337 4) count="four paragraphs";;
1338 5) count="five paragraphs";;
1339 *) count="$count paragraphs";;
1341 echo "Press Return to acknowledge the previous $count."
1342 # Read from /dev/tty, not stdin, so that gettextize cannot be abused by
1343 # non-interactive tools.
1344 read dummy < /dev/tty