Patchwork [PLUGIN] compile and install gengtype, install gtype.state

login
register
mail settings
Submitter Romain Geissler
Date July 26, 2011, 4:42 p.m.
Message ID <CAF+LTefAJy7Qm9+03q3hzNcaJL6JiOG5C1xEf4AzbK0LGeak=g@mail.gmail.com>
Download mbox | patch
Permalink /patch/106893/
State New
Headers show

Comments

Romain Geissler - July 26, 2011, 4:42 p.m.
2011/7/25 Jakub Jelinek <jakub@redhat.com>:
> On Mon, Jul 25, 2011 at 09:10:55PM +0200, Romain Geissler wrote:
>> > 2011-07-18  Romain Geissler  <romain.geissler@gmail.com>
>> >
>> >     * gengtype-state.c (#include "bconfig.h"): Include "bconfig.h"
>> >     if GENERATOR_FILE is defined, "config.h" otherwise.
>
> Still not right, this should have been
>        * gengtype-state.c: Include "bconfig.h" if GENERATOR_FILE is
>        define, "config.h" otherwise.
>
>> >     * gengtype.c: Likewise.
>> >     * gengtype-lex.l: Likewise.
>> >     * gengtype-parse.c: Likewise.
>
>> >     * Makefile.in (gengtype): Compile and install for host when
>> >     $enable_plugins is set to "yes".
>> >     (gtype.state): Install when $enable_plugins is set to "yes".
>
> And this should list all the Makefile.in goals you've changed, added etc.
>
> Ok with those changes.
>
>        Jakub
>

Is it OK with this changelog ? If yes, can someone apply the patch,
as i don't have write access.

Romain Geissler.

2011-07-18  Romain Geissler  <romain.geissler@gmail.com>

	* gengtype-state.c: Include "bconfig.h" if
	GENERATOR_FILE is defined, "config.h" otherwise.
	* gengtype.c: Likewise.
	* gengtype-lex.l: Likewise.
	* gengtype-parse.c: Likewise.
	* Makefile.in (gengtype-lex.o-warn): New variable.
	(plugindir): Likewise.
	(plugin_bindir): Likewise.
	(plugin_includedir): Use $(plugindir) as prefix base.
	(MOSTLYCLEANFILES): Add gengtype$(exeext).
	(native): Depend on gengtype$(exeext) is $enable_plugin
	is set to "yes".
	(gtype.state): Depend on s-gtype. Use temporary file.
	(gengtype-lex.o): New rule.
	(gengtype-parse.o): Likewise.
	(gengtype-state.o): Likewise.
	(gengtype$(exeext)): Likewise.
	(install-gengtype): Likewise.
	(gengtype.o): Likewise.
	(build/gengtype.o): Depend on version.h.
	(build/gengtype-state): Depend on double-int.h, version.h,
	$(HASHTAB_H), $(OBSTACK_H), $(XREGEX_H) and build/errors.o.
	(install-plugin): Depend on install-gengtype.


build/gen%.o $(BUILD_LIBDEPS)
@@ -4641,8 +4664,15 @@ s-header-vars: Makefile
 	$(SHELL) $(srcdir)/../move-if-change tmp-header-vars b-header-vars
 	$(STAMP) s-header-vars

+# Install gengtype
+install-gengtype: installdirs gengtype$(exeext) gtype.state
+	$(mkinstalldirs) $(DESTDIR)$(plugindir)
+	$(INSTALL_DATA) gtype.state $(DESTDIR)$(plugindir)/gtype.state
+	$(mkinstalldirs) $(DESTDIR)$(plugin_bindir)
+	$(INSTALL_PROGRAM) gengtype$(exeext)
$(DESTDIR)$(plugin_bindir)/gengtype$(exeext)
+
 # Install the headers needed to build a plugin.
-install-plugin: installdirs lang.install-plugin s-header-vars
+install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype
 # We keep the directory structure for files in config and .def files. All
 # other files are flattened to a single directory.
 	$(mkinstalldirs) $(DESTDIR)$(plugin_includedir)
Romain Geissler - Aug. 1, 2011, 12:27 p.m.
ping

2011/7/26 Romain Geissler <romain.geissler@gmail.com>:
> 2011/7/25 Jakub Jelinek <jakub@redhat.com>:
>> On Mon, Jul 25, 2011 at 09:10:55PM +0200, Romain Geissler wrote:
>>> > 2011-07-18  Romain Geissler  <romain.geissler@gmail.com>
>>> >
>>> >     * gengtype-state.c (#include "bconfig.h"): Include "bconfig.h"
>>> >     if GENERATOR_FILE is defined, "config.h" otherwise.
>>
>> Still not right, this should have been
>>        * gengtype-state.c: Include "bconfig.h" if GENERATOR_FILE is
>>        define, "config.h" otherwise.
>>
>>> >     * gengtype.c: Likewise.
>>> >     * gengtype-lex.l: Likewise.
>>> >     * gengtype-parse.c: Likewise.
>>
>>> >     * Makefile.in (gengtype): Compile and install for host when
>>> >     $enable_plugins is set to "yes".
>>> >     (gtype.state): Install when $enable_plugins is set to "yes".
>>
>> And this should list all the Makefile.in goals you've changed, added etc.
>>
>> Ok with those changes.
>>
>>        Jakub
>>
>
> Is it OK with this changelog ? If yes, can someone apply the patch,
> as i don't have write access.
>
> Romain Geissler.
>
> 2011-07-18  Romain Geissler  <romain.geissler@gmail.com>
>
>        * gengtype-state.c: Include "bconfig.h" if
>        GENERATOR_FILE is defined, "config.h" otherwise.
>        * gengtype.c: Likewise.
>        * gengtype-lex.l: Likewise.
>        * gengtype-parse.c: Likewise.
>        * Makefile.in (gengtype-lex.o-warn): New variable.
>        (plugindir): Likewise.
>        (plugin_bindir): Likewise.
>        (plugin_includedir): Use $(plugindir) as prefix base.
>        (MOSTLYCLEANFILES): Add gengtype$(exeext).
>        (native): Depend on gengtype$(exeext) is $enable_plugin
>        is set to "yes".
>        (gtype.state): Depend on s-gtype. Use temporary file.
>        (gengtype-lex.o): New rule.
>        (gengtype-parse.o): Likewise.
>        (gengtype-state.o): Likewise.
>        (gengtype$(exeext)): Likewise.
>        (install-gengtype): Likewise.
>        (gengtype.o): Likewise.
>        (build/gengtype.o): Depend on version.h.
>        (build/gengtype-state): Depend on double-int.h, version.h,
>        $(HASHTAB_H), $(OBSTACK_H), $(XREGEX_H) and build/errors.o.
>        (install-plugin): Depend on install-gengtype.
>
>
> Index: gcc/gengtype-state.c
> ===================================================================
> --- gcc/gengtype-state.c        (revision 175907)
> +++ gcc/gengtype-state.c        (working copy)
> @@ -23,7 +23,11 @@
>    and Basile Starynkevitch <basile@starynkevitch.net>
>  */
>
> +#ifdef GENERATOR_FILE
>  #include "bconfig.h"
> +#else
> +#include "config.h"
> +#endif
>  #include "system.h"
>  #include "errors.h"    /* For fatal.  */
>  #include "double-int.h"
> Index: gcc/gengtype.c
> ===================================================================
> --- gcc/gengtype.c      (revision 175907)
> +++ gcc/gengtype.c      (working copy)
> @@ -18,7 +18,11 @@
>    along with GCC; see the file COPYING3.  If not see
>    <http://www.gnu.org/licenses/>.  */
>
> +#ifdef GENERATOR_FILE
>  #include "bconfig.h"
> +#else
> +#include "config.h"
> +#endif
>  #include "system.h"
>  #include "errors.h"            /* for fatal */
>  #include "getopt.h"
> Index: gcc/gengtype-lex.l
> ===================================================================
> --- gcc/gengtype-lex.l  (revision 175907)
> +++ gcc/gengtype-lex.l  (working copy)
> @@ -22,7 +22,11 @@ along with GCC; see the file COPYING3.
>  %option noinput
>
>  %{
> +#ifdef GENERATOR_FILE
>  #include "bconfig.h"
> +#else
> +#include "config.h"
> +#endif
>  #include "system.h"
>
>  #define malloc xmalloc
> Index: gcc/gengtype-parse.c
> ===================================================================
> --- gcc/gengtype-parse.c        (revision 175907)
> +++ gcc/gengtype-parse.c        (working copy)
> @@ -17,7 +17,11 @@
>    along with GCC; see the file COPYING3.  If not see
>    <http://www.gnu.org/licenses/>.  */
>
> +#ifdef GENERATOR_FILE
>  #include "bconfig.h"
> +#else
> +#include "config.h"
> +#endif
>  #include "system.h"
>  #include "gengtype.h"
>
> Index: gcc/Makefile.in
> ===================================================================
> --- gcc/Makefile.in     (revision 175907)
> +++ gcc/Makefile.in     (working copy)
> @@ -192,6 +192,7 @@ GCC_WARN_CXXFLAGS = $(LOOSE_WARN) $($(@D
>  # be subject to -Werror:
>  # flex output may yield harmless "no previous prototype" warnings
>  build/gengtype-lex.o-warn = -Wno-error
> +gengtype-lex.o-warn = -Wno-error
>  # mips-tfile.c contains -Wcast-qual warnings.
>  mips-tfile.o-warn = -Wno-error
>  expmed.o-warn = -Wno-error
> @@ -566,8 +567,12 @@ libexecdir = @libexecdir@
>  libsubdir = $(libdir)/gcc/$(target_noncanonical)/$(version)
>  # Directory in which the compiler finds executables
>  libexecsubdir = $(libexecdir)/gcc/$(target_noncanonical)/$(version)
> -# Directory in which plugin headers are installed
> -plugin_includedir = $(libsubdir)/plugin/include
> +# Directory in which all plugin resources are installed
> +plugindir = $(libsubdir)/plugin
> + # Directory in which plugin headers are installed
> +plugin_includedir = $(plugindir)/include
> +# Directory in which plugin specific executables are installed
> +plugin_bindir = $(plugindir)/bin
>  # Used to produce a relative $(gcc_tooldir) in gcc.o
>  unlibsubdir = ../../..
>  # $(prefix), expressed as a path relative to $(libsubdir).
> @@ -1532,8 +1537,8 @@ MOSTLYCLEANFILES = insn-flags.h insn-con
>  $(EXTRA_PARTS) $(EXTRA_PROGRAMS) gcc-cross$(exeext) \
>  $(SPECS) collect2$(exeext) lto-wrapper$(exeext) \
>  gcov-iov$(build_exeext) gcov$(exeext) gcov-dump$(exeext) \
> - *.[0-9][0-9].* *.[si] *-checksum.c libbackend.a libcommon-target.a \
> - libcommon.a libgcc.mk
> + gengtype$(exeext) *.[0-9][0-9].* *.[si] *-checksum.c libbackend.a \
> + libcommon-target.a libcommon.a libgcc.mk
>
>  # Defined in libgcc2.c, included only in the static library.
>  LIB2FUNCS_ST = _eprintf __gcc_bcmp
> @@ -1825,6 +1830,10 @@ rest.encap: lang.rest.encap
>  native: config.status auto-host.h build-@POSUB@ $(LANGUAGES) \
>        $(EXTRA_PASSES) $(EXTRA_PROGRAMS) $(COLLECT2) lto-wrapper$(exeext)
>
> +ifeq ($(enable_plugin),yes)
> +native: gengtype$(exeext)
> +endif
> +
>  # Define the names for selecting languages in LANGUAGES.
>  c: cc1$(exeext)
>
> @@ -3879,7 +3888,7 @@ ALL_GTFILES_H := $(sort $(GTFILES_H) $(G
>  # write it out to a file (taking care not to do that in a way that
>  # overflows a command line!) and then have gengtype read the file in.
>
> -$(ALL_GTFILES_H) gtype-desc.c gtype-desc.h : s-gtype ; @true
> +$(ALL_GTFILES_H) gtype-desc.c gtype-desc.h gtype.state: s-gtype ; @true
>
>  ### Common flags to gengtype [e.g. -v or -B backupdir]
>  GENGTYPE_FLAGS=
> @@ -3894,9 +3903,10 @@ s-gtype: build/gengtype$(build_exeext) $
>         gtyp-input.list
>  # First, parse all files and save a state file.
>        $(RUN_GEN) build/gengtype$(build_exeext) $(GENGTYPE_FLAGS) \
> -                    -S $(srcdir) -I gtyp-input.list -w gtype.state
> +                    -S $(srcdir) -I gtyp-input.list -w tmp-gtype.state
>  # Second, read the state file and generate all files.  This ensure that
>  # gtype.state is correctly read:
> +       $(SHELL) $(srcdir)/../move-if-change tmp-gtype.state gtype.state
>        $(RUN_GEN) build/gengtype$(build_exeext) $(GENGTYPE_FLAGS) \
>                     -r gtype.state
>        $(STAMP) s-gtype
> @@ -3993,14 +4003,23 @@ build/genextract.o : genextract.c $(RTL_
>  build/genflags.o : genflags.c $(RTL_BASE_H) $(OBSTACK_H) $(BCONFIG_H)  \
>   $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h
>  build/gengenrtl.o : gengenrtl.c $(BCONFIG_H) $(SYSTEM_H) rtl.def
> -build/gengtype-lex.o : gengtype-lex.c gengtype.h $(BCONFIG_H) $(SYSTEM_H)
> -build/gengtype-parse.o : gengtype-parse.c gengtype.h $(BCONFIG_H)      \
> +gengtype-lex.o build/gengtype-lex.o : gengtype-lex.c gengtype.h $(SYSTEM_H)
> +gengtype-lex.o: $(CONFIG_H)
> +build/gengtype-lex.o: $(BCONFIG_H)
> +gengtype-parse.o build/gengtype-parse.o : gengtype-parse.c gengtype.h \
>   $(SYSTEM_H)
> -build/gengtype-state.o: gengtype-state.c gengtype.h $(BCONFIG_H)       \
> -  $(SYSTEM_H) errors.h
> -build/gengtype.o : gengtype.c $(BCONFIG_H) $(SYSTEM_H) gengtype.h      \
> -  rtl.def insn-notes.def errors.h double-int.h $(HASHTAB_H)             \
> +gengtype-parse.o: $(CONFIG_H)
> +build/gengtype-parse.o: $(BCONFIG_H)
> +gengtype-state.o build/gengtype-state.o: gengtype-state.c $(SYSTEM_H) \
> +  gengtype.h errors.h double-int.h version.h $(HASHTAB_H) $(OBSTACK_H) \
> +  $(XREGEX_H)
> +gengtype-state.o: $(CONFIG_H)
> +build/gengtype-state.o: $(BCONFIG_H)
> +gengtype.o build/gengtype.o : gengtype.c $(SYSTEM_H) gengtype.h        \
> +  rtl.def insn-notes.def errors.h double-int.h version.h $(HASHTAB_H) \
>   $(OBSTACK_H) $(XREGEX_H)
> +gengtype.o: $(CONFIG_H)
> +build/gengtype.o: $(BCONFIG_H)
>  build/genmddeps.o: genmddeps.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h    \
>   errors.h $(READ_MD_H)
>  build/genmodes.o : genmodes.c $(BCONFIG_H) $(SYSTEM_H) errors.h                \
> @@ -4044,7 +4063,11 @@ build/genautomata$(build_exeext) : BUILD
>
>  # These programs are not linked with the MD reader.
>  build/gengtype$(build_exeext) : build/gengtype-lex.o build/gengtype-parse.o \
> -              build/gengtype-state.o build/version.o
> +              build/gengtype-state.o build/version.o build/errors.o
> +
> +gengtype$(exeext) : gengtype.o gengtype-lex.o gengtype-parse.o \
> +              gengtype-state.o version.o errors.o $(LIBDEPS)
> +       +$(LINKER) $(ALL_LINKERFLAGS) -o $@ $(filter-out ($LIBDEPS), $^) $(LIBS)
>
>  # Rule for the generator programs:
>  $(genprog:%=build/gen%$(build_exeext)): build/gen%$(build_exeext):
> build/gen%.o $(BUILD_LIBDEPS)
> @@ -4641,8 +4664,15 @@ s-header-vars: Makefile
>        $(SHELL) $(srcdir)/../move-if-change tmp-header-vars b-header-vars
>        $(STAMP) s-header-vars
>
> +# Install gengtype
> +install-gengtype: installdirs gengtype$(exeext) gtype.state
> +       $(mkinstalldirs) $(DESTDIR)$(plugindir)
> +       $(INSTALL_DATA) gtype.state $(DESTDIR)$(plugindir)/gtype.state
> +       $(mkinstalldirs) $(DESTDIR)$(plugin_bindir)
> +       $(INSTALL_PROGRAM) gengtype$(exeext)
> $(DESTDIR)$(plugin_bindir)/gengtype$(exeext)
> +
>  # Install the headers needed to build a plugin.
> -install-plugin: installdirs lang.install-plugin s-header-vars
> +install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype
>  # We keep the directory structure for files in config and .def files. All
>  # other files are flattened to a single directory.
>        $(mkinstalldirs) $(DESTDIR)$(plugin_includedir)
>
Jakub Jelinek - Aug. 3, 2011, 6:40 p.m.
On Mon, Aug 01, 2011 at 02:27:49PM +0200, Romain Geissler wrote:
> ping

I went ahead and bootstrapped/regtested/and make install tested your patch
(note your mailer wrapped it up so that it didn't apply cleanly), but now
that I think about it, it is wrong to put the gengtype binary into
$(libsubdir)/plugin/bin/
IMNSHO it should go into
$(libexecsubdir)/plugin/
directory instead, libexec is where binaries go...  So please change
plugin_bindir.

	Jakub

Patch

Index: gcc/gengtype-state.c
===================================================================
--- gcc/gengtype-state.c	(revision 175907)
+++ gcc/gengtype-state.c	(working copy)
@@ -23,7 +23,11 @@ 
    and Basile Starynkevitch <basile@starynkevitch.net>
 */

+#ifdef GENERATOR_FILE
 #include "bconfig.h"
+#else
+#include "config.h"
+#endif
 #include "system.h"
 #include "errors.h"	/* For fatal.  */
 #include "double-int.h"
Index: gcc/gengtype.c
===================================================================
--- gcc/gengtype.c	(revision 175907)
+++ gcc/gengtype.c	(working copy)
@@ -18,7 +18,11 @@ 
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */

+#ifdef GENERATOR_FILE
 #include "bconfig.h"
+#else
+#include "config.h"
+#endif
 #include "system.h"
 #include "errors.h"		/* for fatal */
 #include "getopt.h"
Index: gcc/gengtype-lex.l
===================================================================
--- gcc/gengtype-lex.l	(revision 175907)
+++ gcc/gengtype-lex.l	(working copy)
@@ -22,7 +22,11 @@  along with GCC; see the file COPYING3.
 %option noinput

 %{
+#ifdef GENERATOR_FILE
 #include "bconfig.h"
+#else
+#include "config.h"
+#endif
 #include "system.h"

 #define malloc xmalloc
Index: gcc/gengtype-parse.c
===================================================================
--- gcc/gengtype-parse.c	(revision 175907)
+++ gcc/gengtype-parse.c	(working copy)
@@ -17,7 +17,11 @@ 
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */

+#ifdef GENERATOR_FILE
 #include "bconfig.h"
+#else
+#include "config.h"
+#endif
 #include "system.h"
 #include "gengtype.h"

Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(revision 175907)
+++ gcc/Makefile.in	(working copy)
@@ -192,6 +192,7 @@  GCC_WARN_CXXFLAGS = $(LOOSE_WARN) $($(@D
 # be subject to -Werror:
 # flex output may yield harmless "no previous prototype" warnings
 build/gengtype-lex.o-warn = -Wno-error
+gengtype-lex.o-warn = -Wno-error
 # mips-tfile.c contains -Wcast-qual warnings.
 mips-tfile.o-warn = -Wno-error
 expmed.o-warn = -Wno-error
@@ -566,8 +567,12 @@  libexecdir = @libexecdir@
 libsubdir = $(libdir)/gcc/$(target_noncanonical)/$(version)
 # Directory in which the compiler finds executables
 libexecsubdir = $(libexecdir)/gcc/$(target_noncanonical)/$(version)
-# Directory in which plugin headers are installed
-plugin_includedir = $(libsubdir)/plugin/include
+# Directory in which all plugin resources are installed
+plugindir = $(libsubdir)/plugin
+ # Directory in which plugin headers are installed
+plugin_includedir = $(plugindir)/include
+# Directory in which plugin specific executables are installed
+plugin_bindir = $(plugindir)/bin
 # Used to produce a relative $(gcc_tooldir) in gcc.o
 unlibsubdir = ../../..
 # $(prefix), expressed as a path relative to $(libsubdir).
@@ -1532,8 +1537,8 @@  MOSTLYCLEANFILES = insn-flags.h insn-con
  $(EXTRA_PARTS) $(EXTRA_PROGRAMS) gcc-cross$(exeext) \
  $(SPECS) collect2$(exeext) lto-wrapper$(exeext) \
  gcov-iov$(build_exeext) gcov$(exeext) gcov-dump$(exeext) \
- *.[0-9][0-9].* *.[si] *-checksum.c libbackend.a libcommon-target.a \
- libcommon.a libgcc.mk
+ gengtype$(exeext) *.[0-9][0-9].* *.[si] *-checksum.c libbackend.a \
+ libcommon-target.a libcommon.a libgcc.mk

 # Defined in libgcc2.c, included only in the static library.
 LIB2FUNCS_ST = _eprintf __gcc_bcmp
@@ -1825,6 +1830,10 @@  rest.encap: lang.rest.encap
 native: config.status auto-host.h build-@POSUB@ $(LANGUAGES) \
 	$(EXTRA_PASSES) $(EXTRA_PROGRAMS) $(COLLECT2) lto-wrapper$(exeext)

+ifeq ($(enable_plugin),yes)
+native: gengtype$(exeext)
+endif
+
 # Define the names for selecting languages in LANGUAGES.
 c: cc1$(exeext)

@@ -3879,7 +3888,7 @@  ALL_GTFILES_H := $(sort $(GTFILES_H) $(G
 # write it out to a file (taking care not to do that in a way that
 # overflows a command line!) and then have gengtype read the file in.

-$(ALL_GTFILES_H) gtype-desc.c gtype-desc.h : s-gtype ; @true
+$(ALL_GTFILES_H) gtype-desc.c gtype-desc.h gtype.state: s-gtype ; @true

 ### Common flags to gengtype [e.g. -v or -B backupdir]
 GENGTYPE_FLAGS=
@@ -3894,9 +3903,10 @@  s-gtype: build/gengtype$(build_exeext) $
 	 gtyp-input.list
 # First, parse all files and save a state file.
 	$(RUN_GEN) build/gengtype$(build_exeext) $(GENGTYPE_FLAGS) \
-                    -S $(srcdir) -I gtyp-input.list -w gtype.state
+                    -S $(srcdir) -I gtyp-input.list -w tmp-gtype.state
 # Second, read the state file and generate all files.  This ensure that
 # gtype.state is correctly read:
+	$(SHELL) $(srcdir)/../move-if-change tmp-gtype.state gtype.state
 	$(RUN_GEN) build/gengtype$(build_exeext) $(GENGTYPE_FLAGS) \
                     -r gtype.state
 	$(STAMP) s-gtype
@@ -3993,14 +4003,23 @@  build/genextract.o : genextract.c $(RTL_
 build/genflags.o : genflags.c $(RTL_BASE_H) $(OBSTACK_H) $(BCONFIG_H)	\
   $(SYSTEM_H) coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h
 build/gengenrtl.o : gengenrtl.c $(BCONFIG_H) $(SYSTEM_H) rtl.def
-build/gengtype-lex.o : gengtype-lex.c gengtype.h $(BCONFIG_H) $(SYSTEM_H)
-build/gengtype-parse.o : gengtype-parse.c gengtype.h $(BCONFIG_H)	\
+gengtype-lex.o build/gengtype-lex.o : gengtype-lex.c gengtype.h $(SYSTEM_H)
+gengtype-lex.o: $(CONFIG_H)
+build/gengtype-lex.o: $(BCONFIG_H)
+gengtype-parse.o build/gengtype-parse.o : gengtype-parse.c gengtype.h \
   $(SYSTEM_H)
-build/gengtype-state.o: gengtype-state.c gengtype.h $(BCONFIG_H)	\
-  $(SYSTEM_H) errors.h
-build/gengtype.o : gengtype.c $(BCONFIG_H) $(SYSTEM_H) gengtype.h 	\
-  rtl.def insn-notes.def errors.h double-int.h $(HASHTAB_H)             \
+gengtype-parse.o: $(CONFIG_H)
+build/gengtype-parse.o: $(BCONFIG_H)
+gengtype-state.o build/gengtype-state.o: gengtype-state.c $(SYSTEM_H) \
+  gengtype.h errors.h double-int.h version.h $(HASHTAB_H) $(OBSTACK_H) \
+  $(XREGEX_H)
+gengtype-state.o: $(CONFIG_H)
+build/gengtype-state.o: $(BCONFIG_H)
+gengtype.o build/gengtype.o : gengtype.c $(SYSTEM_H) gengtype.h 	\
+  rtl.def insn-notes.def errors.h double-int.h version.h $(HASHTAB_H) \
   $(OBSTACK_H) $(XREGEX_H)
+gengtype.o: $(CONFIG_H)
+build/gengtype.o: $(BCONFIG_H)
 build/genmddeps.o: genmddeps.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h	\
   errors.h $(READ_MD_H)
 build/genmodes.o : genmodes.c $(BCONFIG_H) $(SYSTEM_H) errors.h		\
@@ -4044,7 +4063,11 @@  build/genautomata$(build_exeext) : BUILD

 # These programs are not linked with the MD reader.
 build/gengtype$(build_exeext) : build/gengtype-lex.o build/gengtype-parse.o \
-              build/gengtype-state.o build/version.o
+              build/gengtype-state.o build/version.o build/errors.o
+
+gengtype$(exeext) : gengtype.o gengtype-lex.o gengtype-parse.o \
+              gengtype-state.o version.o errors.o $(LIBDEPS)
+	+$(LINKER) $(ALL_LINKERFLAGS) -o $@ $(filter-out ($LIBDEPS), $^) $(LIBS)

 # Rule for the generator programs:
 $(genprog:%=build/gen%$(build_exeext)): build/gen%$(build_exeext):