]> git.saurik.com Git - cycript.git/blob - makefile
ce70b5559424b2143183ee395fd32c0b5ede7890
[cycript.git] / makefile
1 SHELL :=$(shell which bash 2>/dev/null)
2
3 ifndef PKG_TARG
4 target :=
5 else
6 target := $(PKG_TARG)-
7 endif
8
9 #flags := -g3 -O0 -DYYDEBUG=1
10 flags := -g0 -O3
11 flags += -Wall -Werror -Wno-parentheses
12 flags += -fPIC -fno-common
13 flags += -I. -I$(shell apr-1-config --includedir)
14
15 svn := $(shell svnversion)
16
17 all:
18 all := libcycript.plist cycript
19
20 dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null)
21 ifneq ($(dpkg_architecture),)
22 arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null)
23 endif
24
25 header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp
26 code := ffi_type.o parse.o
27 code += Replace.o Output.o
28 code += Cycript.tab.o lex.cy.o
29 code += Network.o Parser.o
30
31 filters := C
32 ldid := echo
33 dll := so
34 apr := $(shell apr-1-config --link-ld)
35 library := $(apr) -lffi
36 console := $(apr) -lreadline
37
38 uname_s := $(shell uname -s)
39 uname_p := $(shell uname -p)
40 -include $(uname_s).mk
41 -include $(uname_s)-$(uname_p).mk
42
43 all += libcycript.$(dll)
44
45 ifdef arch
46 deb := $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb
47
48 all: $(deb)
49
50 $(deb): $(all)
51 rm -rf package
52 mkdir -p package/DEBIAN
53 sed -e 's/#/$(svn)/' control >package/DEBIAN/control
54 mkdir -p package/System/Library/LaunchDaemons
55 #cp -a com.saurik.Cyrver.plist package/System/Library/LaunchDaemons
56 mkdir -p package/Library/MobileSubstrate/DynamicLibraries
57 if [[ -e Settings.plist ]]; then \
58 mkdir -p package/Library/PreferenceLoader/Preferences; \
59 cp -a Settings.png package/Library/PreferenceLoader/Preferences/CycriptIcon.png; \
60 cp -a Settings.plist package/Library/PreferenceLoader/Preferences/Cycript.plist; \
61 fi
62 if [[ -e Tweak.plist ]]; then cp -a Tweak.plist package/Library/MobileSubstrate/DynamicLibraries/Cycript.plist; fi
63 cp -a Cycript.$(dll) package/Library/MobileSubstrate/DynamicLibraries
64 mkdir -p package/usr/{bin,lib,sbin}
65 cp -a libcycript.$(dll) package/usr/lib
66 cp -a cycript package/usr/bin
67 #cp -a cyrver package/usr/sbin
68 cp -a libcycript.plist package/usr/lib
69 dpkg-deb -b package $(deb)
70 endif
71
72 all: $(all)
73
74 clean:
75 rm -f *.o libcycript.$(dll) cycript libcycript.plist Struct.hpp lex.cy.c Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh cyrver Cycript.y
76
77 libcycript.plist: Bridge.def
78 { \
79 echo '({'; \
80 grep '^[CFV]' Bridge.def | sed -e 's/^C/0/;s/^F/1/;s/^V/2/' | sed -e 's/"/\\"/g;s/^\([^ ]*\) \([^ ]*\) \(.*\)$$/\2 = (\1, \"\3\");/'; \
81 echo '},{'; \
82 grep '^:' Bridge.def | sed -e 's/^: \([^ ]*\) \(.*\)/"\1" = "\2";/'; \
83 echo '},{'; \
84 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\");/'; \
85 echo '})'; \
86 } >$@
87
88 Cycript.y: Cycript.y.in
89 ./Filter.sh <$< >$@ $(filters)
90
91 Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y
92 bison -v --report=state $<
93
94 lex.cy.c: Cycript.l
95 flex $<
96
97 #Parser.hpp: Parser.py Parser.dat
98 # ./Parser.py <Parser.dat >$@
99
100 %.o: sig/%.cpp
101 $(target)g++ $(flags) -c -o $@ $<
102
103 Cycript.tab.o: Cycript.tab.cc Cycript.tab.hh Parser.hpp Pooling.hpp
104 $(target)g++ $(flags) -c -o $@ $<
105
106 lex.cy.o: lex.cy.c Cycript.tab.hh Parser.hpp Pooling.hpp
107 $(target)g++ $(flags) -c -o $@ $<
108
109 %.o: %.cpp $(header)
110 $(target)g++ $(flags) -c -o $@ $<
111
112 %.o: %.mm $(header)
113 $(target)g++ $(flags) -c -o $@ $<
114
115 libcycript.$(dll): $(code)
116 $(target)g++ $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) $(link)
117 $(ldid) -S $@
118
119 cycript: Console.o libcycript.$(dll)
120 $(target)g++ $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(console) $(link)
121 $(ldid) -S cycript
122
123 package: $(deb)
124
125 test: $(deb)
126 dpkg -i $(deb)
127 cycript test.cy
128
129 .PHONY: all clean extra package