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