13 top_builddir := @top_builddir@
18 cflags := @CPPFLAGS@ @CXXFLAGS@ -DYYDEBUG=1
20 library := @LIBS@ @LTLIBAPR@ @LTLIBICONV@
21 time := $(shell which @TIME@)
24 INSTALL_PROGRAM := @INSTALL_PROGRAM@
25 INSTALL_DATA := @INSTALL_DATA@
27 PACKAGE_TARNAME := @PACKAGE_TARNAME@
29 exec_prefix := @exec_prefix@
32 libexecdir := @libexecdir@
33 datarootdir := @datarootdir@
35 sysconfdir := @sysconfdir@
36 sharedstatedir := @sharedstatedir@
37 localstatedir := @localstatedir@
38 includedir := @includedir@
39 oldincludedir := @oldincludedir@
47 localedir := @localedir@
50 paths := $(foreach path,$(paths),$(wildcard $(path)))
51 cflags += $(foreach path,$(paths),-I$(path) -L$(path))
53 svn := $(shell svnversion $(srcdir))
58 dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null)
59 ifneq ($(dpkg_architecture),)
60 arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null)
63 header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp
66 code += Replace.lo Output.lo
67 code += Cycript.tab.lo lex.cy.lo
68 code += Network.lo Parser.lo
69 code += JavaScriptCore.lo Library.lo
81 uname_s ?= $(shell uname -s)
82 uname_p ?= $(shell uname -p)
84 -include $(uname_s).mk
85 -include $(uname_s)-$(uname_p).mk
88 ifeq ($(filter ObjectiveC,$(filters)),)
89 ifneq ($(shell which gnustep-config 2>/dev/null),)
95 cflags += -Wall -Werror -Wno-parentheses #-Wno-unused
100 cflags += -I$(srcdir) -I$(srcdir)/include
102 all += $(lib)cycript.la
104 filters += $(shell bison <(echo '%code{}%%_:') -o/dev/null 2>/dev/null && echo Bison24 || echo Bison23)
107 deb := $(shell grep ^Package: $(srcdir)/control.in | cut -d ' ' -f 2-)_$(shell grep ^Version: $(srcdir)/control.in | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb
113 ifeq ($(depends)$(dll),dylib)
114 control.tmp: control.in cycript $(lib)cycript.dylib
115 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)/' $< >$@
117 ifeq ($(depends)$(dll),so)
118 control.tmp: control.in cycript $(lib)cycript.so
119 sed -e 's/&/'"$$(dpkg-query -S $$(ldd cycript $(lib)cycript.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)/' $< >$@
121 control.tmp: control.in
122 sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@
127 [[ -e control ]] && diff control control.tmp &>/dev/null || cp -pRf control.tmp control
129 $(deb): $(all) control
131 mkdir -p package/DEBIAN
132 cp -pR control package/DEBIAN
133 mkdir -p package/usr/{bin,lib,sbin}
135 cp -pR $(lib)cycript.$(dll) package/usr/lib
136 cp -pR cycript package/usr/bin
137 #cp -pR cyrver package/usr/sbin
138 dpkg-deb -b package $(deb)
144 rm -rf *.lo *.o .libs $(lib)cycript.$(dll) $(lib)cycript.la $(all) Struct.hpp lex.cy.c Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh cyrver Cycript.yy Cycript.l control Bridge.hpp Cycript.output
147 rm -f GNUmakefile config.log config.status libtool
150 $(srcdir)/Filter.sh <$< >$@ $(filters)
153 $(srcdir)/Filter.sh <$< >$@ $(filters)
155 Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.yy
156 bison -v --report=state $<
159 $(flex) -t $< | sed -e 's/int yyl;/yy_size_t yyl;/;s/int yyleng_r;/yy_size_t yyleng_r;/' >$@
161 #Parser.hpp: Parser.py Parser.dat
162 # ./Parser.py <Parser.dat >$@
164 Cycript.tab.lo: Cycript.tab.cc $(header)
165 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
167 lex.cy.lo: lex.cy.c $(header)
168 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
170 %.lo: %.cpp $(header)
171 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
174 $(libtool) --mode=compile $(objcxx) $(cflags) -c -o $@ $<
176 $(lib)cycript.la: $(code)
177 $(libtool) --mode=link $(cxx) $(ldflags) -o $@ $(filter %.lo,$^) $(library) $(link) -rpath $(libdir)
180 cycript: Console.lo $(lib)cycript.la $(inject)
181 $(libtool) --mode=link $(cxx) $(ldflags) -o $@ $(filter %.lo,$^) $(lib)cycript.la $(link) -rpath $(libdir)
188 if [[ -e target.cy ]]; then cycript -c target.cy && echo; fi
189 if [[ -e jquery.js ]]; then $(time) cycript -c jquery.js >jquery.cyc.js; gzip -9c jquery.cyc.js >jquery.cyc.js.gz; wc -c jquery.{mam,gcc,cyc,bak,yui}.js; wc -c jquery.{cyc,gcc,bak,mam,yui}.js.gz; fi
190 if [[ -e test.cy ]]; then cycript test.cy; fi
192 install: cycript $(lib)cycript.$(dll)
193 cp -p cycript /usr/bin
194 cp -p $(lib)cycript.$(dll) /usr/lib
196 .PHONY: all clean extra package control.tmp