]> git.saurik.com Git - cycript.git/blob - makefile
2cd6880d5c503be2fea5784427379a1e85028c02
[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 depends :=
38
39 uname_s := $(shell uname -s)
40 uname_p := $(shell uname -p)
41 -include $(uname_s).mk
42 -include $(uname_s)-$(uname_p).mk
43
44 all += libcycript.$(dll)
45
46 ifdef arch
47 deb := $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb
48
49 all: $(deb)
50
51 extra:
52
53 $(deb): $(all)
54 rm -rf package
55 mkdir -p package/DEBIAN
56 sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' control >package/DEBIAN/control
57 $(MAKE) extra
58 mkdir -p package/usr/{bin,lib,sbin}
59 cp -a libcycript.$(dll) package/usr/lib
60 cp -a cycript package/usr/bin
61 #cp -a cyrver package/usr/sbin
62 cp -a libcycript.plist package/usr/lib
63 dpkg-deb -b package $(deb)
64 endif
65
66 all: $(all)
67
68 clean:
69 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
70
71 libcycript.plist: Bridge.def
72 { \
73 echo '({'; \
74 grep '^[CFV]' Bridge.def | sed -e 's/^C/0/;s/^F/1/;s/^V/2/' | sed -e 's/"/\\"/g;s/^\([^ ]*\) \([^ ]*\) \(.*\)$$/\2 = (\1, \"\3\");/'; \
75 echo '},{'; \
76 grep '^:' Bridge.def | sed -e 's/^: \([^ ]*\) \(.*\)/"\1" = "\2";/'; \
77 echo '},{'; \
78 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\");/'; \
79 echo '})'; \
80 } >$@
81
82 Cycript.y: Cycript.y.in
83 ./Filter.sh <$< >$@ $(filters)
84
85 Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y
86 bison -v --report=state $<
87
88 lex.cy.c: Cycript.l
89 flex $<
90
91 #Parser.hpp: Parser.py Parser.dat
92 # ./Parser.py <Parser.dat >$@
93
94 %.o: sig/%.cpp
95 $(target)g++ $(flags) -c -o $@ $<
96
97 Cycript.tab.o: Cycript.tab.cc Cycript.tab.hh Parser.hpp Pooling.hpp
98 $(target)g++ $(flags) -c -o $@ $<
99
100 lex.cy.o: lex.cy.c Cycript.tab.hh Parser.hpp Pooling.hpp
101 $(target)g++ $(flags) -c -o $@ $<
102
103 %.o: %.cpp $(header)
104 $(target)g++ $(flags) -c -o $@ $<
105
106 %.o: %.mm $(header)
107 $(target)g++ $(flags) -c -o $@ $<
108
109 libcycript.$(dll): $(code)
110 $(target)g++ $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) $(link)
111 $(ldid) -S $@
112
113 cycript: Console.o libcycript.$(dll)
114 $(target)g++ $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(console) $(link)
115 $(ldid) -S cycript
116
117 package: $(deb)
118
119 test: $(deb)
120 dpkg -i $(deb)
121 cycript test.cy
122
123 .PHONY: all clean extra package