Thread: SGML index build fix

SGML index build fix

From
Bruce Momjian
Date:
The attached patch warns users when they create documentation output
that has no index, and suggests re-running 'gmake'.

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/Makefile
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/Makefile,v
retrieving revision 1.86
diff -c -c -r1.86 Makefile
*** doc/src/sgml/Makefile    15 Dec 2006 16:50:07 -0000    1.86
--- doc/src/sgml/Makefile    7 Jan 2007 04:26:05 -0000
***************
*** 95,101 ****
  ifeq ($(vpath_build), yes)
      @cp $(srcdir)/stylesheet.css .
  endif
!

  COLLATEINDEX := LC_ALL=C $(PERL) $(COLLATEINDEX) -f -g

--- 95,103 ----
  ifeq ($(vpath_build), yes)
      @cp $(srcdir)/stylesheet.css .
  endif
! # for some reason $wildcard expands too early, so we use 'test'
!     @test -f bookindex.valid || echo "Run 'gmake' again to generate output with a proper index"
!

  COLLATEINDEX := LC_ALL=C $(PERL) $(COLLATEINDEX) -f -g

***************
*** 105,113 ****
--- 107,119 ----
  ifeq (,$(wildcard HTML.index))
  bookindex.sgml:
      $(COLLATEINDEX) -o $@ -N
+     @rm -f bookindex.valid
+     @touch bookindex.dummy
  else
  bookindex.sgml: HTML.index
      $(COLLATEINDEX) -i 'bookindex' -o $@ $<
+     @rm -f bookindex.dummy
+     @touch bookindex.valid
  endif

  version.sgml: $(top_builddir)/src/Makefile.global
***************
*** 141,155 ****
--- 147,165 ----

  %-A4.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@ $<
+     @test -f bookindex.valid || echo "Run 'gmake' again to generate output with a proper index"

  %-US.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=USletter -o $@ $<
+     @test -f bookindex.valid || echo "Run 'gmake' again to generate output with a proper index"

  %-A4.tex-pdf: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=A4 -o $@ $<
+     @test -f bookindex.valid || echo "Run 'gmake' again to generate output with a proper index"

  %-US.tex-pdf: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=USletter -o $@ $<
+     @test -f bookindex.valid || echo "Run 'gmake' again to generate output with a proper index"

  %.dvi: %.tex-ps
      @rm -f $*.aux $*.log
***************
*** 233,238 ****
--- 243,249 ----
            -e '1a\' -e '<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">'\ 
        >$@
  # ' hello Emacs
+     @test -f bookindex.valid || echo "Run 'gmake' again to generate output with a proper index"

  override XSLTPROCFLAGS += --stringparam pg.version '$(VERSION)'

***************
*** 285,291 ****

  clean distclean maintainer-clean:
  # HTML
!     rm -f HTML.manifest *.html *.gif
  # man
      rm -rf *.1 *.$(DEFAULTSECTION) man1 man$(DEFAULTSECTION) manpage.refs manpage.links manpage.log
  # print
--- 296,302 ----

  clean distclean maintainer-clean:
  # HTML
!     rm -f HTML.manifest *.html *.gif bookindex.dummy bookindex.valid
  # man
      rm -rf *.1 *.$(DEFAULTSECTION) man1 man$(DEFAULTSECTION) manpage.refs manpage.links manpage.log
  # print

Re: SGML index build fix

From
Tom Lane
Date:
Bruce Momjian <bruce@momjian.us> writes:
> The attached patch warns users when they create documentation output
> that has no index, and suggests re-running 'gmake'.

This is just useless noise.  If it could tell the difference between an
up-to-date index and a not-up-to-date one, there might be some value
to it ... but as-is I think it's just getting in the user's face.
Everyone using these tools knows about the two-pass behavior.

I just got done reading an interesting comparison of MS Vista versus
Mac OS X:
http://www.informationweek.com/news/showArticle.jhtml?articleID=196800670
The guy's very first complaint about Vista is how it demands your
attention constantly with trivial warning messages.  This seems in much
the same vein.

            regards, tom lane

Re: SGML index build fix

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > The attached patch warns users when they create documentation output
> > that has no index, and suggests re-running 'gmake'.
>
> This is just useless noise.  If it could tell the difference between an
> up-to-date index and a not-up-to-date one, there might be some value
> to it ... but as-is I think it's just getting in the user's face.
> Everyone using these tools knows about the two-pass behavior.

I certainly did not, and it warns only when an invalid HTML.index is
used.

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Re: [HACKERS] SGML index build fix

From
Bruce Momjian
Date:
Bruce Momjian wrote:
> Tom Lane wrote:
> > Bruce Momjian <bruce@momjian.us> writes:
> > > The attached patch warns users when they create documentation output
> > > that has no index, and suggests re-running 'gmake'.
> >
> > This is just useless noise.  If it could tell the difference between an
> > up-to-date index and a not-up-to-date one, there might be some value
> > to it ... but as-is I think it's just getting in the user's face.
> > Everyone using these tools knows about the two-pass behavior.
>
> I certainly did not, and it warns only when an invalid HTML.index is
> used.

And the people creating our PDFs didn't know because we often have to
update the web site with valid ones that have indexes.

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Re: [HACKERS] SGML index build fix

From
"Joshua D. Drake"
Date:
On Sat, 2007-01-06 at 23:38 -0500, Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > The attached patch warns users when they create documentation output
> > that has no index, and suggests re-running 'gmake'.
>
> This is just useless noise.  If it could tell the difference between an
> up-to-date index and a not-up-to-date one, there might be some value
> to it ... but as-is I think it's just getting in the user's face.
> Everyone using these tools knows about the two-pass behavior.

No, not everyone knows. In fact I would argue that most do not know. It
isn't intuitive to the process. You *expect* that an index will be made.

Joshua D. Drake

--

      === The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive  PostgreSQL solutions since 1997
             http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate




Re: [HACKERS] SGML index build fix

From
Bruce Momjian
Date:
Joshua D. Drake wrote:
> On Sat, 2007-01-06 at 23:38 -0500, Tom Lane wrote:
> > Bruce Momjian <bruce@momjian.us> writes:
> > > The attached patch warns users when they create documentation output
> > > that has no index, and suggests re-running 'gmake'.
> >
> > This is just useless noise.  If it could tell the difference between an
> > up-to-date index and a not-up-to-date one, there might be some value
> > to it ... but as-is I think it's just getting in the user's face.
> > Everyone using these tools knows about the two-pass behavior.
>
> No, not everyone knows. In fact I would argue that most do not know. It
> isn't intuitive to the process. You *expect* that an index will be made.

The idea for the warning message actually came from Peter.

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Re: SGML index build fix

