[Top][All Lists]

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

Re: problems with $(eval include...)

From: Fabio Alemagna
Subject: Re: problems with $(eval include...)
Date: Sat, 28 Jun 2003 01:49:58 +0200 (CEST)

On Fri, 27 Jun 2003, Fabio Alemagna wrote:
> Yes, that's what I thought too, however You'd agree that it would take
> time for make to accomplish that job, and perhaps there could be other
> issues, like dependency loops, which would be impossible to solve, or very
> very difficult. It seems only perfectly logical, to me, to exploit make
> itself to do that dependencies check rather than doing it "by hand".

Well, I've come up with some code which calculates all dependencies and
even detects loops, so this might be used as fall-back solution in case
the make's bug doesn't get solved.

This is the code:

define getdeplist_1
$(eval __ALLDEPS__ += $(1)) $(foreach m,$(1),$(foreach d,$($(m)/DEPS),$(if \
$(findstring $(d),$(__ALLDEPS__)),,$(call getdeplist_1,$(d)))))

getdeplist = $(eval __ALLDEPS__ :=) $(call getdeplist_1,$(1)) $(__ALLDEPS__)

The function to call is getdeplist, which in turn calls getdeplist_1 which
is implemented by recursion.

Given this makefile:

#the dependency graph for the following modules is not acyclic
a/DEPS := e f g h
e/DEPS := i j k e
i/DEPS := j
j/DEPS := a f o

        @echo $(call getdeplist,a b c d)

Gives the following result:

a b c d e i j f o k g h

Which is correct.

Fabio Alemagna

reply via email to

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