tech-toolchain archive

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

Strange (b)make behaviour



After half a day of debugging, I need a (b)make expert, please.

I want to be able to pass something (a variable or an additional target) to a 
(b)make invocation, such that inside each makefile, there's an easy way to 
express, on a per-target basis, "if that switch is on, re-create this target 
even though the time stamp makes it look up-to-date". Outside the makefile, I 
have no knowledge about what these special targets are, so I can't pass a list 
of them or such (if I had a list, I could as well just rm them before invoking 
make).

I came up with the following (the switch being the presence of the 
"initial-config" target):

.ifmake initial-config
initial-config: .PHONY
.else
initial-config: .OPTIONAL
.endif

config: /some/file

/some/file: initial-config ...
	...

[The first block going into a utility .include file]

This works perfectly with recent versions of (b)make. It fails with an ancient 
(NetBSD 4.0.1) make iff the ordering of the targets of the make invocation is 
"initial-config config" (I can provide -dm output if needed).

Is this a bug in old versions of make(1) or am I provoking undefined behaviour? 
Of course, I can use a more modern version of bmake or I can chose the "right" 
order of the targets on the command line, but I'm afraid I might be doing 
something fragile that may break unexpectedly.

Is there a better or more robust solution to my original problem?


Home | Main Index | Thread Index | Old Index