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