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