#! /usr/bin/env python
import os

plugindir = '%s/radare/'%bld.env['LIBDIR']

so_hello = bld.new_task_gen('cc', 'shlib')
so_hello.includes = '../..'
so_hello.target = 'hello'
so_hello.source = 'hello.c'
so_hello.install_path = plugindir

so_nj = bld.new_task_gen('cc', 'shlib')
so_nj.includes = '../..'
so_nj.target = 'nj'
so_nj.source = 'nj.c'
so_nj.install_path = plugindir

so_fj = bld.new_task_gen('cc', 'shlib')
so_fj.includes = '../..'
so_fj.target = 'fj'
so_fj.source = 'fj.c'
so_fj.install_path = plugindir

# TODO: if have python here...
if so_hello.env['HAVE_PYTHON'] == 1:
	so_python = bld.new_task_gen('cc', 'shlib','pyembed')
	so_python.includes = '../..'
	so_python.target = 'python'
	so_python.source = 'python.c'
	so_python.install_path = plugindir

if so_hello.env['HAVE_LIBLUA'] == 1:
	so_lua = bld.new_task_gen('cc', 'shlib','lua')
	so_lua.includes = '../..'
	#so_lua.env.append_value('LINKFLAGS','-llua')
	so_lua.env.append_value('LINKFLAGS', so_hello.env['HAVE_LIBLUA_LD'])
	so_lua.env.append_value('CCFLAGS', so_hello.env['HAVE_LIBLUA_CC'])
	so_lua.target = 'lua'
	so_lua.source = 'lua.c'
	so_lua.install_path = plugindir

# setup with ruby!
#require 'mkmf'
#LIBDIR = Config::CONFIG['rubylibdir'] + "/"+Config::CONFIG['arch']
#puts "-I"+LIBDIR

if so_hello.env['HAVE_RUBY'] == 1:
	try:
		os.system("ruby src/plug/hack/mkruby.rb src/plug/hack/ruby.c src/plug/hack/libruby.so src")
	except:
		pass
else:
	print "ruby disabled"
#	so_ruby = bld.new_task_gen('cc', 'shlib','ruby')
#	so_ruby.includes = '../..'
#	#so_ruby.env.append_value('LINKFLAGS','-llua')
#	so_ruby.env.append_value('LINKFLAGS', '-lruby')
#	so_ruby.env.append_value('CCFLAGS', '-I/usr/lib/ruby/1.8/i386-linux')
#	so_ruby.target = 'ruby'
#	so_ruby.source = 'ruby.c'
#	so_ruby.install_path = plugindir

if so_hello.env['GUI'] == 1:
	se = bld.new_task_gen('cc', 'shlib','scriptedit')
	se.includes = '../..'
	se.uselib += 'GTK'
	se.target = 'scriptedit'
	se.source = 'scriptedit.c'
	se.install_path = plugindir
	# gtk-hello
	sh = bld.new_task_gen('cc', 'shlib','gtk-hello')
	sh.includes = '../..'
	sh.uselib += 'GTK'
	sh.target = 'gtk-hello'
	sh.source = 'gtk-hello.c'
	sh.install_path = plugindir
	# gtk-prefs
	sp = bld.new_task_gen('cc', 'shlib','gtk-prefs')
	sp.includes = '../..'
	sp.uselib += 'GTK'
	sp.target = 'gtk-prefs'
	sp.source = 'gtk-prefs.c'
	sp.install_path = plugindir
	# gtk-topbar
	tb = bld.new_task_gen('cc', 'shlib','gtk-topbar')
	tb.includes = '../..'
	tb.uselib += 'GTK'
	tb.target = 'gtk-topbar'
	tb.source = 'gtk-topbar.c'
	tb.install_path = plugindir
	# gtk-actions
	at = bld.new_task_gen('cc', 'shlib','gtk-actions')
	at.includes = '../..'
	at.uselib += 'GTK'
	at.target = 'gtk-actions'
	at.source = 'gtk-actions.c'
	at.install_path = plugindir
