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