]> git.saurik.com Git - cycript.git/blame - GNUmakefile.in
Make sure autogen.sh works somewhat on a Mac.
[cycript.git] / GNUmakefile.in
CommitLineData
3530897b
DWT
1# @configure_input@
2
e9c9a47c 3SHELL := @_BASH@
9c60689e
DWT
4VPATH := @srcdir@
5
6ifndef PKG_TARG
7target :=
8else
9target := $(PKG_TARG)-
10endif
11
12srcdir := @srcdir@
13top_builddir := @top_builddir@
14flex := @FLEX@
15libtool := @LIBTOOL@
16cxx := @CXX@
17objcxx := @OBJCXX@
aff87425 18cflags := @CPPFLAGS@ @CXXFLAGS@ -DYYDEBUG=1 $(filter -DHAVE_FFI% -DHAVE_READLINE% -DHAVE_HISTORY_H,@DEFS@)
47aaa820 19objcxxflags := @OBJCXXFLAGS@
549f29b5
DWT
20ldflags := @LDFLAGS@
21library := @LIBS@ @LTLIBAPR@ @LTLIBICONV@
e1cce270
DWT
22sed := @SED@
23bison := @BISON@
e9c9a47c 24time := @TIME@
3fd51f51 25gperf := @GPERF@
e1cce270 26otool := @OTOOL@
3530897b
DWT
27
28INSTALL := @INSTALL@
29INSTALL_PROGRAM := @INSTALL_PROGRAM@
30INSTALL_DATA := @INSTALL_DATA@
31
32PACKAGE_TARNAME := @PACKAGE_TARNAME@
33prefix := @prefix@
34exec_prefix := @exec_prefix@
35bindir := @bindir@
36sbindir := @sbindir@
37libexecdir := @libexecdir@
38datarootdir := @datarootdir@
39datadir := @datadir@
40sysconfdir := @sysconfdir@
41sharedstatedir := @sharedstatedir@
42localstatedir := @localstatedir@
43includedir := @includedir@
44oldincludedir := @oldincludedir@
45docdir := @docdir@
46infodir := @infodir@
47htmldir := @htmldir@
48dvidir := @dvidir@
49pdfdir := @pdfdir@
50psdir := @psdir@
51libdir := @libdir@
52localedir := @localedir@
53mandir := @mandir@
9c60689e 54
3fd51f51 55CY_EXECUTE := @CY_EXECUTE@
47aaa820 56CY_OBJECTIVEC := @CY_OBJECTIVEC@
e1cce270 57CY_OBJECTIVEC_MACH := @CY_OBJECTIVEC_MACH@
3fd51f51 58
b65019fe
DWT
59svn := @SVN@
60svnversion := @SVNVERSION@
61
62ifneq ($(svnversion),)
63release := $(shell svnversion $(srcdir))
64
65ifneq ($(release),exported)
66gnutar := @GNUTAR@
67version := @PACKAGE_VERSION@.$(release)
68tarname := @PACKAGE_TARNAME@-$(version)
69endif
70endif
71
9c60689e 72paths := $(foreach path,$(paths),$(wildcard $(path)))
549f29b5 73cflags += $(foreach path,$(paths),-I$(path) -L$(path))
9c60689e 74
b65019fe 75#svn := $(shell svnversion $(srcdir))
9c60689e
DWT
76
77all:
78all := cycript
79
b65019fe
DWT
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
9c60689e
DWT
84
85header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp
86
87code :=
549f29b5
DWT
88code += Replace.lo Output.lo
89code += Cycript.tab.lo lex.cy.lo
90code += Network.lo Parser.lo
91code += JavaScriptCore.lo Library.lo
9c60689e
DWT
92
93inject :=
94
95filters := #E4X
96ldid := true
97entitle := $(ldid)
98lib := lib
99dll := so
9c60689e
DWT
100depends :=
101
102restart ?= $(MAKE)
103uname_s ?= $(shell uname -s)
104uname_p ?= $(shell uname -p)
105
3fd51f51
DWT
106ifeq ($(CY_EXECUTE),1)
107cflags += -DCY_EXECUTE
108code += sig/ffi_type.lo sig/parse.lo sig/copy.lo
109code += Execute.lo Bridge.lo
110filters += C
25b7683a 111header += JavaScript.hpp
9c60689e
DWT
112endif
113
549f29b5
DWT
114cflags += -Wall -Werror -Wno-parentheses #-Wno-unused
115cflags += -fno-common
9c60689e 116ifneq ($(srcdir),.)
549f29b5 117cflags += -I.
9c60689e 118endif
549f29b5 119cflags += -I$(srcdir) -I$(srcdir)/include
9c60689e 120
a7f2d052 121all += libcycript.la
9c60689e 122
e1cce270 123filters += $(shell $(bison) <(echo '%code{}%%_:') -o/dev/null 2>/dev/null && echo Bison24 || echo Bison23)
9c60689e
DWT
124
125ifdef arch
e1cce270 126deb := $(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
9c60689e
DWT
127
128all:
129
130extra::
131
132ifeq ($(depends)$(dll),dylib)
133control.tmp: control.in cycript $(lib)cycript.dylib
e1cce270 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)/' $< >$@
9c60689e
DWT
135else
136ifeq ($(depends)$(dll),so)
137control.tmp: control.in cycript $(lib)cycript.so
e1cce270 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)/' $< >$@
9c60689e
DWT
139else
140control.tmp: control.in
e1cce270 141 $(sed) -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@
9c60689e
DWT
142endif
143endif
144
145control: 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)
158endif
159
3fd51f51
DWT
160ifeq ($(CY_EXECUTE),1)
161Bridge.gperf: Bridge.def Bridge.sh
162 $(srcdir)/Bridge.sh $< >$@
163
164Bridge.hpp: Bridge.gperf
e1cce270 165 $(gperf) $< | $(sed) -e 's/defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__/0/' >$@
3fd51f51
DWT
166
167Bridge.lo: Bridge.hpp
168endif
169
47aaa820
DWT
170ifeq ($(CY_OBJECTIVEC),1)
171filters += ObjectiveC
172header += Struct.hpp ObjectiveC/Internal.hpp ObjectiveC/Syntax.hpp
173code += ObjectiveC/Output.lo ObjectiveC/Replace.lo ObjectiveC/Library.lo
174
175Struct.hpp:
176 $$($(objcxx) -print-prog-name=cc1obj) -print-objc-runtime-info </dev/null >$@
e1cce270
DWT
177
178ifeq ($(CY_OBJECTIVEC_MACH),1)
b112996a 179code += Handler.lo
e1cce270
DWT
180cflags += -DCY_ATTACH
181inject += Mach/Inject.lo
182
183Mach/Inject.lo: Trampoline.t.hpp Baton.hpp
184
185%.t.hpp: %.t.cpp
3e42a88d
JF
186 # LC_SEGMENT_64
187 $(libtool) --mode=compile $(cxx) -c -fno-stack-protector -fno-exceptions -I$(srcdir)/include -o $*.t.lo $< $(cflags) && { file=($$($(otool) -l .libs/$*.t.o | $(sed) -e 'x; /^1/ { x; /^ *filesize / { s/^.* //; p; }; /^ *fileoff / { s/^.* //; p; }; x; }; x; /^ *cmd LC_SEGMENT/ { s/.*/1/; x; }; d;')); od -t x1 -j $${file[0]} -N $${file[1]} .libs/$*.t.o | $(sed) -e 's/^[^ ]*//' | tr $$'\n' ' ' | $(sed) -e 's/ */ /g;s/^ *//;s/ $$//;s/ /,/g;s/\([^,][^,]\)/0x\1/g' | $(sed) -e 's/^/static const char $*_[] = {/;s/$$/};/' && echo && echo "/*" && $(otool) -vVt .libs/$*.t.o && echo "*/"; } >$@ && rm -f $*.t.lo .libs/$*.t.o
e1cce270 188endif
47aaa820
DWT
189endif
190
9c60689e
DWT
191all: $(all)
192
193clean::
b65019fe 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
94690cff 195ifneq ($(srcdir),.)
790e5246 196 rm -rf Mach ObjectiveC sig
94690cff 197endif
9c60689e
DWT
198
199distclean: clean
790e5246 200 rm -f GNUmakefile Makefile config.log config.status libtool
9c60689e
DWT
201
202%.yy: %.yy.in
203 $(srcdir)/Filter.sh <$< >$@ $(filters)
204
205%.l: %.l.in
206 $(srcdir)/Filter.sh <$< >$@ $(filters)
207
208Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.yy
e1cce270 209 $(bison) -v --report=state $<
9c60689e
DWT
210
211lex.cy.c: Cycript.l
e1cce270 212 $(flex) -t $< | $(sed) -e 's/int yyl;/yy_size_t yyl;/;s/int yyleng_r;/yy_size_t yyleng_r;/' >$@
9c60689e
DWT
213
214#Parser.hpp: Parser.py Parser.dat
215# ./Parser.py <Parser.dat >$@
216
549f29b5
DWT
217Cycript.tab.lo: Cycript.tab.cc $(header)
218 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
9c60689e 219
549f29b5
DWT
220lex.cy.lo: lex.cy.c $(header)
221 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
9c60689e 222
549f29b5
DWT
223%.lo: %.cpp $(header)
224 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
9c60689e 225
549f29b5 226%.lo: %.mm $(header)
47aaa820 227 $(libtool) --mode=compile $(objcxx) $(objcxxflags) $(cflags) -c -o $@ $<
9c60689e 228
a7f2d052 229libcycript.la: $(code)
3530897b 230 $(libtool) --mode=link $(cxx) $(ldflags) -o $@ $(filter %.lo,$^) $(library) $(link) -rpath $(libdir)
9c60689e
DWT
231 $(ldid) $@
232
a7f2d052
DWT
233cycript: Console.lo libcycript.la $(inject)
234 $(libtool) --mode=link $(cxx) $(ldflags) -o $@ $(filter %.lo,$^) libcycript.la $(link) -rpath $(libdir)
9c60689e
DWT
235 $(entitle) cycript
236
237package: $(deb)
238
a7f2d052
DWT
239test: 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
9c60689e 243
b5bd4353 244ifneq ($(gnutar),:)
b65019fe 245dist:
ab3d214f 246 echo -n >> $(tarname).tar.gz
b65019fe
DWT
247 $(gnutar) -cC $(srcdir) -f $(tarname).tar.gz -vX <($(svn) propget svn:ignore $(srcdir)) -z --exclude-vcs --show-transformed-names --transform='s#^\.#$(tarname)#' .
248endif
249
a7f2d052 250install: cycript libcycript.la
af896e32 251 $(INSTALL) -d $(DESTDIR)$(bindir) $(DESTDIR)$(libdir)
a7f2d052
DWT
252 $(libtool) --mode=install $(INSTALL_PROGRAM) libcycript.la $(DESTDIR)$(libdir)/libcycript.la
253 $(libtool) --mode=install $(INSTALL_PROGRAM) cycript $(DESTDIR)$(bindir)/cycript
9c60689e 254
a7f2d052
DWT
255uninstall:
256 $(libtool) --mode=uninstall rm -f $(DESTDIR)$(bindir)/cycript
257 $(libtool) --mode=uninstall rm -f $(DESTDIR)$(libdir)/libcycript.la
258
b65019fe 259.PHONY: all clean extra dist install uninstall package test control.tmp