]> git.saurik.com Git - cycript.git/blame_incremental - makefile
Changed "%zu" to "%"APR_SIZE_T_FMT on APR format calls, removed the accidental NSAuto...
[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 := libcycript.db 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
26code := sig/ffi_type.o sig/parse.o sig/copy.o
27code += Replace.o Output.o
28code += Cycript.tab.o lex.cy.o
29code += Network.o Parser.o
30code += JavaScriptCore.o Library.o
31
32inject :=
33
34filters := C #E4X
35ldid := true
36entitle := $(ldid)
37dll := so
38apr := -lapr-1
39library := $(apr) -lffi -lsqlite3
40console := $(apr) -lreadline
41depends :=
42
43restart ?= $(MAKE)
44uname_s ?= $(shell uname -s)
45uname_p ?= $(shell uname -p)
46
47-include $(uname_s).mk
48-include $(uname_s)-$(uname_p).mk
49
50ifeq ($(filter ObjectiveC,$(filters)),)
51ifneq ($(shell which gnustep-config 2>/dev/null),)
52include GNUstep.mk
53endif
54endif
55
56flags += -Wall -Werror -Wno-parentheses #-Wno-unused
57flags += -fPIC -fno-common
58flags += -I. -Iinclude -I$(shell apr-1-config --includedir)
59
60all += libcycript.$(dll)
61
62ifdef arch
63deb := $(shell grep ^Package: control.in | cut -d ' ' -f 2-)_$(shell grep ^Version: control.in | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb
64
65all: $(deb)
66
67extra:
68
69ifeq ($(depends)$(dll),dylib)
70control: control.in cycript libcycript.dylib
71 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)/' $< >$@
72else
73ifeq ($(depends)$(dll),so)
74control: control.in cycript libcycript.so
75 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)/' $< >$@
76else
77control: control.in
78 sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@
79endif
80endif
81
82$(deb): $(all) control
83 rm -rf package
84 mkdir -p package/DEBIAN
85 cp -pR control package/DEBIAN
86 $(restart) extra
87 mkdir -p package/usr/{bin,lib,sbin}
88 cp -pR libcycript.$(dll) package/usr/lib
89 cp -pR cycript package/usr/bin
90 #cp -pR cyrver package/usr/sbin
91 cp -pR libcycript.db package/usr/lib
92 dpkg-deb -b package $(deb)
93endif
94
95all: $(all)
96
97clean:
98 rm -f *.o libcycript.$(dll) cycript libcycript.db Struct.hpp lex.cy.c Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh cyrver Cycript.y Cycript.l control
99
100libcycript.db: Bridge.def
101 rm -f libcycript.db
102 { \
103 echo 'create table "bridge" ("mode" int not null, "name" text not null, "value" text null);'; \
104 grep '^[CFV]' Bridge.def | sed -e 's/^C/0/;s/^F/1/;s/^V/2/' | sed -e 's/"/\\"/g;s/^\([^ ]*\) \([^ ]*\) \(.*\)$$/insert into "bridge" ("mode", "name", "value") values (\1, '"'"'\2'"'"', '"'"'\3'"'"');/'; \
105 grep '^:' Bridge.def | sed -e 's/^: \([^ ]*\) \(.*\)/insert into "bridge" ("mode", "name", "value") values (-1, '"'"'\1'"'"', '"'"'\2'"'"');/'; \
106 grep '^[EST]' Bridge.def | sed -e 's/^S/3/;s/^T/4/;s/^E/5/' | sed -e 's/^5\(.*\)$$/4\1 i/' | sed -e 's/^\([^ ]*\) \([^ ]*\) \(.*\)$$/insert into "bridge" ("mode", "name", "value") values (\1, '"'"'\2'"'"', '"'"'\3'"'"');/'; \
107 } | sqlite3 libcycript.db
108
109%.y: %.y.in
110 ./Filter.sh <$< >$@ $(filters)
111
112%.l: %.l.in
113 ./Filter.sh <$< >$@ $(filters)
114
115Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y
116 bison -v --report=state $<
117
118lex.cy.c: Cycript.l
119 flex $<
120
121#Parser.hpp: Parser.py Parser.dat
122# ./Parser.py <Parser.dat >$@
123
124Cycript.tab.o: Cycript.tab.cc $(header)
125 $(target)g++ $(flags) -c -o $@ $<
126
127lex.cy.o: lex.cy.c $(header)
128 $(target)g++ $(flags) -c -o $@ $<
129
130%.o: %.cpp $(header)
131 $(target)g++ $(flags) -c -o $@ $<
132
133#objc := -x c++
134%.o: %.mm $(header)
135 $(target)g++ $(objc) $(flags) -c -o $@ $<
136
137libcycript.$(dll): $(code)
138 $(target)g++ $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) $(link)
139 $(ldid) $@
140
141cycript: Console.o libcycript.$(dll) $(inject)
142 $(target)g++ $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(console) $(link)
143 $(entitle) cycript
144
145package: $(deb)
146
147test: $(deb)
148 dpkg -i $(deb)
149 cycript test.cy
150
151.PHONY: all clean extra package