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