9 flags := -mthumb -g3 -O0 -Wall -Werror -I. -fno-common
10 flags += -F${PKG_ROOT}/System/Library/PrivateFrameworks
12 svn := $(shell svnversion)
13 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 header := Cycript.tab.hh Parser.hpp Pooling.hpp Struct.hpp cycript.hpp
17 all: cycript libcycript.dylib libcycript.plist
20 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 libcycript.plist: Bridge.def
25 grep '^[CFV]' Bridge.def | sed -e 's/^C/0/;s/^F/1/;s/^V/2/' | sed -e 's/"/\\"/g;s/^\([^ ]*\) \([^ ]*\) \(.*\)$$/\2 = (\1, \"\3\");/'; \
27 grep '^:' Bridge.def | sed -e 's/^: \([^ ]*\) \(.*\)/"\1" = "\2";/'; \
29 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\");/'; \
33 Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y
34 bison -v --report=state $<
40 $$($(target)gcc -print-prog-name=cc1obj) -print-objc-runtime-info </dev/null >$@
42 #Parser.hpp: Parser.py Parser.dat
43 # ./Parser.py <Parser.dat >$@
46 $(target)g++ $(flags) -c -o $@ $<
48 Cycript.tab.o: Cycript.tab.cc Cycript.tab.hh Parser.hpp Pooling.hpp
49 $(target)g++ $(flags) -c -o $@ $<
51 lex.cy.o: lex.cy.c Cycript.tab.hh Parser.hpp Pooling.hpp
52 $(target)g++ $(flags) -c -o $@ $<
55 $(target)g++ $(flags) -c -o $@ $<
58 $(target)g++ $(flags) -c -o $@ $<
60 libcycript.dylib: ffi_type.o parse.o Output.o Cycript.tab.o lex.cy.o Library.o
61 $(target)g++ $(flags) -dynamiclib -o $@ $(filter %.o,$^) \
62 -install_name /usr/lib/libcycript.dylib \
63 -lobjc -lapr-1 -lffi -lsubstrate \
64 -framework CoreFoundation -framework Foundation \
65 -framework CFNetwork \
66 -framework JavaScriptCore -framework WebCore
69 cycript: Application.o libcycript.dylib
70 $(target)g++ $(flags) -o $@ $(filter %.o,$^) \
71 -lobjc -lapr-1 -lreadline \
73 -framework Foundation -framework CoreFoundation \
74 -framework JavaScriptCore -framework UIKit
79 mkdir -p package/DEBIAN
80 sed -e 's/#/$(svn)/' control >package/DEBIAN/control
81 mkdir -p package/Library/MobileSubstrate/DynamicLibraries
82 if [[ -e Settings.plist ]]; then \
83 mkdir -p package/Library/PreferenceLoader/Preferences; \
84 cp -a Settings.png package/Library/PreferenceLoader/Preferences/CycriptIcon.png; \
85 cp -a Settings.plist package/Library/PreferenceLoader/Preferences/Cycript.plist; \
87 if [[ -e Tweak.plist ]]; then cp -a Tweak.plist package/Library/MobileSubstrate/DynamicLibraries/Cycript.plist; fi
88 #cp -a Cycript.dylib package/Library/MobileSubstrate/DynamicLibraries
89 mkdir -p package/usr/{bin,lib}
90 cp -a libcycript.dylib package/usr/lib
91 #ln -s /usr/lib/libcycript.dylib package/Library/MobileSubstrate/DynamicLibraries/Cycript.dylib
92 cp -a cycript package/usr/bin
93 cp -a libcycript.plist package/usr/lib
94 dpkg-deb -b package $(deb)
100 .PHONY: all clean extra package