1 SHELL := $(shell which bash 2>/dev/null)
 
   9 flags ?= -g3 -O0 -DYYDEBUG=1
 
  11 paths := $(foreach path,$(paths),$(wildcard $(path)))
 
  12 flags += $(foreach path,$(paths),-I$(path) -L$(path))
 
  15 svn := $(shell svnversion)
 
  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 Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp Context.hpp
 
  28 code += Replace.o Output.o
 
  29 code += Cycript.tab.o lex.cy.o
 
  30 code += Network.o Parser.o
 
  31 code += JavaScriptCore.o Library.o
 
  41 console := $(apr) -lreadline
 
  45 uname_s ?= $(shell uname -s)
 
  46 uname_p ?= $(shell uname -p)
 
  48 -include $(uname_s).mk
 
  49 -include $(uname_s)-$(uname_p).mk
 
  52 ifeq ($(filter ObjectiveC,$(filters)),)
 
  53 ifneq ($(shell which gnustep-config 2>/dev/null),)
 
  59 flags += -Wall -Werror -Wno-parentheses #-Wno-unused
 
  60 flags += -fPIC -fno-common
 
  61 flags += -I. -Iinclude -I$(shell apr-1-config --includedir)
 
  63 all += libcycript.$(dll)
 
  66 deb := $(shell grep ^Package: control.in | cut -d ' ' -f 2-)_$(shell grep ^Version: control.in | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb
 
  72 ifeq ($(depends)$(dll),dylib)
 
  73 control: control.in cycript libcycript.dylib
 
  74         sed -e 's/&/'"$$(dpkg-query -S $$(otool -lah cycript *.dylib | grep dylib | grep -v ':$$' | sed -e 's/^ *name //;s/ (offset [0-9]*)$$//' | sort -u) 2>/dev/null | sed -e 's/:.*//; /^cycript$$/ d; s/$$/,/' | sort -u | tr '\n' ' ')"'/;s/, $$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@
 
  76 ifeq ($(depends)$(dll),so)
 
  77 control: control.in cycript libcycript.so
 
  78         sed -e 's/&/'"$$(dpkg-query -S $$(ldd cycript libcycript.so | sed -e '/:$$/ d; s/^[ \t]*\([^ ]* => \)\?\([^ ]*\) .*/\2/' | sort -u) 2>/dev/null | sed -e 's/:.*//; /^cycript$$/ d; s/$$/,/' | sort -u | tr '\n' ' ')"'/;s/, $$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@
 
  81         sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@
 
  85 $(deb): $(all) control
 
  87         mkdir -p package/DEBIAN
 
  88         cp -pR control package/DEBIAN
 
  89         mkdir -p package/usr/{bin,lib,sbin}
 
  91         cp -pR libcycript.$(dll) package/usr/lib
 
  92         cp -pR cycript package/usr/bin
 
  93         #cp -pR cyrver package/usr/sbin
 
  94         dpkg-deb -b package $(deb)
 
 100         rm -f *.o libcycript.$(dll) $(all) Struct.hpp lex.cy.c Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh cyrver Cycript.y Cycript.l control
 
 103         ./Filter.sh <$< >$@ $(filters)
 
 106         ./Filter.sh <$< >$@ $(filters)
 
 108 Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y
 
 109         bison -v --report=state $<
 
 114 #Parser.hpp: Parser.py Parser.dat
 
 115 #       ./Parser.py <Parser.dat >$@
 
 117 Cycript.tab.o: Cycript.tab.cc $(header)
 
 118         $(target)g++ $(flags) -c -o $@ $<
 
 120 lex.cy.o: lex.cy.c $(header)
 
 121         $(target)g++ $(flags) -c -o $@ $<
 
 124         $(target)g++ $(flags) -c -o $@ $<
 
 128         $(target)g++ $(objc) $(flags) -c -o $@ $<
 
 130 libcycript.$(dll): $(code)
 
 131         $(target)g++ $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) $(link)
 
 134 cycript: Console.o libcycript.$(dll) $(inject)
 
 135         $(target)g++ $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(console) $(link)
 
 142         if [[ -e target.cy ]]; then cycript -c target.cy && echo; fi
 
 143         if [[ -e jquery.js ]]; then /usr/bin/time cycript -c jquery.js >jquery.cyc.js; gzip -9c jquery.cyc.js >jquery.cyc.js.gz; ls -la jquery.{cyc,mam,yui}.js{,.gz}; fi
 
 144         if [[ -e test.cy ]]; then cycript test.cy; fi
 
 146 .PHONY: all clean extra package control