[GRASS-dev] GRASS7: makefile issue with -j4

Glynn Clements glynn at gclements.plus.com
Thu Sep 29 19:00:16 EDT 2011


Markus Neteler wrote:

> when compiling G7 after make distclean, always
> Errors in:
> /home/neteler/grass70/gui/wxpython/docs
> 
> when using make -jX. A second run solves it.
> 
> Trivial, but it would be nice to see that fixed. My Makefile foo
> is not sufficient for this.

The pattern rule in Html.make for $(HTMLDIR)/%.html installs all of
the PNG and JPG files in the directory to $(HTMLDIR), using an
explicit recursive invocation of $(MAKE).

So, when using -j, multiple .html files are "built" in parallel, and
each one attempts to "build" all of the images. AFAICT, the recursive
makes don't communicate with each other, so they each try to make all
of the image targets.

One option is to eliminate the recusive make and have the images as
normal prerequisites, i.e.:

 IMGSRC := $(wildcard *.png) $(wildcard *.jpg)
+IMGDST := $(patsubst %,$(HTMLDIR)/%,$(IMGSRC))
 
-$(HTMLDIR)/%.html: %.html %.tmp.html $(HTMLSRC) | $(HTMLDIR)
+$(HTMLDIR)/%.html: %.html %.tmp.html $(HTMLSRC) $(IMGDST) | $(HTMLDIR)
 	$(PYTHON) $(GISBASE)/tools/mkhtml.py $* $(GRASS_VERSION_DATE) > $@
-ifneq ($(strip $(IMGSRC)),)
-	if test -n "$(IMGSRC)" ; then \
-		$(MAKE) $(patsubst %,$(HTMLDIR)/%,$(IMGSRC)) ; \
-	fi
-endif

Another option is to have gui/wxpython/docs/Makefile explicitly make
the images before the HTML files, e.g.:

 FILES := $(wildcard *.html)
+IMAGES := $(wildcard *.jpg)

-default: $(patsubst %,$(HTMLDIR)/%,$(FILES))
+default:
+	$(MAKE) $(patsubst %,$(HTMLDIR)/%,$(IMAGES))
+	$(MAKE) $(patsubst %,$(HTMLDIR)/%,$(FILES))

If the first option works, I'd choose that, as it should work for all
cases; gui/wxpython/docs may not be the only directory with images and
multiple HTML files.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list