]> git.saurik.com Git - cycript.git/blame - makefile
Started setting up build environment for Cyrver, fixed Functor prototype, organized...
[cycript.git] / makefile
CommitLineData
ea2d184c
JF
1ifndef PKG_TARG
2target :=
3else
4target := $(PKG_TARG)-
5endif
6
e80b023d 7flags := -mthumb -g0 -O3 -Wall -Werror -I. -fno-common
057f943f 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
dc68b74c 12all := cycript libcycript.dylib libcycript.plist Cycript.dylib #cyrver
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 60
dc68b74c
JF
61cyrver: Server.o
62 $(target)g++ $(flags) -o $@ $(filter %.o,$^) \
63 -lobjc -lapr-1 -lsubstrate \
64 -framework CoreFoundation -framework CFNetwork
65 ldid -S $@
66
1ef7d061
JF
67Cycript.dylib: Connector.o
68 $(target)g++ $(flags) -dynamiclib -o $@ $(filter %.o,$^) \
69 -lobjc -lapr-1 -lsubstrate \
70 -framework CoreFoundation
71 ldid -S $@
72
5999c315 73libcycript.dylib: ffi_type.o parse.o Output.o Cycript.tab.o lex.cy.o Library.o
f7c38a29
JF
74 $(target)g++ $(flags) -dynamiclib -o $@ $(filter %.o,$^) \
75 -install_name /usr/lib/libcycript.dylib \
61933e16 76 -lobjc -lapr-1 -lffi -lsubstrate \
f7c38a29
JF
77 -framework CoreFoundation -framework Foundation \
78 -framework CFNetwork \
79 -framework JavaScriptCore -framework WebCore
ea2d184c
JF
80 ldid -S $@
81
b6d0605d 82cycript: Console.o libcycript.dylib
f7c38a29
JF
83 $(target)g++ $(flags) -o $@ $(filter %.o,$^) \
84 -lobjc -lapr-1 -lreadline \
85 -L. -lcycript \
86 -framework Foundation -framework CoreFoundation \
87 -framework JavaScriptCore -framework UIKit
262e358c
JF
88 ldid -S cycript
89
8953777c 90$(deb): $(all)
ea2d184c
JF
91 rm -rf package
92 mkdir -p package/DEBIAN
9e20b0b7 93 sed -e 's/#/$(svn)/' control >package/DEBIAN/control
dc68b74c
JF
94 mkdir -p package/System/Library/LaunchDaemons
95 cp -a com.saurik.Cyrver.plist package/System/Library/LaunchDaemons
ea2d184c 96 mkdir -p package/Library/MobileSubstrate/DynamicLibraries
ea2d184c
JF
97 if [[ -e Settings.plist ]]; then \
98 mkdir -p package/Library/PreferenceLoader/Preferences; \
262e358c
JF
99 cp -a Settings.png package/Library/PreferenceLoader/Preferences/CycriptIcon.png; \
100 cp -a Settings.plist package/Library/PreferenceLoader/Preferences/Cycript.plist; \
ea2d184c 101 fi
262e358c 102 if [[ -e Tweak.plist ]]; then cp -a Tweak.plist package/Library/MobileSubstrate/DynamicLibraries/Cycript.plist; fi
1ef7d061 103 cp -a Cycript.dylib package/Library/MobileSubstrate/DynamicLibraries
dc68b74c 104 mkdir -p package/usr/{bin,lib,sbin}
262e358c 105 cp -a libcycript.dylib package/usr/lib
107e3ed0 106 cp -a cycript package/usr/bin
dc68b74c 107 #cp -a cyrver package/usr/sbin
107e3ed0 108 cp -a libcycript.plist package/usr/lib
9e20b0b7 109 dpkg-deb -b package $(deb)
88c977fa 110
9b5527f0
JF
111package: $(deb)
112
113test: $(deb)
9e20b0b7 114 dpkg -i $(deb)
953647c1 115 cycript test.cy
1dbba6cc 116
88c977fa 117.PHONY: all clean extra package