#
# This is msvc-stlport-tools.jam. It adds support for STLport used with
# the msvc toolset.
#
# Written by Markus Schöpflin.
# Originally based on "gcc-stlport-tools.jam", copyrighted by David
# Abrahams and Carlos Pinto Coelho 2001.
#
# To use it, you have to:
#
# 1. specify msvc-stlport as the tool name, for example by placing
#       TOOLS = msvc-stlport ;
#    in your jam rules file.
#
# 2a. Set STLPORT_PATH to point to the directory _above_ the STLport
#     directory. This assumes that you didn't rename the STLport folder
#     and allows for automatic selection of multiple STLport versions.
#
# and / or
#
# 2b. For STLPort version X.Y, set STLPORT_X.Y_PATH to the STLport
#     directory for each STLport version you are going to use.
#     This also overrides any setting of STLPORT_PATH for this version.
#
# NOTE: For msvc, the link libs are pulled in by the STLport header files
# automatically; there's no need to specify them manually.
#

# this is simply an extension to the msvc toolset. 
extends-toolset msvc ;

MSVC_STDHDRS = $(STDHDRS) ;
MSVC_STDLIBPATH = $(STDLIBPATH) ;

STDHDRS = ;
STDLIBPATH = ;

# STLport iostreams or native iostreams
feature stlport-iostream : off on ;

# major versions of STLport
feature stlport-version : 4.0 4.5 ;

#############################################################################

# Returns a path which is assumed to be the root of the STLport installation.
#
# The result depends on the current version X.Y of STLport.
# 1. If global STLPORT_<X.Y>_PATH is set, return it.
# 2. If global STLPORT_PATH is set, return $(STLPORT_PATH)/STLport-<X.Y>
#
rule get-stlport-root
{
    local version = [ get-values <stlport-version> : $(gBUILD_PROPERTIES) ] ;

    local path ;
    path ?= $(STLPORT_$(version)_PATH) ;
    path ?= $(STLPORT_PATH)$(SLASH)STLport-$(version) ;

    return $(path) ;
}

#############################################################################

# flags which work for any STLport version

flags msvc-stlport STDHDRS : [ join [ get-stlport-root ] $(SLASH)stlport ] ;
flags msvc-stlport STDLIBPATH <stlport-iostream>on : [ join [ get-stlport-root ] $(SLASH)lib ] ;

# special flags for STLport 4.0

flags msvc-stlport DEFINES <stlport-version>4.0/<stlport-iostream>off : __STL_NO_SGI_IOSTREAMS=1 ;
flags msvc-stlport UNDEFS <stlport-version>4.0/<stlport-iostream>on : __STL_NO_SGI_IOSTREAMS ;

flags msvc-stlport DEFINES <stlport-version>4.0/<runtime-build>debug : __STL_DEBUG=1 __STL_DEBUG_UNINITIALIZED=1 ;

# special flags for STLport 4.5

flags msvc-stlport DEFINES <stlport-version>4.5/<stlport-iostream>off : _STLP_NO_OWN_IOSTREAMS=1 ;
flags msvc-stlport UNDEFS <stlport-version>4.5/<stlport-iostream>on : _STLP_NO_OWN_IOSTREAMS ;

flags msvc-stlport DEFINES <stlport-version>4.5/<runtime-build>debug : _STLP_DEBUG=1 _STLP_DEBUG_UNINITIALIZED=1 ;

# Append the old values for STDHDRS and STDLIBPATH

flags msvc-stlport STDHDRS : $(MSVC_STDHDRS) ;
flags msvc-stlport STDLIBPATH : $(MSVC_STDLIBPATH) ;
