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