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