#! /bin/sh -e

# DP: Allow transformations on info file names. Reference the
# DP: transformed info file names in the texinfo files.

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
        #cd ${dir}gcc && autoconf
        ;;
    -unpatch)
        patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
        #rm ${dir}gcc/configure
        ;;
    *)
        echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
        exit 1
esac
exit 0


gcc/ChangeLog:

2004-02-17  Matthias Klose  <doko@debian.org>

	* Makefile.in: Allow transformations on info file names.
	Define MAKEINFODEFS, macros to pass transformated info file
	names to makeinfo.
	* doc/cpp.texi: Use macros defined in MAKEINFODEFS for references.
	* doc/cppinternals.texi: Likewise.
	* doc/extend.texi: Likewise.
	* doc/gcc.texi: Likewise.
	* doc/gccint.texi: Likewise.
	* doc/invoke.texi: Likewise.
	* doc/libgcc.texi: Likewise.
	* doc/makefile.texi: Likewise.
	* doc/passes.texi: Likewise.
	* doc/sourcebuild.texi: Likewise.
	* doc/standards.texi: Likewise.
	* doc/trouble.texi: Likewise.

gcc/f/ChangeLog:
	* Make-lang.in: Allow transformations on info file names.
	Pass macros of transformated info file defined in MAKEINFODEFS
	names to makeinfo.
	* g77.texi: Use macros defined in MAKEINFODEFS for references.

gcc/java/ChangeLog:
	* Make-lang.in: Allow transformations on info file names.
	Pass macros of transformated info file defined in MAKEINFODEFS
	names to makeinfo.
	* gcj.texi: Use macros defined in MAKEINFODEFS for references.

gcc/treelang/ChangeLog:
	* Make-lang.in: Allow transformations on info file names.
	Pass macros of transformated info file defined in MAKEINFODEFS
	names to makeinfo.
	Define TREELANG_MAKEINFODEFS macros to pass transformated info file
	names to makeinfo.
	* treelang.texi: Use macros defined in MAKEINFO_DEFS for references.


diff -ur gcc.old/Makefile.in gcc/Makefile.in
--- gcc.old/Makefile.in	2004-02-06 08:03:12.000000000 +0100
+++ gcc/Makefile.in	2004-02-21 13:28:52.000000000 +0100
@@ -2615,8 +2615,24 @@
 
 doc: $(BUILD_INFO) $(GENERATED_MANPAGES) gccbug
 
-INFOFILES = doc/cpp.info doc/gcc.info doc/gccint.info \
-            doc/gccinstall.info doc/cppinternals.info
+INFO_CPP_NAME = $(shell echo cpp|sed '$(program_transform_name)')
+INFO_GCC_NAME = $(shell echo gcc|sed '$(program_transform_name)')
+INFO_GCCINT_NAME = $(shell echo gccint|sed '$(program_transform_name)')
+INFO_GCCINSTALL_NAME = $(shell echo gccinstall|sed '$(program_transform_name)')
+INFO_CPPINT_NAME = $(shell echo cppinternals|sed '$(program_transform_name)')
+
+INFO_G77_NAME = $(shell echo g77|sed '$(program_transform_name)')
+INFO_GCJ_NAME = $(shell echo gcj|sed '$(program_transform_name)')
+
+INFOFILES = doc/$(INFO_CPP_NAME).info doc/$(INFO_GCC_NAME).info \
+            doc/$(INFO_GCCINT_NAME).info \
+            doc/$(INFO_GCCINSTALL_NAME).info doc/$(INFO_CPPINT_NAME).info
+
+MAKEINFODEFS = -D 'fncpp $(INFO_CPP_NAME)' -D 'fngcc $(INFO_GCC_NAME)' \
+               -D 'fngccint $(INFO_GCCINT_NAME)' \
+               -D 'fngccinstall $(INFO_GCCINSTALL_NAME)' \
+               -D 'fncppint $(INFO_CPPINT_NAME)' \
+               -D 'fng77 $(INFO_G77_NAME)' -D 'fngcj $(INFO_GCJ_NAME)'
 
 info: $(INFOFILES) lang.info @GENINSRC@ srcinfo lang.srcinfo
 
@@ -2645,21 +2661,40 @@
 # patterns.   To use them, put each of the specific target with with their 
 # specific dependencies but no build commands.
 