From
Peter Eisentraut
Date:
Bruce Momjian wrote:
> The attached patch warns users when they create documentation output
> that has no index, and suggests re-running 'gmake'.

> ! # for some reason $wildcard expands too early, so we use 'test'

$wildcard is expanded whenever you tell it to.  What did you write?

> !     @test -f bookindex.valid || echo "Run 'gmake' again to generate output with a proper index"

The proper command to run is $(MAKE).

> !

There is a redundant tab on that line.

> +     @test -f bookindex.valid || echo "Run 'gmake' again to generate output with a proper index"

Probably better to capture that in a variable instead of copying it half a dozen times.

>             -e '1a\' -e '<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">'\ 
>         >$@
>   # ' hello Emacs
> +     @test -f bookindex.valid || echo "Run 'gmake' again to generate output with a proper index"

When converting to XML, you probably don't want an index because it will
be built differently by the XSLT toolchain.  It's not clear what we want
anyway.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: [HACKERS] SGML index build fix

From
Martijn van Oosterhout
Date:
On Sun, Jan 07, 2007 at 12:42:06AM -0500, Bruce Momjian wrote:
> Joshua D. Drake wrote:
> > On Sat, 2007-01-06 at 23:38 -0500, Tom Lane wrote:
> > > Everyone using these tools knows about the two-pass behavior.
> >
> > No, not everyone knows. In fact I would argue that most do not know. It
> > isn't intuitive to the process. You *expect* that an index will be made.
>
> The idea for the warning message actually came from Peter.

FWIW, I have this problem with LaTeX also, which needs multiple passes
occasionally to fix cross-references and idexes and stuff. The solution
I have in the makefile is a fragment like the following:

while egrep -q "^LaTeX Warning:.*Rerun to" logfile ; do
  rm logfile
  latex taxfile
done

I don't know enough about the relevent tool to know if they actually
generate a warning about whether they need to be rerun. In any case it
seems a much better approach to simply run it again when needed rather
than printing a warning.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment

Re: [HACKERS] SGML index build fix

From
Bruce Momjian
Date:
Martijn van Oosterhout wrote:
-- Start of PGP signed section.
> On Sun, Jan 07, 2007 at 12:42:06AM -0500, Bruce Momjian wrote:
> > Joshua D. Drake wrote:
> > > On Sat, 2007-01-06 at 23:38 -0500, Tom Lane wrote:
> > > > Everyone using these tools knows about the two-pass behavior.
> > >
> > > No, not everyone knows. In fact I would argue that most do not know. It
> > > isn't intuitive to the process. You *expect* that an index will be made.
> >
> > The idea for the warning message actually came from Peter.
>
> FWIW, I have this problem with LaTeX also, which needs multiple passes
> occasionally to fix cross-references and idexes and stuff. The solution
> I have in the makefile is a fragment like the following:
>
> while egrep -q "^LaTeX Warning:.*Rerun to" logfile ; do
>   rm logfile
>   latex taxfile
> done

Our Makefile has:

    %.dvi: %.tex-ps
            @rm -f $*.aux $*.log
            # multiple runs are necessary to create proper intra-document links
            jadetex $<
            jadetex $<
            jadetex $<

so there should be no reason for you to have to rerun.

>
> I don't know enough about the relevent tool to know if they actually
> generate a warning about whether they need to be rerun. In any case it
> seems a much better approach to simply run it again when needed rather
> than printing a warning.

The problem is that there is no indication from the make (no warning)
that you have to rerun, and it isn't something people are used to doing
like with latex.

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Re: SGML index build fix

From
Bruce Momjian
Date:
Peter Eisentraut wrote:
> Bruce Momjian wrote:
> > The attached patch warns users when they create documentation output
> > that has no index, and suggests re-running 'gmake'.
>
> > ! # for some reason $wildcard expands too early, so we use 'test'
>
> $wildcard is expanded whenever you tell it to.  What did you write?

I wrote:

    ifeq (,$(wildcard bookindex.valid))
        echo "Run 'gmake' again to generate output with a proper index"
    endif

but that warns on the first _two_ runs, meaning it expanded at the time
the rule started, not at the time it hit that line.

> > !     @test -f bookindex.valid || echo "Run 'gmake' again to generate output with a proper index"
>
> The proper command to run is $(MAKE).

OK, updated.

>
> > !
>
> There is a redundant tab on that line.

OK, removed.

>
> > +     @test -f bookindex.valid || echo "Run 'gmake' again to generate output with a proper index"
>
> Probably better to capture that in a variable instead of copying it half a dozen times.
>
> >             -e '1a\' -e '<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">'\ 
> >         >$@
> >   # ' hello Emacs
> > +     @test -f bookindex.valid || echo "Run 'gmake' again to generate output with a proper index"
>
> When converting to XML, you probably don't want an index because it will
> be built differently by the XSLT toolchain.  It's not clear what we want
> anyway.

OK, removed.

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Re: [HACKERS] SGML index build fix

From
Tom Lane
Date:
Bruce Momjian <bruce@momjian.us> writes:
> Martijn van Oosterhout wrote:
>> I don't know enough about the relevent tool to know if they actually
>> generate a warning about whether they need to be rerun. In any case it
>> seems a much better approach to simply run it again when needed rather
>> than printing a warning.

> The problem is that there is no indication from the make (no warning)
> that you have to rerun, and it isn't something people are used to doing
> like with latex.

If the objective is to make it safe against people who do not understand
how the tools work, then I still complain that this method is
insufficient.  All you are testing is whether an index was generated,
not whether it was correct (ie, up to date).  A valid test would be
along the lines of comparing the pre-run and post-run copies of the
index data to see if they're the same.

Perhaps even more to the point, what makes you think that someone will
notice the warning?  If the docs build is one step in an automated build
process, this seems unlikely.

            regards, tom lane

Re: SGML index build fix

From
Peter Eisentraut
Date:
Bruce Momjian wrote:
> I wrote:
>
>     ifeq (,$(wildcard bookindex.valid))
>         echo "Run 'gmake' again to generate output with a proper index"
>     endif
>
> but that warns on the first _two_ runs, meaning it expanded at the
> time the rule started, not at the time it hit that line.

This expands at the time the makefile is read.  You may get it to work
with

target:
    $(if $(wildcard blah), this, that)

The following may be helpful:
http://www.gnu.org/software/make/manual/html_node/Reading-Makefiles.html#Reading-Makefiles

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: [HACKERS] SGML index build fix

From
Peter Eisentraut
Date:
Tom Lane wrote:
> Perhaps even more to the point, what makes you think that someone
> will notice the warning?  If the docs build is one step in an
> automated build process, this seems unlikely.

Taking a closer look, it's pretty much guaranteed that no one will see
them, because the targets they are attached to are intermediate,
normally followed by latex runs.
--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: [HACKERS] SGML index build fix

