From 9039f04a51180e21791fd061acee89d5f1e507d6 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 7 Mar 2021 15:52:11 +0100 Subject: Makefile: Create build directories Ensure the build directories are available when building. Read up on techniques for creating directories in prerequisites here: https://www.cmcrossroads.com/article/making-directories-gnu-make --- Makefile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 65a24f3..3748d95 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,9 @@ SOURCES := $(shell ls *.{h,m}) DDHOTKEY_OBJ := $(patsubst %.m,%.o,$(wildcard lib/DDHotKey/*.m)) +BUILD_DIR := $(abspath build) +LOCAL_INCLUDE_DIR := $(BUILD_DIR)/include + all: $(SOURCES) build/libddhotkey.a build/include/*.h clang -x objective-c \ @@ -18,7 +21,7 @@ all: $(SOURCES) build/libddhotkey.a build/include/*.h -o invert-catalina-invert \ $(SOURCES) -build/include/%.h: lib/DDHotKey/%.h +build/include/%.h: lib/DDHotKey/%.h | $(LOCAL_INCLUDE_DIR) cp $^ build/include/ lib/DDHotKey/%.o: lib/DDHotKey/%.m @@ -30,7 +33,13 @@ lib/DDHotKey/%.o: lib/DDHotKey/%.m mv *.o lib/DDHotKey/ -build/libddhotkey.a: $(DDHOTKEY_OBJ) +build/libddhotkey.a: $(DDHOTKEY_OBJ) | $(BUILD_DIR) libtool -static \ -o $@ \ $^ + +$(BUILD_DIR): + mkdir -p $@ + +$(LOCAL_INCLUDE_DIR): | $(BUILD_DIR) + mkdir -p $@ -- cgit v1.2.3