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