13 top_builddir := @top_builddir@
18 cflags := @CPPFLAGS@ @CXXFLAGS@ -DYYDEBUG=1
19 objcxxflags := @OBJCXXFLAGS@
21 library := @LIBS@ @LTLIBAPR@ @LTLIBICONV@
22 time := $(shell which @TIME@)
26 INSTALL_PROGRAM := @INSTALL_PROGRAM@
27 INSTALL_DATA := @INSTALL_DATA@
29 PACKAGE_TARNAME := @PACKAGE_TARNAME@
31 exec_prefix := @exec_prefix@
34 libexecdir := @libexecdir@
35 datarootdir := @datarootdir@
37 sysconfdir := @sysconfdir@
38 sharedstatedir := @sharedstatedir@
39 localstatedir := @localstatedir@
40 includedir := @includedir@
41 oldincludedir := @oldincludedir@
49 localedir := @localedir@
52 CY_EXECUTE := @CY_EXECUTE@
53 CY_OBJECTIVEC := @CY_OBJECTIVEC@
55 paths := $(foreach path,$(paths),$(wildcard $(path)))
56 cflags += $(foreach path,$(paths),-I$(path) -L$(path))
58 svn := $(shell svnversion $(srcdir))
63 dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null)
64 ifneq ($(dpkg_architecture),)
65 arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null)
68 header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp
71 code += Replace.lo Output.lo
72 code += Cycript.tab.lo lex.cy.lo
73 code += Network.lo Parser.lo
74 code += JavaScriptCore.lo Library.lo
86 uname_s ?= $(shell uname -s)
87 uname_p ?= $(shell uname -p)
89 ifeq ($(CY_EXECUTE),1)
90 cflags += -DCY_EXECUTE
91 code += sig/ffi_type.lo sig/parse.lo sig/copy.lo
92 code += Execute.lo Bridge.lo
94 #ifeq ($(filter ObjectiveC,$(filters)),)
95 #ifneq ($(shell which gnustep-config 2>/dev/null),)
101 cflags += -Wall -Werror -Wno-parentheses #-Wno-unused
102 cflags += -fno-common
106 cflags += -I$(srcdir) -I$(srcdir)/include
110 filters += $(shell bison <(echo '%code{}%%_:') -o/dev/null 2>/dev/null && echo Bison24 || echo Bison23)
113 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
119 ifeq ($(depends)$(dll),dylib)
120 control.tmp: control.in cycript $(lib)cycript.dylib
121 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)/' $< >$@
123 ifeq ($(depends)$(dll),so)
124 control.tmp: control.in cycript $(lib)cycript.so
125 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)/' $< >$@
127 control.tmp: control.in
128 sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@
133 [[ -e control ]] && diff control control.tmp &>/dev/null || cp -pRf control.tmp control
135 $(deb): $(all) control
137 mkdir -p package/DEBIAN
138 cp -pR control package/DEBIAN
139 mkdir -p package/usr/{bin,lib,sbin}
141 cp -pR $(lib)cycript.$(dll) package/usr/lib
142 cp -pR cycript package/usr/bin
143 #cp -pR cyrver package/usr/sbin
144 dpkg-deb -b package $(deb)
147 ifeq ($(CY_EXECUTE),1)
148 Bridge.gperf: Bridge.def Bridge.sh
149 $(srcdir)/Bridge.sh $< >$@
151 Bridge.hpp: Bridge.gperf
152 $(gperf) $< | sed -e 's/defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__/0/' >$@
154 Bridge.lo: Bridge.hpp
157 ifeq ($(CY_OBJECTIVEC),1)
158 filters += ObjectiveC
159 header += Struct.hpp ObjectiveC/Internal.hpp ObjectiveC/Syntax.hpp
160 code += ObjectiveC/Output.lo ObjectiveC/Replace.lo ObjectiveC/Library.lo
163 $$($(objcxx) -print-prog-name=cc1obj) -print-objc-runtime-info </dev/null >$@
169 rm -rf *.lo *.o *.d .libs */*.lo */.libs libcycript.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
171 rm -rf sig ObjectiveC
175 rm -f GNUmakefile config.log config.status libtool
178 $(srcdir)/Filter.sh <$< >$@ $(filters)
181 $(srcdir)/Filter.sh <$< >$@ $(filters)
183 Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.yy
184 bison -v --report=state $<
187 $(flex) -t $< | sed -e 's/int yyl;/yy_size_t yyl;/;s/int yyleng_r;/yy_size_t yyleng_r;/' >$@
189 #Parser.hpp: Parser.py Parser.dat
190 # ./Parser.py <Parser.dat >$@
192 Cycript.tab.lo: Cycript.tab.cc $(header)
193 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
195 lex.cy.lo: lex.cy.c $(header)
196 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
198 %.lo: %.cpp $(header)
199 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
202 $(libtool) --mode=compile $(objcxx) $(objcxxflags) $(cflags) -c -o $@ $<
204 libcycript.la: $(code)
205 $(libtool) --mode=link $(cxx) $(ldflags) -o $@ $(filter %.lo,$^) $(library) $(link) -rpath $(libdir)
208 cycript: Console.lo libcycript.la $(inject)
209 $(libtool) --mode=link $(cxx) $(ldflags) -o $@ $(filter %.lo,$^) libcycript.la $(link) -rpath $(libdir)
215 if [[ -e target.cy ]]; then ./cycript -c target.cy && echo; fi
216 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
217 if [[ -e test.cy ]]; then ./cycript test.cy; fi
219 install: cycript libcycript.la
220 $(libtool) --mode=install $(INSTALL_PROGRAM) libcycript.la $(DESTDIR)$(libdir)/libcycript.la
221 $(libtool) --mode=install $(INSTALL_PROGRAM) cycript $(DESTDIR)$(bindir)/cycript
224 $(libtool) --mode=uninstall rm -f $(DESTDIR)$(bindir)/cycript
225 $(libtool) --mode=uninstall rm -f $(DESTDIR)$(libdir)/libcycript.la
227 .PHONY: all clean extra install uninstall package test control.tmp