]> git.saurik.com Git - cycript.git/blame_incremental - makefile
Solve a corner case of dealloc hooking on JS derived class objects using MobileSubstrate.
[cycript.git] / makefile
... / ...
CommitLineData
1ifndef PKG_TARG
2target :=
3else
4target := $(PKG_TARG)-
5endif
6
7package:
8
9flags := -mthumb -g3 -O0 -Wall -Werror -I. -fno-common
10flags += -F${PKG_ROOT}/System/Library/PrivateFrameworks
11
12svn := $(shell svnversion)
13deb := $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_iphoneos-arm.deb
14
15header := Cycript.tab.hh Parser.hpp Pooling.hpp Struct.hpp cycript.hpp
16
17all: cycript libcycript.dylib libcycript.plist
18
19clean:
20 rm -f *.o libcycript.dylib cycript libcycript.plist Struct.hpp lex.cy.c Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh
21
22libcycript.plist: Bridge.def
23 { \
24 echo '({'; \
25 grep '^[CFV]' Bridge.def | sed -e 's/^C/0/;s/^F/1/;s/^V/2/' | sed -e 's/"/\\"/g;s/^\([^ ]*\) \([^ ]*\) \(.*\)$$/\2 = (\1, \"\3\");/'; \
26 echo '},{'; \
27 grep '^:' Bridge.def | sed -e 's/^: \([^ ]*\) \(.*\)/"\1" = "\2";/'; \
28 echo '},{'; \
29 grep '^[EST]' Bridge.def | sed -e 's/^S/0/;s/^T/1/;s/^E/2/' | sed -e 's/^2\(.*\)$$/1\1 i/' | sed -e 's/"/\\"/g;s/^\([^ ]*\) \([^ ]*\) \(.*\)$$/\2 = (\1, \"\3\");/'; \
30 echo '})'; \
31 } >$@
32
33Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y
34 bison -v --report=state $<
35
36lex.cy.c: Cycript.l
37 flex $<
38
39Struct.hpp:
40 $$($(target)gcc -print-prog-name=cc1obj) -print-objc-runtime-info </dev/null >$@
41
42#Parser.hpp: Parser.py Parser.dat
43# ./Parser.py <Parser.dat >$@
44
45%.o: sig/%.cpp
46 $(target)g++ $(flags) -c -o $@ $<
47
48Cycript.tab.o: Cycript.tab.cc Cycript.tab.hh Parser.hpp Pooling.hpp
49 $(target)g++ $(flags) -c -o $@ $<
50
51lex.cy.o: lex.cy.c Cycript.tab.hh Parser.hpp Pooling.hpp
52 $(target)g++ $(flags) -c -o $@ $<
53
54%.o: %.cpp $(header)
55 $(target)g++ $(flags) -c -o $@ $<
56
57%.o: %.mm $(header)
58 $(target)g++ $(flags) -c -o $@ $<
59
60libcycript.dylib: ffi_type.o parse.o Output.o Cycript.tab.o lex.cy.o Library.o
61 $(target)g++ $(flags) -dynamiclib -o $@ $(filter %.o,$^) \
62 -install_name /usr/lib/libcycript.dylib \
63 -lobjc -lapr-1 -lffi -lsubstrate \
64 -framework CoreFoundation -framework Foundation \
65 -framework CFNetwork \
66 -framework JavaScriptCore -framework WebCore
67 ldid -S $@
68
69cycript: Application.o libcycript.dylib
70 $(target)g++ $(flags) -o $@ $(filter %.o,$^) \
71 -lobjc -lapr-1 -lreadline \
72 -L. -lcycript \
73 -framework Foundation -framework CoreFoundation \
74 -framework JavaScriptCore -framework UIKit
75 ldid -S cycript
76
77package: all
78 rm -rf package
79 mkdir -p package/DEBIAN
80 sed -e 's/#/$(svn)/' control >package/DEBIAN/control
81 mkdir -p package/Library/MobileSubstrate/DynamicLibraries
82 if [[ -e Settings.plist ]]; then \
83 mkdir -p package/Library/PreferenceLoader/Preferences; \
84 cp -a Settings.png package/Library/PreferenceLoader/Preferences/CycriptIcon.png; \
85 cp -a Settings.plist package/Library/PreferenceLoader/Preferences/Cycript.plist; \
86 fi
87 if [[ -e Tweak.plist ]]; then cp -a Tweak.plist package/Library/MobileSubstrate/DynamicLibraries/Cycript.plist; fi
88 #cp -a Cycript.dylib package/Library/MobileSubstrate/DynamicLibraries
89 mkdir -p package/usr/{bin,lib}
90 cp -a libcycript.dylib package/usr/lib
91 #ln -s /usr/lib/libcycript.dylib package/Library/MobileSubstrate/DynamicLibraries/Cycript.dylib
92 cp -a cycript package/usr/bin
93 cp -a libcycript.plist package/usr/lib
94 dpkg-deb -b package $(deb)
95
96test: package
97 dpkg -i $(deb)
98 cycript test.cy
99
100.PHONY: all clean extra package