-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
wscript
284 lines (255 loc) · 10.1 KB
/
wscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#! /usr/bin/env python
import os
import os.path
import shutil
import Options
VERSION='1.5'
APPNAME='radare'
srcdir = '.'
blddir = 'build'
prefix = '/usr'
def set_options(opt):
opt.tool_options('compiler_cc')
opt.tool_options('compiler_cxx')
opt.add_option('--with-maemo', action='store_true', default=False, help='Build for maemo', dest='MAEMO')
opt.add_option('--with-sysproxy', action='store_true', default=False, help='Build with syscall proxy', dest='SYSPROXY')
opt.add_option('--without-gui', action='store_false', default=True, help='Build without GUI', dest='GUI')
opt.add_option('--without-debugger', action='store_false', default=True, help='Build without debugger', dest='DEBUGGER')
opt.add_option('--without-readline', action='store_false', default=True, help='Build without readline', dest='HAVE_READLINE')
opt.add_option('--without-lua', action='store_false', default=True, help='Build without LUA', dest='HAVE_LIBLUA')
opt.add_option('--without-python', action='store_false', default=True, help='Build without Python', dest='HAVE_PYTHON')
opt.add_option('--without-ruby', action='store_false', default=True, help='Build without Ruby', dest='HAVE_RUBY')
opt.add_option('--prefix',
help = "installation prefix [Default: '%s']" % prefix,
default = prefix,
dest = 'PREFIX')
def configure(conf):
# Check for compiler tools
conf.check_tool('compiler_cc')
try: conf.check_tool('compiler_cxx')
except: pass
have_valac = False
try:
conf.check_tool('vala')
have_valac = True
except: pass
try: conf.check_tool('perl')
except: pass
try: conf.check_tool('lua')
except: pass
if not conf.env['CC']: fatal('C compiler not found')
# Check libraries
conf.check_pkg('glib-2.0', destvar='GLIB', vnum='2.10.0', mandatory=False)
conf.check_pkg('gtk+-2.0', destvar='GTK', vnum='2.10.0', mandatory=False)
conf.check_pkg('vte', destvar='VTE', vnum='0.16', mandatory=False)
conf.checkEndian()
if Options.options.HAVE_PYTHON == True:
try:
conf.check_tool('python')
conf.check_python_version((2,4,2));
conf.check_python_headers()
conf.env['HAVE_PYTHON']=1 # XXX
except:
print " ==> Use --without-python"
conf.env['HAVE_PYTHON']=0
pass
else:
conf.env['HAVE_PYTHON']=0
if Options.options.MAEMO == True:
conf.check_pkg('hildon-1', destvar='HILDON', vnum='0.1', mandatory=False)
# Generate GLOBAL.H
conf.env['GUI'] = False
# Vala is no longer required for building the GUI
if conf.env['HAVE_GTK'] == 1 and conf.env['HAVE_VTE'] == 1 and Options.options.GUI:
conf.env['GUI'] = True
# if conf.env['HAVE_GTK'] == 1 and conf.env['HAVE_VTE'] == 1 and have_valac and Options.options.GUI:
# conf.env['GUI'] = True
conf.env['OS'] = os.uname()[0]
conf.env['CPU'] = os.uname()[4]
if conf.env['CPU'] == 'Power Macintosh': conf.env['CPU'] = 'powerpc' # osx
if conf.env['CPU'] == 'ppc': conf.env['CPU'] = 'powerpc' # linux
if conf.env['CPU'] == 'i86pc': conf.env['CPU'] = 'i386'
if conf.env['CPU'] == 'i686': conf.env['CPU'] = 'i386'
if conf.env['CPU'] == 'i586': conf.env['CPU'] = 'i386'
if conf.env['CPU'] != 'arm' and conf.env['CPU'] != 'powerpc' and conf.env['CPU'] != 'i386' and conf.env['CPU'] != 'powerpc' and conf.env['CPU'] != 'x86_64' and conf.env['CPU'] != 'mips64':
print "Unknown CPU. Disabling debugger"
Options.options.DEBUGGER = False
conf.define('True', 1)
conf.define('False', 0) # hack for booleans
conf.define('VERSION', VERSION)
conf.define('W32', False)
conf.define('SIZE_OFF_T', 8)
conf.define('DARWIN', False)
conf.define('DEBUGGER', Options.options.DEBUGGER)
conf.define('SYSPROXY', Options.options.SYSPROXY)
conf.define('_MAEMO_', Options.options.MAEMO)
conf.define('CPU', conf.env['CPU'])
conf.define('OS', conf.env['OS'])
conf.define('TARGET', "%s-%s"%(conf.env['CPU'],conf.env['OS']))
conf.define('HAVE_VALAC', conf.env['GUI'])
#conf.define('HAVE_GTK', conf.env['HAVE_GTK'])
conf.define('HAVE_LANG_LUA', False)
endian = True
try:
if conf.env['IS_BIGENDIAN'] == 1:
endian = False
except x:
endian = True
conf.define('LIL_ENDIAN', endian)
conf.define('HAVE_LANG_PYTHON', False)
conf.define('PREFIX', Options.options.PREFIX)
conf.define('LIBDIR', "%s/lib"%Options.options.PREFIX)
conf.define('SHAREDIR', "%s/share/"%Options.options.PREFIX)
conf.define('DOCDIR', "%s/share/doc/radare"%Options.options.PREFIX)
conf.define('GRSCDIR', "%s/share/radare/gradare"%Options.options.PREFIX)
#conf.define('LIBEXECDIR', '/usr/share/doc/radare') # DEPRECATED
# Check for ruby
print "Checking for ruby mkmf\t\t\t :",
if os.system("ruby src/plug/hack/chkruby.rb") == 0:
print "ok"
else:
print "not found"
Options.options.HAVE_RUBY = False
conf.define('HAVE_RUBY', Options.options.HAVE_RUBY)
# Check for libreadline
rl = conf.create_library_configurator()
rl.name = 'readline'
rl.define = 'HAVE_READLINE'
rl.libs = ['readline']
rl.mandatory = False
rl.run()
if conf.env['HAVE_READLINE'] != 1:
Options.options.HAVE_READLINE = False
conf.define('HAVE_LIB_READLINE', Options.options.HAVE_READLINE)
# Check for liblua
rl = conf.create_library_configurator()
rl.name = 'lua'
rl.define = 'HAVE_LIBLUA'
rl.libs = ['lua']
rl.mandatory = False
rl.run()
if conf.env['HAVE_LIBLUA'] != 1:
rl2 = conf.create_library_configurator()
rl2.name = 'lua5.1'
rl2.define = 'HAVE_LIBLUA51'
rl2.libs = ['lua5.1']
rl2.mandatory = False
rl2.run()
if conf.env['HAVE_LIBLUA51'] != 1:
Options.options.HAVE_LIBLUA = False
else:
conf.env['HAVE_LIBLUA_LD'] = "-llua5.1"
conf.env['HAVE_LIBLUA_CC'] = "-I /usr/include/lua5.1"
else:
conf.env['HAVE_LIBLUA_LD'] = "-llua"
conf.define('HAVE_LIBLUA', Options.options.HAVE_LIBLUA)
conf.define('HAVE_GUI', conf.env['GUI'])
rl2 = conf.create_library_configurator()
rl2.name = 'dl'
rl2.libs = ['dl']
rl2.mandatory = False
rl2.run()
rl2 = conf.create_library_configurator()
rl2.name = 'ewf'
rl2.libs = ['ewf']
rl2.mandatory = False
rl2.run()
if conf.env['HAVE_EWF'] != 1:
conf.env['HAVE_EWF'] = False
conf.define('HAVE_LIB_EWF', conf.env['HAVE_EWF'])
# Write global.h and show report to stdout
conf.write_config_header('global.h')
shutil.copyfile("%s/default/global.h"%blddir, "%s/global.h"%srcdir)
print " * Prefix : %s"%conf.env['PREFIX']
#print " * InstDir : %s"%inst_var
print " * Target : %s"%conf.env['TARGET']
print " * LilEndian : %s"%conf.env['LIL_ENDIAN']
print " * HaveRuby : %s"%conf.env['HAVE_RUBY']
if conf.env['HAVE_LIB_EWF'] == 1:
print " * EWF : enabled"
else:
print " * EWF : disabled"
if Options.options.DEBUGGER:
print " * Debugger : enabled"
else:
print " * Debugger : disabled"
if Options.options.HAVE_READLINE:
print " * Readline : enabled"
else:
print " * Readline : disabled"
if Options.options.SYSPROXY:
print " * SysProxy : enabled"
else:
print " * SysProxy : disabled"
if conf.env['GUI'] == 1:
print " * GUI : enabled"
else:
print " * GUI : disabled"
print "Use --without-gui : vala-waf support is not yet complete"
def build(bld):
#shutil.copyfile(srcdir+"/src/utils.c", srcdir+"/src/ut.c")
if bld.env['GUI']:
bld.add_subdirs('vala')
bld.add_subdirs('src')
#if Params.g_commands['clean']:
# os.system("echo unknown clean")
bld.install_files('${PREFIX}/lib/python2.5/site-packages/radare',
'api/python/radare/*')
bld.install_files('${PREFIX}/lib/python2.6/site-packages/radare',
'api/python/radare/*')
bld.install_files('${PREFIX}/lib/radare/lua', 'api/lua/radare/*')
bld.install_files('${PREFIX}/lib/ruby/1.8/radare',
'api/ruby/radare/*')
# RSC scripts
#if bld.env['HAVE_RUBY'] == 1:
try:
if os.path.exists('src/plug/hack/ruby.so'):
bld.install_files('${PREFIX}/lib/radare', 'src/plug/hack/ruby.so', chmod=0755)
except:
print "WTF with ruby!!"
bld.install_files('${PREFIX}/lib/radare/bin', 'src/rsc/pool/*', chmod=0755)
bld.install_files('${PREFIX}/lib/radare/bin', 'src/radiff/bindiff-ng/bindiff-ng', chmod=0755)
bld.install_files('${PREFIX}/lib/radare/bin', 'src/javasm/javasm', chmod=0755)
if bld.env['OS'] == 'Darwin' : bld.install_files('${PREFIX}/lib/radare/bin', 'src/arch/arm/aasm/armasm', chmod=0755)
bld.install_files('${PREFIX}/lib/radare/bin', 'src/lsbstego', chmod=0755)
# Documentation
bld.install_files('${PREFIX}/share/man/man1', 'man/*.1')
bld.install_files('${PREFIX}/share/man/man5', 'man/*.5')
bld.install_files('${PREFIX}/share/doc/radare', 'README')
bld.install_files('${PREFIX}/share/doc/radare', 'COPYING')
bld.install_files('${PREFIX}/share/doc/radare', 'AUTHORS')
bld.install_files('${PREFIX}/share/doc/radare', 'HISTORY')
bld.install_files('${PREFIX}/share/doc/radare', 'TODO')
bld.install_files('${PREFIX}/share/doc/radare', 'doc/csr')
bld.install_files('${PREFIX}/share/doc/radare', 'doc/flags')
bld.install_files('${PREFIX}/share/doc/radare', 'doc/fortunes')
bld.install_files('${PREFIX}/share/doc/radare', 'doc/gdb.scripts')
bld.install_files('${PREFIX}/share/doc/radare', 'doc/map-struct')
bld.install_files('${PREFIX}/share/doc/radare', 'doc/shell')
bld.install_files('${PREFIX}/share/doc/radare/xtra', 'doc/xtra/*')
bld.install_files('${PREFIX}/share/doc/radare/', 'src/radiff/ida2rdb.idc')
if bld.env['GUI']:
bld.install_files('${PREFIX}/share/radare/gradare', 'gui/grsc/Shell', chmod=0755)
for dir in "Config Debugger Disassembly Flags Hacks Movement Search Visual".split(" "):
bld.install_files('${PREFIX}/share/radare/gradare/%s'%dir, 'gui/grsc/%s/*'%dir, chmod=0755)
def install():
print "Installing..."
def shutdown():
pass
# # display the graph of header dependencies
## if 1: return
# import Params, os, types
#
# f = open('foo.dot', 'w')
# f.write("digraph G {\n")
# table = Params.g_build.node_deps
# for a in table:
# for x in table[a]:
# if type(table[a][x]) is types.ListType:
# for y in table[a][x]:
# f.write('"%s" -> "%s";\n' % (x, y))
# else:
# f.write('"%s" -> "%s";\n' % (x, table[a][x]))
# f.write('}\n')
# f.close()
#