]>
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 | 20 | ldflags := @LDFLAGS@ |
9d13f949 | 21 | ltflags := @LTFLAGS@ |
549f29b5 | 22 | library := @LIBS@ @LTLIBAPR@ @LTLIBICONV@ |
e1cce270 DWT |
23 | sed := @SED@ |
24 | bison := @BISON@ | |
e9c9a47c | 25 | time := @TIME@ |
3fd51f51 | 26 | gperf := @GPERF@ |
794e88e7 DWT |
27 | otool := @_OTOOL@ |
28 | lipo := @_LIPO@ | |
29 | nm := @_NM@ | |
3530897b DWT |
30 | |
31 | INSTALL := @INSTALL@ | |
32 | INSTALL_PROGRAM := @INSTALL_PROGRAM@ | |
33 | INSTALL_DATA := @INSTALL_DATA@ | |
34 | ||
35 | PACKAGE_TARNAME := @PACKAGE_TARNAME@ | |
36 | prefix := @prefix@ | |
37 | exec_prefix := @exec_prefix@ | |
38 | bindir := @bindir@ | |
39 | sbindir := @sbindir@ | |
40 | libexecdir := @libexecdir@ | |
41 | datarootdir := @datarootdir@ | |
42 | datadir := @datadir@ | |
43 | sysconfdir := @sysconfdir@ | |
44 | sharedstatedir := @sharedstatedir@ | |
45 | localstatedir := @localstatedir@ | |
46 | includedir := @includedir@ | |
47 | oldincludedir := @oldincludedir@ | |
48 | docdir := @docdir@ | |
49 | infodir := @infodir@ | |
50 | htmldir := @htmldir@ | |
51 | dvidir := @dvidir@ | |
52 | pdfdir := @pdfdir@ | |
53 | psdir := @psdir@ | |
54 | libdir := @libdir@ | |
55 | localedir := @localedir@ | |
56 | mandir := @mandir@ | |
9c60689e | 57 | |
3fd51f51 | 58 | CY_EXECUTE := @CY_EXECUTE@ |
47aaa820 | 59 | CY_OBJECTIVEC := @CY_OBJECTIVEC@ |
e1cce270 | 60 | CY_OBJECTIVEC_MACH := @CY_OBJECTIVEC_MACH@ |
794e88e7 | 61 | CY_ATTACH_GROUP := @CY_ATTACH_GROUP@ |
3fd51f51 | 62 | |
fb726fc5 | 63 | git := @GIT@ |
b65019fe | 64 | |
fb726fc5 JF |
65 | ifneq ($(git),) |
66 | version := $(shell $(git) describe --always --tags --dirty="+" --match="v*" | $(sed) -e 's@-\([^-]*\)-\([^-]*\)$$@+\1.\2@;s@^v@@') | |
67 | else | |
68 | version := @PACKAGE_VERSION@ | |
b65019fe DWT |
69 | endif |
70 | ||
9c60689e | 71 | paths := $(foreach path,$(paths),$(wildcard $(path))) |
549f29b5 | 72 | cflags += $(foreach path,$(paths),-I$(path) -L$(path)) |
9c60689e | 73 | |
9c60689e DWT |
74 | all: |
75 | all := cycript | |
76 | ||
b65019fe DWT |
77 | #dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null) |
78 | #ifneq ($(dpkg_architecture),) | |
79 | #arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null) | |
80 | #endif | |
9c60689e | 81 | |
da2af935 | 82 | header := Cycript.tab.hh Parser.hpp Pooling.hpp List.hpp Local.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp |
9c60689e DWT |
83 | |
84 | code := | |
74296173 JF |
85 | code += Replace.lo Output.lo |
86 | code += Highlight.lo Display.lo | |
549f29b5 DWT |
87 | code += Cycript.tab.lo lex.cy.lo |
88 | code += Network.lo Parser.lo | |
89 | code += JavaScriptCore.lo Library.lo | |
9c60689e DWT |
90 | |
91 | inject := | |
92 | ||
93 | filters := #E4X | |
94 | ldid := true | |
8ad1528b | 95 | entitle = $(ldid) -Scycript.xml |
9c60689e | 96 | lib := lib |
f8ed1165 | 97 | dll := @SO@ |
8ad1528b | 98 | depends ?= |
9c60689e DWT |
99 | |
100 | restart ?= $(MAKE) | |
101 | uname_s ?= $(shell uname -s) | |
102 | uname_p ?= $(shell uname -p) | |
103 | ||
3fd51f51 DWT |
104 | ifeq ($(CY_EXECUTE),1) |
105 | cflags += -DCY_EXECUTE | |
106 | code += sig/ffi_type.lo sig/parse.lo sig/copy.lo | |
107 | code += Execute.lo Bridge.lo | |
108 | filters += C | |
25b7683a | 109 | header += JavaScript.hpp |
9c60689e DWT |
110 | endif |
111 | ||
84152e4b | 112 | cflags := -Wall -Werror -Wno-parentheses $(cflags) |
549f29b5 | 113 | cflags += -fno-common |
9c60689e | 114 | ifneq ($(srcdir),.) |
549f29b5 | 115 | cflags += -I. |
9c60689e | 116 | endif |
549f29b5 | 117 | cflags += -I$(srcdir) -I$(srcdir)/include |
9c60689e | 118 | |
a7f2d052 | 119 | all += libcycript.la |
9c60689e | 120 | |
e1cce270 | 121 | filters += $(shell $(bison) <(echo '%code{}%%_:') -o/dev/null 2>/dev/null && echo Bison24 || echo Bison23) |
9c60689e DWT |
122 | |
123 | ifdef arch | |
8ad1528b | 124 | deb := $(shell grep ^Package: $(srcdir)/control.in | cut -d ' ' -f 2-)_$(shell grep ^Version: $(srcdir)/control.in | cut -d ' ' -f 2 | $(sed) -e 's/\#/$(version)/')_$(arch).deb |
9c60689e DWT |
125 | |
126 | all: | |
127 | ||
9c60689e | 128 | ifeq ($(depends)$(dll),dylib) |
8ad1528b JF |
129 | control.tmp: control.in .libs/cycript .libs/$(lib)cycript.dylib |
130 | $(sed) -e 's/&/'"$$(dpkg-query -S $$(otool -lah .libs/cycript .libs/*.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/#/$(version)/;s/%/$(arch)/' $< >$@ | |
9c60689e DWT |
131 | else |
132 | ifeq ($(depends)$(dll),so) | |
8ad1528b JF |
133 | control.tmp: control.in .libs/cycript .libs/$(lib)cycript.so |
134 | $(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/#/$(version)/;s/%/$(arch)/' $< >$@ | |
9c60689e DWT |
135 | else |
136 | control.tmp: control.in | |
5930c53d | 137 | $(sed) -e 's/&/$(depends)/;s/,$$//;s/#/$(version)/;s/%/$(arch)/' $< >$@ |
9c60689e DWT |
138 | endif |
139 | endif | |
140 | ||
141 | control: control.tmp | |
142 | [[ -e control ]] && diff control control.tmp &>/dev/null || cp -pRf control.tmp control | |
143 | ||
144 | $(deb): $(all) control | |
145 | rm -rf package | |
146 | mkdir -p package/DEBIAN | |
147 | cp -pR control package/DEBIAN | |
148 | mkdir -p package/usr/{bin,lib,sbin} | |
8ad1528b JF |
149 | cp -pR .libs/$(lib)cycript.0.$(dll) package/usr/lib |
150 | cp -pR .libs/$(lib)cycript.$(dll) package/usr/lib | |
151 | cp -pR .libs/cycript package/usr/bin | |
9c60689e DWT |
152 | dpkg-deb -b package $(deb) |
153 | endif | |
154 | ||
3fd51f51 DWT |
155 | ifeq ($(CY_EXECUTE),1) |
156 | Bridge.gperf: Bridge.def Bridge.sh | |
157 | $(srcdir)/Bridge.sh $< >$@ | |
158 | ||
159 | Bridge.hpp: Bridge.gperf | |
e1cce270 | 160 | $(gperf) $< | $(sed) -e 's/defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__/0/' >$@ |
3fd51f51 DWT |
161 | |
162 | Bridge.lo: Bridge.hpp | |
163 | endif | |
164 | ||
47aaa820 DWT |
165 | ifeq ($(CY_OBJECTIVEC),1) |
166 | filters += ObjectiveC | |
167 | header += Struct.hpp ObjectiveC/Internal.hpp ObjectiveC/Syntax.hpp | |
168 | code += ObjectiveC/Output.lo ObjectiveC/Replace.lo ObjectiveC/Library.lo | |
169 | ||
170 | Struct.hpp: | |
171 | $$($(objcxx) -print-prog-name=cc1obj) -print-objc-runtime-info </dev/null >$@ | |
e1cce270 DWT |
172 | |
173 | ifeq ($(CY_OBJECTIVEC_MACH),1) | |
b112996a | 174 | code += Handler.lo |
f8ed1165 | 175 | cflags += -DCY_ATTACH -DCY_LIBRARY='"$(libdir)/libcycript.$(dll)"' |
e1cce270 DWT |
176 | inject += Mach/Inject.lo |
177 | ||
178 | Mach/Inject.lo: Trampoline.t.hpp Baton.hpp | |
179 | ||
d2a2df03 | 180 | %.t.lo: %.t.cpp Baton.hpp Trampoline.hpp |
f0b471d9 | 181 | $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $< -fno-stack-protector -fno-exceptions -O0 |
d2a2df03 JF |
182 | |
183 | %.t.hpp: %.t.lo trampoline.sh | |
8a84ecb4 | 184 | $(srcdir)/trampoline.sh $@ .libs/lib$*.t.$(dll) $* $(sed) $(otool) $(lipo) $(nm) $(libtool) --mode=link $(cxx) $(ldflags) -o lib$*.t.la $< -rpath $(libdir) -Xcompiler -nostdlib |
e1cce270 | 185 | endif |
47aaa820 DWT |
186 | endif |
187 | ||
9c60689e DWT |
188 | all: $(all) |
189 | ||
190 | clean:: | |
3a8ac548 | 191 | rm -rf *.lo *.o *.d *.t.hpp .libs */*.d */*.lo */.libs lib*.la $(all) Struct.hpp lex.cy.cpp Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh Cycript.yy Cycript.l control Bridge.gperf Bridge.hpp Cycript.output |
94690cff | 192 | ifneq ($(srcdir),.) |
790e5246 | 193 | rm -rf Mach ObjectiveC sig |
94690cff | 194 | endif |
9c60689e DWT |
195 | |
196 | distclean: clean | |
790e5246 | 197 | rm -f GNUmakefile Makefile config.log config.status libtool |
9c60689e DWT |
198 | |
199 | %.yy: %.yy.in | |
200 | $(srcdir)/Filter.sh <$< >$@ $(filters) | |
201 | ||
202 | %.l: %.l.in | |
203 | $(srcdir)/Filter.sh <$< >$@ $(filters) | |
204 | ||
205 | Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.yy | |
e1cce270 | 206 | $(bison) -v --report=state $< |
cab9dcf2 | 207 | ! grep -n '^ *$$default reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Cycript.output -B 2 | grep 'shift, and go to state [0-9]*$$' |
19ece266 | 208 | ! grep -n '^ *$$default reduce using rule [0-9]* (Lex[A-Z][^)]*)$$' Cycript.output -B 2 | grep -v '$$default' | grep 'reduce using rule [0-9]* ([^)]*)$$' |
9c60689e | 209 | |
3a8ac548 | 210 | lex.cy.cpp: 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 | |
3a8ac548 | 219 | lex.cy.lo: lex.cy.cpp $(header) |
549f29b5 | 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) |
9d13f949 | 229 | $(libtool) --mode=link $(cxx) $(ltflags) $(ldflags) -o $@ $(filter %.lo,$^) $(library) $(link) -rpath $(libdir) |
8ad1528b | 230 | $(ldid) .libs/$(lib)cycript.$(dll) |
9c60689e | 231 | |
a7f2d052 | 232 | cycript: Console.lo libcycript.la $(inject) |
9d13f949 | 233 | $(libtool) --mode=link $(cxx) $(ltflags) $(ldflags) -o $@ $(filter %.lo,$^) libcycript.la $(link) -rpath $(libdir) |
8ad1528b | 234 | $(entitle) .libs/cycript |
9c60689e DWT |
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 | |
a7f2d052 | 243 | install: cycript libcycript.la |
af896e32 | 244 | $(INSTALL) -d $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) |
a7f2d052 DWT |
245 | $(libtool) --mode=install $(INSTALL_PROGRAM) libcycript.la $(DESTDIR)$(libdir)/libcycript.la |
246 | $(libtool) --mode=install $(INSTALL_PROGRAM) cycript $(DESTDIR)$(bindir)/cycript | |
794e88e7 DWT |
247 | ifneq ($(CY_ATTACH_GROUP),) |
248 | chgrp $(CY_ATTACH_GROUP) $(DESTDIR)$(bindir)/cycript | |
249 | chmod g+s $(DESTDIR)$(bindir)/cycript | |
250 | endif | |
9c60689e | 251 | |
a7f2d052 DWT |
252 | uninstall: |
253 | $(libtool) --mode=uninstall rm -f $(DESTDIR)$(bindir)/cycript | |
254 | $(libtool) --mode=uninstall rm -f $(DESTDIR)$(libdir)/libcycript.la | |
255 | ||
8ad1528b | 256 | .PHONY: all clean dist install uninstall package test control.tmp |