-doc/cpp.info: $(TEXI_CPP_FILES)
-doc/gcc.info: $(TEXI_GCC_FILES)
-doc/gccint.info: $(TEXI_GCCINT_FILES)
-doc/cppinternals.info: $(TEXI_CPPINT_FILES)
-
+# Generic entry to handle info files, which are not renamed (currently Ada)
 doc/%.info: %.texi
 	if [ x$(BUILD_INFO) = xinfo ]; then \
 		$(MAKEINFO) $(MAKEINFOFLAGS) -I $(docdir) \
 			-I $(docdir)/include -o $@ $<; \
 	fi
 
-# Duplicate entry to handle renaming of gccinstall.info
-doc/gccinstall.info: $(TEXI_GCCINSTALL_FILES)
+doc/$(INFO_CPP_NAME).info: $(TEXI_CPP_FILES)
 	if [ x$(BUILD_INFO) = xinfo ]; then \
-		$(MAKEINFO) $(MAKEINFOFLAGS) -I $(docdir) \
+		$(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) -I $(docdir) \
+			-I $(docdir)/include -o $@ $<; \
+	fi
+
+doc/$(INFO_GCC_NAME).info: $(TEXI_GCC_FILES)
+	if [ x$(BUILD_INFO) = xinfo ]; then \
+		$(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) -I $(docdir) \
+			-I $(docdir)/include -o $@ $<; \
+	fi
+
+doc/$(INFO_GCCINT_NAME).info: $(TEXI_GCCINT_FILES)
+	if [ x$(BUILD_INFO) = xinfo ]; then \
+		$(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) -I $(docdir) \
+			-I $(docdir)/include -o $@ $<; \
+	fi
+
+doc/$(INFO_CPPINT_NAME).info: $(TEXI_CPPINT_FILES)
+	if [ x$(BUILD_INFO) = xinfo ]; then \
+		$(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) -I $(docdir) \
+			-I $(docdir)/include -o $@ $<; \
+	fi
+
+doc/$(INFO_GCCINSTALL_NAME).info: $(TEXI_GCCINSTALL_FILES)
+	if [ x$(BUILD_INFO) = xinfo ]; then \
+		$(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) -I $(docdir) \
 			-I $(docdir)/include -o $@ $<; \
 	fi
 
@@ -2935,11 +2970,11 @@
 # $(INSTALL_DATA) might be a relative pathname, so we can't cd into srcdir
 # to do the install.
 install-info:: doc installdirs \
-	$(DESTDIR)$(infodir)/cpp.info \
-	$(DESTDIR)$(infodir)/gcc.info \
-	$(DESTDIR)$(infodir)/cppinternals.info \
-	$(DESTDIR)$(infodir)/gccinstall.info \
-	$(DESTDIR)$(infodir)/gccint.info
+	$(DESTDIR)$(infodir)/$(INFO_CPP_NAME).info \
+	$(DESTDIR)$(infodir)/$(INFO_GCC_NAME).info \
+	$(DESTDIR)$(infodir)/$(INFO_CPPINT_NAME).info \
+	$(DESTDIR)$(infodir)/$(INFO_GCCINSTALL_NAME).info \
+	$(DESTDIR)$(infodir)/$(INFO_GCCINT_NAME).info
 
 $(DESTDIR)$(infodir)/%.info: doc/%.info installdirs
 	rm -f $@
@@ -3107,8 +3142,11 @@
 	-rm -rf $(DESTDIR)$(man1dir)/cpp$(man1ext)
 	-rm -rf $(DESTDIR)$(man1dir)/protoize$(man1ext)
 	-rm -rf $(DESTDIR)$(man1dir)/unprotoize$(man1ext)
-	-rm -f $(DESTDIR)$(infodir)/cpp.info* $(DESTDIR)$(infodir)/gcc.info*
-	-rm -f $(DESTDIR)$(infodir)/cppinternals.info* $(DESTDIR)$(infodir)/gccint.info*
+	-rm -f $(DESTDIR)$(infodir)/$(INFO_CPP_NAME).info*
+	-rm -f $(DESTDIR)$(infodir)/$(INFO_GCC_NAME).info*
+	-rm -f $(DESTDIR)$(infodir)/$(INFO_CPPINT_NAME).info*
+	-rm -f $(DESTDIR)$(infodir)/$(INFO_GCCINT_NAME).info*
+	-rm -f $(DESTDIR)$(infodir)/$(INFO_GCCINSTALL_NAME).info*
 #
 # These targets are for the dejagnu testsuites. The file site.exp
 # contains global variables that all the testsuites will use.
