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