bug-automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

info files deleted by "make"


From: Bruno Haible
Subject: info files deleted by "make"
Date: Mon, 24 Feb 2003 12:52:50 +0100 (CET)

Hi,

It's annoying that a failing run of makeinfo, due to a simple syntax error
in the .texi file for example, removes all generated info files.

I was writing two documentation sections and wanted to check the first of
them after writing it. I can easily afford to wait for this check until the
second section is complete. But I need the browse the info file while writing
every section - in order to meet the style of other material on the
documentation, avoid redundancies etc.

This removal makes things worse. Instead of being faced with a simple
problem, the unability to proofread new things, I am faced with a more
severe one: the info file is gone.

The "makeinfo" maintainer, Karl Berry, said on 2002-05-02:

  "I agree with you that it would be better to not remove the output file.
   ... I'll work on fixing this at some point."

Now automake also has the same annoying behaviour. Example:

  $ tar xvfj gperftest.tar.bz2
  $ cd gperftest
  $ aclocal
  $ autoconf
  $ automake
  $ ./configure
  $ make
  $ ls -l *.info*
  -rw-r--r--    1 bruno    user         1973 2003-02-22 17:12 gperf.info
  -rw-r--r--    1 bruno    user        49563 2003-02-22 17:12 gperf.info-1
  -rw-r--r--    1 bruno    user        24828 2003-02-22 17:12 gperf.info-2

Now edit gperf.texi slightly, with a syntax error, e.g. in line 31.

  $ make
  /bin/sh /tmp/missing --run makeinfo   -I . \
   -o gperf.info `test -f 'gperf.texi' || echo './'`gperf.texi
  gperf.texi:31: Unknown command `copright'.
  gperf.texi:31: Misplaced {.
  gperf.texi:31: Misplaced }.
  makeinfo: Removing output file `gperf.info' due to errors; use --force to 
preserve.
  make: *** [gperf.info] Error 1
  $ ls -l *.info*
  ls: *.info*: No such file or directory

gperf.info was removed by makeinfo - this will be fixed in makeinfo.
But gperf.info-1 and gperf.info-2 were removed by a hidden rule in the
Makefile.

Here is a fix. Among two possible implementations:

  - Save each old file's date before calling makeinfo, to see if makeinfo
    overwrites it,

  - Save each old file before calling makeinfo.

I rejected the first one because
  - "oldtime=`ls -l $file`" doesn't save the time of $file with enough
    precision,
  - "touch -r $file $file.stamp" uses GNU touch and is not portable,
  - "cp -p $file $file~" unnecessarily copies a lot of data.

So here is one according to the second idea.

2003-02-22  Bruno Haible  <address@hidden>

        * lib/am/texibuild.am: Don't remove the target info files. Instead,
        backup and restore them if makeinfo fails.

*** automake-1.7.2/lib/am/texibuild.am.bak      2002-11-30 13:47:18.000000000 
+0100
--- automake-1.7.2/lib/am/texibuild.am  2003-02-22 17:57:29.000000000 +0100
***************
*** 20,37 ****
  
  ?GENERIC_INFO?%SOURCE_SUFFIX%%DEST_SUFFIX%:
  ?!GENERIC_INFO?%DEST_PREFIX%%DEST_SUFFIX%: %SOURCE_INFO% %DEPS%
- ## Note that we also remove the possible output files before running
- ## makeinfo.  Otherwise, if the texinfo file shrinks (or if you start
- ## using --no-split), you'll be left with some dead info files lying
- ## around -- dead files which will end up in the distribution.
-       @rm -f $@ address@hidden address@hidden
  ## It is wrong to have `info' files dependent on %DIRSTAMP%, because
  ## `info' files are distributed and %DIRSTAMP% isn't: a distributed file
  ## should never be dependent upon a non-distributed built file.
  ## Therefore we ensure that %DIRSTAMP% exists in the rule.
  ?DIRSTAMP?    @test -f %DIRSTAMP% || $(MAKE) %DIRSTAMP%
        $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) %MAKEINFOFLAGS% \
!        -o $@ `test -f '%SOURCE_INFO%' || echo '$(srcdir)/'`%SOURCE_INFO%
  
  ?GENERIC?%SOURCE_SUFFIX%.dvi:
  ?!GENERIC?%DEST_PREFIX%.dvi: %SOURCE% %DEPS% %DIRSTAMP%
--- 20,56 ----
  
  ?GENERIC_INFO?%SOURCE_SUFFIX%%DEST_SUFFIX%:
  ?!GENERIC_INFO?%DEST_PREFIX%%DEST_SUFFIX%: %SOURCE_INFO% %DEPS%
  ## It is wrong to have `info' files dependent on %DIRSTAMP%, because
  ## `info' files are distributed and %DIRSTAMP% isn't: a distributed file
  ## should never be dependent upon a non-distributed built file.
  ## Therefore we ensure that %DIRSTAMP% exists in the rule.
  ?DIRSTAMP?    @test -f %DIRSTAMP% || $(MAKE) %DIRSTAMP%
+ ## Back up the info files before running makeinfo. This is the cheapest
+ ## way to ensure that
+ ## 1) If the texinfo file shrinks (or if you start using --no-split),
+ ##    you'll not be left with some dead info files lying around -- dead
+ ##    files which would end up in the distribution.
+ ## 2) If the texinfo file has some minor mistakes which cause makeinfo
+ ##    to fail, the info files are not removed.  (They are needed by the
+ ##    developer while he writes documentation.)
+ ## with the additional constraint that there is no portable way in sh to
+ ## get a timestamp with 1 second resolution.
+       savedfiles=""; \
+       for file in $@ address@hidden address@hidden; do \
+         if test -f "$$file"; then \
+           mv "$$file" "$$file"~; \
+           savedfiles="$$savedfiles $$file"; \
+         fi; \
+       done; \
        $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) %MAKEINFOFLAGS% \
!        -o $@ `test -f '%SOURCE_INFO%' || echo '$(srcdir)/'`%SOURCE_INFO%; \
!       rc=$$?; \
!       if test $$rc = 0; then \
!         for file in $$savedfiles; do rm -f "$$file"~; done; \
!       else \
!         for file in $$savedfiles; do mv "$$file"~ "$$file"; done; \
!       fi; \
!       exit $$rc
  
  ?GENERIC?%SOURCE_SUFFIX%.dvi:
  ?!GENERIC?%DEST_PREFIX%.dvi: %SOURCE% %DEPS% %DIRSTAMP%



Attachment: gperftest.tar.bz2
Description: gperftest.tar.bz2


reply via email to

[Prev in Thread] Current Thread [Next in Thread]