diff -ur gcc.old/doc/cpp.texi gcc/doc/cpp.texi
--- gcc.old/doc/cpp.texi	2004-01-18 23:43:09.000000000 +0100
+++ gcc/doc/cpp.texi	2004-02-21 13:28:52.000000000 +0100
@@ -54,7 +54,7 @@
 @ifinfo
 @dircategory Programming
 @direntry
-* Cpp: (cpp).		       The GNU C preprocessor.
+* @value{fncpp}: (@value{fncpp}).		       The GNU C preprocessor.
 @end direntry
 @end ifinfo
 
diff -ur gcc.old/doc/cppinternals.texi gcc/doc/cppinternals.texi
--- gcc.old/doc/cppinternals.texi	2002-03-02 00:38:51.000000000 +0100
+++ gcc/doc/cppinternals.texi	2004-02-21 13:28:52.000000000 +0100
@@ -5,7 +5,7 @@
 @ifinfo
 @dircategory Programming
 @direntry
-* Cpplib: (cppinternals).      Cpplib internals.
+* @value{fncppint}: (@value{fncppint}).      Cpplib internals.
 @end direntry
 @end ifinfo
 
diff -ur gcc.old/doc/extend.texi gcc/doc/extend.texi
--- gcc.old/doc/extend.texi	2004-01-22 00:41:23.000000000 +0100
+++ gcc/doc/extend.texi	2004-02-21 13:28:52.000000000 +0100
@@ -7671,7 +7671,7 @@
 test for the GNU compiler the same way as for C programs: check for a
 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
-Predefined Macros,cpp,The GNU C Preprocessor}).
+Predefined Macros,@value{fncpp},The GNU C Preprocessor}).
 
 @menu
 * Min and Max::		C++ Minimum and maximum operators.
diff -ur gcc.old/doc/gcc.texi gcc/doc/gcc.texi
--- gcc.old/doc/gcc.texi	2004-01-02 12:27:45.000000000 +0100
+++ gcc/doc/gcc.texi	2004-02-21 13:28:52.000000000 +0100
@@ -79,7 +79,7 @@
 @ifnottex
 @dircategory Programming
 @direntry
-* gcc: (gcc).                  The GNU Compiler Collection.
+* @value{fngcc}: (@value{fngcc}).                  The GNU Compiler Collection.
 @end direntry
 This file documents the use of the GNU compilers.
 @sp 1
@@ -131,7 +131,7 @@
 The internals of the GNU compilers, including how to port them to new
 targets and some information about how to write front ends for new
 languages, are documented in a separate manual.  @xref{Top,,
-Introduction, gccint, GNU Compiler Collection (GCC) Internals}.
+Introduction, @value{fngccint}, GNU Compiler Collection (GCC) Internals}.
 
 @menu
 * G++ and GCC::     You can compile C or C++ programs.
diff -ur gcc.old/doc/gccint.texi gcc/doc/gccint.texi
--- gcc.old/doc/gccint.texi	2004-01-02 12:27:45.000000000 +0100
+++ gcc/doc/gccint.texi	2004-02-21 13:28:52.000000000 +0100
@@ -65,7 +65,7 @@
 @ifnottex
 @dircategory Programming
 @direntry
-* gccint: (gccint).            Internals of the GNU Compiler Collection.
+* @value{fngccint}: (@value{fngccint}).            Internals of the GNU Compiler Collection.
 @end direntry
 This file documents the internals of the GNU compilers.
 @sp 1
@@ -114,7 +114,7 @@
 how to port them to new targets and some information about how to
 write front ends for new languages.  It corresponds to GCC version
 @value{version-GCC}.  The use of the GNU compilers is documented in a
