]> git.saurik.com Git - cycript.git/blame - GNUmakefile.in
Support ?expand when used with Objective-C strings.
[cycript.git] / GNUmakefile.in
CommitLineData
3530897b
DWT
1# @configure_input@
2
e9c9a47c 3SHELL := @_BASH@
9c60689e
DWT
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@
aff87425 18cflags := @CPPFLAGS@ @CXXFLAGS@ -DYYDEBUG=1 $(filter -DHAVE_FFI% -DHAVE_READLINE% -DHAVE_HISTORY_H,@DEFS@)
47aaa820 19objcxxflags := @OBJCXXFLAGS@
549f29b5 20ldflags := @LDFLAGS@
9d13f949 21ltflags := @LTFLAGS@
549f29b5 22library := @LIBS@ @LTLIBAPR@ @LTLIBICONV@
e1cce270
DWT
23sed := @SED@
24bison := @BISON@
e9c9a47c 25time := @TIME@
3fd51f51 26gperf := @GPERF@
794e88e7
DWT
27otool := @_OTOOL@
28lipo := @_LIPO@
29nm := @_NM@
3530897b
DWT
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@
9c60689e 57
3fd51f51 58CY_EXECUTE := @CY_EXECUTE@
47aaa820 59CY_OBJECTIVEC := @CY_OBJECTIVEC@
e1cce270 60CY_OBJECTIVEC_MACH := @CY_OBJECTIVEC_MACH@
794e88e7 61CY_ATTACH_GROUP := @CY_ATTACH_GROUP@
3fd51f51 62
fb726fc5 63git := @GIT@
b65019fe 64
fb726fc5
JF
65ifneq ($(git),)
66version := $(shell $(git) describe --always --tags --dirty="+" --match="v*" | $(sed) -e 's@-\([^-]*\)-\([^-]*\)$$@+\1.\2@;s@^v@@')
67else
68version := @PACKAGE_VERSION@
b65019fe
DWT
69endif
70
9c60689e 71paths := $(foreach path,$(paths),$(wildcard $(path)))
549f29b5 72cflags += $(foreach path,$(paths),-I$(path) -L$(path))
9c60689e 73
9c60689e
DWT
74all:
75all := cycript
76
b65019fe
DWT
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
9c60689e 81
da2af935 82header := Cycript.tab.hh Parser.hpp Pooling.hpp List.hpp Local.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp
9c60689e
DWT
83
84code :=
549f29b5
DWT
85code += Replace.lo Output.lo
86code += Cycript.tab.lo lex.cy.lo
87code += Network.lo Parser.lo
88code += JavaScriptCore.lo Library.lo
9c60689e
DWT
89
90inject :=
91
92filters := #E4X
93ldid := true
8ad1528b 94entitle = $(ldid) -Scycript.xml
9c60689e 95lib := lib
f8ed1165 96dll := @SO@
8ad1528b 97depends ?=
9c60689e
DWT
98
99restart ?= $(MAKE)
100uname_s ?= $(shell uname -s)
101uname_p ?= $(shell uname -p)
102
3fd51f51
DWT
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
25b7683a 108header += JavaScript.hpp
9c60689e
DWT
109endif
110
549f29b5
DWT
111cflags += -Wall -Werror -Wno-parentheses #-Wno-unused
112cflags += -fno-common
9c60689e 113ifneq ($(srcdir),.)
549f29b5 114cflags += -I.
9c60689e 115endif
549f29b5 116cflags += -I$(srcdir) -I$(srcdir)/include
9c60689e 117
a7f2d052 118all += libcycript.la
9c60689e 119
e1cce270 120filters += $(shell $(bison) <(echo '%code{}%%_:') -o/dev/null 2>/dev/null && echo Bison24 || echo Bison23)
9c60689e
DWT
121
122ifdef arch
8ad1528b 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
9c60689e
DWT
124
125all:
126
9c60689e 127ifeq ($(depends)$(dll),dylib)
8ad1528b
JF
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)/' $< >$@
9c60689e
DWT
130else
131ifeq ($(depends)$(dll),so)
8ad1528b
JF
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)/' $< >$@
9c60689e
DWT
134else
135control.tmp: control.in
5930c53d 136 $(sed) -e 's/&/$(depends)/;s/,$$//;s/#/$(version)/;s/%/$(arch)/' $< >$@
9c60689e
DWT
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 mkdir -p package/usr/{bin,lib,sbin}
8ad1528b
JF
148 cp -pR .libs/$(lib)cycript.0.$(dll) package/usr/lib
149 cp -pR .libs/$(lib)cycript.$(dll) package/usr/lib
150 cp -pR .libs/cycript package/usr/bin
9c60689e
DWT
151 dpkg-deb -b package $(deb)
152endif
153
3fd51f51
DWT
154ifeq ($(CY_EXECUTE),1)
155Bridge.gperf: Bridge.def Bridge.sh
156 $(srcdir)/Bridge.sh $< >$@
157
158Bridge.hpp: Bridge.gperf
e1cce270 159 $(gperf) $< | $(sed) -e 's/defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__/0/' >$@
3fd51f51
DWT
160
161Bridge.lo: Bridge.hpp
162endif
163
47aaa820
DWT
164ifeq ($(CY_OBJECTIVEC),1)
165filters += ObjectiveC
166header += Struct.hpp ObjectiveC/Internal.hpp ObjectiveC/Syntax.hpp
167code += ObjectiveC/Output.lo ObjectiveC/Replace.lo ObjectiveC/Library.lo
168
169Struct.hpp:
170 $$($(objcxx) -print-prog-name=cc1obj) -print-objc-runtime-info </dev/null >$@
e1cce270
DWT
171
172ifeq ($(CY_OBJECTIVEC_MACH),1)
b112996a 173code += Handler.lo
f8ed1165 174cflags += -DCY_ATTACH -DCY_LIBRARY='"$(libdir)/libcycript.$(dll)"'
e1cce270
DWT
175inject += Mach/Inject.lo
176
177Mach/Inject.lo: Trampoline.t.hpp Baton.hpp
178
d2a2df03 179%.t.lo: %.t.cpp Baton.hpp Trampoline.hpp
f0b471d9 180 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $< -fno-stack-protector -fno-exceptions -O0
d2a2df03
JF
181
182%.t.hpp: %.t.lo trampoline.sh
8a84ecb4 183 $(srcdir)/trampoline.sh $@ .libs/lib$*.t.$(dll) $* $(sed) $(otool) $(lipo) $(nm) $(libtool) --mode=link $(cxx) $(ldflags) -o lib$*.t.la $< -rpath $(libdir) -Xcompiler -nostdlib
e1cce270 184endif
47aaa820
DWT
185endif
186
9c60689e
DWT
187all: $(all)
188
189clean::
8ad1528b 190 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
94690cff 191ifneq ($(srcdir),.)
790e5246 192 rm -rf Mach ObjectiveC sig
94690cff 193endif
9c60689e
DWT
194
195distclean: clean
790e5246 196 rm -f GNUmakefile Makefile config.log config.status libtool
9c60689e
DWT
197
198%.yy: %.yy.in
199 $(srcdir)/Filter.sh <$< >$@ $(filters)
200
201%.l: %.l.in
202 $(srcdir)/Filter.sh <$< >$@ $(filters)
203
204Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.yy
e1cce270 205 $(bison) -v --report=state $<
9c60689e
DWT
206
207lex.cy.c: Cycript.l
e1cce270 208 $(flex) -t $< | $(sed) -e 's/int yyl;/yy_size_t yyl;/;s/int yyleng_r;/yy_size_t yyleng_r;/' >$@
9c60689e
DWT
209
210#Parser.hpp: Parser.py Parser.dat
211# ./Parser.py <Parser.dat >$@
212
549f29b5
DWT
213Cycript.tab.lo: Cycript.tab.cc $(header)
214 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
9c60689e 215
549f29b5
DWT
216lex.cy.lo: lex.cy.c $(header)
217 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
9c60689e 218
549f29b5
DWT
219%.lo: %.cpp $(header)
220 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
9c60689e 221
549f29b5 222%.lo: %.mm $(header)
47aaa820 223 $(libtool) --mode=compile $(objcxx) $(objcxxflags) $(cflags) -c -o $@ $<
9c60689e 224
a7f2d052 225libcycript.la: $(code)
9d13f949 226 $(libtool) --mode=link $(cxx) $(ltflags) $(ldflags) -o $@ $(filter %.lo,$^) $(library) $(link) -rpath $(libdir)
8ad1528b 227 $(ldid) .libs/$(lib)cycript.$(dll)
9c60689e 228
a7f2d052 229cycript: Console.lo libcycript.la $(inject)
9d13f949 230 $(libtool) --mode=link $(cxx) $(ltflags) $(ldflags) -o $@ $(filter %.lo,$^) libcycript.la $(link) -rpath $(libdir)
8ad1528b 231 $(entitle) .libs/cycript
9c60689e
DWT
232
233package: $(deb)
234
a7f2d052
DWT
235test: cycript
236 if [[ -e target.cy ]]; then ./cycript -c target.cy && echo; fi
237 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
238 if [[ -e test.cy ]]; then ./cycript test.cy; fi
9c60689e 239
a7f2d052 240install: cycript libcycript.la
af896e32 241 $(INSTALL) -d $(DESTDIR)$(bindir) $(DESTDIR)$(libdir)
a7f2d052
DWT
242 $(libtool) --mode=install $(INSTALL_PROGRAM) libcycript.la $(DESTDIR)$(libdir)/libcycript.la
243 $(libtool) --mode=install $(INSTALL_PROGRAM) cycript $(DESTDIR)$(bindir)/cycript
794e88e7
DWT
244ifneq ($(CY_ATTACH_GROUP),)
245 chgrp $(CY_ATTACH_GROUP) $(DESTDIR)$(bindir)/cycript
246 chmod g+s $(DESTDIR)$(bindir)/cycript
247endif
9c60689e 248
a7f2d052
DWT
249uninstall:
250 $(libtool) --mode=uninstall rm -f $(DESTDIR)$(bindir)/cycript
251 $(libtool) --mode=uninstall rm -f $(DESTDIR)$(libdir)/libcycript.la
252
8ad1528b 253.PHONY: all clean dist install uninstall package test control.tmp