]> git.saurik.com Git - cycript.git/blame - makefile
Forgot the new JavaScriptCore.cpp from earlier commit.
[cycript.git] / makefile
CommitLineData
f37e3501 1SHELL := $(shell which bash 2>/dev/null)
be4442da 2
ea2d184c
JF
3ifndef PKG_TARG
4target :=
5else
6target := $(PKG_TARG)-
7endif
8
cbaa5f0f 9flags :=
ea2d184c 10
9e20b0b7 11svn := $(shell svnversion)
9e20b0b7 12
1e7ce557
JF
13all:
14all := libcycript.plist cycript
15
bb9f5eef 16dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null)
1e7ce557 17ifneq ($(dpkg_architecture),)
bb9f5eef 18arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null)
1e7ce557
JF
19endif
20
21header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp
9185d5ef
JF
22code := ffi_type.o parse.o
23code += Replace.o Output.o
24code += Cycript.tab.o lex.cy.o
25code += Network.o Parser.o
cbaa5f0f 26code += JavaScriptCore.o Library.o
1e7ce557 27
9185d5ef
JF
28filters := C
29ldid := echo
1e7ce557 30dll := so
9185d5ef 31apr := $(shell apr-1-config --link-ld)
dfa452c2
JF
32library := $(apr) -lffi
33console := $(apr) -lreadline
f37e3501 34depends :=
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
cbaa5f0f
JF
41flags += -g3 -O0 -DYYDEBUG=1
42#flags += -g0 -O3
43flags += -Wall -Werror -Wno-parentheses
44flags += -fPIC -fno-common
45flags += -I. -I$(shell apr-1-config --includedir)
46
1e7ce557 47all += libcycript.$(dll)
f7c38a29 48
1e7ce557
JF
49ifdef arch
50deb := $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb
51
52all: $(deb)
53
f37e3501
JF
54extra:
55
1e7ce557
JF
56$(deb): $(all)
57 rm -rf package
58 mkdir -p package/DEBIAN
f37e3501
JF
59 sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' control >package/DEBIAN/control
60 $(MAKE) extra
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)
dfa452c2 113 $(target)g++ $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) $(link)
9185d5ef 114 $(ldid) -S $@
ea2d184c 115
bb9f5eef 116cycript: Console.o libcycript.$(dll)
dfa452c2 117 $(target)g++ $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(console) $(link)
9185d5ef 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