From 123031dcfecc38a9724243e5317d896d54b06f6f Mon Sep 17 00:00:00 2001
From: jD91mZM2 <me@krake.one>
Date: Sat, 11 May 2019 08:04:03 +0200
Subject: [PATCH] Fix race condition in parallel Makefile

Some recipes require the headers, but they don't explicitly say
so. Parallel make (-j`nproc`) might start compiling the libs when the
headers aren't done yet.
---
 Makefile | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 11cf31d56..8812c112a 100644
--- a/Makefile
+++ b/Makefile
@@ -27,11 +27,12 @@ SRC=\
 	src/* \
 	src/*/* \
 	src/*/*/* \
-	src/*/*/*/*
+	src/*/*/*/* \
+	headers # Used by compiler-builtins
 
 .PHONY: all clean fmt headers install install-headers libs test
 
-all: | headers libs
+all: headers libs
 
 clean:
 	$(CARGO) clean
@@ -179,7 +180,7 @@ $(BUILD)/include: $(SRC)
 	mv $@.partial $@
 	touch $@
 
-$(BUILD)/openlibm: openlibm
+$(BUILD)/openlibm: openlibm headers
 	rm -rf $@ $@.partial
 	mkdir -p $(BUILD)
 	cp -r $< $@.partial
@@ -189,7 +190,7 @@ $(BUILD)/openlibm: openlibm
 $(BUILD)/openlibm/libopenlibm.a: $(BUILD)/openlibm $(BUILD)/include
 	$(MAKE) CC=$(CC) CPPFLAGS="-fno-stack-protector -I$(shell pwd)/include -I $(shell pwd)/$(BUILD)/include" -C $< libopenlibm.a
 
-$(BUILD)/pthreads-emb: pthreads-emb
+$(BUILD)/pthreads-emb: pthreads-emb headers
 	rm -rf $@ $@.partial
 	mkdir -p $(BUILD)
 	cp -r $< $@.partial
-- 
GitLab