]> git.saurik.com Git - cycript.git/blob - GNUmakefile.in
bc8da8260d4dec92f310108170fe0b7d070e7aa9
[cycript.git] / GNUmakefile.in
1 SHELL := @_BASH@
2 VPATH := @srcdir@
3
4 ifndef PKG_TARG
5 target :=
6 else
7 target := $(PKG_TARG)-
8 endif
9
10 srcdir := @srcdir@
11 top_builddir := @top_builddir@
12 flex := @FLEX@
13 libtool := @LIBTOOL@
14 cxx := @CXX@
15 objcxx := @OBJCXX@
16 cflags := @CPPFLAGS@ @CXXFLAGS@ -DYYDEBUG=1
17 ldflags := @LDFLAGS@
18 library := @LIBS@ @LTLIBAPR@ @LTLIBICONV@
19
20 paths := $(foreach path,$(paths),$(wildcard $(path)))
21 cflags += $(foreach path,$(paths),-I$(path) -L$(path))
22
23 svn := $(shell svnversion)
24
25 all:
26 all := cycript
27
28 dpkg_architecture := $(shell which dpkg-architecture 2>/dev/null)
29 ifneq ($(dpkg_architecture),)
30 arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH 2>/dev/null)
31 endif
32
33 header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp Internal.hpp Error.hpp String.hpp Exception.hpp Standard.hpp
34
35 code :=
36 code += Replace.lo Output.lo
37 code += Cycript.tab.lo lex.cy.lo
38 code += Network.lo Parser.lo
39 code += JavaScriptCore.lo Library.lo
40
41 inject :=
42
43 filters := #E4X
44 ldid := true
45 entitle := $(ldid)
46 lib := lib
47 dll := so
48 depends :=
49
50 restart ?= $(MAKE)
51 uname_s ?= $(shell uname -s)
52 uname_p ?= $(shell uname -p)
53
54 -include $(uname_s).mk
55 -include $(uname_s)-$(uname_p).mk
56
57 ifdef CY_EXECUTE
58 ifeq ($(filter ObjectiveC,$(filters)),)
59 ifneq ($(shell which gnustep-config 2>/dev/null),)
60 include GNUstep.mk
61 endif
62 endif
63 endif
64
65 cflags += -Wall -Werror -Wno-parentheses #-Wno-unused
66 cflags += -fno-common
67 ifneq ($(srcdir),.)
68 cflags += -I.
69 endif
70 cflags += -I$(srcdir) -I$(srcdir)/include
71
72 all += $(lib)cycript.la
73
74 filters += $(shell bison <(echo '%code{}%%_:') -o/dev/null 2>/dev/null && echo Bison24 || echo Bison23)
75
76 ifdef arch
77 deb := $(shell grep ^Package: $(srcdir)/control.in | cut -d ' ' -f 2-)_$(shell grep ^Version: $(srcdir)/control.in | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb
78
79 all:
80
81 extra::
82
83 ifeq ($(depends)$(dll),dylib)
84 control.tmp: control.in cycript $(lib)cycript.dylib
85 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)/' $< >$@
86 else
87 ifeq ($(depends)$(dll),so)
88 control.tmp: control.in cycript $(lib)cycript.so
89 sed -e 's/&/'"$$(dpkg-query -S $$(ldd cycript $(lib)cycript.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)/' $< >$@
90 else
91 control.tmp: control.in
92 sed -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@
93 endif
94 endif
95
96 control: control.tmp
97 [[ -e control ]] && diff control control.tmp &>/dev/null || cp -pRf control.tmp control
98
99 $(deb): $(all) control
100 rm -rf package
101 mkdir -p package/DEBIAN
102 cp -pR control package/DEBIAN
103 mkdir -p package/usr/{bin,lib,sbin}
104 $(restart) extra
105 cp -pR $(lib)cycript.$(dll) package/usr/lib
106 cp -pR cycript package/usr/bin
107 #cp -pR cyrver package/usr/sbin
108 dpkg-deb -b package $(deb)
109 endif
110
111 all: $(all)
112
113 clean::
114 rm -rf *.lo *.o .libs $(lib)cycript.$(dll) $(lib)cycript.la $(all) Struct.hpp lex.cy.c Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh cyrver Cycript.yy Cycript.l control Bridge.hpp Cycript.output
115
116 distclean: clean
117 rm -f GNUmakefile config.log config.status libtool
118
119 %.yy: %.yy.in
120 $(srcdir)/Filter.sh <$< >$@ $(filters)
121
122 %.l: %.l.in
123 $(srcdir)/Filter.sh <$< >$@ $(filters)
124
125 Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.yy
126 bison -v --report=state $<
127
128 lex.cy.c: Cycript.l
129 $(flex) -t $< | sed -e 's/int yyl;/yy_size_t yyl;/;s/int yyleng_r;/yy_size_t yyleng_r;/' >$@
130
131 #Parser.hpp: Parser.py Parser.dat
132 # ./Parser.py <Parser.dat >$@
133
134 Cycript.tab.lo: Cycript.tab.cc $(header)
135 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
136
137 lex.cy.lo: lex.cy.c $(header)
138 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
139
140 %.lo: %.cpp $(header)
141 $(libtool) --mode=compile $(cxx) $(cflags) -c -o $@ $<
142
143 %.lo: %.mm $(header)
144 $(libtool) --mode=compile $(objcxx) $(cflags) -c -o $@ $<
145
146 $(lib)cycript.la: $(code)
147 $(libtool) --mode=link $(cxx) $(ldflags) -o $@ $(filter %.lo,$^) $(library) $(link) -rpath /usr/lib
148 $(ldid) $@
149
150 cycript: Console.lo $(lib)cycript.la $(inject)
151 $(libtool) --mode=link $(cxx) $(ldflags) -o $@ $(filter %.lo,$^) $(lib)cycript.la $(link) -rpath /usr/lib
152 $(entitle) cycript
153
154 package: $(deb)
155
156 test: $(deb)
157 dpkg -i $(deb)
158 if [[ -e target.cy ]]; then cycript -c target.cy && echo; fi
159 if [[ -e jquery.js ]]; then /usr/bin/time cycript -c jquery.js >jquery.cyc.js; gzip -9c jquery.cyc.js >jquery.cyc.js.gz; wc -c jquery.{mam,gcc,cyc,bak,yui}.js; wc -c jquery.{cyc,gcc,bak,mam,yui}.js.gz; fi
160 if [[ -e test.cy ]]; then cycript test.cy; fi
161
162 install: cycript $(lib)cycript.$(dll)
163 cp -p cycript /usr/bin
164 cp -p $(lib)cycript.$(dll) /usr/lib
165
166 .PHONY: all clean extra package control.tmp