Hi,

I think that our dependencies for generated header files (gram.h,
fmgroids.h, probes.h) are not as good as they could be.  What we do
right now is make src/backend/Makefile rebuild these before recursing
through its subdirectories.  This works OK for a top-level make, but
if you run make further down in the tree (like under
src/backend/commands) it won't necessarily rebuild everything that it
should.

The attached patch moves some of this logic from src/backend/Makefile
to src/Makefile.global.in.  That way, if you --enable-depend and then
do something like "touch src/include/catalog/pg_proc.h" and then "cd
src/backend/commands; make vacuum.o", it rebuilds fmgroids.h and then
recompiles vacuum.c.  Under HEAD, it just tells you that vacuum.o is
up to date.

I have tested this on vpath and non-vpath builds, with and without
--enable-depend.

...Robert
*** 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,551 ----
  $(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!
+ $(top_srcdir)/src/backend/parser/gram.h: $(top_srcdir)/src/backend/parser/gram.y
+ 	$(MAKE) -C $(top_builddir)/src/backend/parser gram.h
+ 
+ $(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
+ 
+ # 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 ----
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to