The following commit has been merged in the master branch:
commit c0b1f9a49617b8822f26e431101806c314316256
Author: Christoph Berg <[email protected]>
Date:   Fri Dec 31 21:02:10 2010 +0100

    Fix Makefiles for parallel use
    
    With make -j N, the construct "a: b c" does not ensure that b has been
    finished when c is built. Fix this by adding dependencies, or by
    explicity serialization for the case of rules with patterns.

diff --git a/Makefile b/Makefile
index 2d382ea..04264d0 100644
--- a/Makefile
+++ b/Makefile
@@ -35,7 +35,7 @@ install: all install_scripts
        cp -a $(PERL_MODULES) $(DESTDIR)$(PERLMOD_DIR)
        cp $(EXAMPLES) $(DESTDIR)$(EXAMPLES_DIR)
 
-make_scripts:
+make_scripts: version
        $(MAKE) -C scripts/
        touch $@
 clean_scripts: clean_translated_manpages
diff --git a/debian/changelog b/debian/changelog
index dccbca4..f07f924 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -16,6 +16,7 @@ devscripts (2.10.70) UNRELEASED; urgency=low
   * debcheckout: For debian-dir-only repositories, also retrieve the source
     package, unpack it, and move the missing files over. Add a new option
     --source (DEBCHECKOUT_SOURCE) to control this behavior. (Closes: #535767)
+  * Makefiles: Fix parallelization for use with make -j N.
 
  -- James Vega <[email protected]>  Thu, 02 Dec 2010 20:27:34 -0500
 
diff --git a/po4a/Makefile b/po4a/Makefile
index 27f79d6..3ca447f 100644
--- a/po4a/Makefile
+++ b/po4a/Makefile
@@ -1,17 +1,22 @@
 include ../Makefile.common
 GEN_TR_MAN1S := $(patsubst %.1,fr/%.fr.1,$(GEN_MAN1S))
 
-all: translate $(GEN_TR_MAN1S)
+all: translate
+# GEN_TR_MAN1S needs translate finished, serialize the calls
+       @$(MAKE) -C . transform
+transform: $(GEN_TR_MAN1S)
 
-translate:
-       $(MAKE) -C ../scripts/ devscripts.1
+translate: ../scripts/devscripts.1
        po4a --previous --no-backups devscripts-po4a.conf
        touch translate
-clean:
-# The po4a cleanup fails if devscripts.1 has already been cleaned up
-       $(MAKE) -C ../scripts/ devscripts.1
+
+clean: ../scripts/devscripts.1
        po4a --previous --rm-translations --no-backups devscripts-po4a.conf
-       rm -f $(GEN_TR_MAN1S) translate ../scripts/devscripts.1
+       rm -f $(GEN_TR_MAN1S) translate
+
+../scripts/devscripts.1:
+       # po4a translate and clean need ../scripts/devscripts.1, rebuild it
+       $(MAKE) -C ../scripts/ devscripts.1
 
 fr/%.fr.1: fr/%.fr.pl translate
        podchecker $<
diff --git a/scripts/Makefile b/scripts/Makefile
index a14479e..d288027 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -21,6 +21,10 @@ BIN_LIBDIR = /usr/lib/devscripts
 
 all: $(SCRIPTS) $(GEN_MAN1S) $(LIBS) $(CWRAPPERS) $(COMPLETION)
 
+$(VERSION_FILE):
+       @echo "You need to 'make' the toplevel directory first"
+       @false
+
 %: %.sh
 
 %.tmp: %.sh $(VERSION_FILE)
@@ -40,9 +44,13 @@ all: $(SCRIPTS) $(GEN_MAN1S) $(LIBS) $(CWRAPPERS) 
$(COMPLETION)
        xsltproc --nonet -o $@ \
          /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl $<
 
+# There is a slight chance this gets called twice, once here from here and once
+# from ../po4a/Makefile. Treat files with care.
+PID := $(shell echo $$$$-$$PPID)
 devscripts.1: devscripts.1.in
-       cat $+ > $@
-       perl ../debian/genmanpage.pl >> $@
+       cat $+ > $...@.$(PID)
+       perl ../debian/genmanpage.pl >> $...@.$(PID)
+       mv $...@.$(PID) $@
 
 devscripts.%: %.bash_completion
        cp $< $@

-- 
Git repository for devscripts


-- 
To unsubscribe, send mail to [email protected].

Reply via email to