forked from nowsecure/fsmon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
144 lines (111 loc) · 2.73 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
ARCHS=armv7 arm64
CFLAGS+=-I.
CFLAGS+=-Wall
SOURCES=main.c util.c
SOURCES+=backend/*.c
ifeq ($(shell uname),Linux)
# LINUX: GNU / ANDROID
# __
# -=(o '.
# \.-.\
# /| \\
# '| ||
# _\_):,_
all: fsmon
fsmon:
$(CC) -o fsmon $(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+=-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: ios osx wch
$(MAKE) fat
#scp fsmon-ios [email protected]:.
ios:
$(IOS_CC) $(CFLAGS) -DTARGET_IOS=1 -o fsmon-ios $(SOURCES) \
-framework CoreFoundation \
-framework MobileCoreServices
strip fsmon-ios
xcrun --sdk iphoneos codesign -s- fsmon-ios
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:
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
.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=arm
ANDROID_ARCHS=arm mips x86
ANDROID_VERSION=kitkat
and android:
for a in $(ANDROID_ARCHS) ; do \
$(MAKE) $(ANDROID_VERSION) NDK_ARCH=$$a ; \
done
ll lollipop:
./ndk-gcc 21 -fPIC -pie $(LOLLIPOP_CFLAGS) $(CFLAGS) $(LDFLAGS) -o fsmon-and-$(NDK_ARCH) $(SOURCES)
kk kitkat:
./ndk-gcc 19 -fPIC -pie $(KITKAT_CFLAGS) $(CFLAGS) $(LDFLAGS) -o fsmon-kitkat-$(NDK_ARCH) $(SOURCES)
.PHONY: all fsmon clean
.PHONY: install uninstall
.PHONY: and android ll lollipop kk kitkat