# -*- python -*-

Import('env')
import os
import sys

wxenv = env.Clone()

files = [
	'BootManager.cpp',
	]

libs = [
	'core', 'lzo2', 'discio', 'bdisasm', 'videocommon',
	'inputcommon', 'common', 'lua', 'z', 'sfml-network',
	]

if wxenv['HAVE_WX']:
	memcardfiles = [
		'MemcardManager.cpp',
		'MemoryCards/GCMemcard.cpp',
		'WxUtils.cpp',
	]

	files += memcardfiles
	files += [
		'AboutDolphin.cpp',
		'ARCodeAddEdit.cpp',
		'ConfigMain.cpp',
		'Frame.cpp',
		'FrameAui.cpp',
		'FrameTools.cpp',
		'LuaWindow.cpp',
		'LogWindow.cpp',
		'GameListCtrl.cpp',
		'HotkeyDlg.cpp',
		'ISOFile.cpp',
		'ISOProperties.cpp',
		'PatchAddEdit.cpp',
		'CheatsWindow.cpp',
		'MemoryCards/WiiSaveCrypted.cpp',
		'NetPlay.cpp',
		'NetPlayClient.cpp',
		'NetPlayServer.cpp',
		'NetWindow.cpp',
		]

	CPPDEFINES = [
		'wxNEEDS_CHARPP',
		],

	libs = [ 'debwx', 'debugger_ui_util', 'inputuicommon'] + libs
else:
	files+= [
		'cmdline.c',
		]

if sys.platform == 'win32':
	files += [ "stdafx.cpp" ]
elif sys.platform == 'darwin':
	files += [ 'cocoaApp.m' ]

	exeGUI = env['binary_dir'] + 'Dolphin.app/Contents/MacOS/Dolphin'
	exeNoGUI = env['binary_dir'] + 'DolphinNoGUI'

	wxenv.Install(env['binary_dir'] + 'Dolphin.app/Contents/' +
		'Library/Frameworks/Cg.framework',
		'/Library/Frameworks/Cg.framework/Cg')

	wxenv.Install(env['binary_dir'] + 'Dolphin.app/Contents/Resources/',
		'#/Source/Core/DolphinWX/resources/Dolphin.icns')

	wxenv.Plist(
		env['binary_dir'] + 'Dolphin.app/Contents/Info.plist',
		Value(dict(
			CFBundleExecutable = 'Dolphin',
			CFBundleIconFile = 'Dolphin.icns',
			CFBundleIdentifier = 'com.dolphin-emu.dolphin',
			CFBundlePackageType = 'APPL',
			CFBundleShortVersionString =
			os.popen('svnversion -n ' + Dir('#').abspath).read(),
			CFBundleVersion = '2.0',
			LSMinimumSystemVersion = '10.5.0',
			LSRequiresCarbon = True,
			))
		)
else:
	files += [ 'X11Utils.cpp' ]
	exeGUI = env['binary_dir'] + 'dolphin-emu'
	exeNoGUI = env['binary_dir'] + 'dolphin-emu-nogui'

wxenv.Append(
	LIBS = libs
	)

if wxenv['HAVE_WX']:
	wxenv.Program(exeGUI, files + [ 'Main.cpp' ])
	wxenv.StaticLibrary(env['local_libs'] + 'memcard', memcardfiles)
else:
	wxenv.Program(exeNoGUI, files + [ 'MainNoGUI.cpp' ])
