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