1 SHELL := $(shell which bash 2>/dev/null)
9 paths := $(foreach path,$(paths),$(wildcard $(path)))
10 flags := $(foreach path,$(paths),-I$(path) -L$(path))
13 svn := $(shell svnversion)
16 all := libcycript.db cycript
18 dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null)
19 ifneq ($(dpkg_architecture),)
20 arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null)
23 header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp
24 code := sig/ffi_type.o sig/parse.o sig/copy.o
25 code += Replace.o Output.o
26 code += Cycript.tab.o lex.cy.o
27 code += Network.o Parser.o
28 code += JavaScriptCore.o Library.o
33 apr := $(shell apr-1-config --link-ld)
34 library := $(apr) -lffi -lsqlite3
35 console := $(apr) -lreadline
39 uname_s := $(shell uname -s)
43 uname_p := $(shell uname -p)
46 -include $(uname_s).mk
47 -include $(uname_s)-$(uname_p).mk
49 ifeq ($(filter ObjectiveC,$(filters)),)
50 ifneq ($(shell which gnustep-config 2>/dev/null),)
55 #flags += -g3 -O0 -DYYDEBUG=1
57 flags += -Wall -Werror -Wno-parentheses #-Wno-unused
58 flags += -fPIC -fno-common
59 flags += -I. -I$(shell apr-1-config --includedir)
61 all += libcycript.$(dll)
64 deb := $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb
72 mkdir -p package/DEBIAN
73 sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' control >package/DEBIAN/control
75 mkdir -p package/usr/{bin,lib,sbin}
76 cp -a libcycript.$(dll) package/usr/lib
77 cp -a cycript package/usr/bin
78 #cp -a cyrver package/usr/sbin
79 cp -a libcycript.db package/usr/lib
80 dpkg-deb -b package $(deb)
86 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
88 libcycript.db: Bridge.def
91 echo 'create table "bridge" ("mode" int not null, "name" text not null, "value" text null);'; \
92 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'"'"');/'; \
93 grep '^:' Bridge.def | sed -e 's/^: \([^ ]*\) \(.*\)/insert into "bridge" ("mode", "name", "value") values (-1, '"'"'\1'"'"', '"'"'\2'"'"');/'; \
94 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'"'"');/'; \
95 } | sqlite3 libcycript.db
98 ./Filter.sh <$< >$@ $(filters)
101 ./Filter.sh <$< >$@ $(filters)
103 Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y
104 bison -v --report=state $<
109 #Parser.hpp: Parser.py Parser.dat
110 # ./Parser.py <Parser.dat >$@
112 Cycript.tab.o: Cycript.tab.cc $(header)
113 $(target)g++ $(flags) -c -o $@ $<
115 lex.cy.o: lex.cy.c $(header)
116 $(target)g++ $(flags) -c -o $@ $<
119 $(target)g++ $(flags) -c -o $@ $<
123 $(target)g++ $(objc) $(flags) -c -o $@ $<
125 libcycript.$(dll): $(code)
126 $(target)g++ $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) $(link)
129 cycript: Console.o libcycript.$(dll)
130 $(target)g++ $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(console) $(link)
139 .PHONY: all clean extra package