From
Tom Lane
Date:
Peter Eisentraut <peter_e@gmx.net> writes:
> Tom Lane wrote:
>> Perhaps even more to the point, what makes you think that someone
>> will notice the warning?  If the docs build is one step in an
>> automated build process, this seems unlikely.

> Taking a closer look, it's pretty much guaranteed that no one will see
> them, because the targets they are attached to are intermediate,
> normally followed by latex runs.

If we think this is a problem, ISTM the correct answer is to just force
a repeat jade run when doing "make all".  The only objection to that
AFAICS is that when you're doing docs work and only need a draft to
look at, you'd rather it not run twice.  But perhaps we could address
that by providing a separate target, "make draft" say, that runs jade
but once.

            regards, tom lane

Re: [HACKERS] SGML index build fix

From
Gavin Sherry
Date:
On Sun, 7 Jan 2007, Tom Lane wrote:

> Peter Eisentraut <peter_e@gmx.net> writes:
> > Tom Lane wrote:
> >> Perhaps even more to the point, what makes you think that someone
> >> will notice the warning?  If the docs build is one step in an
> >> automated build process, this seems unlikely.
>
> > Taking a closer look, it's pretty much guaranteed that no one will see
> > them, because the targets they are attached to are intermediate,
> > normally followed by latex runs.
>
> If we think this is a problem, ISTM the correct answer is to just force
> a repeat jade run when doing "make all".  The only objection to that
> AFAICS is that when you're doing docs work and only need a draft to
> look at, you'd rather it not run twice.  But perhaps we could address
> that by providing a separate target, "make draft" say, that runs jade
> but once.

That's a nice approach. Those working on the docs will know about the
draft target and those just wanting to build the docs for publication will
get the result.

Gavin

Re: [HACKERS] SGML index build fix

From
Bruce Momjian
Date:
Peter Eisentraut wrote:
> Tom Lane wrote:
> > Perhaps even more to the point, what makes you think that someone
> > will notice the warning?  If the docs build is one step in an
> > automated build process, this seems unlikely.
>
> Taking a closer look, it's pretty much guaranteed that no one will see
> them, because the targets they are attached to are intermediate,
> normally followed by latex runs.

Here is a patch that runs the build twice when HTML.index does not
exist, and once every time after that.  This is not ideal, but it is a
start.

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/Makefile
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/Makefile,v
retrieving revision 1.87
diff -c -c -r1.87 Makefile
*** doc/src/sgml/Makefile    7 Jan 2007 08:49:31 -0000    1.87
--- doc/src/sgml/Makefile    8 Jan 2007 04:02:45 -0000
***************
*** 99,114 ****

  COLLATEINDEX := LC_ALL=C $(PERL) $(COLLATEINDEX) -f -g

- # If HTML.index does not exist, create a dummy bookindex.sgml.  During the
- # next build, create bookindex.sgml with the proper index contents.  A proper
- # bookindex.sgml is required to have an index in the output.
- ifeq (,$(wildcard HTML.index))
- bookindex.sgml:
-     $(COLLATEINDEX) -o $@ -N
- else
  bookindex.sgml: HTML.index
