]> git.saurik.com Git - cycript.git/blame - makefile
Started working on making the build environment more portable.
[cycript.git] / makefile
CommitLineData
ea2d184c
JF
1ifndef PKG_TARG
2target :=
3else
4target := $(PKG_TARG)-
5endif
6
63cd45c9
JF
7#flags := -g3 -O0 -DYYDEBUG=1
8flags := -g0 -O3
6195e7e0 9flags += -Wall -Werror -I. -fno-common
ea2d184c 10
9e20b0b7 11svn := $(shell svnversion)
9e20b0b7 12
1e7ce557
JF
13all:
14all := libcycript.plist cycript
15
16dpkg_architecture := $(shell dpkg-architecture &>/dev/null)
17ifneq ($(dpkg_architecture),)
18arch := $(shell $(dpkg_architecture) -qDEB_HOST_ARCH)
19endif
20
21header := Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp
22
23dll := so
24
25uname_s := $(shell uname -s)
26uname_p := $(shell uname -p)
27-include $(uname_s).mk
28-include $(uname_s)-$(uname_p).mk
29
30all += libcycript.$(dll)
f7c38a29 31
1e7ce557
JF
32ifdef arch
33deb := $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_$(arch).deb
34
35all: $(deb)
36
37$(deb): $(all)
38 rm -rf package
39 mkdir -p package/DEBIAN
40 sed -e 's/#/$(svn)/' control >package/DEBIAN/control
41 mkdir -p package/System/Library/LaunchDaemons
42 #cp -a com.saurik.Cyrver.plist package/System/Library/LaunchDaemons
43 mkdir -p package/Library/MobileSubstrate/DynamicLibraries
44 if [[ -e Settings.plist ]]; then \
45 mkdir -p package/Library/PreferenceLoader/Preferences; \
46 cp -a Settings.png package/Library/PreferenceLoader/Preferences/CycriptIcon.png; \
47 cp -a Settings.plist package/Library/PreferenceLoader/Preferences/Cycript.plist; \
48 fi
49 if [[ -e Tweak.plist ]]; then cp -a Tweak.plist package/Library/MobileSubstrate/DynamicLibraries/Cycript.plist; fi
50 cp -a Cycript.dylib package/Library/MobileSubstrate/DynamicLibraries
51 mkdir -p package/usr/{bin,lib,sbin}
52 cp -a libcycript.dylib package/usr/lib
53 cp -a cycript package/usr/bin
54 #cp -a cyrver package/usr/sbin
55 cp -a libcycript.plist package/usr/lib
56 dpkg-deb -b package $(deb)
57endif
9b5527f0 58
8953777c 59all: $(all)
ea2d184c
JF
60
61clean:
75b0a457 62 rm -f *.o libcycript.dylib cycript libcycript.plist Struct.hpp lex.cy.c Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh cyrver
ea2d184c 63
5999c315 64libcycript.plist: Bridge.def
b09da87b 65 { \
953647c1 66 echo '({'; \
f7c38a29 67 grep '^[CFV]' Bridge.def | sed -e 's/^C/0/;s/^F/1/;s/^V/2/' | sed -e 's/"/\\"/g;s/^\([^ ]*\) \([^ ]*\) \(.*\)$$/\2 = (\1, \"\3\");/'; \
953647c1 68 echo '},{'; \
f33b048a
JF
69 grep '^:' Bridge.def | sed -e 's/^: \([^ ]*\) \(.*\)/"\1" = "\2";/'; \
70 echo '},{'; \
61933e16 71 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 72 echo '})'; \
b09da87b 73 } >$@
88c977fa 74
5999c315 75Cycript.tab.cc Cycript.tab.hh location.hh position.hh: Cycript.y
e7ed5354 76 bison -v --report=state $<
e5332278
JF
77
78lex.cy.c: Cycript.l
79 flex $<
80
e5332278
JF
81#Parser.hpp: Parser.py Parser.dat
82# ./Parser.py <Parser.dat >$@
83
5999c315 84%.o: sig/%.cpp
457afcc9 85 $(target)g++ $(flags) -c -o $@ $<
5999c315
JF
86
87Cycript.tab.o: Cycript.tab.cc Cycript.tab.hh Parser.hpp Pooling.hpp
457afcc9 88 $(target)g++ $(flags) -c -o $@ $<
5999c315
JF
89
90lex.cy.o: lex.cy.c Cycript.tab.hh Parser.hpp Pooling.hpp
457afcc9 91 $(target)g++ $(flags) -c -o $@ $<
5999c315 92
f7c38a29 93%.o: %.cpp $(header)
057f943f
JF
94 $(target)g++ $(flags) -c -o $@ $<
95
f7c38a29 96%.o: %.mm $(header)
457afcc9 97 $(target)g++ $(flags) -c -o $@ $<
5999c315 98
dc68b74c
JF
99cyrver: Server.o
100 $(target)g++ $(flags) -o $@ $(filter %.o,$^) \
101 -lobjc -lapr-1 -lsubstrate \
102 -framework CoreFoundation -framework CFNetwork
103 ldid -S $@
104
1e7ce557 105libcycript.$(dll): ffi_type.o parse.o Replace.o Output.o Cycript.tab.o lex.cy.o Library.o
f7c38a29
JF
106 $(target)g++ $(flags) -dynamiclib -o $@ $(filter %.o,$^) \
107 -install_name /usr/lib/libcycript.dylib \
61933e16 108 -lobjc -lapr-1 -lffi -lsubstrate \
f7c38a29
JF
109 -framework CoreFoundation -framework Foundation \
110 -framework CFNetwork \
111 -framework JavaScriptCore -framework WebCore
ea2d184c
JF
112 ldid -S $@
113
b6d0605d 114cycript: Console.o libcycript.dylib
f7c38a29
JF
115 $(target)g++ $(flags) -o $@ $(filter %.o,$^) \
116 -lobjc -lapr-1 -lreadline \
117 -L. -lcycript \
118 -framework Foundation -framework CoreFoundation \
119 -framework JavaScriptCore -framework UIKit
262e358c
JF
120 ldid -S cycript
121
9b5527f0
JF
122package: $(deb)
123
124test: $(deb)
9e20b0b7 125 dpkg -i $(deb)
953647c1 126 cycript test.cy
1dbba6cc 127
88c977fa 128.PHONY: all clean extra package