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