]> git.saurik.com Git - cycript.git/blob - GNUmakefile.in
caacbbdc840d79c428093f589ddbe0094fbb4f61
[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 objcxxflags := @OBJCXXFLAGS@
20 ldflags := @LDFLAGS@
21 library := @LIBS@ @LTLIBAPR@ @LTLIBICONV@
22 time := $(shell which @TIME@)
23 gperf := @GPERF@
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@
51
52 CY_EXECUTE := @CY_EXECUTE@
53 CY_OBJECTIVEC := @CY_OBJECTIVEC@
54
55 paths := $(foreach path,$(paths),$(wildcard $(path)))
56 cflags += $(foreach path,$(paths),-I$(path) -L$(path))
57
58 svn := $(shell svnversion $(srcdir))
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 :=
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
75
76 inject :=
77
78 filters := #E4X
79 ldid := true
80 entitle := $(ldid)
81 lib := lib
82 dll := so
83 depends :=
84
85 restart ?= $(MAKE)
86 uname_s ?= $(shell uname -s)
87 uname_p ?= $(shell uname -p)
88
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
99 endif
100
101 cflags += -Wall -Werror -Wno-parentheses #-Wno-unused
102 cflags += -fno-common
103 ifneq ($(srcdir),.)
104 cflags += -I.
105 endif
106 cflags += -I$(srcdir) -I$(srcdir)/include
107
108 all += libcycript.la
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
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
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
166 all: $(all)
167
168 clean::
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
170 ifneq ($(srcdir),.)
171 rm -rf sig ObjectiveC
172 endif
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
192 Cycript.tab.lo: Cycript.tab.cc $(header)
193 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
194
195 lex.cy.lo: lex.cy.c $(header)
196 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
197
198 %.lo: %.cpp $(header)
199 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
200
201 %.lo: %.mm $(header)
202 $(libtool) --mode=compile $(objcxx) $(objcxxflags) $(cflags) -c -o $@ $<
203
204 libcycript.la: $(code)
205 $(libtool) --mode=link $(cxx) $(ldflags) -o $@ $(filter %.lo,$^) $(library) $(link) -rpath $(libdir)
206 $(ldid) $@
207
208 cycript: Console.lo libcycript.la $(inject)
209 $(libtool) --mode=link $(cxx) $(ldflags) -o $@ $(filter %.lo,$^) libcycript.la $(link) -rpath $(libdir)
210 $(entitle) cycript
211
212 package: $(deb)
213
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
218
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
222
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