aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorTeddy Wing2021-03-07 01:44:50 +0100
committerTeddy Wing2021-03-07 01:44:50 +0100
commitee7e780efde86970e68e6ab4af6aa1b11d4ac88b (patch)
tree7ec7bd79445df573eed9d77c181e2610432d0415 /Makefile
parent1b29751aca6376d7392356ed8e53048952150606 (diff)
downloadRe-Good-Catalina-Invert-Colours-ee7e780efde86970e68e6ab4af6aa1b11d4ac88b.tar.bz2
Register a global hotkey
Build DDHotKey as a static library so we can compile it with ARC turned on and our project with ARC turned off. Since DDHotKey is written with ARC, if I include its headers directly, I'd need to enable ARC on my project in order to compile it. Initialise an `NSApplication` to give us an environment in which to register the global hotkey. A new class `Invert` will respond to the hotkey and respond accordingly.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile44
1 files changed, 42 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index ef9d048..5baa173 100644
--- a/Makefile
+++ b/Makefile
@@ -1,2 +1,42 @@
-all:
- clang -x objective-c -framework CoreGraphics -o invert-catalina-invert main.m
+# SOURCES := $(shell find . -not -path './lib/*' -and \( -name '*.h' -or -name '*.m' \))
+SOURCES := $(shell ls *.{h,m})
+
+DDHOTKEY_OBJ := $(patsubst %.m,%.o,$(wildcard lib/DDHotKey/*.m))
+
+
+all: $(SOURCES) build/libddhotkey.a build/include/*.h
+ clang -x objective-c \
+ -framework Carbon \
+ -framework Cocoa \
+ -framework CoreGraphics \
+ -framework Foundation \
+ -fno-objc-arc \
+ -I./build/include \
+ -L./build \
+ -lddhotkey \
+ -o invert-catalina-invert \
+ $(SOURCES)
+
+build/include/*.h: lib/DDHotKey/*.h
+ cp $^ build/include/
+
+# build/libddhotkey.o: lib/DDHotKey/*.h lib/DDHotKey/*.m
+lib/DDHotKey/%.o: lib/DDHotKey/%.m
+ clang -x objective-c \
+ -w \
+ -framework Carbon \
+ -framework Cocoa \
+ -framework Foundation \
+ -fobjc-arc \
+ -c \
+ $^
+
+ mv *.o lib/DDHotKey/
+
+lib/DDHotKey/*.o: lib/DDHotKey/*.m
+
+build/libddhotkey.a: $(DDHOTKEY_OBJ)
+# build/libddhotkey.a: lib/DDHotKey/*.o
+ libtool -static \
+ -o $@ \
+ $^