]>
Commit | Line | Data |
---|---|---|
ea2d184c JF |
1 | ifndef PKG_TARG |
2 | target := | |
3 | else | |
4 | target := $(PKG_TARG)- | |
5 | endif | |
6 | ||
63cd45c9 JF |
7 | #flags := -g3 -O0 -DYYDEBUG=1 |
8 | flags := -g0 -O3 | |
6195e7e0 | 9 | flags += -Wall -Werror -I. -fno-common |
ea2d184c | 10 | |
9e20b0b7 | 11 | svn := $(shell svnversion) |
9e20b0b7 | 12 | |
1e7ce557 JF |
13 | all: |
14 | all := libcycript.plist cycript | |
15 | ||
bb9f5eef | 16 | dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null) |
1e7ce557 | 17 | ifneq ($(dpkg_architecture),) |
bb9f5eef | 18 | arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null) |
1e7ce557 JF |
19 | endif |
20 | ||
21 | header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp | |
22 | ||
23 | dll := so | |
24 | ||
25 | uname_s := $(shell uname -s) | |
26 | uname_p := $(shell uname -p) | |
27 | -include $(uname_s).mk | |
28 | -include $(uname_s)-$(uname_p).mk | |
29 | ||
30 | all += libcycript.$(dll) | |
f7c38a29 | 31 | |
1e7ce557 JF |
32 | ifdef arch |
33 | deb := $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb | |
34 | ||
35 | all: $(deb) | |
36 | ||
37 | $(deb): $(all) | |
38 | rm -rf package | |
39 | mkdir -p package/DEBIAN | |
40 | sed -e 's/#/$(svn)/' control >package/DEBIAN/control | |
41 | mkdir -p package/System/Library/LaunchDaemons | |
42 | #cp -a com.saurik.Cyrver.plist package/System/Library/LaunchDaemons | |
43 | mkdir -p package/Library/MobileSubstrate/DynamicLibraries | |
44 | if [[ -e Settings.plist ]]; then \ | |
45 | mkdir -p package/Library/PreferenceLoader/Preferences; \ | |
46 | cp -a Settings.png package/Library/PreferenceLoader/Preferences/CycriptIcon.png; \ | |
47 | cp -a Settings.plist package/Library/PreferenceLoader/Preferences/Cycript.plist; \ | |
48 | fi | |
49 | if [[ -e Tweak.plist ]]; then cp -a Tweak.plist package/Library/MobileSubstrate/DynamicLibraries/Cycript.plist; fi | |
50 | cp -a Cycript.dylib package/Library/MobileSubstrate/DynamicLibraries | |
51 | mkdir -p package/usr/{bin,lib,sbin} | |
52 | cp -a libcycript.dylib package/usr/lib | |
53 | cp -a cycript package/usr/bin | |
54 | #cp -a cyrver package/usr/sbin | |
55 | cp -a libcycript.plist package/usr/lib | |
56 | dpkg-deb -b package $(deb) | |
57 | endif | |
9b5527f0 | 58 | |
8953777c | 59 | all: $(all) |
ea2d184c JF |
60 | |
61 | clean: | |
75b0a457 | 62 | 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 cyrver |
ea2d184c | 63 | |
5999c315 | 64 | libcycript.plist: Bridge.def |
b09da87b | 65 | { \ |
953647c1 | 66 | echo '({'; \ |
f7c38a29 | 67 | grep '^[CFV]' Bridge.def | sed -e 's/^C/0/;s/^F/1/;s/^V/2/' | sed -e 's/"/\\"/g;s/^\([^ ]*\) \([^ ]*\) \(.*\)$$/\2 = (\1, \"\3\");/'; \ |
953647c1 | 68 | echo '},{'; \ |
f33b048a JF |
69 | grep '^:' Bridge.def | sed -e 's/^: \([^ ]*\) \(.*\)/"\1" = "\2";/'; \ |
70 | echo '},{'; \ | |
61933e16 | 71 | 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\");/'; \ |
953647c1 | 72 | echo '})'; \ |
b09da87b | 73 | } >$@ |
88c977fa | 74 | |
5999c315 | 75 | Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y |
e7ed5354 | 76 | bison -v --report=state $< |
e5332278 JF |
77 | |
78 | lex.cy.c: Cycript.l | |
79 | flex $< | |
80 | ||
e5332278 JF |
81 | #Parser.hpp: Parser.py Parser.dat |
82 | # ./Parser.py <Parser.dat >$@ | |
83 | ||
5999c315 | 84 | %.o: sig/%.cpp |
457afcc9 | 85 | $(target)g++ $(flags) -c -o $@ $< |
5999c315 JF |
86 | |
87 | Cycript.tab.o: Cycript.tab.cc Cycript.tab.hh Parser.hpp Pooling.hpp | |
457afcc9 | 88 | $(target)g++ $(flags) -c -o $@ $< |
5999c315 JF |
89 | |
90 | lex.cy.o: lex.cy.c Cycript.tab.hh Parser.hpp Pooling.hpp | |
457afcc9 | 91 | $(target)g++ $(flags) -c -o $@ $< |
5999c315 | 92 | |
f7c38a29 | 93 | %.o: %.cpp $(header) |
057f943f JF |
94 | $(target)g++ $(flags) -c -o $@ $< |
95 | ||
f7c38a29 | 96 | %.o: %.mm $(header) |
457afcc9 | 97 | $(target)g++ $(flags) -c -o $@ $< |
5999c315 | 98 | |
dc68b74c JF |
99 | cyrver: Server.o |
100 | $(target)g++ $(flags) -o $@ $(filter %.o,$^) \ | |
101 | -lobjc -lapr-1 -lsubstrate \ | |
102 | -framework CoreFoundation -framework CFNetwork | |
103 | ldid -S $@ | |
104 | ||
1e7ce557 | 105 | libcycript.$(dll): ffi_type.o parse.o Replace.o Output.o Cycript.tab.o lex.cy.o Library.o |
f7c38a29 JF |
106 | $(target)g++ $(flags) -dynamiclib -o $@ $(filter %.o,$^) \ |
107 | -install_name /usr/lib/libcycript.dylib \ | |
61933e16 | 108 | -lobjc -lapr-1 -lffi -lsubstrate \ |
f7c38a29 JF |
109 | -framework CoreFoundation -framework Foundation \ |
110 | -framework CFNetwork \ | |
111 | -framework JavaScriptCore -framework WebCore | |
ea2d184c JF |
112 | ldid -S $@ |
113 | ||
bb9f5eef | 114 | cycript: Console.o libcycript.$(dll) |
f7c38a29 JF |
115 | $(target)g++ $(flags) -o $@ $(filter %.o,$^) \ |
116 | -lobjc -lapr-1 -lreadline \ | |
117 | -L. -lcycript \ | |
118 | -framework Foundation -framework CoreFoundation \ | |
119 | -framework JavaScriptCore -framework UIKit | |
262e358c JF |
120 | ldid -S cycript |
121 | ||
9b5527f0 JF |
122 | package: $(deb) |
123 | ||
124 | test: $(deb) | |
9e20b0b7 | 125 | dpkg -i $(deb) |
953647c1 | 126 | cycript test.cy |
1dbba6cc | 127 | |
88c977fa | 128 | .PHONY: all clean extra package |