summaryrefslogtreecommitdiffstats
path: root/t/buildsystems/parallel.mk
blob: 3e0d201dd59d99f01c67b0a30e720b8bda81989b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
all: FIRST SECOND

TMPFILE ?= $(CURDIR)/parallel.mk.lock

rmtmpfile:
	@rm -f "$(TMPFILE)"

FIRST: rmtmpfile
	@c=0; \
    while [ $$c -le 5 ] && \
          ([ ! -e "$(TMPFILE)" ] || [ "`cat "$(TMPFILE)"`" != "SECOND" ]); do \
        c=$$(($$c+1)); \
        sleep 0.1; \
    done; \
    rm -f "$(TMPFILE)"; \
    if [ $$c -gt 5 ]; then exit 10; else exit 0; fi

SECOND: rmtmpfile
	@echo $@ > "$(TMPFILE)"

.PHONY: all FIRST SECOND rmtmpfile