1 SHELL := $(shell which bash 2>/dev/null)
 
  12 svn := $(shell svnversion)
 
  15 all := libcycript.db cycript
 
  17 dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null)
 
  18 ifneq ($(dpkg_architecture),)
 
  19 arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null)
 
  22 header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp
 
  23 code := sig/ffi_type.o sig/parse.o sig/copy.o
 
  24 code += Replace.o Output.o
 
  25 code += Cycript.tab.o lex.cy.o
 
  26 code += Network.o Parser.o
 
  27 code += JavaScriptCore.o Library.o
 
  32 apr := $(shell apr-1-config --link-ld)
 
  33 library := $(apr) -lffi -liconv -lsqlite3
 
  34 console := $(apr) -lreadline
 
  37 uname_s := $(shell uname -s)
 
  38 uname_p := $(shell uname -p)
 
  39 -include $(uname_s).mk
 
  40 -include $(uname_s)-$(uname_p).mk
 
  42 ifeq ($(filter ObjectiveC,$(filters)),)
 
  43 ifneq ($(shell which gnustep-config 2>/dev/null),)
 
  48 flags += -g3 -O0 -DYYDEBUG=1
 
  50 flags += -Wall -Werror -Wno-parentheses #-Wno-unused
 
  51 flags += -fPIC -fno-common
 
  52 flags += -I. -I$(shell apr-1-config --includedir)
 
  54 all += libcycript.$(dll)
 
  57 deb := $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb
 
  65         mkdir -p package/DEBIAN
 
  66         sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' control >package/DEBIAN/control
 
  68         mkdir -p package/usr/{bin,lib,sbin}
 
  69         cp -a libcycript.$(dll) package/usr/lib
 
  70         cp -a cycript package/usr/bin
 
  71         #cp -a cyrver package/usr/sbin
 
  72         cp -a libcycript.db package/usr/lib
 
  73         dpkg-deb -b package $(deb)
 
  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
 
  81 libcycript.db: Bridge.def
 
  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
 
  91         ./Filter.sh <$< >$@ $(filters)
 
  94         ./Filter.sh <$< >$@ $(filters)
 
  96 Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y
 
  97         bison -v --report=state $<
 
 102 #Parser.hpp: Parser.py Parser.dat
 
 103 #       ./Parser.py <Parser.dat >$@
 
 105 Cycript.tab.o: Cycript.tab.cc $(header)
 
 106         $(target)g++ $(flags) -c -o $@ $<
 
 108 lex.cy.o: lex.cy.c $(header)
 
 109         $(target)g++ $(flags) -c -o $@ $<
 
 112         $(target)g++ $(flags) -c -o $@ $<
 
 116         $(target)g++ $(objc) $(flags) -c -o $@ $<
 
 118 libcycript.$(dll): $(code)
 
 119         $(target)g++ $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) $(link)
 
 122 cycript: Console.o libcycript.$(dll)
 
 123         $(target)g++ $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(console) $(link)
 
 132 .PHONY: all clean extra package