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