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