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