1 SHELL := $(shell which bash 2>/dev/null)
9 flags := -g3 -O0 -DYYDEBUG=1
11 flags += -Wall -Werror -Wno-parentheses
12 flags += -fPIC -fno-common
13 flags += -I. -I$(shell apr-1-config --includedir)
15 svn := $(shell svnversion)
18 all := libcycript.plist cycript
20 dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null)
21 ifneq ($(dpkg_architecture),)
22 arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null)
25 header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp
26 code := ffi_type.o parse.o
27 code += Replace.o Output.o
28 code += Cycript.tab.o lex.cy.o
29 code += Network.o Parser.o
34 apr := $(shell apr-1-config --link-ld)
35 library := $(apr) -lffi
36 console := $(apr) -lreadline
39 uname_s := $(shell uname -s)
40 uname_p := $(shell uname -p)
41 -include $(uname_s).mk
42 -include $(uname_s)-$(uname_p).mk
44 all += libcycript.$(dll)
47 deb := $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb
55 mkdir -p package/DEBIAN
56 sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' control >package/DEBIAN/control
58 mkdir -p package/usr/{bin,lib,sbin}
59 cp -a libcycript.$(dll) package/usr/lib
60 cp -a cycript package/usr/bin
61 #cp -a cyrver package/usr/sbin
62 cp -a libcycript.plist package/usr/lib
63 dpkg-deb -b package $(deb)
69 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
71 libcycript.plist: Bridge.def
74 grep '^[CFV]' Bridge.def | sed -e 's/^C/0/;s/^F/1/;s/^V/2/' | sed -e 's/"/\\"/g;s/^\([^ ]*\) \([^ ]*\) \(.*\)$$/\2 = (\1, \"\3\");/'; \
76 grep '^:' Bridge.def | sed -e 's/^: \([^ ]*\) \(.*\)/"\1" = "\2";/'; \
78 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\");/'; \
82 Cycript.y: Cycript.y.in
83 ./Filter.sh <$< >$@ $(filters)
85 Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y
86 bison -v --report=state $<
91 #Parser.hpp: Parser.py Parser.dat
92 # ./Parser.py <Parser.dat >$@
95 $(target)g++ $(flags) -c -o $@ $<
97 Cycript.tab.o: Cycript.tab.cc Cycript.tab.hh Parser.hpp Pooling.hpp
98 $(target)g++ $(flags) -c -o $@ $<
100 lex.cy.o: lex.cy.c Cycript.tab.hh Parser.hpp Pooling.hpp
101 $(target)g++ $(flags) -c -o $@ $<
104 $(target)g++ $(flags) -c -o $@ $<
107 $(target)g++ $(flags) -c -o $@ $<
109 libcycript.$(dll): $(code)
110 $(target)g++ $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) $(link)
113 cycript: Console.o libcycript.$(dll)
114 $(target)g++ $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(console) $(link)
123 .PHONY: all clean extra package