]> git.saurik.com Git - cycript.git/blame - makefile
Furthering the cause of removing CoreFoundation.
[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
cbaa5f0f 9flags :=
eacba955 10objc :=
ea2d184c 11
9e20b0b7 12svn := $(shell svnversion)
9e20b0b7 13
1e7ce557
JF
14all:
15all := libcycript.plist cycript
16
bb9f5eef 17dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null)
1e7ce557 18ifneq ($(dpkg_architecture),)
bb9f5eef 19arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null)
1e7ce557
JF
20endif
21
22header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp
9185d5ef
JF
23code := ffi_type.o parse.o
24code += Replace.o Output.o
25code += Cycript.tab.o lex.cy.o
26code += Network.o Parser.o
cbaa5f0f 27code += JavaScriptCore.o Library.o
1e7ce557 28
9185d5ef
JF
29filters := C
30ldid := echo
1e7ce557 31dll := so
9185d5ef 32apr := $(shell apr-1-config --link-ld)
dfa452c2
JF
33library := $(apr) -lffi
34console := $(apr) -lreadline
f37e3501 35depends :=
1e7ce557
JF
36
37uname_s := $(shell uname -s)
38uname_p := $(shell uname -p)
39-include $(uname_s).mk
40-include $(uname_s)-$(uname_p).mk
41
993f82f8
JF
42ifeq ($(filter ObjectiveC,$(filters)),)
43ifneq ($(shell which gnustep-config 2>/dev/null),)
44include GNUstep.mk
45endif
46endif
47
cbaa5f0f
JF
48flags += -g3 -O0 -DYYDEBUG=1
49#flags += -g0 -O3
50flags += -Wall -Werror -Wno-parentheses
51flags += -fPIC -fno-common
52flags += -I. -I$(shell apr-1-config --includedir)
53
1e7ce557 54all += libcycript.$(dll)
f7c38a29 55
1e7ce557
JF
56ifdef arch
57deb := $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb
58
59all: $(deb)
60
f37e3501
JF
61extra:
62
1e7ce557
JF
63$(deb): $(all)
64 rm -rf package
65 mkdir -p package/DEBIAN
f37e3501
JF
66 sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' control >package/DEBIAN/control
67 $(MAKE) extra
1e7ce557 68 mkdir -p package/usr/{bin,lib,sbin}
328ad766 69 cp -a libcycript.$(dll) package/usr/lib
1e7ce557
JF
70 cp -a cycript package/usr/bin
71 #cp -a cyrver package/usr/sbin
72 cp -a libcycript.plist package/usr/lib
73 dpkg-deb -b package $(deb)
74endif
9b5527f0 75
8953777c 76all: $(all)
ea2d184c
JF
77
78clean:
328ad766 79 rm -f *.o libcycript.$(dll) cycript libcycript.plist Struct.hpp lex.cy.c Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh cyrver Cycript.y
ea2d184c 80
5999c315 81libcycript.plist: Bridge.def
b09da87b 82 { \
953647c1 83 echo '({'; \
f7c38a29 84 grep '^[CFV]' Bridge.def | sed -e 's/^C/0/;s/^F/1/;s/^V/2/' | sed -e 's/"/\\"/g;s/^\([^ ]*\) \([^ ]*\) \(.*\)$$/\2 = (\1, \"\3\");/'; \
953647c1 85 echo '},{'; \
f33b048a
JF
86 grep '^:' Bridge.def | sed -e 's/^: \([^ ]*\) \(.*\)/"\1" = "\2";/'; \
87 echo '},{'; \
61933e16 88 grep '^[EST]' Bridge.def | sed -e 's/^S/0/;s/^T/1/;s/^E/2/' | sed -e 's/^2\(.*\)$$/1\1 i/' | sed -e 's/"/\\"/g;s/^\([^ ]*\) \([^ ]*\) \(.*\)$$/\2 = (\1, \"\3\");/'; \
953647c1 89 echo '})'; \
b09da87b 90 } >$@
88c977fa 91
4de0686f
JF
92Cycript.y: Cycript.y.in
93 ./Filter.sh <$< >$@ $(filters)
94
5999c315 95Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y
e7ed5354 96 bison -v --report=state $<
e5332278
JF
97
98lex.cy.c: Cycript.l
99 flex $<
100
e5332278
JF
101#Parser.hpp: Parser.py Parser.dat
102# ./Parser.py <Parser.dat >$@
103
5999c315 104%.o: sig/%.cpp
457afcc9 105 $(target)g++ $(flags) -c -o $@ $<
5999c315
JF
106
107Cycript.tab.o: Cycript.tab.cc Cycript.tab.hh Parser.hpp Pooling.hpp
457afcc9 108 $(target)g++ $(flags) -c -o $@ $<
5999c315
JF
109
110lex.cy.o: lex.cy.c Cycript.tab.hh Parser.hpp Pooling.hpp
457afcc9 111 $(target)g++ $(flags) -c -o $@ $<
5999c315 112
f7c38a29 113%.o: %.cpp $(header)
057f943f
JF
114 $(target)g++ $(flags) -c -o $@ $<
115
f7c38a29 116%.o: %.mm $(header)
eacba955 117 $(target)g++ $(flags) -c -o $@ $< $(objc)
5999c315 118
4de0686f 119libcycript.$(dll): $(code)
dfa452c2 120 $(target)g++ $(flags) -shared -dynamiclib -o $@ $(filter %.o,$^) $(library) $(link)
9185d5ef 121 $(ldid) -S $@
ea2d184c 122
bb9f5eef 123cycript: Console.o libcycript.$(dll)
dfa452c2 124 $(target)g++ $(flags) -o $@ $(filter %.o,$^) -L. -lcycript $(console) $(link)
9185d5ef 125 $(ldid) -S cycript
262e358c 126
9b5527f0
JF
127package: $(deb)
128
129test: $(deb)
9e20b0b7 130 dpkg -i $(deb)
953647c1 131 cycript test.cy
1dbba6cc 132
88c977fa 133.PHONY: all clean extra package