]> git.saurik.com Git - cycript.git/blame_incremental - GNUmakefile.in
Optimize the iOS builds using -O2 (2/3 size).
[cycript.git] / GNUmakefile.in
... / ...
CommitLineData
1# @configure_input@
2
3SHELL := @_BASH@
4VPATH := @srcdir@
5
6ifndef PKG_TARG
7target :=
8else
9target := $(PKG_TARG)-
10endif
11
12srcdir := @srcdir@
13top_builddir := @top_builddir@
14flex := @FLEX@
15libtool := @LIBTOOL@
16cxx := @CXX@
17objcxx := @OBJCXX@
18cflags := @CPPFLAGS@ @CXXFLAGS@ -DYYDEBUG=1 $(filter -DHAVE_FFI% -DHAVE_READLINE% -DHAVE_HISTORY_H,@DEFS@)
19objcxxflags := @OBJCXXFLAGS@
20ldflags := @LDFLAGS@
21ltflags := @LTFLAGS@
22library := @LIBS@ @LTLIBAPR@ @LTLIBICONV@
23sed := @SED@
24bison := @BISON@
25time := @TIME@
26gperf := @GPERF@
27otool := @_OTOOL@
28lipo := @_LIPO@
29nm := @_NM@
30
31INSTALL := @INSTALL@
32INSTALL_PROGRAM := @INSTALL_PROGRAM@
33INSTALL_DATA := @INSTALL_DATA@
34
35PACKAGE_TARNAME := @PACKAGE_TARNAME@
36prefix := @prefix@
37exec_prefix := @exec_prefix@
38bindir := @bindir@
39sbindir := @sbindir@
40libexecdir := @libexecdir@
41datarootdir := @datarootdir@
42datadir := @datadir@
43sysconfdir := @sysconfdir@
44sharedstatedir := @sharedstatedir@
45localstatedir := @localstatedir@
46includedir := @includedir@
47oldincludedir := @oldincludedir@
48docdir := @docdir@
49infodir := @infodir@
50htmldir := @htmldir@
51dvidir := @dvidir@
52pdfdir := @pdfdir@
53psdir := @psdir@
54libdir := @libdir@
55localedir := @localedir@
56mandir := @mandir@
57
58CY_EXECUTE := @CY_EXECUTE@
59CY_OBJECTIVEC := @CY_OBJECTIVEC@
60CY_OBJECTIVEC_MACH := @CY_OBJECTIVEC_MACH@
61CY_ATTACH_GROUP := @CY_ATTACH_GROUP@
62
63git := @GIT@
64
65ifneq ($(git),)
66version := $(shell $(git) describe --always --tags --dirty="+" --match="v*" | $(sed) -e 's@-\([^-]*\)-\([^-]*\)$$@+\1.\2@;s@^v@@')
67else
68version := @PACKAGE_VERSION@
69endif
70
71paths := $(foreach path,$(paths),$(wildcard $(path)))
72cflags += $(foreach path,$(paths),-I$(path) -L$(path))
73
74all:
75all := cycript
76
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)
80#endif
81
82header := Cycript.tab.hh Parser.hpp Pooling.hpp List.hpp Local.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp
83
84code :=
85code += Replace.lo Output.lo
86code += Cycript.tab.lo lex.cy.lo
87code += Network.lo Parser.lo
88code += JavaScriptCore.lo Library.lo
89
90inject :=
91
92filters := #E4X
93ldid := true
94entitle = $(ldid) -Scycript.xml
95lib := lib
96dll := @SO@
97depends ?=
98
99restart ?= $(MAKE)
100uname_s ?= $(shell uname -s)
101uname_p ?= $(shell uname -p)
102
103ifeq ($(CY_EXECUTE),1)
104cflags += -DCY_EXECUTE
105code += sig/ffi_type.lo sig/parse.lo sig/copy.lo
106code += Execute.lo Bridge.lo
107filters += C
108header += JavaScript.hpp
109endif
110
111cflags += -Wall -Werror -Wno-parentheses #-Wno-unused
112cflags += -fno-common
113ifneq ($(srcdir),.)
114cflags += -I.
115endif
116cflags += -I$(srcdir) -I$(srcdir)/include
117
118all += libcycript.la
119
120filters += $(shell $(bison) <(echo '%code{}%%_:') -o/dev/null 2>/dev/null && echo Bison24 || echo Bison23)
121
122ifdef arch
123deb := $(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
124
125all:
126
127ifeq ($(depends)$(dll),dylib)
128control.tmp: control.in .libs/cycript .libs/$(lib)cycript.dylib
129 $(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)/' $< >$@
130else
131ifeq ($(depends)$(dll),so)
132control.tmp: control.in .libs/cycript .libs/$(lib)cycript.so
133 $(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)/' $< >$@
134else
135control.tmp: control.in
136 $(sed) -e 's/&/$(depends)/;s/,$$//;s/#/$(version)/;s/%/$(arch)/' $< >$@
137endif
138endif
139
140control: control.tmp
141 [[ -e control ]] && diff control control.tmp &>/dev/null || cp -pRf control.tmp control
142
143$(deb): $(all) control
144 rm -rf package
145 mkdir -p package/DEBIAN
146 cp -pR control package/DEBIAN
147 #sed -i -e '/^Depends: / s/\<mobilesubstrate\>/mobilesubstrate (>= 0.9.3072)/g' package/DEBIAN/control
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)
153endif
154
155ifeq ($(CY_EXECUTE),1)
156Bridge.gperf: Bridge.def Bridge.sh
157 $(srcdir)/Bridge.sh $< >$@
158
159Bridge.hpp: Bridge.gperf
160 $(gperf) $< | $(sed) -e 's/defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__/0/' >$@
161
162Bridge.lo: Bridge.hpp
163endif
164
165ifeq ($(CY_OBJECTIVEC),1)
166filters += ObjectiveC
167header += Struct.hpp ObjectiveC/Internal.hpp ObjectiveC/Syntax.hpp
168code += ObjectiveC/Output.lo ObjectiveC/Replace.lo ObjectiveC/Library.lo
169
170Struct.hpp:
171 $$($(objcxx) -print-prog-name=cc1obj) -print-objc-runtime-info </dev/null >$@
172
173ifeq ($(CY_OBJECTIVEC_MACH),1)
174code += Handler.lo
175cflags += -DCY_ATTACH -DCY_LIBRARY='"$(libdir)/libcycript.$(dll)"'
176inject += Mach/Inject.lo
177
178Mach/Inject.lo: Trampoline.t.hpp Baton.hpp
179
180%.t.lo: %.t.cpp Baton.hpp Trampoline.hpp
181 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $< -fno-stack-protector -fno-exceptions -O0
182
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
185endif
186endif
187
188all: $(all)
189
190clean::
191 rm -rf *.lo *.o *.d *.t.hpp .libs */*.d */*.lo */.libs lib*.la $(all) Struct.hpp lex.cy.c Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh Cycript.yy Cycript.l control Bridge.gperf Bridge.hpp Cycript.output
192ifneq ($(srcdir),.)
193 rm -rf Mach ObjectiveC sig
194endif
195
196distclean: clean
197 rm -f GNUmakefile Makefile config.log config.status libtool
198
199%.yy: %.yy.in
200 $(srcdir)/Filter.sh <$< >$@ $(filters)
201
202%.l: %.l.in
203 $(srcdir)/Filter.sh <$< >$@ $(filters)
204
205Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.yy
206 $(bison) -v --report=state $<
207
208lex.cy.c: Cycript.l
209 $(flex) -t $< | $(sed) -e 's/int yyl;/yy_size_t yyl;/;s/int yyleng_r;/yy_size_t yyleng_r;/' >$@
210
211#Parser.hpp: Parser.py Parser.dat
212# ./Parser.py <Parser.dat >$@
213
214Cycript.tab.lo: Cycript.tab.cc $(header)
215 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
216
217lex.cy.lo: lex.cy.c $(header)
218 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
219
220%.lo: %.cpp $(header)
221 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
222
223%.lo: %.mm $(header)
224 $(libtool) --mode=compile $(objcxx) $(objcxxflags) $(cflags) -c -o $@ $<
225
226libcycript.la: $(code)
227 $(libtool) --mode=link $(cxx) $(ltflags) $(ldflags) -o $@ $(filter %.lo,$^) $(library) $(link) -rpath $(libdir)
228 $(ldid) .libs/$(lib)cycript.$(dll)
229
230cycript: Console.lo libcycript.la $(inject)
231 $(libtool) --mode=link $(cxx) $(ltflags) $(ldflags) -o $@ $(filter %.lo,$^) libcycript.la $(link) -rpath $(libdir)
232 $(entitle) .libs/cycript
233
234package: $(deb)
235
236test: cycript
237 if [[ -e target.cy ]]; then ./cycript -c target.cy && echo; fi
238 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
239 if [[ -e test.cy ]]; then ./cycript test.cy; fi
240
241install: cycript libcycript.la
242 $(INSTALL) -d $(DESTDIR)$(bindir) $(DESTDIR)$(libdir)
243 $(libtool) --mode=install $(INSTALL_PROGRAM) libcycript.la $(DESTDIR)$(libdir)/libcycript.la
244 $(libtool) --mode=install $(INSTALL_PROGRAM) cycript $(DESTDIR)$(bindir)/cycript
245ifneq ($(CY_ATTACH_GROUP),)
246 chgrp $(CY_ATTACH_GROUP) $(DESTDIR)$(bindir)/cycript
247 chmod g+s $(DESTDIR)$(bindir)/cycript
248endif
249
250uninstall:
251 $(libtool) --mode=uninstall rm -f $(DESTDIR)$(bindir)/cycript
252 $(libtool) --mode=uninstall rm -f $(DESTDIR)$(libdir)/libcycript.la
253
254.PHONY: all clean dist install uninstall package test control.tmp