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