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