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