import os ;

local BOOST_ROOT = [ os.environ BOOST_ROOT ] ;

local CURL_INCLUDE = [ os.environ CURL_INCLUDE ] ;
local CURL_LIB_PATH = [ os.environ CURL_LIB_PATH ] ;
local FUNAMBOL_INCLUDE = [ os.environ FUNAMBOL_INCLUDE ] ;
local FUNAMBOL_LIB_PATH = [ os.environ FUNAMBOL_LIB_PATH ] ;
local OPENSSL_INCLUDE = [ os.environ OPENSSL_INCLUDE ] ;
local OPENSSL_LIB_PATH = [ os.environ OPENSSL_LIB_PATH ] ;
local WBXML_PATH = [ os.environ WBXML_PATH ] ;
local WBXML_LIB_PATH = [ os.environ WBXML_LIB_PATH ] ;

ECHO CURL         $(CURL_INCLUDE) ;
ECHO CURL lib     $(CURL_LIB_PATH) ;
ECHO Funambol     $(FUNAMBOL_INCLUDE) ;
ECHO Funambol lib $(FUNAMBOL_LIB_PATH) ;
ECHO OpenSSL      $(OPENSSL_INCLUDE) ;
ECHO OpenSSL lib  $(OPENSSL_LIB_PATH) ;
ECHO WBXML        $(WBXML_PATH) ;
ECHO WBXML lib    $(WBXML_LIB_PATH) ;

import os : name ;
local os_name = [ os.name ] ;

switch [ os.name ]
{
    case "NT" :
		os_name = "win32" ;
    case "MACOS" :
		os_name = "mac" ;
    case "LINUX" :
		os_name = "posix" ;
}

ECHO os_name $(os_name) ;

project
	:
	requirements

	<variant>release:<optimization>space

	<include>../include/
	<include>../include/common/
	<os>LINUX:<include>../include/common/posix/
	<os>MACOSX:<include>../include/common/mac/
	<os>NT:<include>../include/common/windows/
	<include>../include/Logger/
	<variant>debug:<dll-path>../build/$(os_name)/debug 
	<variant>release:<dll-path>../build/$(os_name)/release 
	

## include Funambol headers - $platform includes should precede $common includes 
	<os>LINUX:<include>/usr/local/include/funambol/posix/
	<os>LINUX:<include>/usr/local/include/funambol/common/
	<os>NT:<include>$(FUNAMBOL_INCLUDE)/windows/
	<os>NT:<include>$(FUNAMBOL_INCLUDE)/common/
	<os>MACOSX:<include>$(FUNAMBOL_INCLUDE)/mac/
	<os>MACOSX:<include>$(FUNAMBOL_INCLUDE)/posix/
	<os>MACOSX:<include>$(FUNAMBOL_INCLUDE)/common/

## include boost headers 
	<os>MACOSX:<library-path>/usr/lib/
	<os>MACOSX:<include>$(BOOST_ROOT)
	<os>LINUX:<library-path>/usr/include/boost/ 
###	<os>NT:<library-path>$(BOOST_ROOT)/build/win32/
###	<os>NT:<library-path>$(BOOST_ROOT)/lib/
	<os>NT:<library-path>$(BOOST_ROOT)/stage/lib/
	<os>NT:<include>$(BOOST_ROOT)

	<os>NT:<define>WIN32 
	<os>NT:<define>_CRT_SECURE_NO_WARNINGS
	<define>ENABLE_FUNAMBOL_NAMESPACE
	<define>_WINSOCKAPI_
	<os>MACOSX:<define>BOOST_TEST_DYN_LINK
	<os>LINUX:<linkflags>"-lpthread -lrt -lresolv"
	<os>NT:<linkflags>"User32.lib Dnsapi.lib Psapi.lib advapi32.lib"
	<os>MACOSX:<linkflags>"-lpthread -lresolv -framework AppKit -framework CoreFoundation"

## curl
	<os>NT:<include>$(CURL_INCLUDE)

## OpenSSL
	<os>MACOSX:<include>$(OPENSSL_INCLUDE)
	<os>NT:<include>$(OPENSSL_INCLUDE)/

## WBXML headers
	<os>NT:<include>$(WBXML_PATH)/src/
	<os>MACOSX:<include>$(WBXML_PATH)/src/
#	<threading>multi // check if multi on linux
	:
	default-build debug
	:
	build-dir ../build/bin 
	;


import testing ;

