forked from tealbathingsuit/ellekit
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
152 lines (117 loc) · 6.04 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
.PHONY: all deb-ios-rootless deb-ios-rootful
ifneq ($(ONLY_TAG),)
VERSION := $(shell git describe --tags --abbrev=0 | sed 's/^v//g')
else
VERSION := $(shell git describe --tags --always | sed 's/-/|/' | sed 's/-/\./g' | sed 's/|/-/' | sed 's/\.g/\./g' | sed 's/^v//g')
endif
COMMON_OPTIONS = BUILD_DIR="build/" CODE_SIGNING_ALLOWED="NO" CODE_SIGNING_REQUIRED="NO" CODE_SIGN_IDENTITY="" -configuration $(CONFIGURATION)
ifneq ($(RELEASE),)
CONFIGURATION = Release
DEB_VERSION = $(VERSION)
else
CONFIGURATION = Debug
DEB_VERSION = $(VERSION)+debug
endif
ifneq ($(MAC),)
COMMON_OPTIONS += -destination 'generic/platform=macOS'
else
COMMON_OPTIONS += -destination 'generic/platform=iOS'
endif
ifneq ($(MAC),)
PRODUCTS_DIR = build/$(CONFIGURATION)
else
PRODUCTS_DIR = build/$(CONFIGURATION)-iphoneos
endif
STAGE_DIR = work-$(ARCHITECTURE)/stage
INSTALL_ROOT = $(STAGE_DIR)/$(INSTALL_PREFIX)
# TODO: maybe split each scheme into its own target?
all: deb
clean:
xcodebuild -scheme ellekit $(COMMON_OPTIONS) clean
xcodebuild -scheme injector $(COMMON_OPTIONS) clean
xcodebuild -scheme launchd $(COMMON_OPTIONS) clean
xcodebuild -scheme loader $(COMMON_OPTIONS) clean
xcodebuild -scheme safemode-ui $(COMMON_OPTIONS) clean
build-ios:
xcodebuild -scheme ellekit $(COMMON_OPTIONS)
xcodebuild -scheme injector $(COMMON_OPTIONS)
xcodebuild -scheme launchd $(COMMON_OPTIONS)
xcodebuild -scheme loader $(COMMON_OPTIONS)
xcodebuild -scheme safemode-ui $(COMMON_OPTIONS)
build-macos:
xcodebuild -scheme ellekit $(COMMON_OPTIONS)
xcodebuild -scheme launchd $(COMMON_OPTIONS)
xcodebuild -scheme loader $(COMMON_OPTIONS)
deb-ios-rootful: ARCHITECTURE = iphoneos-arm
deb-ios-rootful: INSTALL_PREFIX =
deb-ios-rootless: ARCHITECTURE = iphoneos-arm64
deb-ios-rootless: INSTALL_PREFIX = /var/jb
deb-ios-rootful deb-ios-rootless: build-ios
@rm -rf work-$(ARCHITECTURE)
@mkdir -p $(STAGE_DIR)
@# Because BSD install does not support -D
@mkdir -p $(INSTALL_ROOT)/usr/lib/ellekit
@mkdir -p $(INSTALL_ROOT)/usr/libexec/ellekit
@install -m644 $(PRODUCTS_DIR)/libellekit.dylib $(INSTALL_ROOT)/usr/lib/libellekit.dylib
@install -m644 $(PRODUCTS_DIR)/libinjector.dylib $(INSTALL_ROOT)/usr/lib/ellekit/libinjector.dylib
@install -m644 $(PRODUCTS_DIR)/pspawn.dylib $(INSTALL_ROOT)/usr/lib/ellekit/pspawn.dylib
@install -m644 $(PRODUCTS_DIR)/libsafemode-ui.dylib $(INSTALL_ROOT)/usr/lib/ellekit/MobileSafety.dylib
@install -m755 $(PRODUCTS_DIR)/loader $(INSTALL_ROOT)/usr/libexec/ellekit/loader
@find $(INSTALL_ROOT)/usr/lib -type f -exec ldid -S {} \;
@ldid -S./loader/taskforpid.xml $(INSTALL_ROOT)/usr/libexec/ellekit/loader
@ln -s $(INSTALL_PREFIX)/usr/lib/ellekit/libinjector.dylib $(INSTALL_ROOT)/usr/lib/TweakLoader.dylib
@ln -s $(INSTALL_PREFIX)/usr/lib/ellekit/libinjector.dylib $(INSTALL_ROOT)/usr/lib/TweakInject.dylib
@ln -s $(INSTALL_PREFIX)/usr/lib/libellekit.dylib $(INSTALL_ROOT)/usr/lib/libsubstrate.dylib
@ln -s $(INSTALL_PREFIX)/usr/lib/libellekit.dylib $(INSTALL_ROOT)/usr/lib/libhooker.dylib
@ln -s $(INSTALL_PREFIX)/usr/lib/libellekit.dylib $(INSTALL_ROOT)/usr/lib/libblackjack.dylib
@mkdir -p $(INSTALL_ROOT)/etc/rc.d
@ln -s ${INSTALL_PREFIX}/usr/libexec/ellekit/loader $(INSTALL_ROOT)/etc/rc.d/ellekit-loader
@mkdir -p $(INSTALL_ROOT)/usr/lib/TweakInject
@mkdir -p $(INSTALL_ROOT)/Library/Frameworks/CydiaSubstrate.framework
@ln -s ${INSTALL_PREFIX}/usr/lib/libellekit.dylib $(INSTALL_ROOT)/Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate
@mkdir -p $(INSTALL_ROOT)/Library/MobileSubstrate
@ln -s ${INSTALL_PREFIX}/usr/lib/TweakInject $(INSTALL_ROOT)/Library/MobileSubstrate/DynamicLibraries
@mkdir -p $(INSTALL_ROOT)/usr/share/doc/ellekit
@install -m644 LICENSE $(INSTALL_ROOT)/usr/share/doc/ellekit/LICENSE
@mkdir -p $(STAGE_DIR)/DEBIAN
@sed -e "s|@DEB_VERSION@|$(DEB_VERSION)|g" -e "s|@DEB_ARCH@|$(ARCHITECTURE)|g" packaging/control >$(STAGE_DIR)/DEBIAN/control
@sed -e "s|@DEB_VERSION@|$(DEB_VERSION)|g" -e "s|@DEB_ARCH@|$(ARCHITECTURE)|g" -e "s|@INSTALL_PREFIX@|$(INSTALL_PREFIX)|g" packaging/preinst >$(STAGE_DIR)/DEBIAN/preinst
@sed -e "s|@DEB_VERSION@|$(DEB_VERSION)|g" -e "s|@DEB_ARCH@|$(ARCHITECTURE)|g" -e "s|@INSTALL_PREFIX@|$(INSTALL_PREFIX)|g" packaging/postinst >$(STAGE_DIR)/DEBIAN/postinst
@sed -e "s|@DEB_VERSION@|$(DEB_VERSION)|g" -e "s|@DEB_ARCH@|$(ARCHITECTURE)|g" -e "s|@INSTALL_PREFIX@|$(INSTALL_PREFIX)|g" packaging/postrm >$(STAGE_DIR)/DEBIAN/postrm
@chmod 0755 $(STAGE_DIR)/DEBIAN/preinst $(STAGE_DIR)/DEBIAN/postinst $(STAGE_DIR)/DEBIAN/postrm
@mkdir -p packages
dpkg-deb --root-owner-group -b $(STAGE_DIR) packages/ellekit_$(DEB_VERSION)_$(ARCHITECTURE).deb
@rm -rf work-$(ARCHITECTURE)
deb-ios: deb-ios-rootful deb-ios-rootless
deb-macos: ARCHITECTURE = macos
deb-macos: build-macos
@rm -rf work-$(ARCHITECTURE)
@mkdir -p $(STAGE_DIR)
@# Because BSD install does not support -D
@mkdir -p $(INSTALL_ROOT)/Library/TweakInject
@mkdir -p $(INSTALL_ROOT)/Library/Frameworks
@mkdir -p $(INSTALL_ROOT)/usr/local/bin
@mkdir -p $(INSTALL_ROOT)/usr/local/lib
@install -m644 $(PRODUCTS_DIR)/libellekit.dylib $(INSTALL_ROOT)/Library/TweakInject/ellekit.dylib
@install -m644 $(PRODUCTS_DIR)/pspawn.dylib $(INSTALL_ROOT)/Library/TweakInject/pspawn.dylib
@install -m755 $(PRODUCTS_DIR)/loader $(INSTALL_ROOT)/usr/local/bin/loader
@find $(INSTALL_ROOT)/Library/TweakInject -type f -exec ldid -S {} \;
@find $(INSTALL_ROOT)/usr/local/ -type f -exec ldid -S {} \;
@ln -s $(INSTALL_PREFIX)/Library/TweakInject/ellekit.dylib $(INSTALL_ROOT)/usr/local/lib/libsubstrate.dylib
@ln -s $(INSTALL_PREFIX)/Library/TweakInject/ellekit.dylib $(INSTALL_ROOT)/Library/Frameworks/libsubstrate.dylib
@ln -s $(INSTALL_PREFIX)/Library/TweakInject/ellekit.dylib $(INSTALL_ROOT)/Library/Frameworks/ellekit.dylib
@mkdir -p $(INSTALL_ROOT)/usr/local/share/doc/ellekit
@install -m644 LICENSE $(INSTALL_ROOT)/usr/local/share/doc/ellekit/LICENSE
@mkdir -p packages
@tar -czvf packages/ellekit_$(DEB_VERSION)_$(ARCHITECTURE).tar.gz -C ./$(STAGE_DIR) .
@rm -rf work-$(ARCHITECTURE)
ifneq ($(MAC),)
deb: deb-macos
else
deb: deb-ios
endif
ifneq ($(MAC),)
build: build-macos
else
build: build-ios
endif