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