-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathMakefile
55 lines (39 loc) · 1.89 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
VERSION = 1.4.0
BINDIR = bin
SRCDIR = src
ALL = $(patsubst $(SRCDIR)/%.c,%,$(wildcard $(SRCDIR)/io*.c))
PKG = pkg
XZ = iokit-utils.tar.xz
DEB = net.siguza.iokit-utils_$(VERSION)_iphoneos-arm.deb
C_FLAGS ?= -Wall -O3 -framework IOKit -framework CoreFoundation -framework Security $(CFLAGS)
CC_FLAGS ?= -arch x86_64 -arch arm64
IOS_CC ?= xcrun -sdk iphoneos clang
IOS_CFLAGS ?= -arch armv7 -arch arm64
CODESIGN ?= codesign
.PHONY: all dist xz deb clean
all: $(addprefix $(BINDIR)/macos/, $(ALL)) $(addprefix $(BINDIR)/ios/, $(ALL))
$(BINDIR)/macos/%: $(SRCDIR)/%.c $(SRCDIR)/common.c $(SRCDIR)/cfj.c | $(BINDIR)/macos
$(CC) $(CC_FLAGS) $(C_FLAGS) -o $@ $^
$(CODESIGN) -s - $@
$(BINDIR)/ios/%: $(SRCDIR)/%.c $(SRCDIR)/common.c $(SRCDIR)/cfj.c | $(BINDIR)/ios
$(IOS_CC) $(IOS_CFLAGS) $(C_FLAGS) -o $@ $^
$(CODESIGN) -s - $@
dist: xz deb
xz: $(XZ)
deb: $(DEB)
$(XZ): $(addprefix $(BINDIR)/macos/, $(ALL)) $(addprefix $(BINDIR)/ios/, $(ALL))
tar -cJf $(XZ) -C $(BINDIR) macos ios
$(DEB): $(PKG)/control.tar.gz $(PKG)/data.tar.lzma $(PKG)/debian-binary
( cd "$(PKG)"; ar -cr "../$(DEB)" 'debian-binary' 'control.tar.gz' 'data.tar.lzma'; )
$(PKG)/control.tar.gz: $(PKG)/control
tar -czf '$(PKG)/control.tar.gz' --exclude '.DS_Store' --exclude '._*' --exclude 'control.tar.gz' --include '$(PKG)' --include '$(PKG)/control' -s '%^$(PKG)%.%' $(PKG)
$(PKG)/data.tar.lzma: $(addprefix $(BINDIR)/ios/, $(ALL)) | $(PKG)
tar -c --lzma -f '$(PKG)/data.tar.lzma' --exclude '.DS_Store' --exclude '._*' -s '%^bin/ios%./usr/bin%' @misc/template.tar $(BINDIR)/ios
$(PKG)/debian-binary: | $(PKG)
echo '2.0' > "$(PKG)/debian-binary"
$(PKG)/control: misc/control | $(PKG)
( echo "Version: $(VERSION)"; cat misc/control; ) > $(PKG)/control
$(BINDIR) $(BINDIR)/macos $(BINDIR)/ios $(PKG):
mkdir -p $@
clean:
rm -rf $(BINDIR) $(PKG) $(XZ) net.siguza.iokit-utils_*_iphoneos-arm.deb