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