]> git.saurik.com Git - cycript.git/blame - makefile
Setup iPhone cross-compilation and runtime abstracted JSObjectMakeArray support.
[cycript.git] / makefile
CommitLineData
f37e3501 1SHELL := $(shell which bash 2>/dev/null)
be4442da 2
ea2d184c
JF
3ifndef PKG_TARG
4target :=
5else
6target := $(PKG_TARG)-
7endif
8
e0625f37
JF
9paths := $(foreach path,$(paths),$(wildcard $(path)))
10flags := $(foreach path,$(paths),-I$(path) -L$(path))
eacba955 11objc :=
ea2d184c 12
9e20b0b7 13svn := $(shell svnversion)
9e20b0b7 14
1e7ce557 15all:
856b8cd0 16all := libcycript.db cycript
1e7ce557 17
bb9f5eef 18dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null)
1e7ce557 19ifneq ($(dpkg_architecture),)
bb9f5eef 20arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null)
1e7ce557
JF
21endif
22
37954781 23header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp
3c1c3635 24code := sig/ffi_type.o sig/parse.o sig/copy.o
9185d5ef
JF
25code += Replace.o Output.o
26code += Cycript.tab.o lex.cy.o
27code += Network.o Parser.o
cbaa5f0f 28code += JavaScriptCore.o Library.o
1e7ce557 29
b1589845 30filters := C #E4X
82149e4b 31ldid := true
1e7ce557 32dll := so
9185d5ef 33apr := $(shell apr-1-config --link-ld)
28926538 34library := $(apr) -lffi -lsqlite3
dfa452c2 35console := $(apr) -lreadline
f37e3501 36depends :=
1e7ce557 37
e0625f37 38ifndef uname_s
1e7ce557 39uname_s := $(shell uname -s)
e0625f37
JF
40endif
41
42ifndef uname_p
1e7ce557 43uname_p := $(shell uname -p)
e0625f37
JF
44endif
45
1e7ce557
JF
46-include $(uname_s).mk
47-include $(uname_s)-$(uname_p).mk
48
993f82f8
JF
49ifeq ($(filter ObjectiveC,$(filters)),)
50ifneq ($(shell which gnustep-config 2>/dev/null),)
28926538 51#include GNUstep.mk
993f82f8
JF
52endif
53endif
54
69caa5be
JF
55#flags += -g3 -O0 -DYYDEBUG=1
56flags += -g0 -O3
82149e4b 57flags += -Wall -Werror -Wno-parentheses #-Wno-unused
cbaa5f0f
JF
58flags += -fPIC -fno-common
59flags += -I. -I$(shell apr-1-config --includedir)
60
1e7ce557 61all += libcycript.$(dll)
f7c38a29 62
1e7ce557
JF
63ifdef arch
64deb := $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb
65
66all: $(deb)
67
f37e3501
JF
68extra:
69
1e7ce557
JF
70$(deb): $(all)
71 rm -rf package
72 mkdir -p package/DEBIAN
f37e3501
JF
73 sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' control >package/DEBIAN/control
74 $(MAKE) extra
1e7ce557 75 mkdir -p package/usr/{bin,lib,sbin}
328ad766 76 cp -a libcycript.$(dll) package/usr/lib
1e7ce557
JF
77 cp -a cycript package/usr/bin
78 #cp -a cyrver package/usr/sbin
856b8cd0 79 cp -a libcycript.db package/usr/lib
1e7ce557
JF
80 dpkg-deb -b package $(deb)
81endif
9b5527f0 82
8953777c 83all: $(all)
ea2d184c
JF
84
85clean:
856b8cd0 86 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
ea2d184c 87
3c1c3635 88libcycript.db: Bridge.def
856b8cd0 89 rm -f libcycript.db
b09da87b 90 { \
856b8cd0
JF
91 echo 'create table "bridge" ("mode" int not null, "name" text not null, "value" text null);'; \
92 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'"'"');/'; \
93 grep '^:' Bridge.def | sed -e 's/^: \([^ ]*\) \(.*\)/insert into "bridge" ("mode", "name", "value") values (-1, '"'"'\1'"'"', '"'"'\2'"'"');/'; \
94 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'"'"');/'; \
95 } | sqlite3 libcycript.db
88c977fa 96
cb02f8ae
JF
97%.y: %.y.in
98 ./Filter.sh <$< >$@ $(filters)
99
100%.l: %.l.in
4de0686f
JF
101 ./Filter.sh <$< >$@ $(filters)
102
5999c315 103Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y
e7ed5354 104 bison -v --report=state $<
e5332278
JF
105
106lex.cy.c: Cycript.l
107 flex $<
108
e5332278
JF
109#Parser.hpp: Parser.py Parser.dat
110# ./Parser.py <Parser.dat >$@
111
cacd1a88 112Cycript.tab.o: Cycript.tab.cc $(header)
457afcc9 113 $(target)g++ $(flags) -c -o $@ $<
5999c315 114
cacd1a88 115lex.cy.o: lex.cy.c $(header)
457afcc9 116 $(target)g++ $(flags) -c -o $@ $<
5999c315 117
f7c38a29 118%.o: %.cpp $(header)
057f943f
JF
119 $(target)g++ $(flags) -c -o $@ $<
120
cacd1a88 121#objc := -x c++
f7c38a29 122%.o: %.mm $(header)
7677a045 123 $(target)g++ $(objc) $(flags) -c -o $@ $<
5999c315 124
4de0686f 125libcycript.$(dll): $(code)
dfa452c2 126 $(target)g++ $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) $(link)
82149e4b 127 $(ldid) $@
ea2d184c 128
bb9f5eef 129cycript: Console.o libcycript.$(dll)
dfa452c2 130 $(target)g++ $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(console) $(link)
82149e4b 131 $(ldid) cycript
262e358c 132
9b5527f0
JF
133package: $(deb)
134
135test: $(deb)
9e20b0b7 136 dpkg -i $(deb)
953647c1 137 cycript test.cy
1dbba6cc 138
88c977fa 139.PHONY: all clean extra package