]>
Commit | Line | Data |
---|---|---|
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 | library := @LIBS@ @LTLIBAPR@ @LTLIBICONV@ | |
22 | sed := @SED@ | |
23 | bison := @BISON@ | |
24 | time := @TIME@ | |
25 | gperf := @GPERF@ | |
26 | otool := @OTOOL@ | |
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@ | |
54 | ||
55 | CY_EXECUTE := @CY_EXECUTE@ | |
56 | CY_OBJECTIVEC := @CY_OBJECTIVEC@ | |
57 | CY_OBJECTIVEC_MACH := @CY_OBJECTIVEC_MACH@ | |
58 | ||
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 | ||
72 | paths := $(foreach path,$(paths),$(wildcard $(path))) | |
73 | cflags += $(foreach path,$(paths),-I$(path) -L$(path)) | |
74 | ||
75 | #svn := $(shell svnversion $(srcdir)) | |
76 | ||
77 | all: | |
78 | all := 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 | ||
85 | header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp | |
86 | ||
87 | code := | |
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 | |
92 | ||
93 | inject := | |
94 | ||
95 | filters := #E4X | |
96 | ldid := true | |
97 | entitle := $(ldid) | |
98 | lib := lib | |
99 | dll := so | |
100 | depends := | |
101 | ||
102 | restart ?= $(MAKE) | |
103 | uname_s ?= $(shell uname -s) | |
104 | uname_p ?= $(shell uname -p) | |
105 | ||
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 | |
111 | header += JavaScript.hpp | |
112 | endif | |
113 | ||
114 | cflags += -Wall -Werror -Wno-parentheses #-Wno-unused | |
115 | cflags += -fno-common | |
116 | ifneq ($(srcdir),.) | |
117 | cflags += -I. | |
118 | endif | |
119 | cflags += -I$(srcdir) -I$(srcdir)/include | |
120 | ||
121 | all += libcycript.la | |
122 | ||
123 | filters += $(shell $(bison) <(echo '%code{}%%_:') -o/dev/null 2>/dev/null && echo Bison24 || echo Bison23) | |
124 | ||
125 | ifdef arch | |
126 | 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 | |
127 | ||
128 | all: | |
129 | ||
130 | extra:: | |
131 | ||
132 | ifeq ($(depends)$(dll),dylib) | |
133 | control.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)/' $< >$@ | |
135 | else | |
136 | ifeq ($(depends)$(dll),so) | |
137 | control.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)/' $< >$@ | |
139 | else | |
140 | control.tmp: control.in | |
141 | $(sed) -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@ | |
142 | endif | |
143 | endif | |
144 | ||
145 | control: 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) | |
158 | endif | |
159 | ||
160 | ifeq ($(CY_EXECUTE),1) | |
161 | Bridge.gperf: Bridge.def Bridge.sh | |
162 | $(srcdir)/Bridge.sh $< >$@ | |
163 | ||
164 | Bridge.hpp: Bridge.gperf | |
165 | $(gperf) $< | $(sed) -e 's/defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__/0/' >$@ | |
166 | ||
167 | Bridge.lo: Bridge.hpp | |
168 | endif | |
169 | ||
170 | ifeq ($(CY_OBJECTIVEC),1) | |
171 | filters += ObjectiveC | |
172 | header += Struct.hpp ObjectiveC/Internal.hpp ObjectiveC/Syntax.hpp | |
173 | code += ObjectiveC/Output.lo ObjectiveC/Replace.lo ObjectiveC/Library.lo | |
174 | ||
175 | Struct.hpp: | |
176 | $$($(objcxx) -print-prog-name=cc1obj) -print-objc-runtime-info </dev/null >$@ | |
177 | ||
178 | ifeq ($(CY_OBJECTIVEC_MACH),1) | |
179 | code += Handler.lo | |
180 | cflags += -DCY_ATTACH | |
181 | inject += Mach/Inject.lo | |
182 | ||
183 | Mach/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) | |
188 | endif | |
189 | endif | |
190 | ||
191 | all: $(all) | |
192 | ||
193 | clean:: | |
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 | |
195 | ifneq ($(srcdir),.) | |
196 | rm -rf Mach ObjectiveC sig | |
197 | endif | |
198 | ||
199 | distclean: 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 | ||
208 | Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.yy | |
209 | $(bison) -v --report=state $< | |
210 | ||
211 | lex.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 | ||
217 | Cycript.tab.lo: Cycript.tab.cc $(header) | |
218 | $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $< | |
219 | ||
220 | lex.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 | ||
229 | libcycript.la: $(code) | |
230 | $(libtool) --mode=link $(cxx) $(ldflags) -o $@ $(filter %.lo,$^) $(library) $(link) -rpath $(libdir) | |
231 | $(ldid) $@ | |
232 | ||
233 | cycript: Console.lo libcycript.la $(inject) | |
234 | $(libtool) --mode=link $(cxx) $(ldflags) -o $@ $(filter %.lo,$^) libcycript.la $(link) -rpath $(libdir) | |
235 | $(entitle) cycript | |
236 | ||
237 | package: $(deb) | |
238 | ||
239 | test: 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 | ||
244 | ifneq ($(gnutar),:) | |
245 | dist: | |
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)#' . | |
248 | endif | |
249 | ||
250 | install: 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 | ||
255 | uninstall: | |
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 |