-separate manual.  @xref{Top,, Introduction, gcc, Using the GNU
+separate manual.  @xref{Top,, Introduction, @value{fngcc}, Using the GNU
 Compiler Collection (GCC)}.
 
 This manual is mainly a reference manual rather than a tutorial.  It
diff -ur gcc.old/doc/invoke.texi gcc/doc/invoke.texi
--- gcc.old/doc/invoke.texi	2004-02-18 09:17:23.000000000 +0100
+++ gcc/doc/invoke.texi	2004-02-21 13:28:52.000000000 +0100
@@ -763,7 +763,7 @@
 Fortran source code which must be preprocessed with a RATFOR
 preprocessor (not included with GCC)@.
 
-@xref{Overall Options,,Options Controlling the Kind of Output, g77,
+@xref{Overall Options,,Options Controlling the Kind of Output, @value{fng77},
 Using and Porting GNU Fortran}, for more details of the handling of
 Fortran input files.
 
@@ -5045,7 +5045,7 @@
 @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
 that GCC uses to overcome shortcomings of particular machines, or special
 needs for some languages.
-(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
+(@xref{Interface,,Interfacing to GCC Output,@value{fngccint},GNU Compiler
 Collection (GCC) Internals},
 for more discussion of @file{libgcc.a}.)
 In most cases, you need @file{libgcc.a} even when you want to avoid
@@ -5053,7 +5053,7 @@
 or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
 This ensures that you have no unresolved references to internal GCC
 library subroutines.  (For example, @samp{__main}, used to ensure C++
-constructors will be called; @pxref{Collect2,,@code{collect2}, gccint,
+constructors will be called; @pxref{Collect2,,@code{collect2}, @value{fngccint},
 GNU Compiler Collection (GCC) Internals}.)
 
 @item -pie
@@ -11211,7 +11211,7 @@
 @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}).  These
 take precedence over places specified using environment variables, which
 in turn take precedence over those specified by the configuration of GCC@.
-@xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
+@xref{Driver,, Controlling the Compilation Driver @file{gcc}, @value{fngccint},
 GNU Compiler Collection (GCC) Internals}.
 
 @table @env
@@ -11363,7 +11363,7 @@
 
 A precompiled header file will be searched for when @code{#include} is
 seen in the compilation.  As it searches for the included file
-(@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
+(@pxref{Search Path,,Search Path,@value{fncpp},The C Preprocessor}) the
 compiler looks for a precompiled header in each directory just before it
 looks for the include file in that directory.  The name searched for is
 the name specified in the @code{#include} with @samp{.gch} appended.  If
diff -ur gcc.old/doc/libgcc.texi gcc/doc/libgcc.texi
--- gcc.old/doc/libgcc.texi	2004-01-18 23:43:10.000000000 +0100
+++ gcc/doc/libgcc.texi	2004-02-21 13:28:52.000000000 +0100
@@ -24,7 +24,7 @@
 GCC will also generate calls to C library routines, such as
 @code{memcpy} and @code{memset}, in some cases.  The set of routines
 that GCC may possibly use is documented in @ref{Other
-Builtins,,,gcc, Using the GNU Compiler Collection (GCC)}.
+Builtins,,,@value{fngcc}, Using the GNU Compiler Collection (GCC)}.
 
 These routines take arguments and return values of a specific machine
 mode, not a specific C type.  @xref{Machine Modes}, for an explanation
diff -ur gcc.old/doc/makefile.texi gcc/doc/makefile.texi
--- gcc.old/doc/makefile.texi	2004-02-08 09:09:36.000000000 +0100
+++ gcc/doc/makefile.texi	2004-02-21 13:28:52.000000000 +0100
@@ -121,7 +121,7 @@
 @item profiledbootstrap
 Builds a compiler with profiling feedback information.  For more
 information, see
-@ref{Building,,Building with profile feedback,gccinstall,Installing GCC}.
+@ref{Building,,Building with profile feedback,@value{fngccinstall},Installing GCC}.
 This is actually a target in the top-level directory, which then
 recurses into the @file{gcc} subdirectory multiple times.
 
diff -ur gcc.old/doc/passes.texi gcc/doc/passes.texi
--- gcc.old/doc/passes.texi	2003-11-24 00:52:07.000000000 +0100
+++ gcc/doc/passes.texi	2004-02-21 13:28:52.000000000 +0100
@@ -45,7 +45,7 @@
 definition's compilation is entirely freed, unless it is an inline
 function, or was deferred for some reason (this can occur in
 templates, for example).
-(@pxref{Inline,,An Inline Function is As Fast As a Macro,gcc,Using the
+(@pxref{Inline,,An Inline Function is As Fast As a Macro,@value{fngcc},Using the
 GNU Compiler Collection (GCC)}).
 
 Here is a list of all the passes of the compiler and their source files.
@@ -74,7 +74,7 @@
 C preprocessing, for language front ends, that want or require it, is
 performed by cpplib, which is covered in separate documentation.  In
 particular, the internals are covered in @xref{Top, ,Cpplib internals,
-cppinternals, Cpplib Internals}.
+@value{fncppinternals}, Cpplib Internals}.
 
 The source files to parse C are found in the toplevel directory, and
 by convention are named @file{c-*}.  Some of these are also used by
diff -ur gcc.old/doc/standards.texi gcc/doc/standards.texi
--- gcc.old/doc/standards.texi	2004-01-18 23:43:10.000000000 +0100
+++ gcc/doc/standards.texi	2004-02-21 13:28:52.000000000 +0100
@@ -185,8 +185,8 @@
 GNAT Reference Manual}, for information on standard
 conformance and compatibility of the Ada compiler.
 
-@xref{Language,,The GNU Fortran Language, g77, Using and Porting GNU
+@xref{Language,,The GNU Fortran Language, @value{fng77}, Using and Porting GNU
 Fortran}, for details of the Fortran language supported by GCC@.
 
-@xref{Compatibility,,Compatibility with the Java Platform, gcj, GNU gcj},
+@xref{Compatibility,,Compatibility with the Java Platform, @value{fngcj}, GNU gcj},
 for details of compatibility between @command{gcj} and the Java Platform.
diff -ur gcc.old/doc/trouble.texi gcc/doc/trouble.texi
--- gcc.old/doc/trouble.texi	2004-02-04 22:12:40.000000000 +0100
+++ gcc/doc/trouble.texi	2004-02-21 13:28:52.000000000 +0100
@@ -88,7 +88,7 @@
 as @code{REAL_VALUE_TYPE}.  But doing so is a substantial amount of
 work for each target machine.
 @xref{Cross-compilation,,Cross Compilation and Floating Point,
-gccint, GNU Compiler Collection (GCC) Internals}.
+@value{fngccint}, GNU Compiler Collection (GCC) Internals}.
 
 @item
 At present, the program @file{mips-tfile} which adds debug
diff -ur gcc.old/f/Make-lang.in gcc/f/Make-lang.in
--- gcc.old/f/Make-lang.in	2004-02-20 11:53:17.000000000 +0100
+++ gcc/f/Make-lang.in	2004-02-21 13:28:52.000000000 +0100
@@ -153,7 +153,8 @@
 	cd $(srcdir)/f; etags -o TAGS.sub *.c *.h; \
 	etags --include TAGS.sub --include ../TAGS.sub
 
-f77.info: doc/g77.info
+INFO_G77_NAME = $(shell echo g77|sed '$(program_transform_name)')
+f77.info: doc/$(INFO_G77_NAME).info
 dvi:: doc/g77.dvi
 f77.man: doc/g77.1
 
@@ -166,10 +167,10 @@
 		 $(docdir)/include/gpl.texi $(docdir)/include/funding.texi \
 		 $(docdir)/include/gcc-common.texi $(srcdir)/f/intdoc.texi
 
-doc/g77.info: $(TEXI_G77_FILES)
+doc/$(INFO_G77_NAME).info: $(TEXI_G77_FILES)
 	if test "x$(BUILD_INFO)" = xinfo; then \
 	  rm -f $(@)*; \
-	  $(MAKEINFO) $(MAKEINFOFLAGS) -I$(docdir)/include -I$(srcdir)/f \
+	  $(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) -I$(docdir)/include -I$(srcdir)/f \
             -o$@ $<; \
 	else true; fi
 
@@ -264,7 +265,7 @@
 	  echo ''; \
 	else true; fi
 
-install-info:: $(DESTDIR)$(infodir)/g77.info
+install-info:: $(DESTDIR)$(infodir)/$(INFO_G77_NAME).info
 
 f77.install-man: installdirs $(DESTDIR)$(man1dir)/$(G77_INSTALL_NAME)$(man1ext)
 
@@ -280,7 +281,7 @@
 	else : ; fi
 	rm -rf $(DESTDIR)$(bindir)/$(G77_INSTALL_NAME)$(exeext); \
 	rm -rf $(DESTDIR)$(man1dir)/$(G77_INSTALL_NAME)$(man1ext); \
-	rm -rf $(DESTDIR)$(infodir)/g77.info*
+	rm -f $(DESTDIR)$(infodir)/$(INFO_G77_NAME).info*
 #
 # Clean hooks:
 # A lot of the ancillary files are deleted by the main makefile.
diff -ur gcc.old/java/Make-lang.in gcc/java/Make-lang.in
--- gcc.old/java/Make-lang.in	2004-02-06 08:04:13.000000000 +0100
+++ gcc/java/Make-lang.in	2004-02-21 13:28:52.000000000 +0100
@@ -158,12 +158,23 @@
 	  --regex='/DEFTREECODE [(]\([A-Z_]+\)/\1/' java-tree.def; \
 	etags --include TAGS.sub --include ../TAGS.sub
 
+TEXI_GCJ_FILES = java/gcj.texi \
+		 $(docdir)/include/gpl.texi $(docdir)/include/funding.texi \
+		 $(docdir)/include/fdl.texi $(docdir)/include/gcc-common.texi
+INFO_GCJ_NAME = $(shell echo gcj|sed '$(program_transform_name)')
 
-java.info: doc/gcj.info
+java.info: doc/$(INFO_GCJ_NAME).info
 
-java.srcinfo: doc/gcj.info
+java.srcinfo: doc/$(INFO_GCJ_NAME).info
 	-cp -p $^ $(srcdir)/doc
 
+doc/$(INFO_GCJ_NAME).info: $(TEXI_GCJ_FILES)
+	if test "x$(BUILD_INFO)" = xinfo; then \
+	  rm -f $(@)*; \
+	  $(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) \
+	    -I$(docdir)/include -I$(srcdir)/f -o$@ $<; \
+	else true; fi
+
 dvi:: doc/gcj.dvi
 JAVA_MANFILES = doc/gcj.1 doc/gcjh.1 doc/jv-scan.1 doc/jcf-dump.1 doc/gij.1 \
                 doc/jv-convert.1 doc/rmic.1 doc/rmiregistry.1
@@ -224,8 +235,9 @@
 	-rm -rf $(DESTDIR)$(man1dir)/jcf-dump$(man1ext)
 	-rm -rf $(DESTDIR)$(man1dir)/gij$(man1ext)
 	-rm -rf $(DESTDIR)$(man1dir)/jv-convert$(man1ext)
+	-rm -f $(DESTDIR)$(infodir)/$(INFO_GCJ_NAME).info*
 
-install-info:: $(DESTDIR)$(infodir)/gcj.info
+install-info:: $(DESTDIR)$(infodir)/$(INFO_GCJ_NAME).info
 
 #
 # Clean hooks:
diff -ur gcc.old/java/gcj.texi gcc/java/gcj.texi
--- gcc.old/java/gcj.texi	2003-08-29 23:25:30.000000000 +0200
+++ gcc/java/gcj.texi	2004-02-21 13:28:52.000000000 +0100
@@ -52,7 +52,7 @@
 @format
 @dircategory Programming
 @direntry
-* Gcj: (gcj).               Ahead-of-time compiler for the Java language
+* @value{fngcj}: (@value{fngcj}).               Ahead-of-time compiler for the Java language
 @end direntry
 
 @dircategory Individual utilities
@@ -151,7 +151,7 @@
 
 As @command{gcj} is just another front end to @command{gcc}, it supports many
 of the same options as gcc.  @xref{Option Summary, , Option Summary,
-gcc, Using the GNU Compiler Collection (GCC)}.  This manual only documents the
+@value{fngcc}, Using the GNU Compiler Collection (GCC)}.  This manual only documents the
 options specific to @command{gcj}.
 
 @c man end
diff -ur gcc.old/treelang/Make-lang.in gcc/treelang/Make-lang.in
--- gcc.old/treelang/Make-lang.in	2004-01-31 07:53:34.000000000 +0100
+++ gcc/treelang/Make-lang.in	2004-02-21 13:28:52.000000000 +0100
@@ -146,17 +146,21 @@
 	cd $(srcdir)/treelang; etags -o TAGS.sub *.y *.l *.c *.h; \
 	etags --include TAGS.sub --include ../TAGS.sub
 
-treelang.info: doc/treelang.info
+INFO_TREELANG_NAME = $(shell echo treelang|sed '$(program_transform_name)')
+TREELANG_MAKEINFODEFS = -D 'fntreelang $(INFO_TREELANG_NAME)'
 
-treelang.srcinfo: doc/treelang.info
+treelang.info: doc/$(INFO_TREELANG_NAME).info
+
+treelang.srcinfo: doc/$(INFO_TREELANG_NAME).info
 	-cp -p $^ $(srcdir)/doc
 
 dvi:: doc/treelang.dvi
 
-doc/treelang.info: treelang/treelang.texi $(docdir)/include/gcc-common.texi \
+doc/$(INFO_TREELANG_NAME).info: treelang/treelang.texi $(docdir)/include/gcc-common.texi \
 	 $(docdir)/include/gpl.texi $(docdir)/include/fdl.texi \
 	 $(docdir)/include/funding.texi
-	$(MAKEINFO) $(MAKEINFOFLAGS) -I$(docdir)/include -o $@ $<
+	$(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) \
+		$(TREELANG_MAKEINFODEFS) -I$(docdir)/include -o $@ $<
 
 doc/treelang.dvi: treelang/treelang.texi $(docdir)/include/gcc-common.texi \
 	 $(docdir)/include/gpl.texi $(docdir)/include/fdl.texi \
@@ -189,7 +193,7 @@
 	$(STAMP) treelang.install.common.done
 
 # We might not be able to build the info files
-install-info:: $(DESTDIR)$(infodir)/treelang.info
+install-info:: $(DESTDIR)$(infodir)/$(INFO_TREELANG_NAME).info
 
 treelang.install-man:
 
@@ -202,6 +206,7 @@
 	  echo -rm -rf $(DESTDIR)$(bindir)/$$name2$(exeext); \
 	  rm -rf $(DESTDIR)$(bindir)/$$name2$(exeext); \
 	done
+	-rm -f $(DESTDIR)$(infodir)/$(INFO_TREELANG_NAME).info*
 	-rm treelang.install.common.done
 
 #
diff -ur gcc.old/treelang/treelang.texi gcc/treelang/treelang.texi
--- gcc.old/treelang/treelang.texi	2003-12-06 00:15:02.000000000 +0100
+++ gcc/treelang/treelang.texi	2004-02-21 13:28:52.000000000 +0100
@@ -106,7 +106,7 @@
 @ifnottex
 @dircategory Programming
 @direntry
-* treelang: (treelang).                  The GNU Treelang compiler.
+* @value{fntreelang}: (@value{fntreelang}).                  The GNU Treelang compiler.
 @end direntry
 @ifset INTERNALS
 @ifset USING
@@ -278,7 +278,7 @@
 @item
 The packaging and compiler portions of GNU Treelang are based largely
 on the GCC compiler.
-@xref{Contributors,,Contributors to GCC,GCC,Using and Maintaining GCC},
+@xref{Contributors,,Contributors to GCC,@value{fngcc},Using and Maintaining GCC},
 for more information.
 
 @item
@@ -885,7 +885,7 @@
 command-line options that are designed to cater to Treelang users
 but apply to other languages as well.
 
-@xref{G++ and GCC,,Programming Languages Supported by GCC,GCC,Using
+@xref{G++ and GCC,,Programming Languages Supported by GCC,@value{fngcc},Using
 the GNU Compiler Collection (GCC)},
 for information on the way different languages are handled
 by the GCC compiler (@code{gcc}).
diff -ur gcc.old/f/g77.texi gcc/f/g77.texi
--- gcc.old/f/g77.texi	2003-05-16 17:08:37.000000000 +0200
+++ gcc/f/g77.texi	2004-02-28 16:04:22.000000000 +0100
@@ -88,7 +88,7 @@
 @ifinfo
 @dircategory Programming
 @direntry
-* g77: (g77).                  The GNU Fortran compiler.
+* * @value{fng77}: (@value{fng77}).          The GNU Fortran compiler.
 @end direntry
 @ifset INTERNALS
 @ifset USING
