]>
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 |
107e5814 | 41 | apr := $(shell apr-1-config --link-ld) |
4e869640 | 42 | library := $(apr) |
dfa452c2 | 43 | console := $(apr) -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 | |
52 | ||
9cad30fa | 53 | ifdef CY_EXECUTE |
993f82f8 JF |
54 | ifeq ($(filter ObjectiveC,$(filters)),) |
55 | ifneq ($(shell which gnustep-config 2>/dev/null),) | |
ba4fa42f | 56 | include GNUstep.mk |
993f82f8 JF |
57 | endif |
58 | endif | |
9cad30fa | 59 | endif |
993f82f8 | 60 | |
82149e4b | 61 | flags += -Wall -Werror -Wno-parentheses #-Wno-unused |
4e869640 | 62 | flags += -fno-common |
7c6c5b0a | 63 | flags += -I. -Iinclude -I$(shell apr-1-config --includedir) |
cbaa5f0f | 64 | |
4e869640 | 65 | all += $(lib)cycript.$(dll) |
f7c38a29 | 66 | |
be36c292 JF |
67 | filters += $(shell bison <(echo '%code{}%%_:') -o/dev/null 2>/dev/null && echo Bison24 || echo Bison23) |
68 | ||
1e7ce557 | 69 | ifdef arch |
b5dd57dc | 70 | 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 | 71 | |
d3c59903 | 72 | all: |
1e7ce557 | 73 | |
9cad30fa | 74 | extra:: |
f37e3501 | 75 | |
65cf734f | 76 | ifeq ($(depends)$(dll),dylib) |
4e869640 | 77 | control.tmp: control.in cycript $(lib)cycript.dylib |
65cf734f JF |
78 | 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)/' $< >$@ |
79 | else | |
80 | ifeq ($(depends)$(dll),so) | |
4e869640 JF |
81 | control.tmp: control.in cycript $(lib)cycript.so |
82 | 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 | 83 | else |
afe00096 | 84 | control.tmp: control.in |
b5dd57dc JF |
85 | sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@ |
86 | endif | |
65cf734f | 87 | endif |
b5dd57dc | 88 | |
afe00096 | 89 | control: control.tmp |
f7720478 | 90 | [[ -e control ]] && diff control control.tmp &>/dev/null || cp -pRf control.tmp control |
afe00096 | 91 | |
b5dd57dc | 92 | $(deb): $(all) control |
1e7ce557 JF |
93 | rm -rf package |
94 | mkdir -p package/DEBIAN | |
7c6c5b0a | 95 | cp -pR control package/DEBIAN |
1e7ce557 | 96 | mkdir -p package/usr/{bin,lib,sbin} |
9cad30fa | 97 | $(restart) extra |
4e869640 | 98 | cp -pR $(lib)cycript.$(dll) package/usr/lib |
7c6c5b0a JF |
99 | cp -pR cycript package/usr/bin |
100 | #cp -pR cyrver package/usr/sbin | |
1e7ce557 JF |
101 | dpkg-deb -b package $(deb) |
102 | endif | |
9b5527f0 | 103 | |
8953777c | 104 | all: $(all) |
ea2d184c JF |
105 | |
106 | clean: | |
4e869640 | 107 | 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 |
88c977fa | 108 | |
4e869640 | 109 | %.yy: %.yy.in |
cb02f8ae JF |
110 | ./Filter.sh <$< >$@ $(filters) |
111 | ||
112 | %.l: %.l.in | |
4de0686f JF |
113 | ./Filter.sh <$< >$@ $(filters) |
114 | ||
4e869640 | 115 | Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.yy |
e7ed5354 | 116 | bison -v --report=state $< |
e5332278 JF |
117 | |
118 | lex.cy.c: Cycript.l | |
119 | flex $< | |
120 | ||
e5332278 JF |
121 | #Parser.hpp: Parser.py Parser.dat |
122 | # ./Parser.py <Parser.dat >$@ | |
123 | ||
cacd1a88 | 124 | Cycript.tab.o: Cycript.tab.cc $(header) |
a4dbf05b | 125 | $(target)$(gcc) $(flags) -c -o $@ $< |
5999c315 | 126 | |
cacd1a88 | 127 | lex.cy.o: lex.cy.c $(header) |
a4dbf05b | 128 | $(target)$(gcc) $(flags) -c -o $@ $< |
5999c315 | 129 | |
f7c38a29 | 130 | %.o: %.cpp $(header) |
a4dbf05b | 131 | $(target)$(gcc) $(flags) -c -o $@ $< |
057f943f | 132 | |
cacd1a88 | 133 | #objc := -x c++ |
f7c38a29 | 134 | %.o: %.mm $(header) |
a4dbf05b | 135 | $(target)$(gcc) $(objc) $(flags) -c -o $@ $< |
5999c315 | 136 | |
4e869640 | 137 | $(lib)cycript.$(dll): $(code) |
a4dbf05b | 138 | $(target)$(gcc) $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) $(link) |
82149e4b | 139 | $(ldid) $@ |
ea2d184c | 140 | |
4e869640 | 141 | cycript: Console.o $(lib)cycript.$(dll) $(inject) |
a4dbf05b | 142 | $(target)$(gcc) $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(console) $(link) |
b6961e53 | 143 | $(entitle) cycript |
262e358c | 144 | |
9b5527f0 JF |
145 | package: $(deb) |
146 | ||
147 | test: $(deb) | |
9e20b0b7 | 148 | dpkg -i $(deb) |
029bc65b | 149 | if [[ -e target.cy ]]; then cycript -c target.cy && echo; fi |
45d0c928 | 150 | 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 | 151 | if [[ -e test.cy ]]; then cycript test.cy; fi |
1dbba6cc | 152 | |
d3c59903 JF |
153 | install: cycript $(lib)cycript.$(dll) |
154 | cp -p cycript /usr/bin | |
155 | cp -p $(lib)cycript.$(dll) /usr/lib | |
156 | ||
afe00096 | 157 | .PHONY: all clean extra package control.tmp |