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