]>
Commit | Line | Data |
---|---|---|
9c60689e DWT |
1 | SHELL := @_BASH@ |
2 | VPATH := @srcdir@ | |
3 | ||
4 | ifndef PKG_TARG | |
5 | target := | |
6 | else | |
7 | target := $(PKG_TARG)- | |
8 | endif | |
9 | ||
10 | srcdir := @srcdir@ | |
11 | top_builddir := @top_builddir@ | |
12 | flex := @FLEX@ | |
13 | libtool := @LIBTOOL@ | |
14 | cxx := @CXX@ | |
15 | objcxx := @OBJCXX@ | |
16 | flags := @CPPFLAGS@ @CXXFLAGS@ -DYYDEBUG=1 | |
17 | ||
18 | paths := $(foreach path,$(paths),$(wildcard $(path))) | |
19 | flags += $(foreach path,$(paths),-I$(path) -L$(path)) | |
20 | ||
21 | svn := $(shell svnversion) | |
22 | ||
23 | all: | |
24 | all := cycript | |
25 | ||
26 | dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null) | |
27 | ifneq ($(dpkg_architecture),) | |
28 | arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null) | |
29 | endif | |
30 | ||
31 | header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp | |
32 | ||
33 | code := | |
34 | code += Replace.o Output.o | |
35 | code += Cycript.tab.o lex.cy.o | |
36 | code += Network.o Parser.o | |
37 | code += JavaScriptCore.o Library.o | |
38 | ||
39 | inject := | |
40 | ||
41 | filters := #E4X | |
42 | ldid := true | |
43 | entitle := $(ldid) | |
44 | lib := lib | |
45 | dll := so | |
46 | apr_config := apr-1-config | |
47 | library := | |
48 | console := -lreadline | |
49 | depends := | |
50 | ||
51 | restart ?= $(MAKE) | |
52 | uname_s ?= $(shell uname -s) | |
53 | uname_p ?= $(shell uname -p) | |
54 | ||
55 | -include $(uname_s).mk | |
56 | -include $(uname_s)-$(uname_p).mk | |
57 | ||
58 | ifneq ($(shell pkg-config libffi --modversion 2>/dev/null),) | |
59 | flags += $(shell pkg-config --cflags libffi) | |
60 | endif | |
61 | ||
62 | ifdef CY_EXECUTE | |
63 | ifeq ($(filter ObjectiveC,$(filters)),) | |
64 | ifneq ($(shell which gnustep-config 2>/dev/null),) | |
65 | include GNUstep.mk | |
66 | endif | |
67 | endif | |
68 | endif | |
69 | ||
70 | apr := $(shell $(apr_config) --link-ld) | |
71 | library += $(apr) | |
72 | console += $(apr) | |
73 | ||
74 | flags += -Wall -Werror -Wno-parentheses #-Wno-unused | |
75 | flags += -fno-common | |
76 | ifneq ($(srcdir),.) | |
77 | flags += -I. | |
78 | endif | |
79 | flags += -I$(srcdir) -I$(srcdir)/include -I$(shell $(apr_config) --includedir) | |
80 | ||
81 | all += $(lib)cycript.$(dll) | |
82 | ||
83 | filters += $(shell bison <(echo '%code{}%%_:') -o/dev/null 2>/dev/null && echo Bison24 || echo Bison23) | |
84 | ||
85 | ifdef arch | |
86 | 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 | |
87 | ||
88 | all: | |
89 | ||
90 | extra:: | |
91 | ||
92 | ifeq ($(depends)$(dll),dylib) | |
93 | control.tmp: control.in cycript $(lib)cycript.dylib | |
94 | 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)/' $< >$@ | |
95 | else | |
96 | ifeq ($(depends)$(dll),so) | |
97 | control.tmp: control.in cycript $(lib)cycript.so | |
98 | 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)/' $< >$@ | |
99 | else | |
100 | control.tmp: control.in | |
101 | sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@ | |
102 | endif | |
103 | endif | |
104 | ||
105 | control: control.tmp | |
106 | [[ -e control ]] && diff control control.tmp &>/dev/null || cp -pRf control.tmp control | |
107 | ||
108 | $(deb): $(all) control | |
109 | rm -rf package | |
110 | mkdir -p package/DEBIAN | |
111 | cp -pR control package/DEBIAN | |
112 | mkdir -p package/usr/{bin,lib,sbin} | |
113 | $(restart) extra | |
114 | cp -pR $(lib)cycript.$(dll) package/usr/lib | |
115 | cp -pR cycript package/usr/bin | |
116 | #cp -pR cyrver package/usr/sbin | |
117 | dpkg-deb -b package $(deb) | |
118 | endif | |
119 | ||
120 | all: $(all) | |
121 | ||
122 | clean:: | |
123 | rm -f *.lo *.o $(lib)cycript.$(dll) $(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 | |
124 | ||
125 | distclean: clean | |
126 | rm -f GNUmakefile config.log config.status libtool | |
127 | ||
128 | %.yy: %.yy.in | |
129 | $(srcdir)/Filter.sh <$< >$@ $(filters) | |
130 | ||
131 | %.l: %.l.in | |
132 | $(srcdir)/Filter.sh <$< >$@ $(filters) | |
133 | ||
134 | Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.yy | |
135 | bison -v --report=state $< | |
136 | ||
137 | lex.cy.c: Cycript.l | |
138 | $(flex) -t $< | sed -e 's/int yyl;/yy_size_t yyl;/;s/int yyleng_r;/yy_size_t yyleng_r;/' >$@ | |
139 | ||
140 | #Parser.hpp: Parser.py Parser.dat | |
141 | # ./Parser.py <Parser.dat >$@ | |
142 | ||
143 | Cycript.tab.o: Cycript.tab.cc $(header) | |
144 | $(libtool) --mode=compile $(cxx) $(flags) -c -o $@ $< | |
145 | ||
146 | lex.cy.o: lex.cy.c $(header) | |
147 | $(libtool) --mode=compile $(cxx) $(flags) -c -o $@ $< | |
148 | ||
149 | %.o: %.cpp $(header) | |
150 | $(libtool) --mode=compile $(cxx) $(flags) -c -o $@ $< | |
151 | ||
152 | %.o: %.mm $(header) | |
153 | $(libtool) --mode=compile $(objcxx) $(flags) -c -o $@ $< | |
154 | ||
155 | $(lib)cycript.$(dll): $(code) | |
156 | $(libtool) --mode=link $(cxx) $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) $(link) | |
157 | $(ldid) $@ | |
158 | ||
159 | cycript: Console.o $(lib)cycript.$(dll) $(inject) | |
160 | $(libtool) --mode=link $(cxx) $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(console) $(link) | |
161 | $(entitle) cycript | |
162 | ||
163 | package: $(deb) | |
164 | ||
165 | test: $(deb) | |
166 | dpkg -i $(deb) | |
167 | if [[ -e target.cy ]]; then cycript -c target.cy && echo; fi | |
168 | if [[ -e jquery.js ]]; then /usr/bin/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 | |
169 | if [[ -e test.cy ]]; then cycript test.cy; fi | |
170 | ||
171 | install: cycript $(lib)cycript.$(dll) | |
172 | cp -p cycript /usr/bin | |
173 | cp -p $(lib)cycript.$(dll) /usr/lib | |
174 | ||
175 | .PHONY: all clean extra package control.tmp |