Solve a corner case of dealloc hooking on JS derived class objects using MobileSubstrate.
[cycript.git] / makefile
1 ifndef PKG_TARG
2 target :=
3 else
4 target := $(PKG_TARG)-
5 endif
6
7 package:
8
9 flags := -mthumb -g3 -O0 -Wall -Werror -I. -fno-common
10 flags += -F${PKG_ROOT}/System/Library/PrivateFrameworks
11
12 svn := $(shell svnversion)
13 deb := $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_iphoneos-arm.deb
14
15 header := Cycript.tab.hh Parser.hpp Pooling.hpp Struct.hpp cycript.hpp
16
17 all: cycript libcycript.dylib libcycript.plist
18
19 clean:
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
22 libcycript.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
33 Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y
34 bison -v --report=state $<
35
36 lex.cy.c: Cycript.l
37 flex $<
38
39 Struct.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
48 Cycript.tab.o: Cycript.tab.cc Cycript.tab.hh Parser.hpp Pooling.hpp
49 $(target)g++ $(flags) -c -o $@ $<
50
51 lex.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
60 libcycript.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
69 cycript: 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
77 package: 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
96 test: package
97 dpkg -i $(deb)
98 cycript test.cy
99
100 .PHONY: all clean extra package