*** a/src/Makefile.global.in
--- b/src/Makefile.global.in
***************
*** 517,522 **** $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h: $(top_builddir)/src/i
--- 517,555 ----
  $(top_builddir)/config.status: $(top_srcdir)/configure
  	cd $(top_builddir) && ./config.status --recheck
  
+ # Generated header files need dependencies here to ensure that everything
+ # which depends on them gets rebuilt when necessary.  Note that it's important
+ # we match the dependencies shown in the subdirectory makefiles!
+ ifneq ($(subdir),src/backend/parser)
+ $(top_srcdir)/src/backend/parser/gram.h: $(top_srcdir)/src/backend/parser/gram.y
+ 	$(MAKE) -C $(top_builddir)/src/backend/parser gram.h
+ endif
+ 
+ ifneq ($(subdir),src/backend/utils)
+ $(top_builddir)/src/backend/utils/fmgroids.h: $(top_srcdir)/src/backend/utils/Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h
+ 	$(MAKE) -C $(top_builddir)/src/backend/utils fmgroids.h
+ 
+ $(top_builddir)/src/backend/utils/probes.h: $(top_srcdir)/src/backend/utils/probes.d
+ 	$(MAKE) -C $(top_builddir)/src/backend/utils probes.h
+ endif
+ 
+ # Make symlinks for these headers in the include directory. That way
+ # we can cut down on the -I options. Also, a symlink is automatically
+ # up to date when we update the base file.
+ 
+ $(top_builddir)/src/include/parser/gram.h: $(top_srcdir)/src/backend/parser/gram.h
+ 	prereqdir=`cd $(dir $<) >/dev/null && pwd` && \
+ 	  cd $(dir $@) && rm -f $(notdir $@) && \
+ 	  $(LN_S) "$$prereqdir/$(notdir $<)" .
+ 
+ $(top_builddir)/src/include/utils/fmgroids.h: $(top_builddir)/src/backend/utils/fmgroids.h
+ 	cd $(dir $@) && rm -f $(notdir $@) && \
+ 	    $(LN_S) ../../../src/backend/utils/fmgroids.h .
+ 
+ $(top_builddir)/src/include/utils/probes.h: $(top_builddir)/src/backend/utils/probes.h
+ 	cd $(dir $@) && rm -f $(notdir $@) && \
+ 	    $(LN_S) ../../../src/backend/utils/probes.h .
+ 
  endif # not PGXS
  
  
*** a/src/backend/Makefile
--- b/src/backend/Makefile
***************
*** 113,150 **** $(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_buildd
  postgres.o: $(OBJS)
  	$(CC) $(LDREL) $(LDFLAGS) $(call expand_subsys,$^) $(LIBS) -o $@
  
- 
- # The following targets are specified in make commands that appear in
- # the make files in our subdirectories. Note that it's important we
- # match the dependencies shown in the subdirectory makefiles!
- 
- $(srcdir)/parser/gram.h: parser/gram.y
- 	$(MAKE) -C parser gram.h
- 
- utils/fmgroids.h: utils/Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h
- 	$(MAKE) -C utils fmgroids.h
- 
- utils/probes.h: utils/probes.d
- 	$(MAKE) -C utils probes.h
- 
- # Make symlinks for these headers in the include directory. That way
- # we can cut down on the -I options. Also, a symlink is automatically
- # up to date when we update the base file.
- 
- $(top_builddir)/src/include/parser/gram.h: $(srcdir)/parser/gram.h
- 	prereqdir=`cd $(dir $<) >/dev/null && pwd` && \
- 	  cd $(dir $@) && rm -f $(notdir $@) && \
- 	  $(LN_S) "$$prereqdir/$(notdir $<)" .
- 
- $(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h
- 	cd $(dir $@) && rm -f $(notdir $@) && \
- 	    $(LN_S) ../../../$(subdir)/utils/fmgroids.h .
- 
- $(top_builddir)/src/include/utils/probes.h: utils/probes.h
- 	cd $(dir $@) && rm -f $(notdir $@) && \
- 	    $(LN_S) ../../../$(subdir)/utils/probes.h .
- 
- 
  ifeq ($(PORTNAME), solaris)
  utils/probes.o: utils/probes.d $(SUBDIROBJS)
  	$(DTRACE) $(DTRACEFLAGS) -C -G -s $(call expand_subsys,$^) -o $@
--- 113,118 ----
