/*
 * This source file is part of KEOS (Free 3D Engine)
 * For the latest info, see http://www.keosengine.org/
 * E-mails : thierry.vouriot@keosengine.org, yeri@keosengine.org
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place - Suite 330, Boston, MA 02111-1307, USA, or go to
 * http://www.gnu.org/copyleft/lesser.txt.
 *
 */

#ifndef KEOS_PLATFORM_H
#define KEOS_PLATFORM_H

#include "KeosConfig.h"

namespace Keos {

/* Initial platform/compiler-related stuff to set.
 */
#define KEOS_PLATFORM_WIN32 1

#define KEOS_COMPILER_MSVC 1
#define KEOS_COMPILER_GNUC 2

/* Finds the compiler type and version.
 */
#if defined( _MSC_VER )
#   define KEOS_COMPILER KEOS_COMPILER_MSVC
#   define KEOS_COMP_VER _MSC_VER

#elif defined( __GNUC__ )
#   define KEOS_COMPILER KEOS_COMPILER_GNUC
#   define KEOS_COMP_VER (((__GNUC__)*100)+__GNUC_MINOR__)

#else
#   pragma error "Work only under MSVC or GNU compiler !!"

#endif

#define MSVC_VER_6 1200
#define MSVC_VER_7 1300

/* Finds the current platform 
 */
#if defined( __WIN32__ ) || defined( _WIN32 )
#   define KEOS_PLATFORM KEOS_PLATFORM_WIN32
#else
#   pragma error "Work only under Windows system !!"
#endif

// For generating compiler warnings - should work on any compiler
// As a side note, if you start your message with 'Warning: ', the MSVC
// IDE actually does catch a warning :)
#define KEOS_QUOTE_INPLACE(x) # x
#define KEOS_QUOTE(x) KEOS_QUOTE_INPLACE(x)
#define KEOS_WARN( x )  message( __FILE__ "(" QUOTE( __LINE__ ) ") : " x "\n" )

//----------------------------------------------------------------------------
// Windows Settings
#if KEOS_PLATFORM == KEOS_PLATFORM_WIN32

// If we're not including this from a client build, specify that the stuff
// should get exported. Otherwise, import it.
#	if defined( __MINGW32__ )
		// Linux compilers don't have symbol import/export directives.
#   	define KEOS_EXPORT
#   else
#   	if defined( KEOSENGINE_EXPORTS )
#       	define KEOS_EXPORT __declspec( dllexport )
#   	else
#       	define KEOS_EXPORT __declspec( dllimport )
#   	endif
#	endif

// Win32 compilers use _DEBUG for specifying debug builds.
#   ifdef _DEBUG
#       define KEOS_DEBUG_MODE 1
#   else
#       define KEOS_DEBUG_MODE 0
#   endif

#if defined( __MINGW32__ )
    #define GCC_3_1
    #define EXT_HASH
#else
    #define snprintf _snprintf
    #define vsnprintf _vsnprintf
#endif

#if KEOS_DEBUG_MODE
    #define KEOS_PLATFORM_LIB "PlatformManager_Win32_d.dll"
#else
    #define KEOS_PLATFORM_LIB "PlatformManager_Win32.dll"
#endif

#endif

  #if KEOS_COMPILER == KEOS_COMPILER_MSVC

// Turn off warnings generated by long std templates
// This warns about truncation to 255 characters in debug/browse info
#   pragma warning (disable : 4786)

// Turn off warnings generated by long std templates
// This warns about truncation to 255 characters in debug/browse info
#   pragma warning (disable : 4503)

// disable: "conversion from 'double' to 'float', possible loss of data
#   pragma warning (disable : 4244)

// disable: "truncation from 'double' to 'float'
#   pragma warning (disable : 4305)

// disable: "<type> needs to have dll-interface to be used by clients'
// Happens on STL member variables which are not public therefore is ok
#   pragma warning (disable : 4251)

// disable: "non dll-interface class used as base for dll-interface class"
// Happens when deriving from Singleton because bug in compiler ignores
// template export
#   pragma warning (disable : 4275)

// disable: "C++ Exception Specification ignored"
// This is because MSVC 6 did not implement all the C++ exception 
// specifications in the ANSI C++ draft.
#   pragma warning( disable : 4290 )

// disable: "no suitable definition provided for explicit template 
// instantiation request" Occurs in VC7 for no justifiable reason on all 
// #includes of Singleton
#   pragma warning( disable: 4661)

// disable: deprecation warnings when using CRT calls in VC8 
// These show up on all C runtime lib code in VC8, disable since they clutter
// the warnings with things we may not be able to do anything about (e.g. 
// generated code from nvparse etc). I doubt very much that these calls
// will ever be actually removed from VC anyway, it would break too much code.
#	pragma warning( disable: 4996)
#endif

#if KEOS_COMPILER == KEOS_COMPILER_MSVC
#   undef _DEFINE_DEPRECATED_HASH_CLASSES
#   if KEOS_COMP_VER > MSVC_VER_7
#       define _DEFINE_DEPRECATED_HASH_CLASSES 0
#   else
#      define _DEFINE_DEPRECATED_HASH_CLASSES 1
#   endif
#endif

}

#endif // KEOS_PLATFORM_H
