]> git.saurik.com Git - cycript.git/blame - makefile
Finally got this damned thing actually executing JavaScript on Linux.
[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 :=
eacba955 10objc :=
ea2d184c 11
9e20b0b7 12svn := $(shell svnversion)
9e20b0b7 13
1e7ce557 14all:
856b8cd0 15all := libcycript.db cycript
1e7ce557 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
37954781 22header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp
3c1c3635 23code := sig/ffi_type.o sig/parse.o sig/copy.o
9185d5ef
JF
24code += Replace.o Output.o
25code += Cycript.tab.o lex.cy.o
26code += Network.o Parser.o
cbaa5f0f 27code += JavaScriptCore.o Library.o
1e7ce557 28
856b8cd0 29filters := C #E4X
82149e4b 30ldid := true
1e7ce557 31dll := so
9185d5ef 32apr := $(shell apr-1-config --link-ld)
28926538 33library := $(apr) -lffi -lsqlite3
dfa452c2 34console := $(apr) -lreadline
f37e3501 35depends :=
1e7ce557
JF
36
37uname_s := $(shell uname -s)
38uname_p := $(shell uname -p)
39-include $(uname_s).mk
40-include $(uname_s)-$(uname_p).mk
41
993f82f8
JF
42ifeq ($(filter ObjectiveC,$(filters)),)
43ifneq ($(shell which gnustep-config 2>/dev/null),)
28926538 44#include GNUstep.mk
993f82f8
JF
45endif
46endif
47
37954781
JF
48flags += -g3 -O0 -DYYDEBUG=1
49#flags += -g0 -O3
82149e4b 50flags += -Wall -Werror -Wno-parentheses #-Wno-unused
cbaa5f0f
JF
51flags += -fPIC -fno-common
52flags += -I. -I$(shell apr-1-config --includedir)
53
1e7ce557 54all += libcycript.$(dll)
f7c38a29 55
1e7ce557
JF
56ifdef arch
57deb := $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb
58
59all: $(deb)
60
f37e3501
JF
61extra:
62
1e7ce557
JF
63$(deb): $(all)
64 rm -rf package
65 mkdir -p package/DEBIAN
f37e3501
JF
66 sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' control >package/DEBIAN/control
67 $(MAKE) extra
1e7ce557 68 mkdir -p package/usr/{bin,lib,sbin}
328ad766 69 cp -a libcycript.$(dll) package/usr/lib
1e7ce557
JF
70 cp -a cycript package/usr/bin
71 #cp -a cyrver package/usr/sbin
856b8cd0 72 cp -a libcycript.db package/usr/lib
1e7ce557
JF
73 dpkg-deb -b package $(deb)
74endif
9b5527f0 75
8953777c 76all: $(all)
ea2d184c
JF
77
78clean:
856b8cd0 79 rm -f *.o libcycript.$(dll) cycript libcycript.db Struct.hpp lex.cy.c Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh cyrver Cycript.y
ea2d184c 80
3c1c3635 81libcycript.db: Bridge.def
856b8cd0 82 rm -f libcycript.db
b09da87b 83 { \
856b8cd0
JF
84 echo 'create table "bridge" ("mode" int not null, "name" text not null, "value" text null);'; \
85 grep '^[CFV]' Bridge.def | sed -e 's/^C/0/;s/^F/1/;s/^V/2/' | sed -e 's/"/\\"/g;s/^\([^ ]*\) \([^ ]*\) \(.*\)$$/insert into "bridge" ("mode", "name", "value") values (\1, '"'"'\2'"'"', '"'"'\3'"'"');/'; \
86 grep '^:' Bridge.def | sed -e 's/^: \([^ ]*\) \(.*\)/insert into "bridge" ("mode", "name", "value") values (-1, '"'"'\1'"'"', '"'"'\2'"'"');/'; \
87 grep '^[EST]' Bridge.def | sed -e 's/^S/3/;s/^T/4/;s/^E/5/' | sed -e 's/^5\(.*\)$$/4\1 i/' | sed -e 's/^\([^ ]*\) \([^ ]*\) \(.*\)$$/insert into "bridge" ("mode", "name", "value") values (\1, '"'"'\2'"'"', '"'"'\3'"'"');/'; \
88 } | sqlite3 libcycript.db
88c977fa 89
cb02f8ae
JF
90%.y: %.y.in
91 ./Filter.sh <$< >$@ $(filters)
92
93%.l: %.l.in
4de0686f
JF
94 ./Filter.sh <$< >$@ $(filters)
95
5999c315 96Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y
e7ed5354 97 bison -v --report=state $<
e5332278
JF
98
99lex.cy.c: Cycript.l
100 flex $<
101
e5332278
JF
102#Parser.hpp: Parser.py Parser.dat
103# ./Parser.py <Parser.dat >$@
104
cacd1a88 105Cycript.tab.o: Cycript.tab.cc $(header)
457afcc9 106 $(target)g++ $(flags) -c -o $@ $<
5999c315 107
cacd1a88 108lex.cy.o: lex.cy.c $(header)
457afcc9 109 $(target)g++ $(flags) -c -o $@ $<
5999c315 110
f7c38a29 111%.o: %.cpp $(header)
057f943f
JF
112 $(target)g++ $(flags) -c -o $@ $<
113
cacd1a88 114#objc := -x c++
f7c38a29 115%.o: %.mm $(header)
7677a045 116 $(target)g++ $(objc) $(flags) -c -o $@ $<
5999c315 117
4de0686f 118libcycript.$(dll): $(code)
dfa452c2 119 $(target)g++ $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) $(link)
82149e4b 120 $(ldid) $@
ea2d184c 121
bb9f5eef 122cycript: Console.o libcycript.$(dll)
dfa452c2 123 $(target)g++ $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(console) $(link)
82149e4b 124 $(ldid) cycript
262e358c 125
9b5527f0
JF
126package: $(deb)
127
128test: $(deb)
9e20b0b7 129 dpkg -i $(deb)
953647c1 130 cycript test.cy
1dbba6cc 131
88c977fa 132.PHONY: all clean extra package