#This file was made from config.mk
#
# OS_RELEASE
# OS_NAME
# OS_MAJOR
# HARDWARE_TYPE
#
# WIN32, SUN, BSDI, HPUX, CYGWIN, DARWIN
# ALPHA, SPARC
#

# guarding "ifdef"
IF (NOT CONFIG_MK)
SET(CONFIG_MK yes)

SET(CURRENT_STLPORT_VERSION 5.1.4)

SET_IF_NOTSET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${PATH_TO_ROOT}/cmake/include)
SET_IF_NOTSET(USE_PRECOMPILED yes)

IF (WIN32)
	# Windows. Set all values manually

	SET(OS_RELEASE 5.0) # TODO: Fix it
	SET(OS_NAME WIN32)
	SET(OS_MAJOR 5) # Fix it, too
    IF (CMAKE_CL_64 OR ("${CMAKE_GENERATOR}" MATCHES "Win64"))
        SET(HARDWARE_TYPE x86_64)
    ELSE (CMAKE_CL_64 OR ("${CMAKE_GENERATOR}" MATCHES "Win64"))
        SET(HARDWARE_TYPE i386)
    ENDIF (CMAKE_CL_64 OR ("${CMAKE_GENERATOR}" MATCHES "Win64"))

ELSE (WIN32)
	# Any unix-like environment
	EXECUTE_PROCESS(COMMAND hostname
	OUTPUT_VARIABLE HOSTNAME)

	EXECUTE_PROCESS(COMMAND uname -r
	COMMAND tr /[:lower:]/ /[:upper:]/
	OUTPUT_VARIABLE OS_RELEASE)

	STRING(REGEX REPLACE "\n" "" OS_RELEASE ${OS_RELEASE})

	EXECUTE_PROCESS(COMMAND uname -s
	COMMAND tr /[:lower:]/ /[:upper:]/
	OUTPUT_VARIABLE OS_NAME)

	STRING(REGEX REPLACE "\n" "" OS_NAME ${OS_NAME})

	EXECUTE_PROCESS(COMMAND uname -r
	OUTPUT_VARIABLE tmp_var)
	STRING(REGEX REPLACE "\([0-9][0-9]*\).*" "\\1" OS_MAJOR "${tmp_var}" )

	STRING(REGEX REPLACE "\n" "" OS_MAJOR ${OS_MAJOR})

	IF (NOT HARDWARE_TYPE)
		EXECUTE_PROCESS(COMMAND uname -m
		OUTPUT_VARIABLE HARDWARE_TYPE)
		STRING (REGEX REPLACE "[^_A-Za-z0-9]" "" HARDWARE_TYPE ${HARDWARE_TYPE})
	ENDIF (NOT HARDWARE_TYPE)

	IF ("${OS_NAME}" MATCHES "LINUX")
		SET_IF_NOTSET(LINUX yes)
	ELSEIF ("${OS_NAME}" MATCHES "SUNOS")
		SET_IF_NOTSET(SUN yes)
		SET_IF_NOTSET(NO_WERROR yes)
	ELSEIF ("${OS_NAME}" MATCHES "BSDI")
		SET_IF_NOTSET(BSDI yes)
		SET_IF_NOTSET(NO_WERROR yes)
	ELSEIF ("${OS_NAME}" MATCHES "HPUX")
		SET_IF_NOTSET(HPUX yes)
		SET_IF_NOTSET(NO_WERROR yes)
	ELSEIF ("${OS_NAME}" MATCHES "CYGWIN_NT-5.1")
		SET_IF_NOTSET(CYGWIN yes)
	ELSEIF ("${OS_NAME}" MATCHES "DARWIN")
		SET_IF_NOTSET(DARWIN yes)
		SET_IF_NOTSET(NOGCCSTACKCHECK yes)
	ELSEIF ("${OS_NAME}" MATCHES "FREEBSD")
		SET_IF_NOTSET(FREEBSD yes)
	ENDIF ("${OS_NAME}" MATCHES "LINUX")

	IF ("${HARDWARE_TYPE}" MATCHES "alpha")
		SET_IF_NOTSET(ALPHA yes)
		SET_IF_NOTSET(NO_WERROR yes)
	ELSEIF ("${HARDWARE_TYPE}" MATCHES "amd64")
		SET(HARDWARE_TYPE x86_64)
	ELSEIF ("${HARDWARE_TYPE}" MATCHES "sun4u")
		SET_IF_NOTSET(SPARC yes)
	ELSEIF ("${HARDWARE_TYPE}" MATCHES "mips")
	    SET_IF_NOTSET(MIPS yes)
	ENDIF ("${HARDWARE_TYPE}" MATCHES "alpha")

	IF ("${HOSTNAME}" MATCHES "arc.yandex.ru")
		SET(ARCOS yes)
	ELSEIF ("${HOSTNAME}" MATCHES "tsearch1.yandex.ru")
		SET(ARCOS yes)
	ENDIF ("${HOSTNAME}" MATCHES "arc.yandex.ru")

    IF ("${HARDWARE_TYPE}" MATCHES "i386")
       SET(HARDWARE_TYPE i686)
    ENDIF ("${HARDWARE_TYPE}" MATCHES "i386")

    SET(PROFFLAG -pg)
ENDIF (WIN32)

IF ("${HARDWARE_TYPE}" MATCHES "i686" OR "${HARDWARE_TYPE}" MATCHES "i386")
    SET(HARDWARE_ARCH 32)
ELSE ("${HARDWARE_TYPE}" MATCHES "i686" OR "${HARDWARE_TYPE}" MATCHES "i386")
    SET(HARDWARE_ARCH 64)
ENDIF ("${HARDWARE_TYPE}" MATCHES "i686" OR "${HARDWARE_TYPE}" MATCHES "i386")

ENDIF (NOT CONFIG_MK)
