13 top_builddir := @top_builddir@
18 cflags := @CPPFLAGS@ @CXXFLAGS@ -DYYDEBUG=1
20 library := @LIBS@ @LTLIBAPR@ @LTLIBICONV@
21 time := $(shell which @TIME@)
25 INSTALL_PROGRAM := @INSTALL_PROGRAM@
26 INSTALL_DATA := @INSTALL_DATA@
28 PACKAGE_TARNAME := @PACKAGE_TARNAME@
30 exec_prefix := @exec_prefix@
33 libexecdir := @libexecdir@
34 datarootdir := @datarootdir@
36 sysconfdir := @sysconfdir@
37 sharedstatedir := @sharedstatedir@
38 localstatedir := @localstatedir@
39 includedir := @includedir@
40 oldincludedir := @oldincludedir@
48 localedir := @localedir@
51 CY_EXECUTE := @CY_EXECUTE@
53 paths := $(foreach path,$(paths),$(wildcard $(path)))
54 cflags += $(foreach path,$(paths),-I$(path) -L$(path))
56 svn := $(shell svnversion $(srcdir))
61 dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null)
62 ifneq ($(dpkg_architecture),)
63 arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null)
66 header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp
69 code += Replace.lo Output.lo
70 code += Cycript.tab.lo lex.cy.lo
71 code += Network.lo Parser.lo
72 code += JavaScriptCore.lo Library.lo
84 uname_s ?= $(shell uname -s)
85 uname_p ?= $(shell uname -p)
87 ifeq ($(CY_EXECUTE),1)
88 cflags += -DCY_EXECUTE
89 code += sig/ffi_type.lo sig/parse.lo sig/copy.lo
90 code += Execute.lo Bridge.lo
92 #ifeq ($(filter ObjectiveC,$(filters)),)
93 #ifneq ($(shell which gnustep-config 2>/dev/null),)
99 cflags += -Wall -Werror -Wno-parentheses #-Wno-unused
100 cflags += -fno-common
104 cflags += -I$(srcdir) -I$(srcdir)/include
106 all += $(lib)cycript.la
108 filters += $(shell bison <(echo '%code{}%%_:') -o/dev/null 2>/dev/null && echo Bison24 || echo Bison23)
111 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
117 ifeq ($(depends)$(dll),dylib)
118 control.tmp: control.in cycript $(lib)cycript.dylib
119 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)/' $< >$@
121 ifeq ($(depends)$(dll),so)
122 control.tmp: control.in cycript $(lib)cycript.so
123 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)/' $< >$@
125 control.tmp: control.in
126 sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@
131 [[ -e control ]] && diff control control.tmp &>/dev/null || cp -pRf control.tmp control
133 $(deb): $(all) control
135 mkdir -p package/DEBIAN
136 cp -pR control package/DEBIAN
137 mkdir -p package/usr/{bin,lib,sbin}
139 cp -pR $(lib)cycript.$(dll) package/usr/lib
140 cp -pR cycript package/usr/bin
141 #cp -pR cyrver package/usr/sbin
142 dpkg-deb -b package $(deb)
145 ifeq ($(CY_EXECUTE),1)
146 Bridge.gperf: Bridge.def Bridge.sh
147 $(srcdir)/Bridge.sh $< >$@
149 Bridge.hpp: Bridge.gperf
150 $(gperf) $< | sed -e 's/defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__/0/' >$@
152 Bridge.lo: Bridge.hpp
158 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.gperf Bridge.hpp Cycript.output sig/*.lo sig/.libs
162 rm -f GNUmakefile config.log config.status libtool
165 $(srcdir)/Filter.sh <$< >$@ $(filters)
168 $(srcdir)/Filter.sh <$< >$@ $(filters)
170 Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.yy
171 bison -v --report=state $<
174 $(flex) -t $< | sed -e 's/int yyl;/yy_size_t yyl;/;s/int yyleng_r;/yy_size_t yyleng_r;/' >$@
176 #Parser.hpp: Parser.py Parser.dat
177 # ./Parser.py <Parser.dat >$@
179 Cycript.tab.lo: Cycript.tab.cc $(header)
180 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
182 lex.cy.lo: lex.cy.c $(header)
183 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
185 %.lo: %.cpp $(header)
186 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
189 $(libtool) --mode=compile $(objcxx) $(cflags) -c -o $@ $<
191 $(lib)cycript.la: $(code)
192 $(libtool) --mode=link $(cxx) $(ldflags) -o $@ $(filter %.lo,$^) $(library) $(link) -rpath $(libdir)
195 cycript: Console.lo $(lib)cycript.la $(inject)
196 $(libtool) --mode=link $(cxx) $(ldflags) -o $@ $(filter %.lo,$^) $(lib)cycript.la $(link) -rpath $(libdir)
203 if [[ -e target.cy ]]; then cycript -c target.cy && echo; fi
204 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
205 if [[ -e test.cy ]]; then cycript test.cy; fi
207 install: cycript $(lib)cycript.$(dll)
208 cp -p cycript /usr/bin
209 cp -p $(lib)cycript.$(dll) /usr/lib
211 .PHONY: all clean extra package control.tmp