#! /bin/sh -e

# DP: Set gettext's domain and textdomain to the versioned package name.

dir=
if [ $# -eq 3 -a "$2" = '-d' ]; then
    pdir="-d $3"
    dir="$3/"
elif [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi
case "$1" in
    -patch)
        patch $pdir -f --no-backup-if-mismatch -p0 < $0
        ;;
    -unpatch)
        patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
        ;;
    *)
        echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
        exit 1
esac
exit 0


Index: gcc/Makefile.in
===================================================================
*** gcc/Makefile.in.orig	2009-07-22 15:59:41.000000000 +0200
--- gcc/Makefile.in	2009-07-22 15:59:48.000000000 +0200
*************** install-po:
*** 4722,4729 ****
  	  dir=$(localedir)/$$lang/LC_MESSAGES; \
  	  echo $(mkinstalldirs) $(DESTDIR)$$dir; \
  	  $(mkinstalldirs) $(DESTDIR)$$dir || exit 1; \
! 	  echo $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/gcc.mo; \
! 	  $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/gcc.mo; \
  	done
  
  # Rule for regenerating the message template (gcc.pot).
--- 4722,4729 ----
  	  dir=$(localedir)/$$lang/LC_MESSAGES; \
  	  echo $(mkinstalldirs) $(DESTDIR)$$dir; \
  	  $(mkinstalldirs) $(DESTDIR)$$dir || exit 1; \
! 	  echo $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/gcc-4.5.mo; \
! 	  $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/gcc-4.5.mo; \
  	done
  
  # Rule for regenerating the message template (gcc.pot).
Index: gcc/intl.c
===================================================================
*** gcc/intl.c.orig	2009-05-05 14:09:52.000000000 +0200
--- gcc/intl.c	2009-07-22 15:59:48.000000000 +0200
*************** gcc_init_libintl (void)
*** 57,64 ****
    setlocale (LC_ALL, "");
  #endif
  
!   (void) bindtextdomain ("gcc", LOCALEDIR);
!   (void) textdomain ("gcc");
  
    /* Opening quotation mark.  */
    open_quote = _("`");
--- 57,64 ----
    setlocale (LC_ALL, "");
  #endif
  
!   (void) bindtextdomain ("gcc-4.5", LOCALEDIR);
!   (void) textdomain ("gcc-4.5");
  
    /* Opening quotation mark.  */
    open_quote = _("`");
Index: libcpp/Makefile.in
===================================================================
*** libcpp/Makefile.in.orig	2009-07-22 15:40:32.000000000 +0200
--- libcpp/Makefile.in	2009-07-22 16:00:51.000000000 +0200
*************** LDFLAGS = @LDFLAGS@
*** 49,54 ****
--- 49,55 ----
  LIBICONV = @LIBICONV@
  LIBINTL = @LIBINTL@
  PACKAGE = @PACKAGE@
+ PACKAGE_SUFFIX = -4.5
  RANLIB = @RANLIB@
  SHELL = @SHELL@
  USED_CATALOGS = @USED_CATALOGS@
*************** INCLUDES = -I$(srcdir) -I. -I$(srcdir)/.
*** 72,78 ****
--- 73,81 ----
  	-I$(srcdir)/include
  
  ALL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(INCLUDES) $(CPPFLAGS)
+ ALL_CFLAGS += -DPACKAGE_SUFFIX=\"$(strip $(PACKAGE_SUFFIX))\"
  ALL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(INCLUDES) $(CPPFLAGS)
+ ALL_CXXFLAGS += -DPACKAGE_SUFFIX=\"$(strip $(PACKAGE_SUFFIX))\"
  
  # The name of the compiler to use.
  ENABLE_BUILD_WITH_CXX = @ENABLE_BUILD_WITH_CXX@
*************** install-strip install: all installdirs
*** 168,175 ****
  	  else continue; \
  	  fi; \
  	  dir=$(localedir)/$$lang/LC_MESSAGES; \
! 	  echo $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(PACKAGE).mo; \
! 	  $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(PACKAGE).mo; \
  	done
  
  mostlyclean:
--- 171,178 ----
  	  else continue; \
  	  fi; \
  	  dir=$(localedir)/$$lang/LC_MESSAGES; \
! 	  echo $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(PACKAGE)$(PACKAGE_SUFFIX).mo; \
! 	  $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(PACKAGE)$(PACKAGE_SUFFIX).mo; \
  	done
  
  mostlyclean:
Index: libcpp/system.h
===================================================================
*** libcpp/system.h.orig	2009-04-29 17:24:05.000000000 +0200
--- libcpp/system.h	2009-07-22 15:59:48.000000000 +0200
*************** extern int errno;
*** 259,265 ****
  #endif
  
  #ifndef _
! # define _(msgid) dgettext (PACKAGE, msgid)
  #endif
  
  #ifndef N_
--- 259,265 ----
  #endif
  
  #ifndef _
! # define _(msgid) dgettext (PACKAGE PACKAGE_SUFFIX, msgid)
  #endif
  
  #ifndef N_
Index: libcpp/init.c
===================================================================
*** libcpp/init.c.orig	2009-07-02 15:37:27.000000000 +0200
--- libcpp/init.c	2009-07-22 15:59:48.000000000 +0200
*************** init_library (void)
*** 133,139 ****
        init_trigraph_map ();
  
  #ifdef ENABLE_NLS
!        (void) bindtextdomain (PACKAGE, LOCALEDIR);
  #endif
      }
  }
--- 133,139 ----
        init_trigraph_map ();
  
  #ifdef ENABLE_NLS
!        (void) bindtextdomain (PACKAGE PACKAGE_SUFFIX, LOCALEDIR);
  #endif
      }
  }
