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