I tried doing a VPATH build referencing a source directory that I'd distclean'd
but not maintainer-clean'd, which should simulate the case of a VPATH
build from a tarball.  I was quite surprised that it fell over:

...
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement 
-Wendif-labels -Wmissing-format-attribute -Wformat-security 
-fno-strict-aliasing -fwrapv -g -O2 -I. -I/home/postgres/pgsql/src/bin/psql 
-I/home/postgres/pgsql/src/interfaces/libpq -I../../../src/include 
-I/home/postgres/pgsql/src/include  -D_GNU_SOURCE   -c -o sql_help.o sql_help.c
gcc: sql_help.c: No such file or directory
gcc: no input files
make[3]: *** [sql_help.o] Error 1
make[3]: Leaving directory `/home/postgres/buildroot/src/bin/psql'

gmake should be generating a path to sql_help.c, since that exists
in the corresponding source directory, but it does not.  I can reproduce
this on RHEL6 with make-3.81-23, but not on Fedora 26 with make-4.2.1-2,
and (curiously) also not on High Sierra with Apple's copy of make 3.81.
I wonder how many other people see it.

The attached patch seems to fix it, indicating that there's something
about the rules relating sql_help.c and sql_help.h that is confusing
make, such that turning sql_help.c into the primary target for the
create_help rule removes the confusion.

Comments?

                        regards, tom lane

diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile
index c8eb2f9..4482097 100644
*** a/src/bin/psql/Makefile
--- b/src/bin/psql/Makefile
*************** psql: $(OBJS) | submake-libpq submake-li
*** 35,49 ****
  
  help.o: sql_help.h
  
! sql_help.c: sql_help.h ;
! sql_help.h: create_help.pl $(wildcard $(REFDOCDIR)/*.sgml)
  	$(PERL) $< $(REFDOCDIR) $*
  
  psqlscanslash.c: FLEXFLAGS = -Cfe -p -p
  psqlscanslash.c: FLEX_NO_BACKUP=yes
  psqlscanslash.c: FLEX_FIX_WARNING=yes
  
! distprep: sql_help.h psqlscanslash.c
  
  install: all installdirs
  	$(INSTALL_PROGRAM) psql$(X) '$(DESTDIR)$(bindir)/psql$(X)'
--- 35,49 ----
  
  help.o: sql_help.h
  
! sql_help.h: sql_help.c ;
! sql_help.c: create_help.pl $(wildcard $(REFDOCDIR)/*.sgml)
  	$(PERL) $< $(REFDOCDIR) $*
  
  psqlscanslash.c: FLEXFLAGS = -Cfe -p -p
  psqlscanslash.c: FLEX_NO_BACKUP=yes
  psqlscanslash.c: FLEX_FIX_WARNING=yes
  
! distprep: sql_help.c psqlscanslash.c
  
  install: all installdirs
  	$(INSTALL_PROGRAM) psql$(X) '$(DESTDIR)$(bindir)/psql$(X)'

Reply via email to