!     $(COLLATEINDEX) -i 'bookindex' -o $@ $<
! endif

  version.sgml: $(top_builddir)/src/Makefile.global
      { \
--- 99,115 ----

  COLLATEINDEX := LC_ALL=C $(PERL) $(COLLATEINDEX) -f -g

  bookindex.sgml: HTML.index
!     # If HTML.index is zero length, create a dummy bookindex.sgml
!     test -s HTML.index || $(COLLATEINDEX) -o $@ -N
!     # If HTML.index is valid, create valid bookindex.sgml.  This
!     # is required so the output has a proper index.
!     test ! -s HTML.index || $(COLLATEINDEX) -i 'bookindex' -o $@ $<
!
! # If HTML.index does not exist, create an empty file and recusively call
! # our own Makefile to create a valid bookindex.sgml.
! HTML.index:
!     test -f HTML.index || (touch HTML.index && $(MAKE) $(MAKECMDGOALS))

  version.sgml: $(top_builddir)/src/Makefile.global
      { \
***************
*** 285,291 ****

  clean distclean maintainer-clean:
  # HTML
!     rm -f HTML.manifest *.html *.gif
  # man
      rm -rf *.1 *.$(DEFAULTSECTION) man1 man$(DEFAULTSECTION) manpage.refs manpage.links manpage.log
  # print
--- 286,292 ----

  clean distclean maintainer-clean:
  # HTML
!     rm -f HTML.manifest *.html *.gif bookindex.skip
  # man
      rm -rf *.1 *.$(DEFAULTSECTION) man1 man$(DEFAULTSECTION) manpage.refs manpage.links manpage.log
  # print

Re: [HACKERS] SGML index build fix

From
Peter Eisentraut
Date:
Am Montag, 8. Januar 2007 05:10 schrieb Bruce Momjian:
> Here is a patch that runs the build twice when HTML.index does not
> exist, and once every time after that.  This is not ideal, but it is a
> start.

The problem is that this requires two runs even to proof the documentation,
which I think no one wants.

> !     # If HTML.index is zero length, create a dummy bookindex.sgml
> !     test -s HTML.index || $(COLLATEINDEX) -o $@ -N
> !     # If HTML.index is valid, create valid bookindex.sgml.  This
> !     # is required so the output has a proper index.
> !     test ! -s HTML.index || $(COLLATEINDEX) -i 'bookindex' -o $@ $<

Please indent the comments properly so they don't appear in the output.

> ! HTML.index:
> !     test -f HTML.index || (touch HTML.index && $(MAKE) $(MAKECMDGOALS))

I think this is partially redundant.  If HTML.index exists, then this
rule will never be called.

> !     rm -f HTML.manifest *.html *.gif bookindex.skip

I don't see bookindex.skip mentioned anywhere else.  Left over from a
previous version?

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: [HACKERS] SGML index build fix

From
Bruce Momjian
Date:
Peter Eisentraut wrote:
> Am Montag, 8. Januar 2007 05:10 schrieb Bruce Momjian:
> > Here is a patch that runs the build twice when HTML.index does not
> > exist, and once every time after that.  This is not ideal, but it is a
> > start.
>
> The problem is that this requires two runs even to proof the documentation,
> which I think no one wants.

So what would the API be to signal you want a draft build?

    gmake DRAFT="Y" html

I can do that.

> > !     # If HTML.index is zero length, create a dummy bookindex.sgml
> > !     test -s HTML.index || $(COLLATEINDEX) -o $@ -N
> > !     # If HTML.index is valid, create valid bookindex.sgml.  This
> > !     # is required so the output has a proper index.
> > !     test ! -s HTML.index || $(COLLATEINDEX) -i 'bookindex' -o $@ $<
>
> Please indent the comments properly so they don't appear in the output.

Done.

>
> > ! HTML.index:
> > !     test -f HTML.index || (touch HTML.index && $(MAKE) $(MAKECMDGOALS))
>
> I think this is partially redundant.  If HTML.index exists, then this
> rule will never be called.

Uh, wouldn't HTML.index be newer than bookindex.sgml after a build?
Also, I need the HTML.index dependency and I can't use 'ifeq' to
add/remove it because the test condition result will change during the
Makefile execution.  So, HTML.index has to exist after the dependency
rule returns.  Am I missing something?

I did replace the test -f with $if.

> > !     rm -f HTML.manifest *.html *.gif bookindex.skip
>
> I don't see bookindex.skip mentioned anywhere else.  Left over from a
> previous version?

Sorry, removed.

Updated patch attached.  This is a more complete solution that saves off
HTML.index before each jade run, and checks after if the new HTML.index
differs from the original, and if so, run it again.  It also adds a
DRAFT 'make' option, and documents it.  It also removes the
documentation about running it multiple times.

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/Makefile
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/Makefile,v
retrieving revision 1.87
diff -c -c -r1.87 Makefile
*** doc/src/sgml/Makefile    7 Jan 2007 08:49:31 -0000    1.87
--- doc/src/sgml/Makefile    8 Jan 2007 23:58:27 -0000
***************
*** 95,114 ****
  ifeq ($(vpath_build), yes)
      @cp $(srcdir)/stylesheet.css .
  endif


  COLLATEINDEX := LC_ALL=C $(PERL) $(COLLATEINDEX) -f -g

- # If HTML.index does not exist, create a dummy bookindex.sgml.  During the
- # next build, create bookindex.sgml with the proper index contents.  A proper
- # bookindex.sgml is required to have an index in the output.
- ifeq (,$(wildcard HTML.index))
- bookindex.sgml:
-     $(COLLATEINDEX) -o $@ -N
- else
  bookindex.sgml: HTML.index
!     $(COLLATEINDEX) -i 'bookindex' -o $@ $<
! endif

  version.sgml: $(top_builddir)/src/Makefile.global
      { \
--- 95,119 ----
  ifeq ($(vpath_build), yes)
      @cp $(srcdir)/stylesheet.css .
  endif
+ ifneq ($(DRAFT), "Y")
+     cmp -s HTML.index.start HTML.index || $(MAKE) $(MAKECMDGOALS)
+ endif


  COLLATEINDEX := LC_ALL=C $(PERL) $(COLLATEINDEX) -f -g

  bookindex.sgml: HTML.index
! # create a dummy bookindex.html
!     test -s HTML.index || $(COLLATEINDEX) -o $@ -N
! # If HTML.index is valid, create a valid bookindex.sgml.  This
! # is required so the output has a proper index.
!     test ! -s HTML.index || $(COLLATEINDEX) -i 'bookindex' -o $@ $<
! # save copy of HTML.index for later comparison
!     cp HTML.index HTML.index.start
!
! HTML.index:
! # create HTML.index if it does not exist
!     $(if $(wildcard HTML.index), , touch HTML.index)

  version.sgml: $(top_builddir)/src/Makefile.global
      { \
***************
*** 141,155 ****
--- 146,172 ----

  %-A4.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@ $<
+ ifneq ($(DRAFT), "Y")
+     cmp -s HTML.index.start HTML.index || $(MAKE) $(MAKECMDGOALS)
+ endif

  %-US.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=USletter -o $@ $<
+ ifneq ($(DRAFT), "Y")
+     cmp -s HTML.index.start HTML.index || $(MAKE) $(MAKECMDGOALS)
+ endif

  %-A4.tex-pdf: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=A4 -o $@ $<
+ ifneq ($(DRAFT), "Y")
+     cmp -s HTML.index.start HTML.index || $(MAKE) $(MAKECMDGOALS)
+ endif

  %-US.tex-pdf: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=USletter -o $@ $<
+ ifneq ($(DRAFT), "Y")
+     cmp -s HTML.index.start HTML.index || $(MAKE) $(MAKECMDGOALS)
+ endif

  %.dvi: %.tex-ps
      @rm -f $*.aux $*.log
***************
*** 291,297 ****
  # print
      rm -f *.rtf *.tex-ps *.tex-pdf *.dvi *.aux *.log *.ps *.pdf *.out *.eps *.fot
  # index
!     rm -f HTML.index $(GENERATED_SGML)
  # text
      rm -f INSTALL HISTORY regress_README
  # XSLT
--- 308,314 ----
  # print
      rm -f *.rtf *.tex-ps *.tex-pdf *.dvi *.aux *.log *.ps *.pdf *.out *.eps *.fot
  # index
!     rm -f HTML.index HTML.index.start $(GENERATED_SGML)
  # text
      rm -f INSTALL HISTORY regress_README
  # XSLT
Index: doc/src/sgml/docguide.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/docguide.sgml,v
retrieving revision 1.63
diff -c -c -r1.63 docguide.sgml
*** doc/src/sgml/docguide.sgml    15 Dec 2006 16:50:07 -0000    1.63
--- doc/src/sgml/docguide.sgml    8 Jan 2007 23:58:27 -0000
***************
*** 542,552 ****
     </para>

     <para>
!     When the HTML documentation is built, the process also generates
!     the linking information for the index entries.  Thus, if you want
!     your documentation to have a concept index at the end, you need to
!     build the HTML documentation once, and then build the
!     documentation again in whatever format you like.
     </para>

     <para>
--- 542,553 ----
     </para>

     <para>
!     To create a proper index, the build might process several identical
!     stages.  If you do not care about an index, and just want to
!     proof-read the output, use <literal>DRAFT</>:
! <screen>
! <prompt>doc/src/sgml$ </prompt><userinput>gmake DRAFT="Y" html</userinput>
! </screen>
     </para>

     <para>

Re: [HACKERS] SGML index build fix

From
Tom Lane
Date:
Bruce Momjian <bruce@momjian.us> writes:
> Peter Eisentraut wrote:
>> The problem is that this requires two runs even to proof the documentation,
>> which I think no one wants.

> So what would the API be to signal you want a draft build?
>     gmake DRAFT="Y" html

I'd vote for

    gmake draft

            regards, tom lane

Re: [HACKERS] SGML index build fix

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > Peter Eisentraut wrote:
> >> The problem is that this requires two runs even to proof the documentation,
> >> which I think no one wants.
>
> > So what would the API be to signal you want a draft build?
> >     gmake DRAFT="Y" html
>
> I'd vote for
>
>     gmake draft

OK, I used that syntax (and needed another use of recursion to do it).
Attached.

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/Makefile
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/Makefile,v
retrieving revision 1.87
diff -c -c -r1.87 Makefile
*** doc/src/sgml/Makefile    7 Jan 2007 08:49:31 -0000    1.87
--- doc/src/sgml/Makefile    9 Jan 2007 03:13:06 -0000
***************
*** 65,71 ****
  ## Man pages
  ##

! .PHONY: man

  DEFAULTSECTION := $(sqlmansect_dummy)

--- 65,71 ----
  ## Man pages
  ##

! .PHONY: man draft

  DEFAULTSECTION := $(sqlmansect_dummy)

***************
*** 95,115 ****
  ifeq ($(vpath_build), yes)
      @cp $(srcdir)/stylesheet.css .
  endif


  COLLATEINDEX := LC_ALL=C $(PERL) $(COLLATEINDEX) -f -g

! # If HTML.index does not exist, create a dummy bookindex.sgml.  During the
! # next build, create bookindex.sgml with the proper index contents.  A proper
! # bookindex.sgml is required to have an index in the output.
! ifeq (,$(wildcard HTML.index))
! bookindex.sgml:
!     $(COLLATEINDEX) -o $@ -N
  else
! bookindex.sgml: HTML.index
!     $(COLLATEINDEX) -i 'bookindex' -o $@ $<
  endif

  version.sgml: $(top_builddir)/src/Makefile.global
      { \
        echo "<!entity version \"$(VERSION)\">"; \
--- 95,132 ----
  ifeq ($(vpath_build), yes)
      @cp $(srcdir)/stylesheet.css .
  endif
+ ifndef DRAFT
+     @cmp -s HTML.index.start HTML.index || $(MAKE) $*
+ endif


  COLLATEINDEX := LC_ALL=C $(PERL) $(COLLATEINDEX) -f -g

! draft:
! ifndef DRAFT
! ifneq ($(MAKECMDGOALS), draft)
! # Call ourselves with the DRAFT value set.  This seems to be the only
! # way to set gmake variables in a rule.
!     @$(MAKE) DRAFT="Y" $(MAKECMDGOALS))
  else
! # run default 'all' rule
!     @$(MAKE) DRAFT="Y" html
! endif
  endif

+ bookindex.sgml: HTML.index
+ # create a dummy bookindex.html
+     test -s HTML.index || $(COLLATEINDEX) -o $@ -N
+ # If HTML.index is valid, create a valid bookindex.sgml.  This
+ # is required so the output has a proper index.
+     test ! -s HTML.index || $(COLLATEINDEX) -i 'bookindex' -o $@ $<
+ # save copy of HTML.index for later comparison
+     @cp HTML.index HTML.index.start
+
+ HTML.index:
+ # create HTML.index if it does not exist
+     @$(if $(wildcard HTML.index), , touch HTML.index)
+
  version.sgml: $(top_builddir)/src/Makefile.global
      { \
        echo "<!entity version \"$(VERSION)\">"; \
***************
*** 141,155 ****
--- 158,184 ----

  %-A4.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@ $<
+ ifndef DRAFT
+     @cmp -s HTML.index.start HTML.index || $(MAKE) $*
+ endif

  %-US.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=USletter -o $@ $<
+ ifndef DRAFT
+     @cmp -s HTML.index.start HTML.index || $(MAKE) $*
+ endif

  %-A4.tex-pdf: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=A4 -o $@ $<
+ ifndef DRAFT
+     @cmp -s HTML.index.start HTML.index || $(MAKE) $*
+ endif

  %-US.tex-pdf: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=USletter -o $@ $<
+ ifndef DRAFT
+     @cmp -s HTML.index.start HTML.index || $(MAKE) $*
+ endif

  %.dvi: %.tex-ps
      @rm -f $*.aux $*.log
***************
*** 291,297 ****
  # print
      rm -f *.rtf *.tex-ps *.tex-pdf *.dvi *.aux *.log *.ps *.pdf *.out *.eps *.fot
  # index
!     rm -f HTML.index $(GENERATED_SGML)
  # text
      rm -f INSTALL HISTORY regress_README
  # XSLT
--- 320,326 ----
  # print
      rm -f *.rtf *.tex-ps *.tex-pdf *.dvi *.aux *.log *.ps *.pdf *.out *.eps *.fot
  # index
!     rm -f HTML.index HTML.index.start $(GENERATED_SGML)
  # text
      rm -f INSTALL HISTORY regress_README
  # XSLT
Index: doc/src/sgml/docguide.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/docguide.sgml,v
retrieving revision 1.63
diff -c -c -r1.63 docguide.sgml
*** doc/src/sgml/docguide.sgml    15 Dec 2006 16:50:07 -0000    1.63
--- doc/src/sgml/docguide.sgml    9 Jan 2007 03:13:06 -0000
***************
*** 542,552 ****
     </para>

     <para>
!     When the HTML documentation is built, the process also generates
!     the linking information for the index entries.  Thus, if you want
!     your documentation to have a concept index at the end, you need to
!     build the HTML documentation once, and then build the
!     documentation again in whatever format you like.
     </para>

     <para>
--- 542,553 ----
     </para>

     <para>
!     To create a proper index, the build might process several identical
!     stages.  If you do not care about an index, and just want to
!     proof-read the output, use <literal>draft</>:
! <screen>
! <prompt>doc/src/sgml$ </prompt><userinput>gmake draft html</userinput>
! </screen>
     </para>

     <para>

Re: [HACKERS] SGML index build fix

From
Bruce Momjian
Date:
Patch applied.

---------------------------------------------------------------------------

Bruce Momjian wrote:
> Tom Lane wrote:
> > Bruce Momjian <bruce@momjian.us> writes:
> > > Peter Eisentraut wrote:
> > >> The problem is that this requires two runs even to proof the documentation,
> > >> which I think no one wants.
> >
> > > So what would the API be to signal you want a draft build?
> > >     gmake DRAFT="Y" html
> >
> > I'd vote for
> >
> >     gmake draft
>
> OK, I used that syntax (and needed another use of recursion to do it).
> Attached.
>
> --
>   Bruce Momjian   bruce@momjian.us
>   EnterpriseDB    http://www.enterprisedb.com
>
>   + If your life is a hard drive, Christ can be your backup. +

> Index: doc/src/sgml/Makefile
> ===================================================================
> RCS file: /cvsroot/pgsql/doc/src/sgml/Makefile,v
> retrieving revision 1.87
> diff -c -c -r1.87 Makefile
> *** doc/src/sgml/Makefile    7 Jan 2007 08:49:31 -0000    1.87
> --- doc/src/sgml/Makefile    9 Jan 2007 03:13:06 -0000
> ***************
> *** 65,71 ****
>   ## Man pages
>   ##
>
> ! .PHONY: man
>
>   DEFAULTSECTION := $(sqlmansect_dummy)
>
> --- 65,71 ----
>   ## Man pages
>   ##
>
> ! .PHONY: man draft
>
>   DEFAULTSECTION := $(sqlmansect_dummy)
>
> ***************
> *** 95,115 ****
>   ifeq ($(vpath_build), yes)
>       @cp $(srcdir)/stylesheet.css .
>   endif
>
>
>   COLLATEINDEX := LC_ALL=C $(PERL) $(COLLATEINDEX) -f -g
>
> ! # If HTML.index does not exist, create a dummy bookindex.sgml.  During the
> ! # next build, create bookindex.sgml with the proper index contents.  A proper
> ! # bookindex.sgml is required to have an index in the output.
> ! ifeq (,$(wildcard HTML.index))
> ! bookindex.sgml:
> !     $(COLLATEINDEX) -o $@ -N
>   else
> ! bookindex.sgml: HTML.index
> !     $(COLLATEINDEX) -i 'bookindex' -o $@ $<
>   endif
>
>   version.sgml: $(top_builddir)/src/Makefile.global
>       { \
>         echo "<!entity version \"$(VERSION)\">"; \
> --- 95,132 ----
>   ifeq ($(vpath_build), yes)
>       @cp $(srcdir)/stylesheet.css .
>   endif
> + ifndef DRAFT
> +     @cmp -s HTML.index.start HTML.index || $(MAKE) $*
> + endif
>
>
>   COLLATEINDEX := LC_ALL=C $(PERL) $(COLLATEINDEX) -f -g
>
> ! draft:
> ! ifndef DRAFT
> ! ifneq ($(MAKECMDGOALS), draft)
> ! # Call ourselves with the DRAFT value set.  This seems to be the only
> ! # way to set gmake variables in a rule.
> !     @$(MAKE) DRAFT="Y" $(MAKECMDGOALS))
>   else
> ! # run default 'all' rule
> !     @$(MAKE) DRAFT="Y" html
> ! endif
>   endif
>
> + bookindex.sgml: HTML.index
> + # create a dummy bookindex.html
> +     test -s HTML.index || $(COLLATEINDEX) -o $@ -N
> + # If HTML.index is valid, create a valid bookindex.sgml.  This
> + # is required so the output has a proper index.
> +     test ! -s HTML.index || $(COLLATEINDEX) -i 'bookindex' -o $@ $<
> + # save copy of HTML.index for later comparison
> +     @cp HTML.index HTML.index.start
> +
> + HTML.index:
> + # create HTML.index if it does not exist
> +     @$(if $(wildcard HTML.index), , touch HTML.index)
> +
>   version.sgml: $(top_builddir)/src/Makefile.global
>       { \
>         echo "<!entity version \"$(VERSION)\">"; \
> ***************
> *** 141,155 ****
> --- 158,184 ----
>
>   %-A4.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
>       $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@ $<
> + ifndef DRAFT
> +     @cmp -s HTML.index.start HTML.index || $(MAKE) $*
> + endif
>
>   %-US.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
>       $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=USletter -o $@ $<
> + ifndef DRAFT
> +     @cmp -s HTML.index.start HTML.index || $(MAKE) $*
> + endif
>
>   %-A4.tex-pdf: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
>       $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=A4 -o $@ $<
> + ifndef DRAFT
> +     @cmp -s HTML.index.start HTML.index || $(MAKE) $*
> + endif
>
>   %-US.tex-pdf: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
>       $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=USletter -o $@ $<
> + ifndef DRAFT
> +     @cmp -s HTML.index.start HTML.index || $(MAKE) $*
> + endif
>
>   %.dvi: %.tex-ps
>       @rm -f $*.aux $*.log
> ***************
> *** 291,297 ****
>   # print
>       rm -f *.rtf *.tex-ps *.tex-pdf *.dvi *.aux *.log *.ps *.pdf *.out *.eps *.fot
>   # index
> !     rm -f HTML.index $(GENERATED_SGML)
>   # text
>       rm -f INSTALL HISTORY regress_README
>   # XSLT
> --- 320,326 ----
>   # print
>       rm -f *.rtf *.tex-ps *.tex-pdf *.dvi *.aux *.log *.ps *.pdf *.out *.eps *.fot
>   # index
> !     rm -f HTML.index HTML.index.start $(GENERATED_SGML)
>   # text
>       rm -f INSTALL HISTORY regress_README
>   # XSLT
> Index: doc/src/sgml/docguide.sgml
> ===================================================================
> RCS file: /cvsroot/pgsql/doc/src/sgml/docguide.sgml,v
> retrieving revision 1.63
> diff -c -c -r1.63 docguide.sgml
> *** doc/src/sgml/docguide.sgml    15 Dec 2006 16:50:07 -0000    1.63
> --- doc/src/sgml/docguide.sgml    9 Jan 2007 03:13:06 -0000
> ***************
> *** 542,552 ****
>      </para>
>
>      <para>
> !     When the HTML documentation is built, the process also generates
> !     the linking information for the index entries.  Thus, if you want
> !     your documentation to have a concept index at the end, you need to
> !     build the HTML documentation once, and then build the
> !     documentation again in whatever format you like.
>      </para>
>
>      <para>
> --- 542,553 ----
>      </para>
>
>      <para>
> !     To create a proper index, the build might process several identical
> !     stages.  If you do not care about an index, and just want to
> !     proof-read the output, use <literal>draft</>:
> ! <screen>
> ! <prompt>doc/src/sgml$ </prompt><userinput>gmake draft html</userinput>
> ! </screen>
>      </para>
>
>      <para>

>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
>        choose an index scan if your joining column's datatypes do not
>        match

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Re: [HACKERS] SGML index build fix

From
Peter Eisentraut
Date:
Bruce Momjian wrote:
> >   %-A4.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
> >       $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@ $<
> > + ifndef DRAFT
> > +     @cmp -s HTML.index.start HTML.index || $(MAKE) $*
> > + endif

What is the point of that?

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: [HACKERS] SGML index build fix

From
Peter Eisentraut
Date:
Bruce Momjian wrote:
> > + ifndef DRAFT
> > +     @cmp -s HTML.index.start HTML.index || $(MAKE) $*
> > + endif

Why are you using $*?  This isn't a pattern rule.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: [HACKERS] SGML index build fix

From
Peter Eisentraut
Date:
Bruce Momjian wrote:
> > ! draft:
> > ! ifndef DRAFT
> > ! ifneq ($(MAKECMDGOALS), draft)

How could this condition ever match?

> > ! # Call ourselves with the DRAFT value set.  This seems to be the only
> > ! # way to set gmake variables in a rule.
> > !     @$(MAKE) DRAFT="Y" $(MAKECMDGOALS))
> >   else
> > ! # run default 'all' rule
> > !     @$(MAKE) DRAFT="Y" html
> > ! endif
> >   endif

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: [HACKERS] SGML index build fix

From
Bruce Momjian
Date:
Peter Eisentraut wrote:
> Bruce Momjian wrote:
> > > ? %-A4.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
> > > ? ????$(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@ $<
> > > + ifndef DRAFT
> > > + ????@cmp -s HTML.index.start HTML.index || $(MAKE) $*
> > > + endif
>
> What is the point of that?

If HTML.index changed during the build, we need to rerun it until it is
unchanged.

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Re: [HACKERS] SGML index build fix

From
Bruce Momjian
Date:
Peter Eisentraut wrote:
> Bruce Momjian wrote:
> > > + ifndef DRAFT
> > > + ????@cmp -s HTML.index.start HTML.index || $(MAKE) $*
> > > + endif
>
> Why are you using $*?  This isn't a pattern rule.
>

Sorry, my mistake.  Here is an patch to fix that.

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/Makefile
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/Makefile,v
retrieving revision 1.88
diff -c -c -r1.88 Makefile
*** doc/src/sgml/Makefile    9 Jan 2007 22:19:36 -0000    1.88
--- doc/src/sgml/Makefile    10 Jan 2007 01:23:40 -0000
***************
*** 96,102 ****
      @cp $(srcdir)/stylesheet.css .
  endif
  ifndef DRAFT
!     @cmp -s HTML.index.start HTML.index || $(MAKE) $*
  endif


--- 96,102 ----
      @cp $(srcdir)/stylesheet.css .
  endif
  ifndef DRAFT
!     @cmp -s HTML.index.start HTML.index || $(MAKE) $(MAKECMDGOALS)
  endif


***************
*** 107,113 ****
  ifneq ($(MAKECMDGOALS), draft)
  # Call ourselves with the DRAFT value set.  This seems to be the only
  # way to set gmake variables in a rule.
!     @$(MAKE) DRAFT="Y" $(MAKECMDGOALS))
  else
  # run default 'all' rule
      @$(MAKE) DRAFT="Y" all
--- 107,113 ----
  ifneq ($(MAKECMDGOALS), draft)
  # Call ourselves with the DRAFT value set.  This seems to be the only
  # way to set gmake variables in a rule.
!     @$(MAKE) DRAFT="Y" $(MAKECMDGOALS)
  else
  # run default 'all' rule
      @$(MAKE) DRAFT="Y" all
***************
*** 159,183 ****
  %-A4.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@ $<
  ifndef DRAFT
!     @cmp -s HTML.index.start HTML.index || $(MAKE) $*
  endif

  %-US.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=USletter -o $@ $<
  ifndef DRAFT
!     @cmp -s HTML.index.start HTML.index || $(MAKE) $*
  endif

  %-A4.tex-pdf: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=A4 -o $@ $<
  ifndef DRAFT
!     @cmp -s HTML.index.start HTML.index || $(MAKE) $*
  endif

  %-US.tex-pdf: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=USletter -o $@ $<
  ifndef DRAFT
!     @cmp -s HTML.index.start HTML.index || $(MAKE) $*
  endif

  %.dvi: %.tex-ps
--- 159,183 ----
  %-A4.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@ $<
  ifndef DRAFT
!     @cmp -s HTML.index.start HTML.index || $(MAKE) $@
  endif

  %-US.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=USletter -o $@ $<
  ifndef DRAFT
!     @cmp -s HTML.index.start HTML.index || $(MAKE) $@
  endif

  %-A4.tex-pdf: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=A4 -o $@ $<
  ifndef DRAFT
!     @cmp -s HTML.index.start HTML.index || $(MAKE) $@
  endif

  %-US.tex-pdf: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=USletter -o $@ $<
  ifndef DRAFT
!     @cmp -s HTML.index.start HTML.index || $(MAKE) $@
  endif

  %.dvi: %.tex-ps

Re: [HACKERS] SGML index build fix

From
Bruce Momjian
Date:
Peter Eisentraut wrote:
> Bruce Momjian wrote:
> > > ! draft:
> > > ! ifndef DRAFT
> > > ! ifneq ($(MAKECMDGOALS), draft)
>
> How could this condition ever match?

On first call, 'draft' might be set, but in the recursive call, this
code will not be reached because DRAFT iss set.

---------------------------------------------------------------------------

>
> > > ! # Call ourselves with the DRAFT value set. ?This seems to be the only
> > > ! # way to set gmake variables in a rule.
> > > ! ????@$(MAKE) DRAFT="Y" $(MAKECMDGOALS))
> > > ? else
> > > ! # run default 'all' rule
> > > ! ????@$(MAKE) DRAFT="Y" html
> > > ! endif
> > > ? endif
>
> --
> Peter Eisentraut
> http://developer.postgresql.org/~petere/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faq

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Re: [HACKERS] [PATCHES] SGML index build fix

From
Peter Eisentraut
Date:
Am Mittwoch, 10. Januar 2007 01:41 schrieb Bruce Momjian:
> Peter Eisentraut wrote:
> > Bruce Momjian wrote:
> > > > ? %-A4.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
> > > > ? ????$(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@ $<
> > > > + ifndef DRAFT
> > > > + ????@cmp -s HTML.index.start HTML.index || $(MAKE) $*
> > > > + endif
> >
> > What is the point of that?
>
> If HTML.index changed during the build, we need to rerun it until it is
> unchanged.

But that rule doesn't change HTML.index.
--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: [HACKERS] [PATCHES] SGML index build fix

From
Bruce Momjian
Date:
Peter Eisentraut wrote:
> Am Mittwoch, 10. Januar 2007 01:41 schrieb Bruce Momjian:
> > Peter Eisentraut wrote:
> > > Bruce Momjian wrote:
> > > > > ? %-A4.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
> > > > > ? ????$(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@ $<
> > > > > + ifndef DRAFT
> > > > > + ????@cmp -s HTML.index.start HTML.index || $(MAKE) $*
> > > > > + endif
> > >
> > > What is the point of that?
> >
> > If HTML.index changed during the build, we need to rerun it until it is
> > unchanged.
>
> But that rule doesn't change HTML.index.

Now that the rule is right:

    %-A4.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
            $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@ $<
    ifndef DRAFT
            @cmp -s HTML.index.start HTML.index || $(MAKE) $@
    endif

The rule re-runs the makefile for the specific target, and the target
modifies HTML.index, or it is only the HTML rule that modifies that.
That was a question I had.  If that is true, it has to be:

    %-A4.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
            $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@ $<
    ifndef DRAFT
            @cmp -s HTML.index.start HTML.index || $(MAKE) html $@
    endif

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Re: [HACKERS] [PATCHES] SGML index build fix

From
Peter Eisentraut
Date:
Bruce Momjian wrote:
> The rule re-runs the makefile for the specific target, and the target
> modifies HTML.index, or it is only the HTML rule that modifies that.

Only the html rule modifies HTML.index.

> That was a question I had.  If that is true, it has to be:
>
>     %-A4.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
>             $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@
> $< ifndef DRAFT
>             @cmp -s HTML.index.start HTML.index || $(MAKE) html $@
>     endif

It would much easier to just run the html rule before the other stuff.
--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: [HACKERS] [PATCHES] SGML index build fix

From
Bruce Momjian
Date:
Peter Eisentraut wrote:
> Bruce Momjian wrote:
> > The rule re-runs the makefile for the specific target, and the target
> > modifies HTML.index, or it is only the HTML rule that modifies that.
>
> Only the html rule modifies HTML.index.
>
> > That was a question I had.  If that is true, it has to be:
> >
> >     %-A4.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
> >             $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@
> > $< ifndef DRAFT
> >             @cmp -s HTML.index.start HTML.index || $(MAKE) html $@
> >     endif
>
> It would much easier to just run the html rule before the other stuff.

OK, so just make HTML a depenency for those.  Patch attached and
applied.

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/Makefile
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/Makefile,v
retrieving revision 1.89
diff -c -c -r1.89 Makefile
*** doc/src/sgml/Makefile    10 Jan 2007 01:57:15 -0000    1.89
--- doc/src/sgml/Makefile    10 Jan 2007 17:45:35 -0000
***************
*** 89,94 ****
--- 89,95 ----

  .PHONY: html

+ # This is run for all output formats because we need bookindex.sgml
  html: postgres.sgml $(ALLSGML) stylesheet.dsl
      @rm -f *.html
      $(JADE) $(JADEFLAGS) $(SPFLAGS) $(SGMLINCLUDE) $(CATALOG) -d stylesheet.dsl -i output-html -t sgml $<
***************
*** 96,130 ****
      @cp $(srcdir)/stylesheet.css .
  endif
  ifndef DRAFT
!     @cmp -s HTML.index.start HTML.index || $(MAKE) $(MAKECMDGOALS)
  endif


  COLLATEINDEX := LC_ALL=C $(PERL) $(COLLATEINDEX) -f -g

  draft:
  ifndef DRAFT
  ifneq ($(MAKECMDGOALS), draft)
- # Call ourselves with the DRAFT value set.  This seems to be the only
- # way to set gmake variables in a rule.
      @$(MAKE) DRAFT="Y" $(MAKECMDGOALS)
  else
! # run default 'all' rule
      @$(MAKE) DRAFT="Y" all
  endif
  endif

  bookindex.sgml: HTML.index
  # create a dummy bookindex.html
      test -s HTML.index || $(COLLATEINDEX) -o $@ -N
! # If HTML.index is valid, create a valid bookindex.sgml.  This
! # is required so the output has a proper index.
      test ! -s HTML.index || $(COLLATEINDEX) -i 'bookindex' -o $@ $<
  # save copy of HTML.index for later comparison
      @cp HTML.index HTML.index.start

  HTML.index:
! # create HTML.index if it does not exist
      @$(if $(wildcard HTML.index), , touch HTML.index)

  version.sgml: $(top_builddir)/src/Makefile.global
--- 97,132 ----
      @cp $(srcdir)/stylesheet.css .
  endif
  ifndef DRAFT
!     @cmp -s HTML.index.start HTML.index || $(MAKE) $@
  endif


  COLLATEINDEX := LC_ALL=C $(PERL) $(COLLATEINDEX) -f -g

+ # The draft rule calls $(MAKE) again and sets the DRAFT variable.
+ # This seems to be the only way to set gmake variables in a rule.
  draft:
  ifndef DRAFT
  ifneq ($(MAKECMDGOALS), draft)
      @$(MAKE) DRAFT="Y" $(MAKECMDGOALS)
  else
! # simulate $(MAKE) with no arguments
      @$(MAKE) DRAFT="Y" all
  endif
  endif

+ # bookindex.sgml is required so there is a proper index for all output formats
  bookindex.sgml: HTML.index
  # create a dummy bookindex.html
      test -s HTML.index || $(COLLATEINDEX) -o $@ -N
! # If HTML.index is valid, create a valid bookindex.sgml.
      test ! -s HTML.index || $(COLLATEINDEX) -i 'bookindex' -o $@ $<
  # save copy of HTML.index for later comparison
      @cp HTML.index HTML.index.start

+ # HTML.index is used to create bookindex.sgml
  HTML.index:
! # create an empty HTML.index if it does not exist
      @$(if $(wildcard HTML.index), , touch HTML.index)

  version.sgml: $(top_builddir)/src/Makefile.global
***************
*** 156,184 ****

  JADE.tex.call = $(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -d $(srcdir)/stylesheet.dsl -t tex -V tex-backend -i
output-print

! %-A4.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@ $<
- ifndef DRAFT
-     @cmp -s HTML.index.start HTML.index || $(MAKE) $@
- endif

! %-US.tex-ps: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=USletter -o $@ $<
- ifndef DRAFT
-     @cmp -s HTML.index.start HTML.index || $(MAKE) $@
- endif

! %-A4.tex-pdf: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=A4 -o $@ $<
- ifndef DRAFT
-     @cmp -s HTML.index.start HTML.index || $(MAKE) $@
- endif

! %-US.tex-pdf: %.sgml $(ALLSGML) stylesheet.dsl bookindex.sgml
      $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=USletter -o $@ $<
- ifndef DRAFT
-     @cmp -s HTML.index.start HTML.index || $(MAKE) $@
- endif

  %.dvi: %.tex-ps
      @rm -f $*.aux $*.log
--- 158,174 ----

  JADE.tex.call = $(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -d $(srcdir)/stylesheet.dsl -t tex -V tex-backend -i
output-print

! %-A4.tex-ps: %.sgml $(ALLSGML) html
      $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=A4 -o $@ $<

! %-US.tex-ps: %.sgml $(ALLSGML) html
      $(JADE.tex.call) -V texdvi-output -V '%paper-type%'=USletter -o $@ $<

! %-A4.tex-pdf: %.sgml $(ALLSGML) html
      $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=A4 -o $@ $<

! %-US.tex-pdf: %.sgml $(ALLSGML) html
      $(JADE.tex.call) -V texpdf-output -V '%paper-type%'=USletter -o $@ $<

  %.dvi: %.tex-ps
      @rm -f $*.aux $*.log