]> git.saurik.com Git - cycript.git/blame - makefile
Renamed Application.cpp to Console.cpp.
[cycript.git] / makefile
CommitLineData
ea2d184c
JF
1ifndef PKG_TARG
2target :=
3else
4target := $(PKG_TARG)-
5endif
6
057f943f
JF
7flags := -mthumb -g3 -O0 -Wall -Werror -I. -fno-common
8flags += -F${PKG_ROOT}/System/Library/PrivateFrameworks
ea2d184c 9
9e20b0b7
JF
10svn := $(shell svnversion)
11deb := $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_iphoneos-arm.deb
8953777c 12all := cycript libcycript.dylib libcycript.plist
9e20b0b7 13
f7c38a29
JF
14header := Cycript.tab.hh Parser.hpp Pooling.hpp Struct.hpp cycript.hpp
15
9b5527f0
JF
16$(deb):
17
8953777c 18all: $(all)
ea2d184c
JF
19
20clean:
457afcc9 21 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
ea2d184c 22
5999c315 23libcycript.plist: Bridge.def
b09da87b 24 { \
953647c1 25 echo '({'; \
f7c38a29 26 grep '^[CFV]' Bridge.def | sed -e 's/^C/0/;s/^F/1/;s/^V/2/' | sed -e 's/"/\\"/g;s/^\([^ ]*\) \([^ ]*\) \(.*\)$$/\2 = (\1, \"\3\");/'; \
953647c1 27 echo '},{'; \
f33b048a
JF
28 grep '^:' Bridge.def | sed -e 's/^: \([^ ]*\) \(.*\)/"\1" = "\2";/'; \
29 echo '},{'; \
61933e16 30 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 31 echo '})'; \
b09da87b 32 } >$@
88c977fa 33
5999c315 34Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y
e7ed5354 35 bison -v --report=state $<
e5332278
JF
36
37lex.cy.c: Cycript.l
38 flex $<
39
04450da0
JF
40Struct.hpp:
41 $$($(target)gcc -print-prog-name=cc1obj) -print-objc-runtime-info </dev/null >$@
42
e5332278
JF
43#Parser.hpp: Parser.py Parser.dat
44# ./Parser.py <Parser.dat >$@
45
5999c315 46%.o: sig/%.cpp
457afcc9 47 $(target)g++ $(flags) -c -o $@ $<
5999c315
JF
48
49Cycript.tab.o: Cycript.tab.cc Cycript.tab.hh Parser.hpp Pooling.hpp
457afcc9 50 $(target)g++ $(flags) -c -o $@ $<
5999c315
JF
51
52lex.cy.o: lex.cy.c Cycript.tab.hh Parser.hpp Pooling.hpp
457afcc9 53 $(target)g++ $(flags) -c -o $@ $<
5999c315 54
f7c38a29 55%.o: %.cpp $(header)
057f943f
JF
56 $(target)g++ $(flags) -c -o $@ $<
57
f7c38a29 58%.o: %.mm $(header)
457afcc9 59 $(target)g++ $(flags) -c -o $@ $<
5999c315
JF
60
61libcycript.dylib: ffi_type.o parse.o Output.o Cycript.tab.o lex.cy.o Library.o
f7c38a29
JF
62 $(target)g++ $(flags) -dynamiclib -o $@ $(filter %.o,$^) \
63 -install_name /usr/lib/libcycript.dylib \
61933e16 64 -lobjc -lapr-1 -lffi -lsubstrate \
f7c38a29
JF
65 -framework CoreFoundation -framework Foundation \
66 -framework CFNetwork \
67 -framework JavaScriptCore -framework WebCore
ea2d184c
JF
68 ldid -S $@
69
b6d0605d 70cycript: Console.o libcycript.dylib
f7c38a29
JF
71 $(target)g++ $(flags) -o $@ $(filter %.o,$^) \
72 -lobjc -lapr-1 -lreadline \
73 -L. -lcycript \
74 -framework Foundation -framework CoreFoundation \
75 -framework JavaScriptCore -framework UIKit
262e358c
JF
76 ldid -S cycript
77
8953777c 78$(deb): $(all)
ea2d184c
JF
79 rm -rf package
80 mkdir -p package/DEBIAN
9e20b0b7 81 sed -e 's/#/$(svn)/' control >package/DEBIAN/control
ea2d184c 82 mkdir -p package/Library/MobileSubstrate/DynamicLibraries
ea2d184c
JF
83 if [[ -e Settings.plist ]]; then \
84 mkdir -p package/Library/PreferenceLoader/Preferences; \
262e358c
JF
85 cp -a Settings.png package/Library/PreferenceLoader/Preferences/CycriptIcon.png; \
86 cp -a Settings.plist package/Library/PreferenceLoader/Preferences/Cycript.plist; \
ea2d184c 87 fi
262e358c
JF
88 if [[ -e Tweak.plist ]]; then cp -a Tweak.plist package/Library/MobileSubstrate/DynamicLibraries/Cycript.plist; fi
89 #cp -a Cycript.dylib package/Library/MobileSubstrate/DynamicLibraries
62ca2b82 90 mkdir -p package/usr/{bin,lib}
262e358c 91 cp -a libcycript.dylib package/usr/lib
967067aa 92 ln -s /usr/lib/libcycript.dylib package/Library/MobileSubstrate/DynamicLibraries/Cycript.dylib
107e3ed0
JF
93 cp -a cycript package/usr/bin
94 cp -a libcycript.plist package/usr/lib
9e20b0b7 95 dpkg-deb -b package $(deb)
88c977fa 96
9b5527f0
JF
97package: $(deb)
98
99test: $(deb)
9e20b0b7 100 dpkg -i $(deb)
953647c1 101 cycript test.cy
1dbba6cc 102
88c977fa 103.PHONY: all clean extra package