1 SHELL :=$(shell which bash 2>/dev/null)
9 #flags := -g3 -O0 -DYYDEBUG=1
11 flags += -Wall -Werror -Wno-parentheses
12 flags += -fPIC -fno-common
13 flags += -I. -I$(shell apr-1-config --includedir)
15 svn := $(shell svnversion)
18 all := libcycript.plist cycript
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)
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
34 apr := $(shell apr-1-config --link-ld)
35 library := $(apr) -lffi
36 console := $(apr) -lreadline
38 uname_s := $(shell uname -s)
39 uname_p := $(shell uname -p)
40 -include $(uname_s).mk
41 -include $(uname_s)-$(uname_p).mk
43 all += libcycript.$(dll)
46 deb := $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb
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; \
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)
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
77 libcycript.plist: Bridge.def
80 grep '^[CFV]' Bridge.def | sed -e 's/^C/0/;s/^F/1/;s/^V/2/' | sed -e 's/"/\\"/g;s/^\([^ ]*\) \([^ ]*\) \(.*\)$$/\2 = (\1, \"\3\");/'; \
82 grep '^:' Bridge.def | sed -e 's/^: \([^ ]*\) \(.*\)/"\1" = "\2";/'; \
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\");/'; \
88 Cycript.y: Cycript.y.in
89 ./Filter.sh <$< >$@ $(filters)
91 Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y
92 bison -v --report=state $<
97 #Parser.hpp: Parser.py Parser.dat
98 # ./Parser.py <Parser.dat >$@
101 $(target)g++ $(flags) -c -o $@ $<
103 Cycript.tab.o: Cycript.tab.cc Cycript.tab.hh Parser.hpp Pooling.hpp
104 $(target)g++ $(flags) -c -o $@ $<
106 lex.cy.o: lex.cy.c Cycript.tab.hh Parser.hpp Pooling.hpp
107 $(target)g++ $(flags) -c -o $@ $<
110 $(target)g++ $(flags) -c -o $@ $<
113 $(target)g++ $(flags) -c -o $@ $<
115 libcycript.$(dll): $(code)
116 $(target)g++ $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) $(link)
119 cycript: Console.o libcycript.$(dll)
120 $(target)g++ $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(console) $(link)
129 .PHONY: all clean extra package