-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathMakefile
115 lines (94 loc) · 3.78 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
TARGET_GUI = Spice
TARGET_CLI = spice
PACKAGE = lol.spyware.spicy
VERSION = 1.0.0
BIN = bin
RES = res
APP = $(BIN)/Payload/$(TARGET_GUI).app
SRC_GUI = src/app
SRC_CLI = src/untether
SRC_ALL = src/shared
JAKE = submodules/libjake
ifdef RELEASE
IPA = $(TARGET_GUI).ipa
else
IPA = $(TARGET_GUI)-DEV.ipa
endif
UNTETHER = lib$(TARGET_CLI).dylib
TRAMP = trampoline
ICONS := $(wildcard $(RES)/Icon-*.png)
FILES := $(TARGET_GUI) Info.plist Base.lproj/LaunchScreen.storyboardc $(ICONS:$(RES)/%=%) Unrestrict.dylib bootstrap.tar.lzma jailbreak-resources.deb
IGCC ?= xcrun -sdk iphoneos gcc
ARCH_GUI ?= -arch arm64
ARCH_CLI ?= -arch armv7 -arch arm64
IGCC_FLAGS ?= -Wall -Wformat=0 -flto -Isrc -Iinclude -larchive -fmodules -framework IOKit $(CFLAGS)
ifdef RELEASE
IGCC_FLAGS += -DRELEASE=1
endif
UNTETHER_FLAGS ?= -I$(JAKE)/src -I$(JAKE)/img4lib/libvfs -L$(JAKE) -ljake -L$(JAKE)/img4lib -limg4 -L$(JAKE)/img4lib/lzfse/build/bin -llzfse
IBTOOL ?= xcrun -sdk iphoneos ibtool
IBTOOL_FLAGS ?= --output-format human-readable-text --errors --warnings --notices --target-device iphone --target-device ipad $(IBFLAGS)
SIGN ?= codesign
SIGN_FLAGS ?= -s -
.PHONY: all ipa untether clean install
all: $(IPA) $(UNTETHER) $(TRAMP)
ipa: $(IPA)
untether: $(UNTETHER) $(TRAMP)
$(IPA): $(addprefix $(APP)/, $(FILES))
cd $(BIN) && zip -x .DS_Store -qr9 ../$@ Payload
# TODO: make this less shit
$(APP)/Unrestrict.dylib:
echo Copying file to $@
cp $(RES)/Unrestrict.dylib $@
$(APP)/bootstrap.tar.lzma:
echo Copying file to $@
cp $(RES)/bootstrap.tar.lzma $@
$(APP)/jailbreak-resources.deb:
echo Copying file to $@
cp $(RES)/jailbreak-resources.deb $@
$(APP)/$(TARGET_GUI): $(SRC_GUI)/*.m $(SRC_ALL)/*.m $(SRC_ALL)/*.c | $(APP)
$(IGCC) $(ARCH_GUI) -o $@ -Wl,-exported_symbols_list,res/app.txt $(IGCC_FLAGS) $^
$(APP)/Info.plist: $(RES)/Info.plist | $(APP)
sed 's/$$(TARGET)/$(TARGET_GUI)/g;s/$$(PACKAGE)/$(PACKAGE)/g;s/$$(VERSION)/$(VERSION)/g' $(RES)/Info.plist > $@
$(APP)/Icon-%.png: $(RES)/$(@F) | $(APP)
cp $(RES)/$(@F) $@
$(APP)/Base.lproj/%.storyboardc: $(RES)/%.storyboard | $(APP)/Base.lproj
$(IBTOOL) $(IBTOOL_FLAGS) --compilation-directory $(APP)/Base.lproj $<
$(APP):
mkdir -p $@
$(APP)/Base.lproj:
mkdir -p $@
$(UNTETHER): $(SRC_CLI)/*.m $(SRC_ALL)/*.m $(SRC_ALL)/*.c $(JAKE)/libjake.a
$(IGCC) $(ARCH_CLI) $(UNTETHER_FLAGS) -shared -o $@ -Wl,-exported_symbols_list,res/untether.txt $(IGCC_FLAGS) $^
$(SIGN) $(SIGN_FLAGS) $@
$(TRAMP):
$(IGCC) $(ARCH_CLI) -o $@ -L. -l$(TARGET_CLI) -Wl,-exported_symbols_list,res/tramp.txt $(IGCC_FLAGS) -xc <<<''
$(SIGN) $(SIGN_FLAGS) $@
$(JAKE)/libjake.a: $(JAKE)/Makefile
$(MAKE) $(AM_MAKEFLAGS) -C $(JAKE) CC='$(IGCC) $(ARCH_CLI)' LD='$(IGCC) $(ARCH_CLI)'
$(JAKE)/Makefile:
git submodule update --init --recursive
clean:
rm -rf $(BIN)
rm -f *.ipa *.dylib $(TRAMP)
$(MAKE) $(AM_MAKEFLAGS) -C $(JAKE) clean
ifndef ID
install:
@echo 'Environment variable ID not set'
exit 1
else
install: | $(IPA)
cp res/*.mobileprovision $(APP)/embedded.mobileprovision
echo '<?xml version="1.0" encoding="UTF-8"?>' >tmp.plist
echo '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' >>tmp.plist
echo '<plist version="1.0">' >>tmp.plist
echo '<dict>' >>tmp.plist
strings res/*.mobileprovision | egrep -A1 'application-identifier' >>tmp.plist
strings res/*.mobileprovision | egrep -A1 'team-identifier' >>tmp.plist
echo '</dict>' >>tmp.plist
echo '</plist>' >>tmp.plist
codesign -f -s '$(ID)' --entitlements tmp.plist $(APP)
rm tmp.plist
cd $(BIN) && zip -x .DS_Store -qr9 ../$(IPA) Payload
ideviceinstaller -i $(IPA)
endif