-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathMakefile
70 lines (54 loc) · 2.27 KB
/
Makefile
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
67
68
69
70
iOS_MIN_VERSION = 9.0
ARCH_FLAGS = -arch arm64
TARGET = -target arm64-apple-ios9
PLATFORM = iphoneos
SDK_PATH = $(shell xcrun --show-sdk-path -sdk $(PLATFORM))
TOOLCHAIN = Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/$(PLATFORM)
TOOLCHAIN_PATH = $(shell xcode-select --print-path)/$(TOOLCHAIN)
## SWIFT COMPILER SETUP ##
SWIFT = $(shell xcrun -f swift) -frontend -c -color-diagnostics
SWIFT_FLAGS = -g -Onone $(TARGET) \
-import-objc-header src/bridgingheader.h \
-sdk $(SDK_PATH)
## CLANG COMPILER SETUP FOR C ##
CLANG = $(shell xcrun -f clang) -c
CLANG_FLAGS = $(ARCH_FLAGS) \
-isysroot $(SDK_PATH) \
-mios-version-min=$(iOS_MIN_VERSION)
## LINKER SETTINGS ##
LD = $(shell xcrun -f ld)
LD_FLAGS = -syslibroot $(SDK_PATH) \
-lSystem $(ARCH_FLAGS) \
-ios_version_min $(iOS_MIN_VERSION) \
-no_objc_category_merging \
-L $(TOOLCHAIN_PATH)
SOURCE = $(notdir $(wildcard src/*.swift))
keychaineditor: compile link sign copylibs package removegarbage
compile: decodeSecAccessControl.c $(SOURCE) main.swift
decodeSecAccessControl.c:
$(CLANG) $(CLANG_FLAGS) src/$@
%.swift:
$(SWIFT) $(SWIFT_FLAGS) -primary-file src/$@ \
$(addprefix src/,$(filter-out $@,$(SOURCE))) \
-module-name keychaineditor -o $*.o -emit-module \
-emit-module-path $*~partial.swiftmodule
main.swift:
$(SWIFT) $(SWIFT_FLAGS) -primary-file src/$@ \
$(addprefix src/,$(filter-out $@,$(SOURCE))) \
-module-name keychaineditor -o main.o -emit-module \
-emit-module-path main~partial.swiftmodule
link:
$(LD) $(LD_FLAGS) *.o -o keychaineditor/usr/local/bin/keychaineditor
sign:
ldid -Ssrc/entitlements.xml keychaineditor/usr/local/bin/keychaineditor
FILES = $(addprefix $(TOOLCHAIN_PATH)/,libswiftCore.dylib libswiftCoreFoundation.dylib libswiftCoreGraphics.dylib libswiftDarwin.dylib libswiftDispatch.dylib libswiftFoundation.dylib libswiftObjectiveC.dylib libswiftSwiftOnoneSupport.dylib libswiftos.dylib)
copylibs:
cp $(FILES) keychaineditor/usr/local/lib/
package:
dpkg-deb -Zgzip -b keychaineditor
removegarbage:
rm *.o *.swiftmodule
clean:
rm -f keychaineditor/usr/local/bin/keychaineditor
rm -f keychaineditor/usr/lib/*
rm -f keychaineditor.deb