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