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