On 06/15/2012 11:46 AM, Akim Demaille wrote: > > Le 15 juin 2012 à 11:34, Stefano Lattarini a écrit : > >>> Sometimes you using ifdef, and sometimes ifeq "". Are they equivalent? >>> >> AFAIU, these are equivalent: >> >> ifdef VAR >> >> ifneq "$(VAR)" "" >> >> But of course, there no way to express something like this with ifdef: >> >> ifneq "$(VAR-1)$(VAR-2)" "" > > Yes, of course. Maybe note also this warnings from make.info: > > Often you want to test if a variable has a non-empty value. When > the value results from complex expansions of variables and > functions, expansions you would consider empty may actually > contain whitespace characters and thus are not seen as empty. > However, you can use the `strip' function (*note Text Functions::) > to avoid interpreting whitespace as a non-empty value. For > example: > > ifeq ($(strip $(foo)),) > TEXT-IF-EMPTY > endif > > will evaluate TEXT-IF-EMPTY even if the expansion of `$(foo)' > contains whitespace characters. > >>> There's no way to avoid forking another Make here? >>> >> So far I've found no natural way (note that such a fork is there also in >> mainline Automake, so this is not a performance regression at least). > > I know. > >> The >> problem is that all $(BUILT_SOURCES) must be created before we run any of >> all-recursive, all-am, or *any of their prerequisites*. I don't know >> whether there is any natural way to accomplish that with GNU make. Any >> suggestion? > > I don't know. Maybe using order only dependencies? > > %LOCAL-HEADERS% $(BUILT_SOURCES) :| $(if $(SUBDIRS),all-recursive,all-am) > This is backwards: all-am should be run *after* the $(BUILT_SOURCES) have been built, not before.
> all: %LOCAL-HEADERS% $(BUILT_SOURCES) $(if $(SUBDIRS),all-recursive,all-am) > I already tried to use order-only prereqs to tackle this problem. The failure was spectacular :-( The main issue is that order-only dependencies doesn't have actually anything to do with ordering: <http://lists.gnu.org/archive/html/bug-make/2012-06/msg00003.html> But now that I understand what order-only prereqs are truly about, I think they can still be used to shave the extra $(MAKE) invocation if it's not truly necessary: have 'Makefile' depend on $(BUILT_SOURCES) as an order-only prereq, so that any missing $(BUILT_SOURCES) is built before any other target is considered (because GNU make is still deciding whether it ought to rebuild the Makefile). I will give that a try later today, or tomorrow. >>>> am__mkdir = test -d $1 || $(MKDIR_P) $1 >>> >>> Is the "test" really needed? "mkdir -p /already/exists" should silently >>> exit 0, shouldn't it? >>> >> Yes, but then it would cause an extra fork even if the target directory >> already exists. I reckon that would quite displease our Cygwin users ;-) > > Ah, yes, test is expected to be a built-in. Thanks. > >> Thanks. I understand this is an ACK then? > > > Sure! > Thanks, will push shortly. Stefano
