On 02.02.2013 18:38, Matěj Týč wrote:
>> How about something like this?
>>
>> bar_deps = foo1 foo2
>>
>> bar: $(bar_deps)
>>
>> $(bar_deps):
>> $(MAKE) cache-foo
>> touch $@
>>
>> %:
>> touch $@
>
> I have also thought of that, but this can work well reliably only in the
> case if there is only one make job. If I specify -j4, it may happen that
> all jobs will attempt to load the same cache simultaneously, which I
> have to avoid :-(
If that happens how about replacing
$(MAKE) cache-foo
by something like
mkdir .lock 2>/dev/null || exit 0 ; \
$(MAKE) cache-foo ; \
ret=$$?; \
rmdir .lock && exit $${ret}
The idea is:
- mkdir can only succeed once
- if "$(MAKE) cache-foo" fails
1. the whole should return non-zero
2. .lock is not left laying around
If that works for you conceptually, you could abstract a little more and
turn it into something re-usable like
$(call synced_make,cache-foo)
Best,
Sebastian
_______________________________________________
Bug-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-make