Hello Simon,

I was thinking about the comment in $(TOP)/libraries/Makefile:27-30:

# make doesn't give us an easy way to get the libraries built in
# dependency order the first time, but not rebuild base (for example)
# when we want to rebuild another library later.
# So for now we just don't do anything in parallel in here.

due to running over a list when you need to show Make the list as a set of dependancies. It is not noted in $(TOP)/Makefile but that has the same problem for Make; it does not manifest itself because it is hidden by a shell script:

$(TOP)/Makefile:92-98:

        for i in $(SUBDIRS_BUILD); do \
echo "----------------------------------------------------------------------- -"; \
          echo "== $(MAKE) boot $(MFLAGS);"; \
          echo " in $(shell pwd)/$$i"; \
echo "----------------------------------------------------------------------- -"; \
          $(MAKE) --no-print-directory -C $$i $(MFLAGS) boot; \
          if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ;  then true; else exit 1; fi; \

There is a good solution for this that, as I have tested it, works with GNU Make 3.80 (you do not need 3.81): do a recursive eval for the targets so, as Make evaluates each target in the list it produces a rule. (This would also eliminate the 'for' block in $(TOP)/ Makefile.) Here is a simple demonstration:

--- test Makefile

dirs := one two three four five six

.PHONY : all

all : $(dirs)

% : $(dirs)

# $(call one_target,target)
define one_target
$(1) :
        @echo "$(1)"
endef

# for $(word n,text), if n > num words, evaluates to empty
# $(call depend_rec,first_target,rest)
define depend_rec

$$(eval $$(if $$(word 2, $(2)),\
      $$(call depend_rec,\
         $$(firstword $(2)),$$(wordlist 2, $$(words $(2)), $(2))),\
         $$(call one_target,$(2))))

$(1) : $(2)
        @echo "$(1)"

endef

$(eval $(call depend_rec,$(firstword $(dirs)),\
  $(wordlist 2,$(words $(dirs)),$(dirs))))

--- end test Makefile

At the end of this Make will have created targets for each of the items in the list in reverse order:

six :
        [commands]

five : six
        [commands]

...

one : two three four five six
        [commands]

Following this, Make would easily be able to handle building in parallel for libraries/Makefile. If you like the idea I will implement it and send a patch. The only catch is the base Make version required would go up to 3.80.

Cheers,
Pete


_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to