]> git.saurik.com Git - cycript.git/blame - makefile
Separated out Objective-C and C language extensions using a new Filter.sh shell scrip...
[cycript.git] / makefile
CommitLineData
ea2d184c
JF
1ifndef PKG_TARG
2target :=
3else
4target := $(PKG_TARG)-
5endif
6
4de0686f
JF
7flags := -g3 -O0 -DYYDEBUG=1
8#flags := -g0 -O3
6195e7e0 9flags += -Wall -Werror -I. -fno-common
ea2d184c 10
9e20b0b7 11svn := $(shell svnversion)
9e20b0b7 12
4de0686f
JF
13filters := C
14
1e7ce557
JF
15all:
16all := libcycript.plist cycript
17
bb9f5eef 18dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null)
1e7ce557 19ifneq ($(dpkg_architecture),)
bb9f5eef 20arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null)
1e7ce557
JF
21endif
22
23header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp
4de0686f 24code := ffi_type.o parse.o Replace.o Output.o Cycript.tab.o lex.cy.o Library.o
1e7ce557
JF
25
26dll := so
27
28uname_s := $(shell uname -s)
29uname_p := $(shell uname -p)
30-include $(uname_s).mk
31-include $(uname_s)-$(uname_p).mk
32
33all += libcycript.$(dll)
f7c38a29 34
1e7ce557
JF
35ifdef arch
36deb := $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb
37
38all: $(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.dylib package/Library/MobileSubstrate/DynamicLibraries
54 mkdir -p package/usr/{bin,lib,sbin}
55 cp -a libcycript.dylib 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)
60endif
9b5527f0 61
8953777c 62all: $(all)
ea2d184c
JF
63
64clean:
75b0a457 65 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
ea2d184c 66
5999c315 67libcycript.plist: Bridge.def
b09da87b 68 { \
953647c1 69 echo '({'; \
f7c38a29 70 grep '^[CFV]' Bridge.def | sed -e 's/^C/0/;s/^F/1/;s/^V/2/' | sed -e 's/"/\\"/g;s/^\([^ ]*\) \([^ ]*\) \(.*\)$$/\2 = (\1, \"\3\");/'; \
953647c1 71 echo '},{'; \
f33b048a
JF
72 grep '^:' Bridge.def | sed -e 's/^: \([^ ]*\) \(.*\)/"\1" = "\2";/'; \
73 echo '},{'; \
61933e16 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\");/'; \
953647c1 75 echo '})'; \
b09da87b 76 } >$@
88c977fa 77
4de0686f
JF
78Cycript.y: Cycript.y.in
79 ./Filter.sh <$< >$@ $(filters)
80
5999c315 81Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y
e7ed5354 82 bison -v --report=state $<
e5332278
JF
83
84lex.cy.c: Cycript.l
85 flex $<
86
e5332278
JF
87#Parser.hpp: Parser.py Parser.dat
88# ./Parser.py <Parser.dat >$@
89
5999c315 90%.o: sig/%.cpp
457afcc9 91 $(target)g++ $(flags) -c -o $@ $<
5999c315
JF
92
93Cycript.tab.o: Cycript.tab.cc Cycript.tab.hh Parser.hpp Pooling.hpp
457afcc9 94 $(target)g++ $(flags) -c -o $@ $<
5999c315
JF
95
96lex.cy.o: lex.cy.c Cycript.tab.hh Parser.hpp Pooling.hpp
457afcc9 97 $(target)g++ $(flags) -c -o $@ $<
5999c315 98
f7c38a29 99%.o: %.cpp $(header)
057f943f
JF
100 $(target)g++ $(flags) -c -o $@ $<
101
f7c38a29 102%.o: %.mm $(header)
457afcc9 103 $(target)g++ $(flags) -c -o $@ $<
5999c315 104
dc68b74c
JF
105cyrver: Server.o
106 $(target)g++ $(flags) -o $@ $(filter %.o,$^) \
107 -lobjc -lapr-1 -lsubstrate \
108 -framework CoreFoundation -framework CFNetwork
109 ldid -S $@
110
4de0686f 111libcycript.$(dll): $(code)
f7c38a29
JF
112 $(target)g++ $(flags) -dynamiclib -o $@ $(filter %.o,$^) \
113 -install_name /usr/lib/libcycript.dylib \
61933e16 114 -lobjc -lapr-1 -lffi -lsubstrate \
f7c38a29
JF
115 -framework CoreFoundation -framework Foundation \
116 -framework CFNetwork \
117 -framework JavaScriptCore -framework WebCore
ea2d184c
JF
118 ldid -S $@
119
bb9f5eef 120cycript: Console.o libcycript.$(dll)
f7c38a29
JF
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
262e358c
JF
126 ldid -S cycript
127
9b5527f0
JF
128package: $(deb)
129
130test: $(deb)
9e20b0b7 131 dpkg -i $(deb)
953647c1 132 cycript test.cy
1dbba6cc 133
88c977fa 134.PHONY: all clean extra package