13 top_builddir := @top_builddir@
18 cflags := @CPPFLAGS@ @CXXFLAGS@ -DYYDEBUG=1 $(filter -DHAVE_FFI% -DHAVE_READLINE% -DHAVE_HISTORY_H,@DEFS@)
19 objcxxflags := @OBJCXXFLAGS@
22 library := @LIBS@ @LTLIBAPR@ @LTLIBICONV@
32 INSTALL_PROGRAM := @INSTALL_PROGRAM@
33 INSTALL_DATA := @INSTALL_DATA@
35 PACKAGE_TARNAME := @PACKAGE_TARNAME@
37 exec_prefix := @exec_prefix@
40 libexecdir := @libexecdir@
41 datarootdir := @datarootdir@
43 sysconfdir := @sysconfdir@
44 sharedstatedir := @sharedstatedir@
45 localstatedir := @localstatedir@
46 includedir := @includedir@
47 oldincludedir := @oldincludedir@
55 localedir := @localedir@
58 CY_EXECUTE := @CY_EXECUTE@
59 CY_OBJECTIVEC := @CY_OBJECTIVEC@
60 CY_OBJECTIVEC_MACH := @CY_OBJECTIVEC_MACH@
61 CY_ATTACH_GROUP := @CY_ATTACH_GROUP@
66 version := $(shell $(git) describe --always --tags --dirty="+" --match="v*" | $(sed) -e 's@-\([^-]*\)-\([^-]*\)$$@+\1.\2@;s@^v@@')
68 version := @PACKAGE_VERSION@
71 paths := $(foreach path,$(paths),$(wildcard $(path)))
72 cflags += $(foreach path,$(paths),-I$(path) -L$(path))
77 #dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null)
78 #ifneq ($(dpkg_architecture),)
79 #arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null)
82 header := Cycript.tab.hh Parser.hpp Pooling.hpp List.hpp Local.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp
85 code += Replace.lo Output.lo
86 code += Highlight.lo Display.lo
87 code += Cycript.tab.lo lex.cy.lo
88 code += Network.lo Parser.lo
89 code += JavaScriptCore.lo Library.lo
95 entitle = $(ldid) -Scycript.xml
101 uname_s ?= $(shell uname -s)
102 uname_p ?= $(shell uname -p)
104 ifeq ($(CY_EXECUTE),1)
105 cflags += -DCY_EXECUTE
106 code += sig/ffi_type.lo sig/parse.lo sig/copy.lo
107 code += Execute.lo Bridge.lo
109 header += JavaScript.hpp
112 cflags := -Wall -Werror -Wno-parentheses $(cflags)
113 cflags += -fno-common
117 cflags += -I$(srcdir) -I$(srcdir)/include
121 filters += $(shell $(bison) <(echo '%code{}%%_:') -o/dev/null 2>/dev/null && echo Bison24 || echo Bison23)
124 deb := $(shell grep ^Package: $(srcdir)/control.in | cut -d ' ' -f 2-)_$(shell grep ^Version: $(srcdir)/control.in | cut -d ' ' -f 2 | $(sed) -e 's/\#/$(version)/')_$(arch).deb
128 ifeq ($(depends)$(dll),dylib)
129 control.tmp: control.in .libs/cycript .libs/$(lib)cycript.dylib
130 $(sed) -e 's/&/'"$$(dpkg-query -S $$(otool -lah .libs/cycript .libs/*.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/#/$(version)/;s/%/$(arch)/' $< >$@
132 ifeq ($(depends)$(dll),so)
133 control.tmp: control.in .libs/cycript .libs/$(lib)cycript.so
134 $(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/#/$(version)/;s/%/$(arch)/' $< >$@
136 control.tmp: control.in
137 $(sed) -e 's/&/$(depends)/;s/,$$//;s/#/$(version)/;s/%/$(arch)/' $< >$@
142 [[ -e control ]] && diff control control.tmp &>/dev/null || cp -pRf control.tmp control
144 $(deb): $(all) control
146 mkdir -p package/DEBIAN
147 cp -pR control package/DEBIAN
148 mkdir -p package/usr/{bin,lib,sbin}
149 cp -pR .libs/$(lib)cycript.0.$(dll) package/usr/lib
150 cp -pR .libs/$(lib)cycript.$(dll) package/usr/lib
151 cp -pR .libs/cycript package/usr/bin
152 dpkg-deb -b package $(deb)
155 ifeq ($(CY_EXECUTE),1)
156 Bridge.gperf: Bridge.def Bridge.sh
157 $(srcdir)/Bridge.sh $< >$@
159 Bridge.hpp: Bridge.gperf
160 $(gperf) $< | $(sed) -e 's/defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__/0/' >$@
162 Bridge.lo: Bridge.hpp
165 ifeq ($(CY_OBJECTIVEC),1)
166 filters += ObjectiveC
167 header += Struct.hpp ObjectiveC/Internal.hpp ObjectiveC/Syntax.hpp
168 code += ObjectiveC/Output.lo ObjectiveC/Replace.lo ObjectiveC/Library.lo
171 $$($(objcxx) -print-prog-name=cc1obj) -print-objc-runtime-info </dev/null >$@
173 ifeq ($(CY_OBJECTIVEC_MACH),1)
175 cflags += -DCY_ATTACH -DCY_LIBRARY='"$(libdir)/libcycript.$(dll)"'
176 inject += Mach/Inject.lo
178 Mach/Inject.lo: Trampoline.t.hpp Baton.hpp
180 %.t.lo: %.t.cpp Baton.hpp Trampoline.hpp
181 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $< -fno-stack-protector -fno-exceptions -O0
183 %.t.hpp: %.t.lo trampoline.sh
184 $(srcdir)/trampoline.sh $@ .libs/lib$*.t.$(dll) $* $(sed) $(otool) $(lipo) $(nm) $(libtool) --mode=link $(cxx) $(ldflags) -o lib$*.t.la $< -rpath $(libdir) -Xcompiler -nostdlib
191 rm -rf *.lo *.o *.d *.t.hpp .libs */*.d */*.lo */.libs lib*.la $(all) Struct.hpp lex.cy.cpp Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh Cycript.yy Cycript.l control Bridge.gperf Bridge.hpp Cycript.output
193 rm -rf Mach ObjectiveC sig
197 rm -f GNUmakefile Makefile config.log config.status libtool
200 $(srcdir)/Filter.sh <$< >$@ $(filters)
203 $(srcdir)/Filter.sh <$< >$@ $(filters)
205 Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.yy
206 $(bison) -v --report=state $<
207 ! grep -n '^ *$$default reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Cycript.output -B 2 | grep 'shift, and go to state [0-9]*$$'
208 ! grep -n '^ *$$default reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Cycript.output -B 2 | grep -v '$$default' | grep 'reduce using rule [0-9]* ([^)]*)$$'
210 lex.cy.cpp: Cycript.l
211 $(flex) -t $< | $(sed) -e 's/int yyl;/yy_size_t yyl;/;s/int yyleng_r;/yy_size_t yyleng_r;/' >$@
213 Cycript.tab.lo: Cycript.tab.cc $(header)
214 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
216 %.lo: %.cpp $(header)
217 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
220 $(libtool) --mode=compile $(objcxx) $(objcxxflags) $(cflags) -c -o $@ $<
222 libcycript.la: $(code)
223 $(libtool) --mode=link $(cxx) $(ltflags) $(ldflags) -o $@ $(filter %.lo,$^) $(library) $(link) -rpath $(libdir)
224 $(ldid) .libs/$(lib)cycript.$(dll)
226 cycript: Console.lo libcycript.la $(inject)
227 $(libtool) --mode=link $(cxx) $(ltflags) $(ldflags) -o $@ $(filter %.lo,$^) libcycript.la $(link) -rpath $(libdir)
228 $(entitle) .libs/cycript
233 if [[ -e target.cy ]]; then ./cycript -c target.cy && echo; fi
234 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
235 if [[ -e test.cy ]]; then ./cycript test.cy; fi
237 install: cycript libcycript.la
238 $(INSTALL) -d $(DESTDIR)$(bindir) $(DESTDIR)$(libdir)
239 $(libtool) --mode=install $(INSTALL_PROGRAM) libcycript.la $(DESTDIR)$(libdir)/libcycript.la
240 $(libtool) --mode=install $(INSTALL_PROGRAM) cycript $(DESTDIR)$(bindir)/cycript
241 ifneq ($(CY_ATTACH_GROUP),)
242 chgrp $(CY_ATTACH_GROUP) $(DESTDIR)$(bindir)/cycript
243 chmod g+s $(DESTDIR)$(bindir)/cycript
247 $(libtool) --mode=uninstall rm -f $(DESTDIR)$(bindir)/cycript
248 $(libtool) --mode=uninstall rm -f $(DESTDIR)$(libdir)/libcycript.la
250 .PHONY: all clean dist install uninstall package test control.tmp