# -*- mode: python -*-
# coding=utf-8

#*****************************************************************************
#                    The Dark Mod GPL Source Code
# 
# This file is part of the The Dark Mod Source Code, originally based 
# on the Doom 3 GPL Source Code as published in 2011.
# 
# The Dark Mod Source Code is free software: you can redistribute it 
# and/or modify it under the terms of the GNU General Public License as 
# published by the Free Software Foundation, either version 3 of the License, 
# or (at your option) any later version. For details, see LICENSE.TXT.
# 
# Project: The Dark Mod Updater (http://www.thedarkmod.com/)
# 
# $Revision$ (Revision of last commit) 
# $Date$ (Date of last commit)
# $Author$ (Author of last commit)
# 
#*****************************************************************************

# The Dark Mod Updater build script
# Adapted from id's game sconscript
# Author: greebo

import sys, os, string

Import( 'GLOBALS' )
Import( GLOBALS )

def BuildList( s_prefix, s_string ):
	s_list = string.split( s_string )
	for i in range( len( s_list ) ):
		s_list[ i ] = s_prefix + '/' + s_list[ i ]
	return s_list

# Master list of source files to compile
tdm_update_list = BuildList('./', 'tdm_update.cpp ConsoleUpdater.cpp')

local_env = g_env.Clone()
local_env.Append(CPPFLAGS = [ '-Wno-unused', '-Wno-deprecated', '-Wno-non-virtual-dtor' ])

local_env.Append(CPPPATH = '#/../include')
local_env.Append(CPPPATH = '#/libtdm_update')

# Use local Boost
if g_os == 'MacOSX':
	local_env.Append(LIBS = [
		File('#/../macosx/boost/lib/libboost_filesystem.a'),
		File('#/../macosx/boost/lib/libboost_program_options.a'),
		File('#/../macosx/boost/lib/libboost_thread.a'),
		File('#/../macosx/boost/lib/libboost_regex.a'),
		File('#/../macosx/boost/lib/libboost_system.a'),
		File('#/../macosx/libcurl/libcurl.a')
	])
else:
	local_env.Append(LIBS = [
		File('#/../linux/boost/lib/libboost_filesystem.a'),
		File('#/../linux/boost/lib/libboost_program_options.a'),
		File('#/../linux/boost/lib/libboost_thread.a'),
		File('#/../linux/boost/lib/libboost_regex.a'),
		File('#/../linux/boost/lib/libboost_system.a'),
		File('#/../linux/libcurl/libcurl.a'),
		File('#/../linux/polarssl/libpolarssl.a'),
		'rt',
	])

minizip_list = SConscript( './SConscript.minizip' )
libtdm_update_list = SConscript( './SConscript.libtdm_update' )

executable_name = 'tdm_update'

if g_os == 'MacOSX':
	executable_name = executable_name + '.macosx'
else:
	executable_name = executable_name + '.linux'

ret = local_env.Program(executable_name, tdm_update_list + minizip_list + libtdm_update_list)
Return( 'ret' )