]>
Commit | Line | Data |
---|---|---|
f37e3501 | 1 | SHELL := $(shell which bash 2>/dev/null) |
be4442da | 2 | |
ea2d184c JF |
3 | ifndef PKG_TARG |
4 | target := | |
5 | else | |
6 | target := $(PKG_TARG)- | |
7 | endif | |
8 | ||
aabea98c JF |
9 | flags ?= -g3 -O0 -DYYDEBUG=1 |
10 | ||
e0625f37 | 11 | paths := $(foreach path,$(paths),$(wildcard $(path))) |
aabea98c | 12 | flags += $(foreach path,$(paths),-I$(path) -L$(path)) |
eacba955 | 13 | objc := |
ea2d184c | 14 | |
9e20b0b7 | 15 | svn := $(shell svnversion) |
9e20b0b7 | 16 | |
1e7ce557 | 17 | all: |
856b8cd0 | 18 | all := libcycript.db cycript |
1e7ce557 | 19 | |
bb9f5eef | 20 | dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null) |
1e7ce557 | 21 | ifneq ($(dpkg_architecture),) |
bb9f5eef | 22 | arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null) |
1e7ce557 JF |
23 | endif |
24 | ||
37954781 | 25 | header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp |
3c1c3635 | 26 | code := sig/ffi_type.o sig/parse.o sig/copy.o |
9185d5ef JF |
27 | code += Replace.o Output.o |
28 | code += Cycript.tab.o lex.cy.o | |
29 | code += Network.o Parser.o | |
cbaa5f0f | 30 | code += JavaScriptCore.o Library.o |
1e7ce557 | 31 | |
b6961e53 JF |
32 | inject := |
33 | ||
b1589845 | 34 | filters := C #E4X |
82149e4b | 35 | ldid := true |
b6961e53 | 36 | entitle := $(ldid) |
1e7ce557 | 37 | dll := so |
da858962 | 38 | apr := -lapr-1 |
28926538 | 39 | library := $(apr) -lffi -lsqlite3 |
dfa452c2 | 40 | console := $(apr) -lreadline |
f37e3501 | 41 | depends := |
1e7ce557 | 42 | |
fb81b01c JF |
43 | restart ?= $(MAKE) |
44 | uname_s ?= $(shell uname -s) | |
45 | uname_p ?= $(shell uname -p) | |
e0625f37 | 46 | |
1e7ce557 JF |
47 | -include $(uname_s).mk |
48 | -include $(uname_s)-$(uname_p).mk | |
49 | ||
993f82f8 JF |
50 | ifeq ($(filter ObjectiveC,$(filters)),) |
51 | ifneq ($(shell which gnustep-config 2>/dev/null),) | |
ba4fa42f | 52 | include GNUstep.mk |
993f82f8 JF |
53 | endif |
54 | endif | |
55 | ||
82149e4b | 56 | flags += -Wall -Werror -Wno-parentheses #-Wno-unused |
cbaa5f0f | 57 | flags += -fPIC -fno-common |
7c6c5b0a | 58 | flags += -I. -Iinclude -I$(shell apr-1-config --includedir) |
cbaa5f0f | 59 | |
1e7ce557 | 60 | all += libcycript.$(dll) |
f7c38a29 | 61 | |
1e7ce557 | 62 | ifdef arch |
b5dd57dc | 63 | deb := $(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 |
64 | |
65 | all: $(deb) | |
66 | ||
f37e3501 JF |
67 | extra: |
68 | ||
65cf734f JF |
69 | ifeq ($(depends)$(dll),dylib) |
70 | control: 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)/' $< >$@ | |
72 | else | |
73 | ifeq ($(depends)$(dll),so) | |
5a2ae419 | 74 | control: control.in cycript libcycript.so |
b5dd57dc JF |
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)/' $< >$@ |
76 | else | |
5a2ae419 | 77 | control: control.in |
b5dd57dc JF |
78 | sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@ |
79 | endif | |
65cf734f | 80 | endif |
b5dd57dc JF |
81 | |
82 | $(deb): $(all) control | |
1e7ce557 JF |
83 | rm -rf package |
84 | mkdir -p package/DEBIAN | |
7c6c5b0a | 85 | cp -pR control package/DEBIAN |
fb81b01c | 86 | $(restart) extra |
1e7ce557 | 87 | mkdir -p package/usr/{bin,lib,sbin} |
7c6c5b0a JF |
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 | |
1e7ce557 JF |
92 | dpkg-deb -b package $(deb) |
93 | endif | |
9b5527f0 | 94 | |
8953777c | 95 | all: $(all) |
ea2d184c JF |
96 | |
97 | clean: | |
b5dd57dc | 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 |
ea2d184c | 99 | |
3c1c3635 | 100 | libcycript.db: Bridge.def |
856b8cd0 | 101 | rm -f libcycript.db |
b09da87b | 102 | { \ |
856b8cd0 JF |
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 | |
88c977fa | 108 | |
cb02f8ae JF |
109 | %.y: %.y.in |
110 | ./Filter.sh <$< >$@ $(filters) | |
111 | ||
112 | %.l: %.l.in | |
4de0686f JF |
113 | ./Filter.sh <$< >$@ $(filters) |
114 | ||
5999c315 | 115 | Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y |
e7ed5354 | 116 | bison -v --report=state $< |
e5332278 JF |
117 | |
118 | lex.cy.c: Cycript.l | |
119 | flex $< | |
120 | ||
e5332278 JF |
121 | #Parser.hpp: Parser.py Parser.dat |
122 | # ./Parser.py <Parser.dat >$@ | |
123 | ||
cacd1a88 | 124 | Cycript.tab.o: Cycript.tab.cc $(header) |
457afcc9 | 125 | $(target)g++ $(flags) -c -o $@ $< |
5999c315 | 126 | |
cacd1a88 | 127 | lex.cy.o: lex.cy.c $(header) |
457afcc9 | 128 | $(target)g++ $(flags) -c -o $@ $< |
5999c315 | 129 | |
f7c38a29 | 130 | %.o: %.cpp $(header) |
057f943f JF |
131 | $(target)g++ $(flags) -c -o $@ $< |
132 | ||
cacd1a88 | 133 | #objc := -x c++ |
f7c38a29 | 134 | %.o: %.mm $(header) |
7677a045 | 135 | $(target)g++ $(objc) $(flags) -c -o $@ $< |
5999c315 | 136 | |
4de0686f | 137 | libcycript.$(dll): $(code) |
dfa452c2 | 138 | $(target)g++ $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) $(link) |
82149e4b | 139 | $(ldid) $@ |
ea2d184c | 140 | |
b6961e53 | 141 | cycript: Console.o libcycript.$(dll) $(inject) |
dfa452c2 | 142 | $(target)g++ $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(console) $(link) |
b6961e53 | 143 | $(entitle) cycript |
262e358c | 144 | |
9b5527f0 JF |
145 | package: $(deb) |
146 | ||
147 | test: $(deb) | |
9e20b0b7 | 148 | dpkg -i $(deb) |
953647c1 | 149 | cycript test.cy |
1dbba6cc | 150 | |
88c977fa | 151 | .PHONY: all clean extra package |