lib boost : : 
	<os>MACOSX:<file>/usr/lib/libboost_date_time-xgcc40-mt-1_39.dylib 
	<os>MACOSX:<file>/usr/lib/libboost_filesystem-xgcc40-mt-1_39.dylib 
	<os>MACOSX:<file>/usr/lib/libboost_system-xgcc40-mt-1_39.dylib 
	<os>MACOSX:<file>/usr/lib/libboost_thread-xgcc40-mt-1_39.dylib 
	<os>MACOSX:<file>/usr/lib/libboost_unit_test_framework-xgcc40-mt-1_39.dylib 
	<os>LINUX:<file>/usr/lib/libboost_thread-mt.a 
	<os>LINUX:<file>/usr/lib/libboost_filesystem-mt.a 
	<os>LINUX:<file>/usr/lib/libboost_system-mt.a 
	<os>LINUX:<file>/usr/lib/libboost_unit_test_framework-mt.a 
	<os>LINUX:<file>/usr/lib/libboost_date_time-mt.a ;


lib funambol : : 
	<os>LINUX:<file>/usr/local/lib/libfunambol.a 
	<os>MACOSX:<file>$(FUNAMBOL_LIB_PATH)/libfunambol.a 
	<os>NT:<file>$(FUNAMBOL_LIB_PATH)/funambol.lib ;

lib libcurl : : 
	<os>LINUX:<file>/usr/lib/libcurl.so 
	<os>MACOSX:<file>/usr/lib/libcurl.dylib 
	<os>NT:<file>$(CURL_LIB_PATH)/libcurl_imp.lib ;
	
lib libwbxml : : 
	<os>LINUX:<file>/usr/lib/libwbxml2.so 
	<os>MACOSX:<file>/opt/local/lib/libwbxml2.a 
	<os>NT:<file>$(WBXML_LIB_PATH)/libwbxml2.lib ;

lib libcrypto : : 
	<os>LINUX:<file>/usr/local/ssl/lib/libcrypto.so 
	<os>MACOSX:<file>/opt/local/lib/libcrypto.0.9.8.dylib
	<os>NT:<file>$(OPENSSL_LIB_PATH)/libeay32.lib ;

# build project parts
build-project common ;	
build-project Logger ;
build-project DataStorage ;

build-project treemanager ;
build-project treemanager/commands ;
build-project treemanager/commands ;
build-project DeviceAdapter ;
build-project DeviceAdapter/ManagementObjects/TNDSMgmtTree ;

build-project ClientAdapter/clientadapterproxy ;
build-project ClientAdapter/clientadapterstub ;
#build-project ClientAdapter/UTestClientAdapter ;
build-project ClientAdapter/TestClientAdapter ;

build-project DeviceAdapter ;

build-project serverexchange ;

build-project executionqueue ;

build-project daemon ;

build-project NotificationListener ;

build-project CryptoAPI ;

build-project DaemonDM ;
build-project DaemonDM/ProfileManagerTest ;
build-project DaemonDM/MessengerTest ;
build-project DaemonDM/MessageListenerTest ;
build-project DaemonDM/TestingTool ;
###build-project gui ;

install dist : 
    Logger//Logger 
    treemanager//MOTreeManager 
#    treemanager//UTestMOTree1 
    DeviceAdapter//ManagementObjects 
    DeviceAdapter/ManagementObjects/TNDSMgmtTree//TNDSMgmtTree
    DeviceAdapter//DummyDeviceAdapter
    DeviceAdapter//Diagnostics 
	DeviceAdapter//UTestDeviceAdapter1
    ClientAdapter//clientadapterproxy//ClientAdapter 
    ClientAdapter/clientadapterstub//ClientAdapterStub
    treemanager/commands//MOTreeCommands  
    DataStorage//DataStorage 
    common//Common 
    common//FifoWrapper
    serverexchange//ServerExchangeManager 
    executionqueue//ExecutionQueue
    daemon//DaemonEngine
    daemon//DaemonUtils
    NotificationListener//NotificationListener
    CryptoAPI//CryptoAPI
    DaemonDM//UIAPI
    DaemonDM//oma_dm_client	
    DaemonDM/ProfileManagerTest//ProfileManagerTest
    DaemonDM/MessageListenerTest//UIAPIClientTest
    DaemonDM/MessengerTest//MessengerTest
    DaemonDM/TestingTool//TestingTool
    ClientAdapter/TestClientAdapter//TestClientAdapter1
    ClientAdapter/TestClientAdapterDll//TestClientAdapter
###    gui//OMADMClientGUI
:
	<variant>debug:<location>../build/$(os_name)/debug  
	<variant>release:<location>../build/$(os_name)/release
;
