]>
Commit | Line | Data |
---|---|---|
3530897b DWT |
1 | # @configure_input@ |
2 | ||
9c60689e DWT |
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@ | |
549f29b5 | 18 | cflags := @CPPFLAGS@ @CXXFLAGS@ -DYYDEBUG=1 |
47aaa820 | 19 | objcxxflags := @OBJCXXFLAGS@ |
549f29b5 DWT |
20 | ldflags := @LDFLAGS@ |
21 | library := @LIBS@ @LTLIBAPR@ @LTLIBICONV@ | |
3530897b | 22 | time := $(shell which @TIME@) |
3fd51f51 | 23 | gperf := @GPERF@ |
3530897b DWT |
24 | |
25 | INSTALL := @INSTALL@ | |
26 | INSTALL_PROGRAM := @INSTALL_PROGRAM@ | |
27 | INSTALL_DATA := @INSTALL_DATA@ | |
28 | ||
29 | PACKAGE_TARNAME := @PACKAGE_TARNAME@ | |
30 | prefix := @prefix@ | |
31 | exec_prefix := @exec_prefix@ | |
32 | bindir := @bindir@ | |
33 | sbindir := @sbindir@ | |
34 | libexecdir := @libexecdir@ | |
35 | datarootdir := @datarootdir@ | |
36 | datadir := @datadir@ | |
37 | sysconfdir := @sysconfdir@ | |
38 | sharedstatedir := @sharedstatedir@ | |
39 | localstatedir := @localstatedir@ | |
40 | includedir := @includedir@ | |
41 | oldincludedir := @oldincludedir@ | |
42 | docdir := @docdir@ | |
43 | infodir := @infodir@ | |
44 | htmldir := @htmldir@ | |
45 | dvidir := @dvidir@ | |
46 | pdfdir := @pdfdir@ | |
47 | psdir := @psdir@ | |
48 | libdir := @libdir@ | |
49 | localedir := @localedir@ | |
50 | mandir := @mandir@ | |
9c60689e | 51 | |
3fd51f51 | 52 | CY_EXECUTE := @CY_EXECUTE@ |
47aaa820 | 53 | CY_OBJECTIVEC := @CY_OBJECTIVEC@ |
3fd51f51 | 54 | |
9c60689e | 55 | paths := $(foreach path,$(paths),$(wildcard $(path))) |
549f29b5 | 56 | cflags += $(foreach path,$(paths),-I$(path) -L$(path)) |
9c60689e | 57 | |
3530897b | 58 | svn := $(shell svnversion $(srcdir)) |
9c60689e DWT |
59 | |
60 | all: | |
61 | all := cycript | |
62 | ||
63 | dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null) | |
64 | ifneq ($(dpkg_architecture),) | |
65 | arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null) | |
66 | endif | |
67 | ||
68 | header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp | |
69 | ||
70 | code := | |
549f29b5 DWT |
71 | code += Replace.lo Output.lo |
72 | code += Cycript.tab.lo lex.cy.lo | |
73 | code += Network.lo Parser.lo | |
74 | code += JavaScriptCore.lo Library.lo | |
9c60689e DWT |
75 | |
76 | inject := | |
77 | ||
78 | filters := #E4X | |
79 | ldid := true | |
80 | entitle := $(ldid) | |
81 | lib := lib | |
82 | dll := so | |
9c60689e DWT |
83 | depends := |
84 | ||
85 | restart ?= $(MAKE) | |
86 | uname_s ?= $(shell uname -s) | |
87 | uname_p ?= $(shell uname -p) | |
88 | ||
3fd51f51 DWT |
89 | ifeq ($(CY_EXECUTE),1) |
90 | cflags += -DCY_EXECUTE | |
91 | code += sig/ffi_type.lo sig/parse.lo sig/copy.lo | |
92 | code += Execute.lo Bridge.lo | |
93 | filters += C | |
94 | #ifeq ($(filter ObjectiveC,$(filters)),) | |
95 | #ifneq ($(shell which gnustep-config 2>/dev/null),) | |
96 | #include GNUstep.mk | |
97 | #endif | |
98 | #endif | |
9c60689e DWT |
99 | endif |
100 | ||
549f29b5 DWT |
101 | cflags += -Wall -Werror -Wno-parentheses #-Wno-unused |
102 | cflags += -fno-common | |
9c60689e | 103 | ifneq ($(srcdir),.) |
549f29b5 | 104 | cflags += -I. |
9c60689e | 105 | endif |
549f29b5 | 106 | cflags += -I$(srcdir) -I$(srcdir)/include |
9c60689e | 107 | |
a7f2d052 | 108 | all += libcycript.la |
9c60689e DWT |
109 | |
110 | filters += $(shell bison <(echo '%code{}%%_:') -o/dev/null 2>/dev/null && echo Bison24 || echo Bison23) | |
111 | ||
112 | ifdef arch | |
113 | 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 | |
114 | ||
115 | all: | |
116 | ||
117 | extra:: | |
118 | ||
119 | ifeq ($(depends)$(dll),dylib) | |
120 | control.tmp: control.in cycript $(lib)cycript.dylib | |
121 | 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)/' $< >$@ | |
122 | else | |
123 | ifeq ($(depends)$(dll),so) | |
124 | control.tmp: control.in cycript $(lib)cycript.so | |
125 | 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)/' $< >$@ | |
126 | else | |
127 | control.tmp: control.in | |
128 | sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@ | |
129 | endif | |
130 | endif | |
131 | ||
132 | control: control.tmp | |
133 | [[ -e control ]] && diff control control.tmp &>/dev/null || cp -pRf control.tmp control | |
134 | ||
135 | $(deb): $(all) control | |
136 | rm -rf package | |
137 | mkdir -p package/DEBIAN | |
138 | cp -pR control package/DEBIAN | |
139 | mkdir -p package/usr/{bin,lib,sbin} | |
140 | $(restart) extra | |
141 | cp -pR $(lib)cycript.$(dll) package/usr/lib | |
142 | cp -pR cycript package/usr/bin | |
143 | #cp -pR cyrver package/usr/sbin | |
144 | dpkg-deb -b package $(deb) | |
145 | endif | |
146 | ||
3fd51f51 DWT |
147 | ifeq ($(CY_EXECUTE),1) |
148 | Bridge.gperf: Bridge.def Bridge.sh | |
149 | $(srcdir)/Bridge.sh $< >$@ | |
150 | ||
151 | Bridge.hpp: Bridge.gperf | |
152 | $(gperf) $< | sed -e 's/defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__/0/' >$@ | |
153 | ||
154 | Bridge.lo: Bridge.hpp | |
155 | endif | |
156 | ||
47aaa820 DWT |
157 | ifeq ($(CY_OBJECTIVEC),1) |
158 | filters += ObjectiveC | |
159 | header += Struct.hpp ObjectiveC/Internal.hpp ObjectiveC/Syntax.hpp | |
160 | code += ObjectiveC/Output.lo ObjectiveC/Replace.lo ObjectiveC/Library.lo | |
161 | ||
162 | Struct.hpp: | |
163 | $$($(objcxx) -print-prog-name=cc1obj) -print-objc-runtime-info </dev/null >$@ | |
164 | endif | |
165 | ||
9c60689e DWT |
166 | all: $(all) |
167 | ||
168 | clean:: | |
a7f2d052 | 169 | rm -rf *.lo *.o *.d .libs */*.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 DWT |
170 | ifneq ($(srcdir),.) |
171 | rm -rf sig ObjectiveC | |
172 | endif | |
9c60689e DWT |
173 | |
174 | distclean: clean | |
175 | rm -f GNUmakefile config.log config.status libtool | |
176 | ||
177 | %.yy: %.yy.in | |
178 | $(srcdir)/Filter.sh <$< >$@ $(filters) | |
179 | ||
180 | %.l: %.l.in | |
181 | $(srcdir)/Filter.sh <$< >$@ $(filters) | |
182 | ||
183 | Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.yy | |
184 | bison -v --report=state $< | |
185 | ||
186 | lex.cy.c: Cycript.l | |
187 | $(flex) -t $< | sed -e 's/int yyl;/yy_size_t yyl;/;s/int yyleng_r;/yy_size_t yyleng_r;/' >$@ | |
188 | ||
189 | #Parser.hpp: Parser.py Parser.dat | |
190 | # ./Parser.py <Parser.dat >$@ | |
191 | ||
549f29b5 DWT |
192 | Cycript.tab.lo: Cycript.tab.cc $(header) |
193 | $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $< | |
9c60689e | 194 | |
549f29b5 DWT |
195 | lex.cy.lo: lex.cy.c $(header) |
196 | $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $< | |
9c60689e | 197 | |
549f29b5 DWT |
198 | %.lo: %.cpp $(header) |
199 | $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $< | |
9c60689e | 200 | |
549f29b5 | 201 | %.lo: %.mm $(header) |
47aaa820 | 202 | $(libtool) --mode=compile $(objcxx) $(objcxxflags) $(cflags) -c -o $@ $< |
9c60689e | 203 | |
a7f2d052 | 204 | libcycript.la: $(code) |
3530897b | 205 | $(libtool) --mode=link $(cxx) $(ldflags) -o $@ $(filter %.lo,$^) $(library) $(link) -rpath $(libdir) |
9c60689e DWT |
206 | $(ldid) $@ |
207 | ||
a7f2d052 DWT |
208 | cycript: Console.lo libcycript.la $(inject) |
209 | $(libtool) --mode=link $(cxx) $(ldflags) -o $@ $(filter %.lo,$^) libcycript.la $(link) -rpath $(libdir) | |
9c60689e DWT |
210 | $(entitle) cycript |
211 | ||
212 | package: $(deb) | |
213 | ||
a7f2d052 DWT |
214 | test: cycript |
215 | if [[ -e target.cy ]]; then ./cycript -c target.cy && echo; fi | |
216 | 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 | |
217 | if [[ -e test.cy ]]; then ./cycript test.cy; fi | |
9c60689e | 218 | |
a7f2d052 DWT |
219 | install: cycript libcycript.la |
220 | $(libtool) --mode=install $(INSTALL_PROGRAM) libcycript.la $(DESTDIR)$(libdir)/libcycript.la | |
221 | $(libtool) --mode=install $(INSTALL_PROGRAM) cycript $(DESTDIR)$(bindir)/cycript | |
9c60689e | 222 | |
a7f2d052 DWT |
223 | uninstall: |
224 | $(libtool) --mode=uninstall rm -f $(DESTDIR)$(bindir)/cycript | |
225 | $(libtool) --mode=uninstall rm -f $(DESTDIR)$(libdir)/libcycript.la | |
226 | ||
227 | .PHONY: all clean extra install uninstall package test control.tmp |