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