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