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