]>
Commit | Line | Data |
---|---|---|
f37e3501 | 1 | SHELL := $(shell which bash 2>/dev/null) |
be4442da | 2 | |
ea2d184c JF |
3 | ifndef PKG_TARG |
4 | target := | |
5 | else | |
6 | target := $(PKG_TARG)- | |
7 | endif | |
8 | ||
a4dbf05b | 9 | gcc := g++ |
aabea98c JF |
10 | flags ?= -g3 -O0 -DYYDEBUG=1 |
11 | ||
e0625f37 | 12 | paths := $(foreach path,$(paths),$(wildcard $(path))) |
aabea98c | 13 | flags += $(foreach path,$(paths),-I$(path) -L$(path)) |
eacba955 | 14 | objc := |
ea2d184c | 15 | |
9e20b0b7 | 16 | svn := $(shell svnversion) |
9e20b0b7 | 17 | |
1e7ce557 | 18 | all: |
9cad30fa | 19 | all := cycript |
1e7ce557 | 20 | |
bb9f5eef | 21 | dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null) |
1e7ce557 | 22 | ifneq ($(dpkg_architecture),) |
bb9f5eef | 23 | arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null) |
1e7ce557 JF |
24 | endif |
25 | ||
6a981250 | 26 | header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp |
9cad30fa JF |
27 | |
28 | code := | |
9185d5ef JF |
29 | code += Replace.o Output.o |
30 | code += Cycript.tab.o lex.cy.o | |
31 | code += Network.o Parser.o | |
cbaa5f0f | 32 | code += JavaScriptCore.o Library.o |
1e7ce557 | 33 | |
b6961e53 JF |
34 | inject := |
35 | ||
9cad30fa | 36 | filters := #E4X |
82149e4b | 37 | ldid := true |
b6961e53 | 38 | entitle := $(ldid) |
4e869640 | 39 | lib := lib |
1e7ce557 | 40 | dll := so |
71f832e5 JF |
41 | apr_config := apr-1-config |
42 | library := | |
43 | console := -lreadline | |
f37e3501 | 44 | depends := |
1e7ce557 | 45 | |
fb81b01c JF |
46 | restart ?= $(MAKE) |
47 | uname_s ?= $(shell uname -s) | |
48 | uname_p ?= $(shell uname -p) | |
e0625f37 | 49 | |
1e7ce557 JF |
50 | -include $(uname_s).mk |
51 | -include $(uname_s)-$(uname_p).mk | |
4c2a7d11 JF |
52 | |
53 | ifneq ($(shell pkg-config libffi --modversion 2>/dev/null),) | |
54 | flags += $(shell pkg-config --cflags libffi) | |
55 | endif | |
1e7ce557 | 56 | |
9cad30fa | 57 | ifdef CY_EXECUTE |
993f82f8 JF |
58 | ifeq ($(filter ObjectiveC,$(filters)),) |
59 | ifneq ($(shell which gnustep-config 2>/dev/null),) | |
ba4fa42f | 60 | include GNUstep.mk |
993f82f8 JF |
61 | endif |
62 | endif | |
9cad30fa | 63 | endif |
993f82f8 | 64 | |
71f832e5 JF |
65 | apr := $(shell $(apr_config) --link-ld) |
66 | library += $(apr) | |
67 | console += $(apr) | |
68 | ||
82149e4b | 69 | flags += -Wall -Werror -Wno-parentheses #-Wno-unused |
4e869640 | 70 | flags += -fno-common |
71f832e5 | 71 | flags += -I. -Iinclude -I$(shell $(apr_config) --includedir) |
cbaa5f0f | 72 | |
4e869640 | 73 | all += $(lib)cycript.$(dll) |
f7c38a29 | 74 | |
be36c292 JF |
75 | filters += $(shell bison <(echo '%code{}%%_:') -o/dev/null 2>/dev/null && echo Bison24 || echo Bison23) |
76 | ||
1e7ce557 | 77 | ifdef arch |
b5dd57dc | 78 | deb := $(shell grep ^Package: control.in | cut -d ' ' -f 2-)_$(shell grep ^Version: control.in | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb |
1e7ce557 | 79 | |
d3c59903 | 80 | all: |
1e7ce557 | 81 | |
9cad30fa | 82 | extra:: |
f37e3501 | 83 | |
65cf734f | 84 | ifeq ($(depends)$(dll),dylib) |
4e869640 | 85 | control.tmp: control.in cycript $(lib)cycript.dylib |
65cf734f JF |
86 | 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)/' $< >$@ |
87 | else | |
88 | ifeq ($(depends)$(dll),so) | |
4e869640 JF |
89 | control.tmp: control.in cycript $(lib)cycript.so |
90 | 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)/' $< >$@ | |
b5dd57dc | 91 | else |
afe00096 | 92 | control.tmp: control.in |
b5dd57dc JF |
93 | sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@ |
94 | endif | |
65cf734f | 95 | endif |
b5dd57dc | 96 | |
afe00096 | 97 | control: control.tmp |
f7720478 | 98 | [[ -e control ]] && diff control control.tmp &>/dev/null || cp -pRf control.tmp control |
afe00096 | 99 | |
b5dd57dc | 100 | $(deb): $(all) control |
1e7ce557 JF |
101 | rm -rf package |
102 | mkdir -p package/DEBIAN | |
7c6c5b0a | 103 | cp -pR control package/DEBIAN |
1e7ce557 | 104 | mkdir -p package/usr/{bin,lib,sbin} |
9cad30fa | 105 | $(restart) extra |
4e869640 | 106 | cp -pR $(lib)cycript.$(dll) package/usr/lib |
7c6c5b0a JF |
107 | cp -pR cycript package/usr/bin |
108 | #cp -pR cyrver package/usr/sbin | |
1e7ce557 JF |
109 | dpkg-deb -b package $(deb) |
110 | endif | |
9b5527f0 | 111 | |
8953777c | 112 | all: $(all) |
ea2d184c | 113 | |
64058139 | 114 | clean:: |
9c60689e | 115 | rm -f *.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 |
88c977fa | 116 | |
4e869640 | 117 | %.yy: %.yy.in |
cb02f8ae JF |
118 | ./Filter.sh <$< >$@ $(filters) |
119 | ||
120 | %.l: %.l.in | |
4de0686f JF |
121 | ./Filter.sh <$< >$@ $(filters) |
122 | ||
4e869640 | 123 | Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.yy |
e7ed5354 | 124 | bison -v --report=state $< |
e5332278 JF |
125 | |
126 | lex.cy.c: Cycript.l | |
66f8d960 | 127 | flex -t $< | sed -e 's/int yyl;/yy_size_t yyl;/;s/int yyleng_r;/yy_size_t yyleng_r;/' >$@ |
e5332278 | 128 | |
e5332278 JF |
129 | #Parser.hpp: Parser.py Parser.dat |
130 | # ./Parser.py <Parser.dat >$@ | |
131 | ||
cacd1a88 | 132 | Cycript.tab.o: Cycript.tab.cc $(header) |
a4dbf05b | 133 | $(target)$(gcc) $(flags) -c -o $@ $< |
5999c315 | 134 | |
cacd1a88 | 135 | lex.cy.o: lex.cy.c $(header) |
a4dbf05b | 136 | $(target)$(gcc) $(flags) -c -o $@ $< |
5999c315 | 137 | |
f7c38a29 | 138 | %.o: %.cpp $(header) |
a4dbf05b | 139 | $(target)$(gcc) $(flags) -c -o $@ $< |
057f943f | 140 | |
cacd1a88 | 141 | #objc := -x c++ |
f7c38a29 | 142 | %.o: %.mm $(header) |
a4dbf05b | 143 | $(target)$(gcc) $(objc) $(flags) -c -o $@ $< |
5999c315 | 144 | |
4e869640 | 145 | $(lib)cycript.$(dll): $(code) |
a4dbf05b | 146 | $(target)$(gcc) $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) $(link) |
82149e4b | 147 | $(ldid) $@ |
ea2d184c | 148 | |
4e869640 | 149 | cycript: Console.o $(lib)cycript.$(dll) $(inject) |
a4dbf05b | 150 | $(target)$(gcc) $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(console) $(link) |
b6961e53 | 151 | $(entitle) cycript |
262e358c | 152 | |
9b5527f0 JF |
153 | package: $(deb) |
154 | ||
155 | test: $(deb) | |
9e20b0b7 | 156 | dpkg -i $(deb) |
029bc65b | 157 | if [[ -e target.cy ]]; then cycript -c target.cy && echo; fi |
45d0c928 | 158 | 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 |
029bc65b | 159 | if [[ -e test.cy ]]; then cycript test.cy; fi |
1dbba6cc | 160 | |
d3c59903 JF |
161 | install: cycript $(lib)cycript.$(dll) |
162 | cp -p cycript /usr/bin | |
163 | cp -p $(lib)cycript.$(dll) /usr/lib | |
164 | ||
afe00096 | 165 | .PHONY: all clean extra package control.tmp |