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