forked from koekeishiya/yabai
-
Notifications
You must be signed in to change notification settings - Fork 3
/
makefile.arm64
66 lines (53 loc) · 2.78 KB
/
makefile.arm64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
FRAMEWORK_PATH = -F/System/Library/PrivateFrameworks
FRAMEWORK = -framework Carbon -framework Cocoa -framework CoreServices -framework SkyLight -framework ScriptingBridge
BUILD_FLAGS = -std=c99 -Wall -g -O0 -fvisibility=hidden -mmacosx-version-min=10.13
BUILD_PATH = ./bin
DOC_PATH = ./doc
SCRIPT_PATH = ./scripts
ASSET_PATH = ./assets
SMP_PATH = ./examples
ARCH_PATH = ./archive
OSAX_SRC = ./src/osax/sa_payload.c
YABAI_SRC = ./src/manifest.m $(OSAX_SRC) $(OSAX_SRC_ARM)
OSAX_PATH = ./src/osax
OSAX_SRC_ARMSA = $(OSAX_PATH)/arm64/sa_arm64e.h $(OSAX_PATH)/arm64/sa_arm64e.o
OSAX_SRC_ARM = $(OSAX_PATH)/arm64/injector.o
BINS = $(BUILD_PATH)/yabai
CLANG_PATH = /Library/Developer/CommandLineTools/usr/bin/clang
SDK_PATH = $(shell xcrun --sdk macosx --show-sdk-path)
.PHONY: all clean install sign archive man
all: clean-build $(BINS)
install: BUILD_FLAGS=-std=c99 -Wall -DNDEBUG -O2 -fvisibility=hidden -mmacosx-version-min=10.13
install: clean-build $(BINS)
$(OSAX_SRC): $(OSAX_PATH)/payload.m $(OSAX_SRC_ARM)
$(CLANG_PATH) $(OSAX_PATH)/payload.m -shared -fPIC -O2 -mmacosx-version-min=10.13 -arch arm64e -o $(OSAX_PATH)/payload -isysroot "$(SDK_PATH)" -framework Foundation -framework Carbon
xxd -i -a $(OSAX_PATH)/payload $(OSAX_PATH)/sa_payload.c
rm -f $(OSAX_PATH)/payload
$(OSAX_SRC_ARM): $(OSAX_PATH)/arm64/sa_arm64e.o $(OSAX_PATH)/arm64/injector.c
dd if=$(OSAX_PATH)/arm64/sa_arm64e.o of=$(OSAX_PATH)/arm64/sa_arm64e bs=1 count=$(shell otool -l $(OSAX_PATH)/arm64/sa_arm64e.o | grep filesize | sed 's/ filesize //') skip=$(shell otool -l $(OSAX_PATH)/arm64/sa_arm64e.o | grep fileoff | sed 's/ fileoff //')
xxd -i -a $(OSAX_PATH)/arm64/sa_arm64e $(OSAX_PATH)/arm64/sa_arm64e.h
$(CLANG_PATH) -c $(OSAX_PATH)/arm64/injector.c -o $(OSAX_PATH)/arm64/injector.o -arch arm64e -isysroot "$(SDK_PATH)"
rm -f $(OSAX_PATH)/arm64/sa_arm64e
$(OSAX_SRC_ARMSA): $(OSAX_PATH)/arm64/sa_arm64e.s
as -o $(OSAX_PATH)/arm64/sa_arm64e.o $(OSAX_PATH)/arm64/sa_arm64e.s
man:
asciidoctor -b manpage $(DOC_PATH)/yabai.asciidoc -o $(DOC_PATH)/yabai.1
icon:
python $(SCRIPT_PATH)/seticon.py $(ASSET_PATH)/icon/2x/[email protected] $(BUILD_PATH)/yabai
archive: man install sign icon
rm -rf $(ARCH_PATH)
mkdir -p $(ARCH_PATH)
cp -r $(BUILD_PATH) $(ARCH_PATH)/
cp -r $(DOC_PATH) $(ARCH_PATH)/
cp -r $(SMP_PATH) $(ARCH_PATH)/
tar -cvzf $(BUILD_PATH)/$(shell $(BUILD_PATH)/yabai --version).tar.gz $(ARCH_PATH)
rm -rf $(ARCH_PATH)
sign:
codesign -fs "yabai-cert" $(BUILD_PATH)/yabai
clean-build:
rm -rf $(BUILD_PATH)
clean: clean-build
rm -f $(OSAX_SRC) $(OSAX_SRC_ARM) $(OSAX_SRC_ARMSA)
$(BUILD_PATH)/yabai: $(YABAI_SRC)
mkdir -p $(BUILD_PATH)
$(CLANG_PATH) $^ $(BUILD_FLAGS) -arch arm64e $(FRAMEWORK_PATH) $(FRAMEWORK) -isysroot "$(SDK_PATH)" -o $@