forked from nowsecure/fsmon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
183 lines (144 loc) · 4.04 KB
/
Copy pathMakefile
File metadata and controls
183 lines (144 loc) · 4.04 KB
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
ARCHS=armv7 arm64
CFLAGS+=-I.
CFLAGS+=-Wall
include config.mk
CFLAGS+=-DFSMON_VERSION=\"$(VERSION)\"
SOURCES=main.c util.c
SOURCES+=backend/*.c
ifeq ($(shell uname),Linux)
# LINUX: GNU / ANDROID
# __
# -=(o '.
# \.-.\
# /| \\
# '| ||
# _\_):,_
FANOTIFY_CFLAGS+=-DHAVE_FANOTIFY=1
FANOTIFY_CFLAGS+=-DHAVE_SYS_FANOTIFY=1
all: fsmon
fsmon:
$(CC) -o fsmon $(CFLAGS) $(FANOTIFY_CFLAGS) $(LDFLAGS) $(SOURCES)
DESTDIR?=
PREFIX?=/usr
clean:
rm -f fsmon
else
# APPLE: OSX / IOS / IWATCH
# _
# _\)/_
# / \
# \ /
# \_._/
DESTDIR?=
PREFIX?=/usr/local
# iOS
IOS_ARCHS=$(addprefix -arch ,$(ARCHS))
IOS_CFLAGS+=$(IOS_ARCHS)
IOS_SYSROOT=$(shell xcrun --sdk iphoneos --show-sdk-path)
IOS_CFLAGS+=-isysroot ${IOS_SYSROOT}
IOS_CFLAGS+=-fembed-bitcode
IOS_CFLAGS+=-flto
#IOS_CFLAGS+=-Wl,-iphoneos_version_min,10.0
IOS_CFLAGS+=-O3 -Wall
IOS_CC=$(shell xcrun --sdk iphoneos --find clang) $(IOS_CFLAGS)
# iWatch
WCH_CFLAGS=-arch armv7k
WCH_SYSROOT=$(shell xcrun --sdk watchos --show-sdk-path)
WCH_CFLAGS+=-isysroot ${WCH_SYSROOT}
IOS_CFLAGS+=-fembed-bitcode
WCH_CC=$(shell xcrun --sdk iphoneos --find clang) $(WCH_CFLAGS)
CC?=gcc
CFLAGS+=-g -ggdb
OBJS=fsmon.o main.o
all: osx
oldios:
$(IOS_CC) $(CFLAGS) -DTARGET_IOS=1 -o fsmon-ios $(SOURCES) \
-framework CoreFoundation \
-framework MobileCoreServices
xcrun --sdk iphoneos strip fsmon-ios
xcrun --sdk iphoneos codesign -f --entitlements ./entitlements.plist -s- fsmon-ios
ios:
$(IOS_CC) $(CFLAGS) -DTARGET_IOS=1 -o fsmon-ios $(SOURCES) \
-framework CoreFoundation \
-weak_framework MobileCoreServices \
-weak_framework CoreServices
xcrun --sdk iphoneos strip fsmon-ios
xcrun --sdk iphoneos codesign -f --entitlements ./entitlements.plist -s- fsmon-ios
ios2:
$(MAKE) ios
$(MAKE) ios-patch
ios-patch:
rabin2 -x fsmon-ios
export a=fsmon-ios.fat/fsmon-ios.arm_64* ; \
export OFF=`rabin2 -H $$a | grep -C 2 /CoreSer | head -n1 | cut -d ' ' -f 1`; \
echo OFF=$$OFF ; \
r2 -qnwc "wx 18000080 @ $$OFF-4" $$a
rm -f fsmon-ios
lipo -create -arch arm64 fsmon-ios.fat/fsmon-ios.arm_64* -arch armv7 fsmon-ios.fat/fsmon-ios.arm_32* -output fsmon-ios
-xcrun --sdk iphoneos codesign -f --entitlements ./entitlements.plist -s- fsmon-ios
rm -rf fsmon-ios.fat
cydia: ios
$(MAKE) -C cydia
osx:
$(CC) $(CFLAGS) -DTARGET_OSX=1 -o fsmon-osx $(SOURCES) -framework CoreServices
strip fsmon-osx
osx-pkg:
./pkg.sh
wch:
$(WCH_CC) $(CFLAGS) -DTARGET_WATCHOS=1 -o fsmon-wch $(SOURCES)
fat: ios osx wch
lipo fsmon-ios -thin armv7 -output fsmon-ios-armv7
lipo fsmon-ios -thin arm64 -output fsmon-ios-arm64
lipo -create -output fsmon \
-arch arm64 fsmon-ios-arm64 \
-arch armv7 fsmon-ios-armv7 \
-arch armv7k fsmon-wch \
-arch x86_64 fsmon-osx
strip fsmon
codesign -s- fsmon
clean:
rm -f fsmon-osx fsmon-ios
rm -rf fsmon*.dSYM
rm -f fsmon-and*
.PHONY: cydia ios osx osx-pkg fat wch
endif
BINDIR=$(DESTDIR)/$(PREFIX)/bin
MANDIR=$(DESTDIR)/$(PREFIX)/share/man/man1
install:
mkdir -p $(BINDIR)
install -m 0755 fsmon $(BINDIR)/fsmon
mkdir -p $(MANDIR)
install -m 0644 fsmon.1 $(MANDIR)/fsmon.1
uninstall:
rm -f $(BINDIR)/fsmon
rm -f $(MANDIR)/fsmon.1
# ANDROID
#
# \.-----./
# / o o \
# `-------'
KITKAT_CFLAGS=-DHAVE_FANOTIFY=0 -DHAVE_SYS_FANOTIFY=0
LOLLIPOP_CFLAGS=-DHAVE_FANOTIFY=1 -DHAVE_SYS_FANOTIFY=0
NDK_ARCH?=
ANDROID_ARCHS=arm arm64 x86 x86_64
ANDROID_API?=
ifneq ($(NDK_ARCH),)
ANDROID_ARCHS=$(NDK_ARCH)
endif
AAPIMODE=$(shell test ${ANDROID_API} -gt 21 && echo aagt21compile || echo aalt21compile)
and android:
for a in $(ANDROID_ARCHS) ; do \
if [ -z "${NDK}" ] ; then \
./android-shell.sh $$a \
$(MAKE) $(AAPIMODE) ANDROID_API=$(ANDROID_API) NDK_ARCH=$$a ; \
else \
$(MAKE) $(AAPIMODE) ANDROID_API=$(ANDROID_API) NDK_ARCH=$$a ; \
fi; \
done
aagt21compile:
ndk-gcc $(ANDROID_API) $(LOLLIPOP_CFLAGS) $(CFLAGS) $(LDFLAGS) -o fsmon-and$(ANDROID_API)-$(NDK_ARCH) $(SOURCES)
aalt21compile:
ndk-gcc $(ANDROID_API) $(KITKAT_CFLAGS) $(CFLAGS) $(LDFLAGS) -o fsmon-and$(ANDROID_API)-$(NDK_ARCH) $(SOURCES)
.PHONY: all fsmon clean
.PHONY: install uninstall
.PHONY: and android