]> git.saurik.com Git - cycript.git/blame_incremental - makefile
Fixed make extra in cross-compile.
[cycript.git] / makefile
... / ...
CommitLineData
1SHELL := $(shell which bash 2>/dev/null)
2
3ifndef PKG_TARG
4target :=
5else
6target := $(PKG_TARG)-
7endif
8
9paths := $(foreach path,$(paths),$(wildcard $(path)))
10flags := $(foreach path,$(paths),-I$(path) -L$(path))
11objc :=
12
13svn := $(shell svnversion)
14
15all:
16all := libcycript.db cycript
17
18dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null)
19ifneq ($(dpkg_architecture),)
20arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null)
21endif
22
23header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp
24code := sig/ffi_type.o sig/parse.o sig/copy.o
25code += Replace.o Output.o
26code += Cycript.tab.o lex.cy.o
27code += Network.o Parser.o
28code += JavaScriptCore.o Library.o
29
30filters := C #E4X
31ldid := true
32dll := so
33apr := $(shell apr-1-config --link-ld)
34library := $(apr) -lffi -lsqlite3
35console := $(apr) -lreadline
36depends :=
37
38restart ?= $(MAKE)
39uname_s ?= $(shell uname -s)
40uname_p ?= $(shell uname -p)
41
42-include $(uname_s).mk
43-include $(uname_s)-$(uname_p).mk
44
45ifeq ($(filter ObjectiveC,$(filters)),)
46ifneq ($(shell which gnustep-config 2>/dev/null),)
47#include GNUstep.mk
48endif
49endif
50
51#flags += -g3 -O0 -DYYDEBUG=1
52flags += -g0 -O3
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 | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb
61
62all: $(deb)
63
64extra:
65
66$(deb): $(all)
67 rm -rf package
68 mkdir -p package/DEBIAN
69 sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' control >package/DEBIAN/control
70 $(restart) extra
71 mkdir -p package/usr/{bin,lib,sbin}
72 cp -a libcycript.$(dll) package/usr/lib
73 cp -a cycript package/usr/bin
74 #cp -a cyrver package/usr/sbin
75 cp -a libcycript.db package/usr/lib
76 dpkg-deb -b package $(deb)
77endif
78
79all: $(all)
80
81clean:
82 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
83
84libcycript.db: Bridge.def
85 rm -f libcycript.db
86 { \
87 echo 'create table "bridge" ("mode" int not null, "name" text not null, "value" text null);'; \
88 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'"'"');/'; \
89 grep '^:' Bridge.def | sed -e 's/^: \([^ ]*\) \(.*\)/insert into "bridge" ("mode", "name", "value") values (-1, '"'"'\1'"'"', '"'"'\2'"'"');/'; \
90 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'"'"');/'; \
91 } | sqlite3 libcycript.db
92
93%.y: %.y.in
94 ./Filter.sh <$< >$@ $(filters)
95
96%.l: %.l.in
97 ./Filter.sh <$< >$@ $(filters)
98
99Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y
100 bison -v --report=state $<
101
102lex.cy.c: Cycript.l
103 flex $<
104
105#Parser.hpp: Parser.py Parser.dat
106# ./Parser.py <Parser.dat >$@
107
108Cycript.tab.o: Cycript.tab.cc $(header)
109 $(target)g++ $(flags) -c -o $@ $<
110
111lex.cy.o: lex.cy.c $(header)
112 $(target)g++ $(flags) -c -o $@ $<
113
114%.o: %.cpp $(header)
115 $(target)g++ $(flags) -c -o $@ $<
116
117#objc := -x c++
118%.o: %.mm $(header)
119 $(target)g++ $(objc) $(flags) -c -o $@ $<
120
121libcycript.$(dll): $(code)
122 $(target)g++ $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) $(link)
123 $(ldid) $@
124
125cycript: Console.o libcycript.$(dll)
126 $(target)g++ $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(console) $(link)
127 $(ldid) cycript
128
129package: $(deb)
130
131test: $(deb)
132 dpkg -i $(deb)
133 cycript test.cy
134
135.PHONY: all clean extra package