Hi, I'm using help2man to build manpages that I'd like to distribute with the source tarball. I followed the instructions/example in the automake manual, which has manpage foo.1 depend on foo.c and configure.ac, then does a recursive make to build foo$(EXEEXT): <http://www.gnu.org/software/automake/manual/html_node/Errors-with-distclean.html>
This does solve the problem of unnecessarily rebuilding manpages when the binary is rebuilt/relinked, but it also seems to introduce a race condition during parallel makes. The problem is that there are now two ways to build foo$(EXEEXT): (1) the normal automake rule from bin_PROGRAMS/foo_SOURCES and (2) the recursive make for the rule for foo.1. To give a more concrete example, here is a snippet from my Makefile.am: #... bin_PROGRAMS = achd #... achd_SOURCES = src/achd.c src/achutil.c achd_LDADD = libach.la ach_LDADD = libach.la #... doc/achd.1: src/achd.c $(top_srcdir)/configure.ac $(MAKE) $(AM_MAKEFLAGS) achd$(EXEEXT) mkdir -p doc help2man -h -\? -v -V --no-info -n "send ach messages over streams" ./achd$(EXEEXT) -o $@ And then, when the race fails, I get the following output (pruned slightly): % make -kj2 cd . && /bin/bash /home/ntd/git/thebrain.golems.org/lib/ach/missing --run automake-1.11 --gnu Makefile cd . && /bin/bash ./config.status Makefile depfiles config.status: creating Makefile config.status: executing depfiles commands make all-am make[1]: Entering directory `/home/ntd/git/thebrain.golems.org/lib/ach' /usr/bin/gcc -DHAVE_CONFIG_H -I. -I./include -MT achd.o -MD -MP -MF .deps/achd.Tpo -c -o achd.o `test -f 'src/achd.c' || echo './'`src/achd.c make achd make[2]: Entering directory `/home/ntd/git/thebrain.golems.org/lib/ach' /usr/bin/gcc -DHAVE_CONFIG_H -I. -I./include -MT achd.o -MD -MP -MF .deps/achd.Tpo -c -o achd.o `test -f 'src/achd.c' || echo './'`src/achd.c mv -f .deps/achd.Tpo .deps/achd.Po /bin/bash ./libtool --tag=CC --mode=link /usr/bin/gcc -o achd achd.o achutil.o libach.la -lrt -lpthread mv -f .deps/achd.Tpo .deps/achd.Po mv: cannot stat `.deps/achd.Tpo': No such file or directory make[2]: *** [achd.o] Error 1 make[2]: Target `achd' not remade because of errors. make[2]: Leaving directory `/home/ntd/git/thebrain.golems.org/lib/ach' make[1]: *** [doc/achd.1] Error 2 libtool: link: /usr/bin/gcc -o .libs/achd achd.o achutil.o ./.libs/libach.so -lrt -lpthread make[1]: Target `all-am' not remade because of errors. make[1]: Leaving directory `/home/ntd/git/thebrain.golems.org/lib/ach' make: *** [all] Error 2 So, it looks like the second `mv -f .deps/achd.Tpo .deps/achd.Po' is failing because the dependency file was already moved. Is there something silly that I've missed here? It seems that possible resolutions are: * Don't do parallel makes * Don't distribute prebuilt manpages * Build the manpages in a SUBDIR that gets built after . Using SUBDIRs seems like the best of those options, though still not ideal since make may often recurse unnecessarily. Is there any way to do this without more recursive makes? Thanks, -ntd