0031313: Foundation Classes - Dump improvement for classes
[occt.git] / adm / genproj.tcl
index 0adf812..513fe1d 100644 (file)
@@ -1,24 +1,38 @@
 # =======================================================================
-# This script generates project files for different IDEs:
-#      "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "amk"
+# Created on: 2014-07-24
+# Created by: SKI
+# Copyright (c) 2014 OPEN CASCADE SAS
 #
-# Example:
-#      genproj -path=D:/occt -target=vc10
+# This file is part of Open CASCADE Technology software library.
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License version 2.1 as published
+# by the Free Software Foundation, with special exception defined in the file
+# OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+# distribution for complete text of the license and disclaimer of any warranty.
+#
+# Alternatively, this file may be used under the terms of Open CASCADE
+# commercial license or contractual agreement.
+
+# =======================================================================
+# This script defines Tcl command genproj generating project files for 
+# different IDEs and platforms. Run it with -help to get synopsis.
 # =======================================================================
 
-set path ""
+source [file join [file dirname [info script]] genconfdeps.tcl]
+
+# the script is assumed to be run from CASROOT (or dependent Products root)
+set path [file normalize .]
+set THE_CASROOT ""
 set fBranch ""
-switch -exact -- "$tcl_platform(platform)" {
-    "windows"   {set targetStation "wnt"}
-    "unix"      {set targetStation "lin"}
-    #"macos"   {set targetStation "wnt"}
+if { [info exists ::env(CASROOT)] } {
+  set THE_CASROOT [file normalize "$::env(CASROOT)"]
 }
 
 proc _get_options { platform type branch } {
-  global path
   set res ""
-  if {[file exists "$path/adm/CMPLRS"]} {
-    set fd [open "$path/adm/CMPLRS" rb]
+  if {[file exists "$::THE_CASROOT/adm/CMPLRS"]} {
+    set fd [open "$::THE_CASROOT/adm/CMPLRS" rb]
     set opts [split [read $fd] "\n"]
     close $fd
     foreach line $opts {
@@ -33,16 +47,22 @@ proc _get_options { platform type branch } {
 }
 
 proc _get_type { name } {
-  global path
-  if {[file exists "$path/adm/UDLIST"]} {
-    set fd [open "$path/adm/UDLIST" rb]
-    set UDLIST [split [read $fd] "\n"]
+  set UDLIST {}
+  if {[file exists "$::path/adm/UDLIST"]} {
+    set fd [open "$::path/adm/UDLIST" rb]
+    set UDLIST [concat $UDLIST [split [read $fd] "\n"]]
     close $fd
-    foreach uitem $UDLIST {
-      set line [split $uitem]
-      if {[lindex $line 1] == "$name"} {
-        return [lindex $line 0]
-      }
+  }
+  if { "$::path/adm/UDLIST" != "$::THE_CASROOT/adm/UDLIST" && [file exists "$::THE_CASROOT/adm/UDLIST"] } {
+    set fd [open "$::THE_CASROOT/adm/UDLIST" rb]
+    set UDLIST [concat $UDLIST [split [read $fd] "\n"]]
+    close $fd
+  }
+
+  foreach uitem $UDLIST {
+    set line [split $uitem]
+    if {[lindex $line 1] == "$name"} {
+      return [lindex $line 0]
     }
   }
   return ""
@@ -80,147 +100,335 @@ proc _get_used_files { pk {inc true} {src true} } {
   return $lret
 }
 
-# Wrapper-function to generate VS project files
-proc genproj { args } {
-  global path targetStation
-  set aSupportedTargets { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "amk" }
-  set anArgs $args
+# return location of the path within src directory
+proc osutils:findSrcSubPath {theSubPath} {
+  if {[file exists "$::path/src/$theSubPath"]} {
+    return "$::path/src/$theSubPath"
+  }
+  return "$::THE_CASROOT/src/$theSubPath"
+}
+
+# Auxiliary tool comparing content of two files line-by-line.
+proc osutils:isEqualContent { theContent1 theContent2 } {
+  set aLen1 [llength $theContent1]
+  set aLen2 [llength $theContent2]
+  if { $aLen1 != $aLen2 } {
+    return false
+  }
 
-  # Setting default IDE.
-  set anTarget ""
-  switch -exact -- "$targetStation" {
-    "wnt"   {set anTarget "$::env(VCVER)"}
-    "lin"   {set anTarget "amk"}
-    "mac"   {set anTarget "cbp"}
+  for {set aLineIter 0} {$aLineIter < $aLen1} {incr aLineIter} {
+    set aLine1 [lindex $theContent1 $aLineIter]
+    set aLine2 [lindex $theContent2 $aLineIter]
+    if { $aLine1 != $aLine2 } {
+      return false
+    }
   }
+  return true
+}
+
+# Auxiliary function for writing new file content only if it has been actually changed
+# (e.g. to preserve file timestamp on no change).
+# Useful for automatically (re)generated files.
+proc osutils:writeTextFile { theFile theContent {theEol lf} } {
+  if {[file exists "${theFile}"]} {
+    set aFileOld [open "${theFile}" rb]
+    fconfigure $aFileOld -translation crlf
+    set aLineListOld [split [read $aFileOld] "\n"]
+    close $aFileOld
 
-  set isTargetDefault true
+    # append empty line for proper comparison (which will be implicitly added by last puts below)
+    set aContent $theContent
+    lappend aContent ""
+    if { [osutils:isEqualContent $aLineListOld $aContent] == true } {
+      return false
+    }
 
-  if { [set anIndex [lsearch -nocase $anArgs -target=*]] != -1 } {
-    regsub -nocase "\\-target=" [lindex $anArgs $anIndex] "" anTarget
-    set anArgs [removeAllOccurrencesOf -target=* $anArgs]
-    set isTargetDefault false
+    file delete -force "${theFile}"
   }
 
-  if { [set anIndex [lsearch -nocase $anArgs -path=*]] != -1} {
-    regsub -nocase "\\-path=" [lindex $anArgs $anIndex] "" path
-    set anArgs [removeAllOccurrencesOf -path=* $anArgs]
-    puts "Starting work with \"$path\""
+  set anOutFile [open "$theFile" "w"]
+  fconfigure $anOutFile -translation $theEol
+  foreach aLine ${theContent} {
+    puts $anOutFile "${aLine}"
   }
+  close $anOutFile
+  return true
+}
+
+# Function re-generating header files for specified text resource
+proc genResources { theResource } {
+  global path
+
+  set aResFileList {}
+  set aResourceAbsPath [file normalize "${path}/src/${theResource}"]
+  set aResourceDirectory ""
+  set isResDirectory false
 
-  if { [llength $anArgs] == 0 && $isTargetDefault == true } {
-    puts "the default \'$anTarget\' target has been applied"
+  if {[file isdirectory "${aResourceAbsPath}"]} {
+    if {[file exists "${aResourceAbsPath}/FILES"]} {
+      set aFilesFile [open "${aResourceAbsPath}/FILES" rb]
+      set aResFileList [split [read $aFilesFile] "\n"]
+      close $aFilesFile
+    }
+    set aResFileList [lsearch -inline -all -not -exact $aResFileList ""]
+    set aResourceDirectory "${theResource}"
+    set isResDirectory true
+  } else {
+    set aResourceName [file tail "${theResource}"]
+    lappend aResFileList "res:::${aResourceName}"
+    set aResourceDirectory [file dirname "${theResource}"]
   }
 
-  set isHelpRequire false
-  if { [lsearch -nocase $anArgs -h] != -1} {
-    set anArgs [removeAllOccurrencesOf -h $anArgs]
-    set isHelpRequire true
+  foreach aResFileIter ${aResFileList} {
+    if {![regexp {^[^:]+:::(.+)} "${aResFileIter}" dump aResFileIter]} {
+         continue
+       }
+
+    set aResFileName [file tail "${aResFileIter}"]
+    regsub -all {\.} "${aResFileName}" {_} aResFileName
+    set aHeaderFileName "${aResourceDirectory}_${aResFileName}.pxx"
+    if { $isResDirectory == true && [lsearch $aResFileList $aHeaderFileName] == -1 } {
+      continue
+    }
+
+    # generate
+    set aContent {}
+    lappend aContent "// This file has been automatically generated from resource file src/${aResourceDirectory}/${aResFileIter}"
+       lappend aContent ""
+
+    # generate necessary structures
+    set aLineList {}
+    if {[file exists "${path}/src/${aResourceDirectory}/${aResFileIter}"]} {
+      set anInputFile [open "${path}/src/${aResourceDirectory}/${aResFileIter}" rb]
+      fconfigure $anInputFile -translation crlf
+      set aLineList [split [read $anInputFile] "\n"]
+      close $anInputFile
+    }
+
+    # drop empty trailing line
+    set anEndOfFile ""
+    if { [lindex $aLineList end] == "" } {
+      set aLineList [lreplace $aLineList end end]
+      set anEndOfFile "\\n"
+    }
+
+    lappend aContent "static const char ${aResourceDirectory}_${aResFileName}\[\] ="
+    set aNbLines  [llength $aLineList]
+    set aLastLine [expr $aNbLines - 1]
+    for {set aLineIter 0} {$aLineIter < $aNbLines} {incr aLineIter} {
+      set aLine [lindex $aLineList $aLineIter]
+      regsub -all {\"} "${aLine}" {\\"} aLine
+      if { $aLineIter == $aLastLine } {
+        lappend aContent "  \"${aLine}${anEndOfFile}\";"
+      } else {
+        lappend aContent "  \"${aLine}\\n\""
+      }
+    }
+
+    # Save generated content to header file
+    set aHeaderFilePath "${path}/src/${aResourceDirectory}/${aHeaderFileName}"
+    if { [osutils:writeTextFile $aHeaderFilePath $aContent] == true } {
+      puts "Generating header file from resource file: ${path}/src/${aResourceDirectory}/${aResFileIter}"
+    } else {
+         #puts "Header file from resource ${path}/src/${aResourceDirectory}/${aResFileIter} is up-to-date"
+    }
+  }
+}
+
+# Function re-generating header files for all text resources
+proc genAllResources {} {
+  global path
+  set aCasRoot [file normalize $path]
+  if {![file exists "$aCasRoot/adm/RESOURCES"]} {
+    puts "OCCT directory is not defined correctly: $aCasRoot"
+    return
   }
 
-  if {$path == ""} {
-    set isHelpRequire true
+  set aFileResources [open "$aCasRoot/adm/RESOURCES" rb]
+  set anAdmResources [split [read $aFileResources] "\r\n"]
+  close $aFileResources
+  set anAdmResources [lsearch -inline -all -not -exact $anAdmResources ""]
+
+  foreach line $anAdmResources {
+    genResources "${line}"
   }
+}
+
+# Wrapper-function to generate VS project files
+proc genproj {theFormat args} {
+  set aSupportedFormats { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "vc14" "vc141" "vc142" "vclang" "cbp" "xcd" "pro"}
+  set aSupportedPlatforms { "wnt" "uwp" "lin" "mac" "ios" "qnx" }
+  set isHelpRequire false
 
-  if { [lsearch -nocase $aSupportedTargets $anTarget] == -1} {
-    puts "the \'$anTarget\' is wrong TARGET"
+  # check format argument
+  if { $theFormat == "-h" || $theFormat == "-help" || $theFormat == "--help" } {
+    set isHelpRequire true
+  } elseif { [lsearch -exact $aSupportedFormats $theFormat] < 0 } {
+    puts "Error: genproj: unrecognized project format \"$theFormat\""
     set isHelpRequire true
   }
 
-  if {[llength $anArgs] > 0} {
-    set isHelpRequire true
+  # choice of compiler for Code::Blocks, currently hard-coded
+  set aCmpl "gcc"
+
+  # Determine default platform: wnt for vc*, mac for xcd, current for cbp
+  if { [regexp "^vc" $theFormat] } {
+    set aPlatform "wnt"
+  } elseif { $theFormat == "xcd" || $::tcl_platform(os) == "Darwin" } {
+    set aPlatform "mac"
+  } elseif { $::tcl_platform(platform) == "windows" } {
+    set aPlatform "wnt"
+  } elseif { $::tcl_platform(platform) == "unix" } {
+    set aPlatform "lin"
+  }
 
-    foreach anArg $anArgs {
-      puts "genproj: unrecognized option \'$anArg\'"
+  # Check optional arguments
+  set aLibType "dynamic"
+  set aSolution "OCCT"
+  for {set anArgIter 0} {$anArgIter < [llength args]} {incr anArgIter} {
+    set arg [lindex $args $anArgIter]
+    if { $arg == "" } {
+      continue
+    } elseif { $arg == "-h" || $arg == "-help" || $arg == "--help" } {
+      set isHelpRequire true
+    } elseif { [lsearch -exact $aSupportedPlatforms $arg] >= 0 } {
+      set aPlatform $arg
+    } elseif { $arg == "-static" } {
+      set aLibType "static"
+      puts "Static build has been selected"
+    } elseif { $arg == "-dynamic" } {
+      set aLibType "dynamic"
+      puts "Dynamic build has been selected"
+    } elseif { $arg == "-solution" } {
+      incr anArgIter
+      set aSolution [lindex $args $anArgIter]
+    } else {
+      puts "Error: genproj: unrecognized option \"$arg\""
+      set isHelpRequire true
     }
   }
 
   if {  $isHelpRequire == true } {
-    puts "usage: genproj \[ -target=<TARGET> \] \[ -path=<PATH> \]
-
-    PATH: 
-      path to the project
-
-    TARGET:
-      vc8   -  Visual Studio 2005
-      vc9   -  Visual Studio 2008
-      vc10  -  Visual Studio 2010
-      vc11  -  Visual Studio 2012
-      vc12  -  Visual Studio 2013
-      cbp   -  CodeBlocks
-      amk   -  AutoMake"
-      return
+    puts "usage: genproj Format \[Platform\] \[-static\] \[-h|-help|--help\]
+
+    Format must be one of:
+      vc8      -  Visual Studio 2005
+      vc9      -  Visual Studio 2008
+      vc10     -  Visual Studio 2010
+      vc11     -  Visual Studio 2012
+      vc12     -  Visual Studio 2013
+      vc14     -  Visual Studio 2015
+      vc141    -  Visual Studio 2017
+      vc142    -  Visual Studio 2019
+      vclang   -  Visual Studio with ClangCL toolset
+      cbp      -  CodeBlocks
+      xcd      -  XCode
+      pro      -  Qt Creator
+
+    Platform (optional):
+      wnt   -  Windows Desktop
+      uwp   -  Universal Windows Platform
+      lin   -  Linux
+      mac   -  OS X
+      ios   -  iOS
+      qnx   -  QNX
+
+    Option -static can be used with XCode to build static libraries
+    "
+    return
   }
 
-  if {!$isTargetDefault} {
-    puts "the \'$anTarget\' target has been applied"
-  }
-  
-  if {"$anTarget" == "amk"} {
-    set targetStation "lin"
+  if { ! [info exists aPlatform] } {
+    puts "Error: genproj: Cannon identify default platform, please specify!"
+    return
   }
-  set anAdmPath "$path/adm"
 
-  OS:MKPRC "$anAdmPath" "$anTarget"
+  puts "Preparing to generate $theFormat projects for $aPlatform platform..."
 
-  genprojbat "$anAdmPath" "$anTarget"
-}
+  # base path to where to generate projects, hardcoded from current dir
+  set anAdmPath [file normalize "${::path}/adm"]
 
-proc genprojbat {thePath theIDE} {
-  global path
-  
-  set anOsIncPath "$path/src/OS"
-  set anOsRootPath "$path"
+  OS:MKPRC "$anAdmPath" "$theFormat" "$aLibType" "$aPlatform" "$aCmpl" "$aSolution"
 
-  set aTargetPlatform "lin"
-  if { "$::tcl_platform(platform)" == "windows" } {
-    set aTargetPlatform "wnt"
-  }
-  
-  if {[regexp {(vc)[0-9]*$} $theIDE] == 1} {
-    set aTargetPlatform wnt
-  } elseif {"$theIDE" == "amk"} {
-    set aTargetPlatform lin
+  genprojbat "$theFormat" "$aPlatform" "$aSolution"
+  genAllResources
+}
+
+# copy file providing warning if the target file exists and has 
+# different date or size; if it is newer than source, save it as .bak
+proc copy_with_warning {from to} {
+  if { [file exists "$to"] &&
+      ([file size   "$to"] != [file size  "$from"] ||
+       [file mtime  "$to"] != [file mtime "$from"]) } {
+    puts "Warning: file $to is updated (copied from $from)!"
+    if { [file mtime $to] > [file mtime $from] } {
+      puts "Info: old content of file $to is saved in ${to}.bak"
+      file copy -force -- "$to" "${to}.bak"
+    }
   }
 
+  file copy -force -- "$from" "$to"
+}
+
+# Generate auxiliary scripts for launching IDE.
+proc genprojbat {theFormat thePlatform theSolution} {
   set aTargetPlatformExt sh
-  if { "$aTargetPlatform" == "wnt" } {
+  if { $thePlatform == "wnt" || $thePlatform == "uwp" } {
     set aTargetPlatformExt bat
   }
 
-  set aBox [file normalize "$thePath/.."]
+  if {"$theFormat" != "cmake"} {
+    # copy env.bat/sh only if not yet present
+    if { ! [file exists "$::path/env.${aTargetPlatformExt}"] } {
+      set anEnvTmplFile [open "$::THE_CASROOT/adm/templates/env.${aTargetPlatformExt}" "r"]
+      set anEnvTmpl [read $anEnvTmplFile]
+      close $anEnvTmplFile
 
-  if { "$aTargetPlatform" != "wnt" } {
-    file copy -force -- "$path/adm/templates/config.h" "$aBox/src/config.h"
-  }
+      set aCasRoot ""
+      if { [file normalize "$::path"] != [file normalize "$::THE_CASROOT"] } {
+        set aCasRoot [relativePath "$::path" "$::THE_CASROOT"]
+      }
 
-  if {"$theIDE" != "cmake"} {
-    set anEnvTmplFile [open "$path/adm/templates/env.${aTargetPlatformExt}" "r"]
-    set anEnvTmpl [read $anEnvTmplFile]
-    close $anEnvTmplFile
+      regsub -all -- {__CASROOT__}   $anEnvTmpl "$aCasRoot" anEnvTmpl
 
-    set aCasRoot ""
-    if { [file normalize "$anOsRootPath"] != "$aBox" } {
-      set aCasRoot [relativePath "$aBox" "$anOsRootPath"]
+      set anEnvFile [open "$::path/env.${aTargetPlatformExt}" "w"]
+      puts $anEnvFile $anEnvTmpl
+      close $anEnvFile
     }
-    set anOsIncPath [relativePath "$aBox" "$anOsRootPath"]
 
-    regsub -all -- {__CASROOT__}   $anEnvTmpl "$aCasRoot" anEnvTmpl
-
-    set anEnvFile [open "$aBox/env.${aTargetPlatformExt}" "w"]
-    puts $anEnvFile $anEnvTmpl
-    close $anEnvFile
-
-    file copy -force -- "$path/adm/templates/draw.${aTargetPlatformExt}" "$aBox/draw.${aTargetPlatformExt}"
+    copy_with_warning "$::THE_CASROOT/adm/templates/draw.${aTargetPlatformExt}" "$::path/draw.${aTargetPlatformExt}"
   }
 
-  if {[regexp {(vc)[0-9]*$} $theIDE] == 1} {
-    file copy -force -- "$path/adm/templates/msvc.bat" "$aBox/msvc.bat"
+  set aSolShList ""
+  if { [regexp {^vc} $theFormat] } {
+    set aSolShList "msvc.bat"
   } else {
-    switch -exact -- "$theIDE" {
-      "cbp"   { file copy -force -- "$path/adm/templates/codeblocks.sh" "$aBox/codeblocks.sh" }
+    switch -exact -- "$theFormat" {
+      "cbp" {
+        set aSolShList { "codeblocks.sh" "codeblocks.bat" }
+        # Code::Blocks 16.01 does not create directory for import libs, help him
+        set aPlatformAndCompiler "${thePlatform}/gcc"
+        if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } {
+          set aPlatformAndCompiler "${thePlatform}/clang"
+        }
+        file mkdir "$::path/${aPlatformAndCompiler}/lib"
+        file mkdir "$::path/${aPlatformAndCompiler}/libd"
+      }
+      "xcd" { set aSolShList "xcode.sh" }
     }
   }
+
+  foreach aSolSh $aSolShList {
+    set anShFile [open "$::THE_CASROOT/adm/templates/${aSolSh}" "r"]
+    set anShTmpl [read $anShFile]
+    close $anShFile
+
+    regsub -all -- {__SOLUTION__} $anShTmpl "$theSolution" anShTmpl
+
+    set anShFile [open "$::path/${aSolSh}" "w"]
+    puts $anShFile $anShTmpl
+    close $anShFile
+  }
 }
 
 ###### MSVC #############################################################33
@@ -232,50 +440,38 @@ proc removeAllOccurrencesOf { theObject theList } {
   return $theList
 }
 
-proc OS:mkdir { d } {
-    global tcl_version
-    if ![file exists $d] {
-       if { "$tcl_version" == "7.5" } {
-           mkdir -path $d
-       } else {
-           file mkdir $d
-       }
-       if [file exists $d] {
-           return $d
-       } else {
-           return {}
-       }
-    } else {
-       return $d
-    }
-}
-
-# Entry function to generate project files and solutions for IDE
-proc OS:MKPRC { {theOutDir {}} {theIDE ""} } {
-  global path targetStation
-  set aSupportedIDE { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "amk" }
+set aTKNullKey "TKNull"
+set THE_GUIDS_LIST($aTKNullKey) "{00000000-0000-0000-0000-000000000000}"
 
-  if { [lsearch $aSupportedIDE $theIDE] < 0 } {
-    puts stderr "WOK does not support generation of project files for the selected IDE: $theIDE\nSupported IDEs: [join ${aSupportedIDE} " "]"
-    return
-  }
-  
+# Entry function to generate project files
+# @param theOutDir   Root directory for project files
+# @param theFormat   Project format name (vc.. for Visual Studio projects, cbp for Code::Blocks, xcd for XCode)
+# @param theLibType  Library type - dynamic or static
+# @param thePlatform Optional target platform for cross-compiling, e.g. ios for iOS
+# @param theCmpl     Compiler option (msvc or gcc)
+# @param theSolution Solution name
+proc OS:MKPRC { theOutDir theFormat theLibType thePlatform theCmpl theSolution } {
+  global path
   set anOutRoot $theOutDir
   if { $anOutRoot == "" } {
     error "Error : \"theOutDir\" is not initialized"
   }
 
   # Create output directory
-  set aWokStation "$targetStation"
-
-  if { [lsearch -exact {vc7 vc8 vc9 vc10 vc11 vc12} $theIDE] != -1 } {
+  set aWokStation "$thePlatform"
+  if { [regexp {^vc} $theFormat] } {
     set aWokStation "msvc"
   }
-
-  set anOutDir "${anOutRoot}/${aWokStation}/${theIDE}"
+  set aSuffix ""
+  set isUWP 0
+  if { $thePlatform == "uwp" } {
+    set aSuffix "-uwp"
+    set isUWP 1
+  }
+  set anOutDir "${anOutRoot}/${aWokStation}/${theFormat}${aSuffix}"
 
   # read map of already generated GUIDs
-  set aGuidsFilePath [file join $anOutDir "wok_${theIDE}_guids.txt"]
+  set aGuidsFilePath [file join $anOutDir "wok_${theFormat}_guids.txt"]
   if [file exists "$aGuidsFilePath"] {
     set aFileIn [open "$aGuidsFilePath" r]
     set aFileDataRaw [read $aFileIn]
@@ -291,14 +487,17 @@ proc OS:MKPRC { {theOutDir {}} {theIDE ""} } {
 
   # make list of modules and platforms
   set aModules [OS:init]
+  if { "$thePlatform" == "ios" } {
+    set goaway [list Draw]
+    set aModules [osutils:juststation $goaway $aModules]
+  }
 
-  # generate one solution for all projects if complete OS or VAS is processed
-  set anAllSolution "OCCT"
-
-  OS:mkdir $anOutDir
-  if { ![file exists $anOutDir] } {
-    puts stderr "Error: Could not create output directory \"$anOutDir\""
-    return
+  # Draw module is turned off due to it is not supported on UWP
+  if { $isUWP } {
+    set aDrawIndex [lsearch -exact ${aModules} "Draw"]
+    if { ${aDrawIndex} != -1 } {
+      set aModules [lreplace ${aModules} ${aDrawIndex} ${aDrawIndex}]
+    }
   }
 
   # create the out dir if it does not exist
@@ -309,23 +508,36 @@ proc OS:MKPRC { {theOutDir {}} {theIDE ""} } {
 
   # collect all required header files
   puts "Collecting required header files into $path/inc ..."
-  osutils:collectinc $aModules $path/inc $targetStation
+  osutils:collectinc $aModules $path/inc
+
+  if { "$theFormat" == "pro" } {
+    return
+  }
+
+  wokUtils:FILES:mkdir $anOutDir
+  if { ![file exists $anOutDir] } {
+    puts stderr "Error: Could not create output directory \"$anOutDir\""
+    return
+  }
 
-  # Generating project files for the selected IDE
-  switch -exact -- "$theIDE" {
+  # Generating project files for the selected format
+  switch -exact -- "$theFormat" {
     "vc7"   -
     "vc8"   -
     "vc9"   -
-    "vc10"   -
-    "vc11"   -
-    "vc12"  { OS:MKVC  $anOutDir $aModules $anAllSolution $theIDE }
-    "cbp"   { OS:MKCBP $anOutDir $aModules $anAllSolution }
-    "amk"   { OS:MKAMK $anOutDir $aModules "adm/${aWokStation}/${theIDE}"}
+    "vc10"  -
+    "vc11"  -
+    "vc12"  -
+    "vc14"  -
+    "vc141" -
+    "vc142" -
+    "vclang"   { OS:MKVC  $anOutDir $aModules $theSolution $theFormat $isUWP}
+    "cbp"      { OS:MKCBP $anOutDir $aModules $theSolution $thePlatform $theCmpl }
+    "xcd"      {
+      set ::THE_GUIDS_LIST($::aTKNullKey) "000000000000000000000000"
+      OS:MKXCD $anOutDir $aModules $theSolution $theLibType $thePlatform
+    }
   }
-  # generate config.txt file
-  #if { ${anAllSolution} == "Products" && "$targetStation" == "wnt" } {
-  #  osutils:mkCollectScript "collect_binary.cfg" "$anOutRoot/../" ${theIDE} $::env(ARCH) "release"
-  #}
 
   # Store generated GUIDs map
   set anOutFile [open "$aGuidsFilePath" "w"]
@@ -338,14 +550,14 @@ proc OS:MKPRC { {theOutDir {}} {theIDE ""} } {
 }
 
 # Function to generate Visual Studio solution and project files
-proc OS:MKVC { theOutDir {theModules {}} {theAllSolution ""} {theVcVer "vc8"} } {
+proc OS:MKVC { theOutDir theModules theAllSolution theVcVer isUWP } {
 
   puts stderr "Generating VS project files for $theVcVer"
 
   # generate projects for toolkits and separate solution for each module
   foreach aModule $theModules {
     OS:vcsolution $theVcVer $aModule $aModule $theOutDir ::THE_GUIDS_LIST
-    OS:vcproj     $theVcVer $aModule          $theOutDir ::THE_GUIDS_LIST
+    OS:vcproj     $theVcVer $isUWP   $aModule $theOutDir ::THE_GUIDS_LIST
   }
 
   # generate single solution "OCCT" containing projects from all modules
@@ -357,43 +569,39 @@ proc OS:MKVC { theOutDir {theModules {}} {theAllSolution ""} {theVcVer "vc8"} }
 }
 
 proc OS:init {{os {}}} {
-    global path
-    global env
-    global tcl_platform
-    
-    set askplat $os
-    if { "$os" == "" } {
-      set os $tcl_platform(os)
-    }
-
-    ;# Load list of OCCT modules and their definitions
-    source "$path/src/OS/Modules.tcl"
-    set Modules {}
-    foreach module [OS:Modules] {
-        set f "$path/src/OS/${module}.tcl"
-        if [file exists $f] {
-            source $f
-            lappend Modules $module
-        } else {
-            puts stderr "Definition file for module $module is not found in unit OS"
-        }
+  set askplat $os
+  set aModules {}
+  if { "$os" == "" } {
+    set os $::tcl_platform(os)
+  }
+
+  if [file exists "$::path/src/VAS/Products.tcl"] {
+    source "$::path/src/VAS/Products.tcl"
+    foreach aModuleIter [VAS:Products] {
+      set aFileTcl "$::path/src/VAS/${aModuleIter}.tcl"
+      if [file exists $aFileTcl] {
+        source $aFileTcl
+        lappend aModules $aModuleIter
+      } else {
+        puts stderr "Definition file for module $aModuleIter is not found in unit VAS"
+      }
     }
+    return $aModules
+  }
 
-    # Load list of products and their definitions
-#    set Products [woklocate -p VAS:source:Products.tcl]
-    #if { "$Products" != "" } {
-       #source "$Products"
-       #foreach product [VAS:Products] {
-           #set f [woklocate -p VAS:source:${product}.tcl]
-           #if [file exists $f] {
-               #source $f
-           #} else {
-               #puts stderr "Definition file for product $product is not found in unit VAS"
-           #}
-       #}
-    #}
+  # Load list of OCCT modules and their definitions
+  source "$::path/src/OS/Modules.tcl"
+  foreach aModuleIter [OS:Modules] {
+    set aFileTcl "$::path/src/OS/${aModuleIter}.tcl"
+    if [file exists $aFileTcl] {
+      source $aFileTcl
+      lappend aModules $aModuleIter
+    } else {
+      puts stderr "Definition file for module $aModuleIter is not found in unit OS"
+    }
+  }
 
-    return $Modules
+  return $aModules
 }
 
 # topological sort. returns a list {  {a h} {b g} {c f} {c h} {d i}  } => { d a b c i g f h }
@@ -537,13 +745,14 @@ proc osutils:tk:close { ltk } {
   set recurse {}
   foreach dir $ltk {
     set ids [LibToLink $dir]
+#    puts "osutils:tk:close($ltk) ids='$ids'"
     set eated [osutils:tk:eatpk $ids]
     set result [concat $result $eated]
     set ids [LibToLink $dir]
     set result [concat $result $ids]
 
     foreach file $eated {
-      set kds "$path/src/$file/EXTERNLIB"
+      set kds [osutils:findSrcSubPath "$file/EXTERNLIB"]
       if { [osutils:tk:eatpk $kds] !=  {} } {
         lappend recurse $file
       }
@@ -568,14 +777,13 @@ proc osutils:tk:eatpk { EXTERNLIB  } {
 # Define libraries to link using only EXTERNLIB file
 
 proc LibToLink {theTKit} {
-  global path
   regexp {^.*:([^:]+)$} $theTKit dummy theTKit
   set type [_get_type $theTKit]
   if {$type != "t" && $type != "x"} {
     return
   }
   set aToolkits {}
-  set anExtLibList [osutils:tk:eatpk "$path/src/$theTKit/EXTERNLIB"]
+  set anExtLibList [osutils:tk:eatpk [osutils:findSrcSubPath "$theTKit/EXTERNLIB"]]
   foreach anExtLib $anExtLibList {
     set aFullPath [LocateRecur $anExtLib]
     if { "$aFullPath" != "" && [_get_type $anExtLib] == "t" } {
@@ -587,16 +795,15 @@ proc LibToLink {theTKit} {
 # Search unit recursively
 
 proc LocateRecur {theName} {
-  global path
-  set theNamePath "$path/src/$theName"
+  set theNamePath [osutils:findSrcSubPath "$theName"]
   if {[file isdirectory $theNamePath]} {
     return $theNamePath
   }
   return ""
 }
 
-proc OS:genGUID { {theIDE "vc"} } {
-  if { "$theIDE" == "vc" } {
+proc OS:genGUID { {theFormat "vc"} } {
+  if { "$theFormat" == "vc" } {
     set p1 "[format %07X [expr { int(rand() * 268435456) }]][format %X [expr { int(rand() * 16) }]]"
     set p2 "[format %04X [expr { int(rand() * 6536) }]]"
     set p3 "[format %04X [expr { int(rand() * 6536) }]]"
@@ -615,9 +822,8 @@ proc OS:genGUID { {theIDE "vc"} } {
 }
 
 # collect all include file that required for theModules in theOutDir
-proc osutils:collectinc {theModules theIncPath theTargetStation} {
+proc osutils:collectinc {theModules theIncPath} {
   global path
-
   set aCasRoot [file normalize $path]
   set anIncPath [file normalize $theIncPath]
 
@@ -643,33 +849,48 @@ proc osutils:collectinc {theModules theIncPath theTargetStation} {
       }
     }
   }
-  lsort -unique $anUsedToolKits
+  set anUsedToolKits [lsort -unique $anUsedToolKits]
 
   set anUnits {}
   foreach anUsedToolKit $anUsedToolKits {
     set anUnits [concat $anUnits [osutils:tk:units $anUsedToolKit]]
   }
-  lsort -unique $anUnits
+  set anUnits [lsort -unique $anUnits]
+
+  # define copying style
+  set aCopyType "copy"
+  if { [info exists ::env(SHORTCUT_HEADERS)] } {
+    if { [string equal -nocase $::env(SHORTCUT_HEADERS) "hard"]
+      || [string equal -nocase $::env(SHORTCUT_HEADERS) "hardlink"] } {
+      set aCopyType "hardlink"
+    } elseif { [string equal -nocase $::env(SHORTCUT_HEADERS) "true"]
+            || [string equal -nocase $::env(SHORTCUT_HEADERS) "shortcut"] } {
+      set aCopyType "shortcut"
+    }
+  }
 
-  if { [info exists ::env(SHORTCUT_HEADERS)] && 
-       $::env(SHORTCUT_HEADERS) == "true" } {
+  set allHeaderFiles {}
+  if { $aCopyType == "shortcut" } {
     # template preparation
-    if { ![file exists $aCasRoot/adm/templates/header.in] } {
-      puts "template file does not exist: $aCasRoot/adm/templates/header.in"
+    if { ![file exists $::THE_CASROOT/adm/templates/header.in] } {
+      puts "template file does not exist: $::THE_CASROOT/adm/templates/header.in"
       return
     }
-    set aHeaderTmpl [wokUtils:FILES:FileToString $aCasRoot/adm/templates/header.in]
+    set aHeaderTmpl [wokUtils:FILES:FileToString $::THE_CASROOT/adm/templates/header.in]
 
     # relative anIncPath in connection with aCasRoot/src
     set aFromBuildIncToSrcPath [relativePath "$anIncPath" "$aCasRoot/src"]
 
     # create and copy short-cut header files
     foreach anUnit $anUnits {
-      set aHFiles [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.h"]
-      foreach aHeaderFile [concat [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.\[hgl\]xx"] $aHFiles] {
-        set aHeaderFileName [file tail $aHeaderFile]
+      osutils:checksrcfiles ${anUnit}
+
+      set aHFiles [_get_used_files ${anUnit} true false]
+      foreach aHeaderFile ${aHFiles} {
+        set aHeaderFileName [lindex ${aHeaderFile} 1]
+        lappend allHeaderFiles "${aHeaderFileName}"
 
-        regsub -all -- {@OCCT_HEADER_FILE@} $aHeaderTmpl "$aFromBuildIncToSrcPath/$anUnit/$aHeaderFileName" aShortCutHeaderFileContent
+        regsub -all -- {@OCCT_HEADER_FILE_CONTENT@} $aHeaderTmpl "#include \"$aFromBuildIncToSrcPath/$anUnit/$aHeaderFileName\"" aShortCutHeaderFileContent
 
         if {[file exists "$theIncPath/$aHeaderFileName"] && [file readable "$theIncPath/$aHeaderFileName"]} {
           set fp [open "$theIncPath/$aHeaderFileName" r]
@@ -687,6 +908,7 @@ proc osutils:collectinc {theModules theIncPath theTargetStation} {
               continue
             }
           }
+          file delete -force "$theIncPath/$aHeaderFileName"
         }
 
         set aShortCutHeaderFile [open "$theIncPath/$aHeaderFileName" "w"]
@@ -694,31 +916,49 @@ proc osutils:collectinc {theModules theIncPath theTargetStation} {
         puts $aShortCutHeaderFile $aShortCutHeaderFileContent
         close $aShortCutHeaderFile
       }
-    }  
+    }
   } else {
     set nbcopied 0
     foreach anUnit $anUnits {
-      set aHFiles [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.h"]
-      foreach aHeaderFile [concat [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.\[hgl\]xx"] $aHFiles] {
-        set aHeaderFileName [file tail $aHeaderFile]
+      osutils:checksrcfiles ${anUnit}
+
+      set aHFiles [_get_used_files ${anUnit} true false]
+      foreach aHeaderFile ${aHFiles} {
+        set aHeaderFileName [lindex ${aHeaderFile} 1]
+        lappend allHeaderFiles "${aHeaderFileName}"
 
         # copy file only if target does not exist or is older than original
-        set torig [file mtime $aHeaderFile]
-        if { ! [file isfile $anIncPath/$aHeaderFileName] } {
-          set tcopy 0
-        } else {
+        set torig [file mtime $aCasRoot/src/$anUnit/$aHeaderFileName]
+        set tcopy 0
+        if { [file isfile $anIncPath/$aHeaderFileName] } {
           set tcopy [file mtime $anIncPath/$aHeaderFileName]
         }
         if { $tcopy < $torig } {
           incr nbcopied
-          file copy -force $aHeaderFile $anIncPath/$aHeaderFileName
+          if { $aCopyType == "hardlink" } {
+            if { $tcopy != 0 } {
+              file delete -force "$theIncPath/$aHeaderFileName"
+            }
+            file link -hard  $anIncPath/$aHeaderFileName $aCasRoot/src/$anUnit/$aHeaderFileName
+          } else {
+            file copy -force $aCasRoot/src/$anUnit/$aHeaderFileName $anIncPath/$aHeaderFileName
+          }
         } elseif { $tcopy != $torig } {
-          puts "Warning: file $anIncPath/$aHeaderFileName is newer than $aHeaderFile, not changed!"
+          puts "Warning: file $anIncPath/$aHeaderFileName is newer than $aCasRoot/src/$anUnit/$aHeaderFileName, not changed!"
         }
       }
     }
     puts "Info: $nbcopied files updated"
   }
+
+  # remove header files not listed in FILES
+  set anIncFiles [glob -tails -nocomplain -dir ${anIncPath} "*"]
+  foreach anIncFile ${anIncFiles} {
+    if { [lsearch -exact ${allHeaderFiles} ${anIncFile}] == -1 } {
+      puts "Warning: file ${anIncPath}/${anIncFile} is not present in the sources and will be removed from ${theIncPath}"
+      file delete -force "${theIncPath}/${anIncFile}"
+    }
+  }
 }
 
 # Generate header for VS solution file
@@ -744,8 +984,13 @@ proc osutils:vcsolution:header { vcversion } {
       "# Visual Studio 2012\n"
   } elseif { "$vcversion" == "vc12" } {
     append var \
-      "Microsoft Visual Studio Solution File, Format Version 13.00\n" \
+      "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
       "# Visual Studio 2013\n"
+  } elseif { "$vcversion" == "vc14" || "$vcversion" == "vc141" || 
+             "$vcversion" == "vc142" || "$vcversion" == "vclang" } {
+    append var \
+      "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
+      "# Visual Studio 14\n"
   } else {
     puts stderr "Error: Visual Studio version $vcversion is not supported by this function!"
   }
@@ -756,10 +1001,8 @@ proc osutils:vcsolution:header { vcversion } {
 proc osutils:vcproj:ext { vcversion } {
   if { "$vcversion" == "vc7" || "$vcversion" == "vc8" || "$vcversion" == "vc9" } {
     return "vcproj"
-  } elseif { "$vcversion" == "vc10" || "$vcversion" == "vc11" || "$vcversion" == "vc12" } {
-    return "vcxproj"
   } else {
-    puts stderr "Error: Visual Studio version $vc is not supported by this function!"
+    return "vcxproj"
   }
 }
 # Generate start of configuration section of VS solution file
@@ -773,9 +1016,7 @@ proc osutils:vcsolution:config:begin { vcversion } {
       "\t\tRelease = Release\n" \
       "\tEndGlobalSection\n" \
       "\tGlobalSection(ProjectConfiguration) = postSolution\n"
-  } elseif { "$vcversion" == "vc8" || "$vcversion" == "vc9" ||
-             "$vcversion" == "vc10" || "$vcversion" == "vc11" ||
-             "$vcversion" == "vc12" } {
+  } else {
     append var \
       "Global\n" \
       "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n" \
@@ -785,8 +1026,6 @@ proc osutils:vcsolution:config:begin { vcversion } {
       "\t\tRelease|x64 = Release|x64\n" \
       "\tEndGlobalSection\n" \
       "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n"
-  } else {
-    puts stderr "Error: Visual Studio version $vcversion is not supported by this function!"
   }
   return $var
 }
@@ -799,9 +1038,7 @@ proc osutils:vcsolution:config:project { vcversion guid } {
       "\t\t$guid.Debug.Build.0 = Debug|Win32\n" \
       "\t\t$guid.Release.ActiveCfg = Release|Win32\n" \
       "\t\t$guid.Release.Build.0 = Release|Win32\n"
-  } elseif { "$vcversion" == "vc8" || "$vcversion" == "vc9" ||
-             "$vcversion" == "vc10" || "$vcversion" == "vc11" ||
-             "$vcversion" == "vc12" } {
+  } else {
     append var \
       "\t\t$guid.Debug|Win32.ActiveCfg = Debug|Win32\n" \
       "\t\t$guid.Debug|Win32.Build.0 = Debug|Win32\n" \
@@ -811,8 +1048,6 @@ proc osutils:vcsolution:config:project { vcversion guid } {
       "\t\t$guid.Debug|x64.Build.0 = Debug|x64\n" \
       "\t\t$guid.Release|x64.ActiveCfg = Release|x64\n" \
       "\t\t$guid.Release|x64.Build.0 = Release|x64\n"
-  } else {
-    puts stderr "Error: Visual Studio version $vcversion is not supported by this function!"
   }
   return $var
 }
@@ -826,16 +1061,12 @@ proc osutils:vcsolution:config:end { vcversion } {
       "\tEndGlobalSection\n" \
       "\tGlobalSection(ExtensibilityAddIns) = postSolution\n" \
       "\tEndGlobalSection\n"
-  } elseif { "$vcversion" == "vc8" || "$vcversion" == "vc9" ||
-             "$vcversion" == "vc10" || "$vcversion" == "vc11" ||
-             "$vcversion" == "vc12" } {
+  } else {
     append var \
       "\tEndGlobalSection\n" \
       "\tGlobalSection(SolutionProperties) = preSolution\n" \
       "\t\tHideSolutionNode = FALSE\n" \
       "\tEndGlobalSection\n"
-  } else {
-    puts stderr "Error: Visual Studio version $vcversion is not supported by this function!"
   }
   return $var
 }
@@ -965,37 +1196,95 @@ proc OS:vcsolution { theVcVer theSolName theModules theOutDir theGuidsMap } {
 }
 # Generate Visual Studio projects for specified version
 
-proc OS:vcproj { theVcVer theModules theOutDir theGuidsMap } {
+proc OS:vcproj { theVcVer isUWP theModules theOutDir theGuidsMap } {
   upvar $theGuidsMap aGuidsMap
 
   set aProjectFiles {}
 
   foreach aModule $theModules {
     foreach aToolKit [${aModule}:toolkits] {
-      lappend aProjectFiles [osutils:vcproj  $theVcVer $theOutDir $aToolKit     aGuidsMap]
+      lappend aProjectFiles [osutils:vcproj  $theVcVer $isUWP $theOutDir $aToolKit     aGuidsMap]
     }
     foreach anExecutable [OS:executable ${aModule}] {
-      lappend aProjectFiles [osutils:vcprojx $theVcVer $theOutDir $anExecutable aGuidsMap]
+      lappend aProjectFiles [osutils:vcprojx $theVcVer $isUWP $theOutDir $anExecutable aGuidsMap]
     }
   }
   return $aProjectFiles
 }
 # generate template name and load it for given version of Visual Studio and platform
 
-proc osutils:vcproj:readtemplate {vc isexec} {
-  set ext $vc
-  set what "$vc"
-  if { $isexec } {
-    set ext "${ext}x"
+proc osutils:vcproj:readtemplate {theVcVer isUWP isExec} {
+  set anExt $theVcVer
+  if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
+    set anExt vc10
+  }
+
+  # determine versions of runtime and toolset
+  set aVCRTVer $theVcVer 
+  set aToolset "v[string range $theVcVer 2 3]0"
+  if { $theVcVer == "vc141" } {
+    set aVCRTVer "vc14"
+    set aToolset "v141"
+  } elseif { $theVcVer == "vc142" } {
+    set aVCRTVer "vc14"
+    set aToolset "v142"
+  } elseif { $theVcVer == "vclang" } {
+    set aVCRTVer "vc14"
+    set aToolset "ClangCL"
+  }
+
+  set what "$theVcVer"
+  set aCmpl32 ""
+  set aCmpl64 ""
+  set aCharSet "Unicode"
+  if { $isExec } {
+    set anExt "${anExt}x"
     set what "$what executable"
   }
-  return [osutils:readtemplate $ext "MS VC++ project ($what)"]
+  if { "$theVcVer" == "vc10" } {
+    # SSE2 is enabled by default in vc11+, but not in vc10 for 32-bit target
+    set aCmpl32 "<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>"
+  }
+  set aTmpl [osutils:readtemplate $anExt "MS VC++ project ($what)"]
+
+  if { $isUWP } {
+    set UwpWinRt "<CompileAsWinRT>false</CompileAsWinRT>"
+    foreach bitness {32 64} {
+      set indent ""
+      if {"[set aCmpl${bitness}]" != ""} {
+        set indent "\n      "
+      }
+      set aCmpl${bitness} "[set aCmpl${bitness}]${indent}${UwpWinRt}"
+    }
+  }
+
+  set format_template "\[\\r\\n\\s\]*"
+  foreach bitness {32 64} {
+    set format_templateloc ""
+    if {"[set aCmpl${bitness}]" == ""} {
+      set format_templateloc "$format_template"
+    }
+    regsub -all -- "${format_templateloc}__VCMPL${bitness}__" $aTmpl "[set aCmpl${bitness}]" aTmpl
+  }
+
+  set aDebugInfo "no"
+  set aReleaseLnk ""
+  if { "$::HAVE_RelWithDebInfo" == "true" } {
+    set aDebugInfo "true"
+    set aReleaseLnk "\n      <OptimizeReferences>true</OptimizeReferences>\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>"
+  }
+
+  regsub -all -- {__VCVER__}     $aTmpl $aVCRTVer aTmpl
+  regsub -all -- {__VCVEREXT__}  $aTmpl $aToolset aTmpl
+  regsub -all -- {__VCCHARSET__} $aTmpl $aCharSet aTmpl
+  regsub -all -- {__VCReleasePDB__} $aTmpl $aDebugInfo aTmpl
+  regsub -all -- "${format_template}__VCLNKREL__" $aTmpl "${aReleaseLnk}" aTmpl
+
+  return $aTmpl
 }
 
 proc osutils:readtemplate {ext what} {
-  global env
-  global path
-  set loc "$path/adm/templates/template.$ext"
+  set loc "$::THE_CASROOT/adm/templates/template.$ext"
   return [wokUtils:FILES:FileToString $loc]
 }
 # Read a file in a string as is.
@@ -1009,19 +1298,20 @@ proc wokUtils:FILES:FileToString { fin } {
        return {}
     }
 }
-# List extensions of compilable files in OCCT
 
-proc osutils:compilable { } {
-  global targetStation
-  set aWokStation "$targetStation"
-  if { "$aWokStation" == "mac" } {
-    return [list .c .cxx .cpp .mm]
-  }
+# List extensions of compilable files in OCCT
+proc osutils:compilable {thePlatform} {
+  if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } { return [list .c .cxx .cpp .mm] }
   return [list .c .cxx .cpp]
 }
 
+# List extensions of header file in OCCT
+proc osutils:fileExtensionsHeaders {thePlatform} {
+  if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } { return [list .h .hxx .hpp .lxx .pxx .gxx ] }
+  return [list .h .hxx .hpp .lxx .pxx .gxx .mm ]
+}
+
 proc osutils:commonUsedTK { theToolKit } {
-  global path
   set anUsedToolKits [list]
   set aDepToolkits [LibToLink $theToolKit]
   foreach tkx $aDepToolkits {
@@ -1031,9 +1321,9 @@ proc osutils:commonUsedTK { theToolKit } {
   }
   return $anUsedToolKits
 }
-# Return the list of name *CSF_ in a EXTERNLIB description of a toolkit
 
-proc osutils:tk:hascsf { EXTERNLIB } {
+# Return the list of name *CSF_ in a EXTERNLIB description of a toolkit
+proc osutils:tk:csfInExternlib { EXTERNLIB } {
   set l [wokUtils:FILES:FileToList $EXTERNLIB]
   set lret  {STLPort}
   foreach str $l {
@@ -1044,94 +1334,180 @@ proc osutils:tk:hascsf { EXTERNLIB } {
   return $lret
 }
 
-proc osutils:csfList { theOS  theCsfMap } {
-  upvar $theCsfMap aCsfMap
+# Collect dependencies map depending on target OS (libraries for CSF_ codenames used in EXTERNLIB) .
+# @param theOS         - target OS
+# @param theCsfLibsMap - libraries  map
+# @param theCsfFrmsMap - frameworks map, OS X specific
+proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
+  upvar $theCsfLibsMap aLibsMap
+  upvar $theCsfFrmsMap aFrmsMap
 
-  unset theCsfMap
+  unset theCsfLibsMap
+  unset theCsfFrmsMap
 
-  if { "$theOS" == "wnt" } {
-    # -- WinAPI libraries
-    set aCsfMap(CSF_kernel32)   "kernel32.lib"
-    set aCsfMap(CSF_advapi32)   "advapi32.lib"
-    set aCsfMap(CSF_gdi32)      "gdi32.lib"
-    set aCsfMap(CSF_user32)     "user32.lib"
-    set aCsfMap(CSF_glu32)      "glu32.lib"
-    set aCsfMap(CSF_opengl32)   "opengl32.lib"
-    set aCsfMap(CSF_wsock32)    "wsock32.lib"
-    set aCsfMap(CSF_netapi32)   "netapi32.lib"
-    set aCsfMap(CSF_AviLibs)    "ws2_32.lib vfw32.lib"
-    set aCsfMap(CSF_OpenGlLibs) "opengl32.lib glu32.lib"
-
-    # -- 3rd-parties precompiled libraries
-    # Note: Tcl library name depends on version and is chosen by #pragma
-    set aCsfMap(CSF_QT)         "QtCore4.lib QtGui4.lib"
+  set aLibsMap(CSF_FREETYPE)  "freetype"
+  set aLibsMap(CSF_TclLibs)   "tcl8.6"
+  set aLibsMap(CSF_TclTkLibs) "tk8.6"
+  if { "$::HAVE_FREEIMAGE" == "true" } {
+    if { "$theOS" == "wnt" } {
+      set aLibsMap(CSF_FreeImagePlus) "FreeImage"
+    } else {
+      set aLibsMap(CSF_FreeImagePlus) "freeimage"
+    }
+  } elseif { "$theOS" == "wnt" } {
+    set aLibsMap(CSF_FreeImagePlus) "windowscodecs"
+  }
+  if { "$::HAVE_FFMPEG" == "true" } {
+    set aLibsMap(CSF_FFmpeg) "avcodec avformat swscale avutil"
+  }
+  if { "$::HAVE_TBB" == "true" } {
+    set aLibsMap(CSF_TBB) "tbb tbbmalloc"
+  }
+  if { "$::HAVE_VTK" == "true" } {
+    if { "$theOS" == "wnt" } {
+      set aLibsMap(CSF_VTK) [osutils:vtkCsf "wnt"]
+    } else {
+      set aLibsMap(CSF_VTK) [osutils:vtkCsf "unix"]
+    }
+  }
+  if { "$::HAVE_ZLIB" == "true" } {
+    set aLibsMap(CSF_ZLIB) "z"
+  }
+  if { "$::HAVE_LIBLZMA" == "true" } {
+    set aLibsMap(CSF_LIBLZMA) "liblzma"
+  }
+  if { "$::HAVE_E57" == "true" && "$theOS" != "wnt" } {
+    # exclude wnt, as there are different pragma lib depending on debug/release
+    set aLibsMap(CSF_E57)    "E57RefImpl"
+    set aLibsMap(CSF_xerces) "xerces-c"
+  }
 
+  if { "$theOS" == "wnt" } {
+    #  WinAPI libraries
+    set aLibsMap(CSF_kernel32)     "kernel32"
+    set aLibsMap(CSF_advapi32)     "advapi32"
+    set aLibsMap(CSF_gdi32)        "gdi32"
+    set aLibsMap(CSF_user32)       "user32 comdlg32"
+    set aLibsMap(CSF_shell32)      "shell32"
+    set aLibsMap(CSF_opengl32)     "opengl32"
+    set aLibsMap(CSF_wsock32)      "wsock32"
+    set aLibsMap(CSF_netapi32)     "netapi32"
+    set aLibsMap(CSF_winmm)        "winmm"
+    set aLibsMap(CSF_OpenGlLibs)   "opengl32"
+    if { "$::HAVE_GLES2" == "true" } {
+      set aLibsMap(CSF_OpenGlLibs) "libEGL libGLESv2"
+    }
+    set aLibsMap(CSF_psapi)        "Psapi"
+    set aLibsMap(CSF_d3d9)         "d3d9"
+
+    # the naming is different on Windows
+    set aLibsMap(CSF_TclLibs)      "tcl86"
+    set aLibsMap(CSF_TclTkLibs)    "tk86"
+
+    set aLibsMap(CSF_QT)           "QtCore4 QtGui4"
+
+    # tbb headers define different pragma lib depending on debug/release
+    set aLibsMap(CSF_TBB) ""
+
+    if { "$::HAVE_ZLIB" == "true" } {
+      set aLibsMap(CSF_ZLIB) "zlib"
+    }
   } else {
+    set aLibsMap(CSF_dl)           "dl"
+    if { "$theOS" == "mac" || "$theOS" == "ios" } {
+      set aLibsMap(CSF_objc)       "objc"
+      if { "$theOS" == "ios" } {
+        set aFrmsMap(CSF_Appkit)     "UIKit"
+        set aFrmsMap(CSF_OpenGlLibs) "OpenGLES"
+      } else {
+        set aFrmsMap(CSF_Appkit)     "AppKit"
+        set aFrmsMap(CSF_OpenGlLibs) "OpenGL"
+      }
+      set aFrmsMap(CSF_IOKit)      "IOKit"
+      set aFrmsMap(CSF_TclLibs)    "Tcl"
+      set aLibsMap(CSF_TclLibs)    ""
+      set aFrmsMap(CSF_TclTkLibs)  "Tk"
+      set aLibsMap(CSF_TclTkLibs)  ""
+      set aLibsMap(CSF_QT)         "QtCore QtGui"
+    } elseif { "$theOS" == "android" } {
+      set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"
+      set aLibsMap(CSF_androidlog) "log"
+    } else {
+      set aLibsMap(CSF_fontconfig) "fontconfig"
+      if { "$theOS" == "qnx" } {
+        # CSF_ThreadLibs - pthread API is part of libc on QNX
+        set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"
+      } else {
+        set aLibsMap(CSF_ThreadLibs) "pthread rt"
+        set aLibsMap(CSF_OpenGlLibs) "GL"
+        set aLibsMap(CSF_TclTkLibs)  "X11 tk8.6"
+        set aLibsMap(CSF_XwLibs)     "X11 Xext Xmu Xi"
+        set aLibsMap(CSF_MotifLibs)  "X11"
+      }
 
-    #-- Tcl/Tk configuration
-    set aCsfMap(CSF_TclLibs)    "tcl8.6"
-    set aCsfMap(CSF_TclTkLibs)  "X11 tk8.6"
-
-    if { "$theOS" == "lin" } {
-      set aCsfMap(CSF_ThreadLibs) "pthread rt"
-      set aCsfMap(CSF_OpenGlLibs) "GLU GL"
-
-    } elseif { "$theOS" == "mac" } {
-      set aCsfMap(CSF_objc)     "objc"
-
-      # frameworks
-      set aCsfMap(CSF_Appkit)     "Appkit"
-      set aCsfMap(CSF_IOKit)      "IOKit"
-      set aCsfMap(CSF_OpenGlLibs) "OpenGL"
-      set aCsfMap(CSF_TclLibs)    "Tcl"
-      set aCsfMap(CSF_TclTkLibs)  "Tk"
+      if { "$::HAVE_GLES2" == "true" } {
+        set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"
+      }
     }
+  }
+}
 
-    set aCsfMap(CSF_XwLibs)     "X11 Xext Xmu Xi"
-    set aCsfMap(CSF_MotifLibs)  "X11"
-
-    # variable is required for support for OCCT version that use fgtl
-    #-- FTGL (font renderer for OpenGL)
-    set aCsfMap(CSF_FTGL)       "ftgl"
-
-    #-- FreeType
-    set aCsfMap(CSF_FREETYPE)   "freetype"
+# Returns string of library dependencies for generation of Visual Studio project or make lists.
+proc osutils:vtkCsf {{theOS ""}} {
+  set aVtkVer "6.1"
 
-    #-- optional 3rd-parties
-    #-- TBB
-    set aCsfMap(CSF_TBB)            "tbb tbbmalloc"
+  set aPathSplitter ":"
+  if {"$theOS" == "wnt"} {
+    set aPathSplitter ";"
+  }
 
-    #-- FreeImage
-    set aCsfMap(CSF_FreeImagePlus)  "freeimage"
+  set anOptIncs [split $::env(CSF_OPT_INC) "$aPathSplitter"]
+  foreach anIncItem $anOptIncs {
+    if {[regexp -- "vtk-(.*)$" [file tail $anIncItem] dummy aFoundVtkVer]} {
+      set aVtkVer $aFoundVtkVer
+    }
+  }
 
-    #-- GL2PS
-    set aCsfMap(CSF_GL2PS)          "gl2ps"
+  set aLibArray [list vtkCommonCore vtkCommonDataModel vtkCommonExecutionModel vtkCommonMath vtkCommonTransforms vtkRenderingCore \
+                      vtkRenderingOpenGL  vtkFiltersGeneral vtkIOCore vtkIOImage vtkImagingCore vtkInteractionStyle]
 
-    #-- VTK
-    set aCsfMap(CSF_VTK)         "vtkCommonCore-6.1 vtkCommonDataModel-6.1 vtkCommonExecutionModel-6.1 vtkCommonMath-6.1 vtkCommonTransforms-6.1 vtkRenderingCore-6.1"
+  # Additional suffices for the libraries
+  set anIdx 0
+  foreach anItem $aLibArray {
+    lset aLibArray $anIdx $anItem-$aVtkVer
+    incr anIdx
   }
+
+  return [join $aLibArray " "]
 }
 
-proc osutils:usedOsLibs { theToolKit theOS } {
+# @param theLibsList   - dependencies (libraries  list)
+# @param theFrameworks - dependencies (frameworks list, OS X specific)
+proc osutils:usedOsLibs { theToolKit theOS theLibsList theFrameworks } {
   global path
-  set aUsedLibs [list]
+  upvar $theLibsList   aLibsList
+  upvar $theFrameworks aFrameworks
+  set aLibsList   [list]
+  set aFrameworks [list]
 
-  osutils:csfList $theOS anOsCsfList
+  osutils:csfList $theOS aLibsMap aFrmsMap
 
-  foreach element [osutils:tk:hascsf "$path/src/${theToolKit}/EXTERNLIB"] {
-    # test if variable is not setted - continue
-    if ![info exists anOsCsfList($element)] {
-      continue
+  foreach aCsfElem [osutils:tk:csfInExternlib "$path/src/${theToolKit}/EXTERNLIB"] {
+    if [info exists aLibsMap($aCsfElem)] {
+      foreach aLib [split "$aLibsMap($aCsfElem)"] {
+        if { [lsearch $aLibsList $aLib] == "-1" } {
+          lappend aLibsList $aLib
+        }
+      }
     }
-
-    foreach aLib [split "$anOsCsfList($element)"] {
-      if { [lsearch $aUsedLibs $aLib] == "-1"} {
-        lappend aUsedLibs $aLib
+    if [info exists aFrmsMap($aCsfElem)] {
+      foreach aFrm [split "$aFrmsMap($aCsfElem)"] {
+        if { [lsearch $aFrameworks $aFrm] == "-1" } {
+          lappend aFrameworks $aFrm
+        }
       }
     }
   }
-
-  return $aUsedLibs
 }
 
 # Returns liste of UD in a toolkit. tkloc is a full path wok.
@@ -1151,8 +1527,7 @@ proc osutils:tk:units { tkloc } {
 }
 
 proc osutils:justwnt { listloc } {
-  # ImageUtility is required for support for old (<6.5.4) versions of OCCT
-  set goaway [list Xdps Xw  ImageUtility WOKUnix]
+  set goaway [list Xw]
   return [osutils:juststation $goaway $listloc]
 }
 
@@ -1242,31 +1617,28 @@ proc wokUtils:FILES:wtail { f n } {
 }
 
 # Generate entry for one source file in Visual Studio 10 project file
-proc osutils:vcxproj:file { vcversion file params } {
-  append text "    <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
-  if { $params != "" } {
-    append text "      <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|Win32\'\">[string trim ${params}]  %(AdditionalOptions)</AdditionalOptions>\n"
-  }
-
-  if { $params != "" } {
-    append text "      <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|Win32\'\">[string trim ${params}]  %(AdditionalOptions)</AdditionalOptions>\n"
-  }
-
-  if { $params != "" } {
-    append text "      <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|x64\'\">[string trim ${params}]  %(AdditionalOptions)</AdditionalOptions>\n"
-  }
-
-  if { $params != "" } {
-    append text "      <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|x64\'\">[string trim ${params}]  %(AdditionalOptions)</AdditionalOptions>\n"
+proc osutils:vcxproj:cxxfile { theFile theParams } {
+  if { $theParams == "" } {
+    return "    <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\" />\n"
   }
 
+  set aParams [string trim ${theParams}]
+  append text "    <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\">\n"
+  append text "      <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|Win32\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
+  append text "      <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|Win32\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
+  append text "      <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|x64\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
+  append text "      <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|x64\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
   append text "    </ClCompile>\n"
   return $text
 }
 
+# Generate entry for one header file in Visual Studio 10 project file
+proc osutils:vcxproj:hxxfile { theFile } { return "    <ClInclude Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\" />\n" }
+
 # Generate Visual Studio 2010 project filters file
-proc osutils:vcxproj:filters { dir proj theFilesMap } {
-  upvar $theFilesMap aFilesMap
+proc osutils:vcxproj:filters { dir proj theCxxFilesMap theHxxFilesMap } {
+  upvar $theCxxFilesMap aCxxFilesMap
+  upvar $theHxxFilesMap aHxxFilesMap
 
   # header
   append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
@@ -1277,17 +1649,25 @@ proc osutils:vcxproj:filters { dir proj theFilesMap } {
   append text "    <Filter Include=\"Source files\">\n"
   append text "      <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
   append text "    </Filter>\n"
-  foreach unit $aFilesMap(units) {
+  append text "    <Filter Include=\"Header files\">\n"
+  append text "      <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
+  append text "    </Filter>\n"
+  foreach unit $aCxxFilesMap(units) {
     append text "    <Filter Include=\"Source files\\${unit}\">\n"
     append text "      <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
     append text "    </Filter>\n"
   }
+  foreach unit $aHxxFilesMap(units) {
+    append text "    <Filter Include=\"Header files\\${unit}\">\n"
+    append text "      <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
+    append text "    </Filter>\n"
+  }
   append text "  </ItemGroup>\n"
 
-  # list of files
+  # list of cxx files
   append text "  <ItemGroup>\n"
-  foreach unit $aFilesMap(units) {
-    foreach file $aFilesMap($unit) {
+  foreach unit $aCxxFilesMap(units) {
+    foreach file $aCxxFilesMap($unit) {
       append text "    <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
       append text "      <Filter>Source files\\${unit}</Filter>\n"
       append text "    </ClCompile>\n"
@@ -1295,6 +1675,21 @@ proc osutils:vcxproj:filters { dir proj theFilesMap } {
   }
   append text "  </ItemGroup>\n"
 
+  # list of hxx files
+  append text "  <ItemGroup>\n"
+  foreach unit $aHxxFilesMap(units) {
+    foreach file $aHxxFilesMap($unit) {
+      append text "    <ClInclude Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
+      append text "      <Filter>Header files\\${unit}</Filter>\n"
+      append text "    </ClInclude>\n"
+    }
+  }
+  append text "  </ItemGroup>\n"
+
+  append text "  <ItemGroup>\n"
+  append text "    <ResourceCompile Include=\"${proj}.rc\" />\n"
+  append text "  </ItemGroup>\n"
+
   # end
   append text "</Project>"
 
@@ -1307,72 +1702,24 @@ proc osutils:vcxproj:filters { dir proj theFilesMap } {
   return ${proj}.vcxproj.filters
 }
 
-# Generate Visual Studio 2011 project filters file
-proc osutils:vcx1proj:filters { dir proj theFilesMap } {
-  upvar $theFilesMap aFilesMap
+# Generate RC file content for ToolKit from template
+proc osutils:readtemplate:rc {theOutDir theToolKit} {
+  set aLoc "$::THE_CASROOT/adm/templates/template_dll.rc"
+  set aBody [wokUtils:FILES:FileToString $aLoc]
+  regsub -all -- {__TKNAM__} $aBody $theToolKit aBody
 
-  # header
-  append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
-  append text "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
-
-  # list of "filters" (units)
-  append text "  <ItemGroup>\n"
-  append text "    <Filter Include=\"Source files\">\n"
-  append text "      <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
-  append text "    </Filter>\n"
-  foreach unit $aFilesMap(units) {
-    append text "    <Filter Include=\"Source files\\${unit}\">\n"
-    append text "      <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
-    append text "    </Filter>\n"
-  }
-  append text "  </ItemGroup>\n"
-
-  # list of files
-  append text "  <ItemGroup>\n"
-  foreach unit $aFilesMap(units) {
-    foreach file $aFilesMap($unit) {
-      append text "    <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
-      append text "      <Filter>Source files\\${unit}</Filter>\n"
-      append text "    </ClCompile>\n"
-    }
-  }
-  append text "  </ItemGroup>\n"
-
-  append text "  <ItemGroup>\n"
-  append text "    <ResourceCompile Include=\"${proj}.rc\" />"
-  append text "  </ItemGroup>\n"
-
-  # end
-  append text "</Project>"
-
-  # write file
-  set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
-  fconfigure $fp -translation crlf
-  puts $fp $text
-  close $fp
-
-  return ${proj}.vcxproj.filters
-}
-
-# Generate RC file content for ToolKit from template
-proc osutils:readtemplate:rc {theOutDir theToolKit} {
-  global path
-  set aLoc "$path/adm/templates/template_dll.rc"
-  set aBody [wokUtils:FILES:FileToString $aLoc]
-  regsub -all -- {__TKNAM__} $aBody $theToolKit aBody
-
-  set aFile [open "${theOutDir}/${theToolKit}.rc" "w"]
-  fconfigure $aFile -translation lf
-  puts $aFile $aBody
-  close $aFile
-  return "${theOutDir}/${theToolKit}.rc"
-}
+  set aFile [open "${theOutDir}/${theToolKit}.rc" "w"]
+  fconfigure $aFile -translation lf
+  puts $aFile $aBody
+  close $aFile
+  return "${theOutDir}/${theToolKit}.rc"
+}
 
 # Generate Visual Studio project file for ToolKit
-proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} } } {
-  if { $theProjTmpl == {} } {set theProjTmpl [osutils:vcproj:readtemplate $theVcVer 0]}
+proc osutils:vcproj { theVcVer isUWP theOutDir theToolKit theGuidsMap } {
+  set theProjTmpl [osutils:vcproj:readtemplate $theVcVer $isUWP 0]
 
-  set l_compilable [osutils:compilable]
+  set l_compilable [osutils:compilable wnt]
   regsub -all -- {__TKNAM__} $theProjTmpl $theToolKit theProjTmpl
 
   upvar $theGuidsMap aGuidsMap
@@ -1381,30 +1728,41 @@ proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
   }
   regsub -all -- {__PROJECT_GUID__} $theProjTmpl $aGuidsMap($theToolKit) theProjTmpl
 
-  set aCommonUsedTK [list]
+  set theProjTmpl [osutils:uwp:proj $isUWP ${theProjTmpl}]
+
+  set aUsedLibs [list]
+
+  if { $isUWP } {
+    lappend aUsedLibs "WindowsApp.lib"
+  }
+
   foreach tkx [osutils:commonUsedTK  $theToolKit] {
-    lappend aCommonUsedTK "${tkx}.lib"
+    lappend aUsedLibs "${tkx}.lib"
   }
 
-  set aUsedToolKits [concat $aCommonUsedTK [osutils:usedOsLibs $theToolKit "wnt"]]
+  osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
+  foreach aLibIter $aLibs {
+    lappend aUsedLibs "${aLibIter}.lib"
+  }
 
   # correct names of referred third-party libraries that are named with suffix
   # depending on VC version
-  regsub -all -- {vc[0-9]+} $aUsedToolKits $theVcVer aUsedToolKits
+  set aVCRTVer [string range $theVcVer 0 3]
+  regsub -all -- {vc[0-9]+} $aUsedLibs $aVCRTVer aUsedLibs
 
   # and put this list to project file
-  #puts "$theToolKit requires  $aUsedToolKits"
-  if { "$theVcVer" == "vc10" || "$theVcVer" == "vc11" || "$theVcVer" == "vc12" } {
-    set aUsedToolKits [join $aUsedToolKits {;}]
+  #puts "$theToolKit requires  $aUsedLibs"
+  if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
+    set aUsedLibs [join $aUsedLibs {;}]
   }
-  regsub -all -- {__TKDEP__} $theProjTmpl $aUsedToolKits theProjTmpl
+  regsub -all -- {__TKDEP__} $theProjTmpl $aUsedLibs theProjTmpl
 
   set anIncPaths "..\\..\\..\\inc"
-  set aTKDefines ""
+#  set aTKDefines ""
   set aFilesSection ""
-  set aVcFilesX(units) ""
+  set aVcFilesCxx(units) ""
+  set aVcFilesHxx(units) ""
   set listloc [osutils:tk:units $theToolKit]
-  set resultloc [osutils:justwnt $listloc]
   if [array exists written] { unset written }
   #puts "\t1 [wokparam -v %CMPLRS_CXX_Options [w_info -f]] father"
   #puts "\t2 [wokparam -v %CMPLRS_CXX_Options] branch"
@@ -1413,9 +1771,10 @@ proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
   set fxloparamfcxx [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx f] [_get_options wnt cmplrs_cxx b]] 2]
   set fxloparamfc   [lindex [osutils:intersect3 [_get_options wnt cmplrs_c f] [_get_options wnt cmplrs_c b]] 2]
   set fxloparam ""
-  foreach fxlo $resultloc {
+  foreach fxlo $listloc {
     set xlo $fxlo
-    set aSrcFiles [osutils:tk:files $xlo osutils:compilable 0]
+    set aSrcFiles [osutils:tk:cxxfiles $xlo wnt]
+       set aHxxFiles [osutils:tk:hxxfiles $xlo wnt]
        set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx $fxlo]
     if {$fxlo_cmplrs_options_cxx == ""} {
       set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx b]
@@ -1439,17 +1798,27 @@ proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
       set needparam "$needparam $partopt"
     }
 
-    # Format of projects in vc10 and vc11 is different from vc7-9
-    if { "$theVcVer" == "vc10" || "$theVcVer" == "vc11" || "$theVcVer" == "vc12" } {
+    # Format of projects in vc10+ is different from vc7-9
+    if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
       foreach aSrcFile [lsort $aSrcFiles] {
         if { ![info exists written([file tail $aSrcFile])] } {
           set written([file tail $aSrcFile]) 1
-          append aFilesSection [osutils:vcxproj:file $theVcVer $aSrcFile $needparam]
+          append aFilesSection [osutils:vcxproj:cxxfile $aSrcFile $needparam]
         } else {
           puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
         }
-        if { ! [info exists aVcFilesX($xlo)] } { lappend aVcFilesX(units) $xlo }
-        lappend aVcFilesX($xlo) $aSrcFile
+        if { ! [info exists aVcFilesCxx($xlo)] } { lappend aVcFilesCxx(units) $xlo }
+        lappend aVcFilesCxx($xlo) $aSrcFile
+      }
+      foreach aHxxFile [lsort $aHxxFiles] {
+        if { ![info exists written([file tail $aHxxFile])] } {
+          set written([file tail $aHxxFile]) 1
+          append aFilesSection [osutils:vcxproj:hxxfile $aHxxFile]
+        } else {
+          puts "Warning : in vcproj more than one occurences for [file tail $aHxxFile]"
+        }
+        if { ! [info exists aVcFilesHxx($xlo)] } { lappend aVcFilesHxx(units) $xlo }
+        lappend aVcFilesHxx($xlo) $aHxxFile
       }
     } else {
       append aFilesSection "\t\t\t<Filter\n"
@@ -1465,15 +1834,9 @@ proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
       }
       append aFilesSection "\t\t\t</Filter>\n"
     }
-
-    # macros
-    append aTKDefines ";__${xlo}_DLL"
-    # common includes
-#    append anIncPaths ";..\\..\\..\\src\\${xlo}"
   }
 
   regsub -all -- {__TKINC__}  $theProjTmpl $anIncPaths theProjTmpl
-  regsub -all -- {__TKDEFS__} $theProjTmpl $aTKDefines theProjTmpl
   regsub -all -- {__FILES__}  $theProjTmpl $aFilesSection theProjTmpl
 
   # write file
@@ -1482,11 +1845,9 @@ proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
   puts $aFile $theProjTmpl
   close $aFile
 
-  # write filters file for vc10 and vc11
-  if { "$theVcVer" == "vc10" } {
-    lappend aVcFiles [osutils:vcxproj:filters $theOutDir $theToolKit aVcFilesX]
-  } elseif { "$theVcVer" == "vc11" || "$theVcVer" == "vc12" } {
-    lappend aVcFiles [osutils:vcx1proj:filters $theOutDir $theToolKit aVcFilesX]
+  # write filters file for vc10+
+  if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
+    lappend aVcFiles [osutils:vcxproj:filters $theOutDir $theToolKit aVcFilesCxx aVcFilesHxx]
   }
 
   # write resource file
@@ -1518,26 +1879,15 @@ proc osutils:tk:loadunit { loc map } {
   return
 }
 
-# Returns the list of all compilable files name in a toolkit, or devunit of any type
-# Call unit filter on units name to accept or reject a unit
-# Tfiles lists for each unit the type of file that can be compiled.
-proc osutils:tk:files { tkloc  {l_compilable {} } {justail 1} {unitfilter {}} } {
-  global path
+# Returns the list of all files name in a toolkit within specified list of file extensions.
+proc osutils:tk:files { tkloc theExtensions } {
   set Tfiles(source,nocdlpack)     {source pubinclude}
   set Tfiles(source,toolkit)       {}
   set Tfiles(source,executable)    {source pubinclude}
   set listloc [concat [osutils:tk:units $tkloc] $tkloc]
   #puts " listloc = $listloc"
-  if { $l_compilable == {} } {
-    set l_comp [list .c .cxx .cpp]
-  } else {
-    set l_comp [$l_compilable]
-  }
-  if { $unitfilter == {} } {
-    set resultloc $listloc
-  } else {
-    set resultloc [$unitfilter $listloc]
-  }
+
+  set resultloc $listloc
   set lret {}
   foreach loc $resultloc {
     set utyp [_get_type $loc]
@@ -1546,6 +1896,7 @@ proc osutils:tk:files { tkloc  {l_compilable {} } {justail 1} {unitfilter {}} }
          "t" { set utyp "toolkit" }
          "n" { set utyp "nocdlpack" }
          "x" { set utyp "executable" }
+         default { error "Error: Cannot determine type of unit $loc, check adm/UDLIST!" }
     }
     if [array exists map] { unset map }
     osutils:tk:loadunit $loc map
@@ -1560,16 +1911,8 @@ proc osutils:tk:files { tkloc  {l_compilable {} } {justail 1} {unitfilter {}} }
       #puts $type
       foreach f $map($type) {
         #puts $f
-        if { [lsearch $l_comp [file extension $f]] != -1 } {
-          if { $justail == 1 } {
-            if {$type == "source"} {
-              if {[lsearch $lret "@top_srcdir@/src/$loc/[file tail $f]"] == -1} {
-                lappend lret @top_srcdir@/src/$loc/[file tail $f]
-              }
-            }
-          } else {
-            lappend lret $f
-          }
+        if { [lsearch $theExtensions [file extension $f]] != -1 } {
+          lappend lret $f
         }
       }
     }
@@ -1577,18 +1920,20 @@ proc osutils:tk:files { tkloc  {l_compilable {} } {justail 1} {unitfilter {}} }
   return $lret
 }
 
+# Returns the list of all compilable files name in a toolkit.
+proc osutils:tk:cxxfiles { tkloc thePlatform } { return [osutils:tk:files $tkloc [osutils:compilable $thePlatform]] }
+
+# Returns the list of all header files name in a toolkit.
+proc osutils:tk:hxxfiles { tkloc thePlatform } { return [osutils:tk:files $tkloc [osutils:fileExtensionsHeaders $thePlatform]] }
+
 # Generate Visual Studio project file for executable
-proc osutils:vcprojx { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} } } {
-  global path
+proc osutils:vcprojx { theVcVer isUWP theOutDir theToolKit theGuidsMap } {
   set aVcFiles {}
-  foreach f [osutils:tk:files $theToolKit osutils:compilable 0] {
-    if { $theProjTmpl == {} } {
-      set aProjTmpl [osutils:vcproj:readtemplate $theVcVer 1]
-    } else {
-      set aProjTmpl $theProjTmpl
-    }
+  foreach f [osutils:tk:cxxfiles $theToolKit wnt] {
+    set aProjTmpl [osutils:vcproj:readtemplate $theVcVer $isUWP 1]
+
     set aProjName [file rootname [file tail $f]]
-    set l_compilable [osutils:compilable]
+    set l_compilable [osutils:compilable wnt]
     regsub -all -- {__XQTNAM__} $aProjTmpl $aProjName aProjTmpl
 
     upvar $theGuidsMap aGuidsMap
@@ -1597,40 +1942,38 @@ proc osutils:vcprojx { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
     }
     regsub -all -- {__PROJECT_GUID__} $aProjTmpl $aGuidsMap($aProjName) aProjTmpl
 
-    set aCommonUsedTK [list]
+    set aUsedLibs [list]
     foreach tkx [osutils:commonUsedTK  $theToolKit] {
-      lappend aCommonUsedTK "${tkx}.lib"
+      lappend aUsedLibs "${tkx}.lib"
     }
 
-    set aUsedToolKits [concat $aCommonUsedTK [osutils:usedOsLibs $theToolKit "wnt"]]
-       #puts "\t 7 $WOKSteps_exec_link($theToolKit)"
-    if { [regexp {WOKStep_DLLink} [_get_options wnt WOKSteps_exec_link $theToolKit]] || [regexp {WOKStep_Libink} [_get_options wnt WOKSteps_exec_link $theToolKit]] } {
-      set aUsedToolKits [concat $aUsedToolKits "\/dll"]
-      set binext 2
-    } else {
-      set binext 1
+    osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
+    foreach aLibIter $aLibs {
+      lappend aUsedLibs "${aLibIter}.lib"
     }
 
     # correct names of referred third-party libraries that are named with suffix
     # depending on VC version
-    regsub -all -- {vc[0-9]+} $aUsedToolKits $theVcVer aUsedToolKits
+    set aVCRTVer [string range $theVcVer 0 3]
+    regsub -all -- {vc[0-9]+} $aUsedLibs $aVCRTVer aUsedLibs
 
-#    puts "$aProjName requires  $aUsedToolKits"
-    if { "$theVcVer" == "vc10" || "$theVcVer" == "vc11" || "$theVcVer" == "vc12" } {
-      set aUsedToolKits [join $aUsedToolKits {;}]
+#    puts "$aProjName requires  $aUsedLibs"
+    if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
+      set aUsedLibs [join $aUsedLibs {;}]
     }
-    regsub -all -- {__TKDEP__} $aProjTmpl $aUsedToolKits aProjTmpl
+    regsub -all -- {__TKDEP__} $aProjTmpl $aUsedLibs aProjTmpl
 
     set aFilesSection ""
-    set aVcFilesX(units) ""
+    set aVcFilesCxx(units) ""
+       set aVcFilesHxx(units) ""
 
     if { ![info exists written([file tail $f])] } {
       set written([file tail $f]) 1
 
-      if { "$theVcVer" == "vc10" || "$theVcVer" == "vc11" || "$theVcVer" == "vc12" } {
-        append aFilesSection [osutils:vcxproj:file $theVcVer $f ""]
-        if { ! [info exists aVcFilesX($theToolKit)] } { lappend aVcFilesX(units) $theToolKit }
-        lappend aVcFilesX($theToolKit) $f
+      if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
+        append aFilesSection [osutils:vcxproj:cxxfile $f ""]
+        if { ! [info exists aVcFilesCxx($theToolKit)] } { lappend aVcFilesCxx(units) $theToolKit }
+        lappend aVcFilesCxx($theToolKit) $f
       } else {
         append aFilesSection "\t\t\t<Filter\n"
         append aFilesSection "\t\t\t\tName=\"$theToolKit\"\n"
@@ -1642,17 +1985,12 @@ proc osutils:vcprojx { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
       puts "Warning : in vcproj there are than one occurences for [file tail $f]"
     }
     #puts "$aProjTmpl $aFilesSection"
-    set aTKDefines ";__${theToolKit}_DLL"
     set anIncPaths "..\\..\\..\\inc"
     regsub -all -- {__TKINC__}  $aProjTmpl $anIncPaths    aProjTmpl
-    regsub -all -- {__TKDEFS__} $aProjTmpl $aTKDefines    aProjTmpl
     regsub -all -- {__FILES__}  $aProjTmpl $aFilesSection aProjTmpl
-    regsub -all -- {__CONF__}   $aProjTmpl $binext        aProjTmpl
-    if { $binext == 2 } {
-      regsub -all -- {__XQTEXT__} $aProjTmpl "dll" aProjTmpl
-    } else {
-      regsub -all -- {__XQTEXT__} $aProjTmpl "exe" aProjTmpl
-    }
+    regsub -all -- {__CONF__}   $aProjTmpl Application    aProjTmpl
+
+    regsub -all -- {__XQTEXT__} $aProjTmpl "exe" aProjTmpl
 
     set aFile [open [set aVcFilePath [file join $theOutDir ${aProjName}.[osutils:vcproj:ext $theVcVer]]] w]
     fconfigure $aFile -translation crlf
@@ -1663,22 +2001,29 @@ proc osutils:vcprojx { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
     lappend aVcFiles $aVcFilePath
 
     # write filters file for vc10
-    if { "$theVcVer" == "vc10" || "$theVcVer" == "vc11" || "$theVcVer" == "vc12" } {
-      lappend aVcFiles [osutils:vcxproj:filters $theOutDir $aProjName aVcFilesX]
+    if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
+      lappend aVcFiles [osutils:vcxproj:filters $theOutDir $aProjName aVcFilesCxx aVcFilesHxx]
     }
 
+    # write resource file
+    lappend aVcFiles [osutils:readtemplate:rc $theOutDir $aProjName]
+
     set aCommonSettingsFileTmpl ""
-    if { "$theVcVer" == "vc9" } {
-      set aCommonSettingsFileTmpl "$path/adm/templates/vcproj.user.vc9x"
-    } elseif { "$theVcVer" == "vc10" } {
-      set aCommonSettingsFileTmpl "$path/adm/templates/vcxproj.user.vc10x"
-    } elseif { "$theVcVer" == "vc11" } {
-      set aCommonSettingsFileTmpl "$path/adm/templates/vcxproj.user.vc11x"
-    } elseif { "$theVcVer" == "vc12" } {
-      set aCommonSettingsFileTmpl "$path/adm/templates/vcxproj.user.vc12x"
+    if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" } {
+      # nothing
+    } elseif { "$theVcVer" == "vc9" } {
+      set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcproj.user.vc9x"]
+    } else {
+      set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcxproj.user.vc10x"]
     }
     if { "$aCommonSettingsFileTmpl" != "" } {
-      file copy -force -- "$aCommonSettingsFileTmpl" "$aCommonSettingsFile"
+      regsub -all -- {__VCVER__} $aCommonSettingsFileTmpl $aVCRTVer aCommonSettingsFileTmpl
+
+      set aFile [open [set aVcFilePath "$aCommonSettingsFile"] w]
+      fconfigure $aFile -translation crlf
+      puts $aFile $aCommonSettingsFileTmpl
+      close $aFile
+
       lappend aVcFiles "$aCommonSettingsFile"
     }
   }
@@ -1750,46 +2095,6 @@ proc osutils:vcproj:file { theVcVer theFile theOptions } {
   return $aText
 }
 
-### AUTOMAKE ###############################################################################
-proc OS:MKAMK { theOutDir {theModules {}} theSubPath} {
-  global path
-  wokUtils:FILES:mkdir $theOutDir
-
-  foreach aModule $theModules {
-    foreach aToolKit [$aModule:toolkits] {
-      puts " toolkit: $aToolKit ==> $path/src/$aToolKit/EXTERNLIB"
-      wokUtils:FILES:rmdir $theOutDir/$aToolKit
-      wokUtils:FILES:mkdir $theOutDir/$aToolKit
-      osutils:tk:mkam $theOutDir/$aToolKit $aToolKit
-    }
-    foreach anExecutable [OS:executable $aModule] {
-      wokUtils:FILES:rmdir $theOutDir/$anExecutable
-      wokUtils:FILES:mkdir $theOutDir/$anExecutable
-      osutils:tk:mkamx $theOutDir/$anExecutable $anExecutable
-    }
-  }
-  osutils:am:adm $theOutDir $theModules
-  osutils:am:root $path $theSubPath $theModules
-
-  puts "The automake files are stored in the $theOutDir directory"
-}
-
-proc wokUtils:FILES:rmdir { d } {
-    global env
-    global tcl_platform tcl_version  
-    regsub -all {\.[^.]*} $tcl_version "" major
-    if { $major == 8 } {
-       file delete -force $d
-    } else {
-       if { "$tcl_platform(platform)" == "unix" } {
-           catch { exec rm -rf $d}
-       } else {
-           
-       }
-    }
-    return 
-}
-
 proc wokUtils:FILES:mkdir { d } {
     global tcl_version
     regsub -all {\.[^.]*} $tcl_version "" major
@@ -1811,54 +2116,9 @@ proc wokUtils:FILES:mkdir { d } {
     }
 }
 
-# "Nice letter: %s" { a b c } => {Nice letter: %a}  {Nice letter: %b} ..
-# as a string without backslash
-proc wokUtils:EASY:FmtSimple1 { fmt l {backslh 1} } {
-    foreach e $l {
-       if { $backslh } {
-           append str [format $fmt $e] "\n"
-       } else {
-           append str [format $fmt $e]
-       }
-    }
-    return $str
-}
-
-# edit_last is performed ONCE fmt has been applied.
-proc wokUtils:EASY:FmtString2 { fmt l {yes_for_last 0} {edit_last {}} } {
-    set ldeb [lrange $l 0 [expr [llength $l] -2]]
-    set last [lrange $l end end]
-    foreach e $ldeb {
-       append str [format $fmt $e $e] " \\" "\n"
-    }
-
-    if {$edit_last != {} } {
-       set slast [$edit_last [format $fmt $last $last]]
-    } else {
-       set slast [format $fmt $last $last]
-    }
-
-    if { $yes_for_last } {
-       append str $slast " \\" "\n" 
-    } else {
-       append str $slast "\n"
-    }
-
-    return $str
-}
-
-# { a.x b.c c.v } => { a b c}
-proc wokUtils:LIST:sanspoint { l } {
-    set rr {}
-    foreach x $l {
-       lappend rr [file root $x]
-    }
-    return $rr
-}
-
 # remove from listloc OpenCascade units indesirables on Unix
 proc osutils:justunix { listloc } {
-  if { "$::tcl_platform(os)" == "Darwin" && "$::MACOSX_USE_GLX" != "true" } {
+  if { "$::tcl_platform(os)" == "Darwin" } {
     set goaway [list Xw WNT]
   } else {
     set goaway [list WNT]
@@ -1866,663 +2126,16 @@ proc osutils:justunix { listloc } {
   return [osutils:juststation $goaway $listloc]
 }
 
-# remove ":" from last item of dependencies list in target VPATH of Makefile.am
-proc osutils:am:__VPATH__lastoccur { str } {
-  if { [regsub {:$} $str "" u] != 0 } {
-    return $u
-  }
-}
-
-#  ((((((((((((( Formats in Makefile.am )))))))))))))
-# Used to replace the string __VPATH__ in Makefile.am
-# l is the list of the units in a toolkit.
-proc osutils:am:__VPATH__ { l } {
-  set fmt "@top_srcdir@/src/%s:"
-  return [wokUtils:EASY:FmtString2 $fmt $l 0 osutils:am:__VPATH__lastoccur]
-}
-
-# Used to replace the string __INCLUDES__ in Makefile.am
-# l is the list of packages in a toolkit.
-proc osutils:am:__INCLUDES__ { l } {
-  set fmt "-I@top_srcdir@/src/%s"
-  return [wokUtils:EASY:FmtString2 $fmt $l]
-}
-
-# Used to replace the string __LIBADD__ in Makefile.am
-# l is the toolkit closure list of a toolkit.
-proc osutils:am:__LIBADD__ { theIncToolkits {final 0} } {
-  global path
-  global fBranch
-  set aFatherModules ""
-  set aCurrentWorkBench [file tail $path]
-  if { $fBranch != "" } {
-    set fd [open $fBranch/adm/UDLIST rb]
-    set fileContent [split [read $fd] "\n"]
-    close $fd
-    set ftoolkits [lsearch -all -inline $fileContent "t *"]
-    foreach ft $ftoolkits {
-      set aFatherModules "$aFatherModules [string range $ft 2 end]"
-    }
-  }
-  set aLibString ""
-  foreach aIncToolkit $theIncToolkits {
-    if { [lsearch [split $aFatherModules " "] $aIncToolkit] != -1} {
-      append aLibString " \\\n-l$aIncToolkit"
-    } else {
-      append aLibString " \\\n../$aIncToolkit/lib$aIncToolkit.la"
-    }
-  }
-  return $aLibString
-}
-
-# Used to replace the string __SOURCES__ in Makefile.am
-# l is the list of all compilable files in a toolkit.
-proc osutils:am:__SOURCES__ { l } {
-  set fmt "%s"
-  return [wokUtils:EASY:FmtString1 $fmt $l]
-}
-
-proc osutils:am:__CXXFLAG__ { l } {
-  set fmt "%s"
-  return [wokUtils:EASY:FmtString1 $fmt [osutils:am:PkCXXOption $l]]
-}
-
-proc osutils:am:PkCXXOption { ppk } {
-  global path
-  #puts "\t 1 [lindex [wokparam -e  %CMPLRS_CXX_Options [wokcd]] 0]"
-  set CXXCOMMON [_get_options lin cmplrs_cxx b]
-  #puts "\t 2 [wokparam -v %CMPLRS_CXX_Options [w_info -f]]"
-  #puts "\t 3 [wokparam -v %CMPLRS_CXX_Options]"
-  set FoundFlag "[lindex [osutils:intersect3 [split [_get_options lin cmplrs_cxx f]] [split [_get_options lin cmplrs_cxx b]] ] 2]"
-  foreach pk $ppk {
-    #puts $pk
-       if {![file isdirectory $path/src/$pk]} {
-         continue
-       }
-    set src_files [_get_used_files $pk false]
-    set only_src_files {}
-    foreach s $src_files { 
-      regexp {source ([^\s]+)} $s dummy name
-      lappend only_src_files $name
-    }
-    if {[lsearch $only_src_files ${pk}_CMPLRS.edl] != "-1"} {
-      set pk_cmplrs_cxx [_get_options lin cmplrs_cxx $pk]
-      if {$pk_cmplrs_cxx == ""} {
-           set pk_cmplrs_cxx [_get_options lin cmplrs_cxx b]
-         }
-      set CXXStr  $pk_cmplrs_cxx
-         #puts "\t 4 [wokparam -e %CMPLRS_CXX_Options [woklocate -u $pk]] $pk"
-      set LastIndex [expr {[string length $CXXCOMMON ] - 1}]
-      if {[string equal $CXXCOMMON [string range $CXXStr 0 $LastIndex]]} {
-        set CXXOption " "
-      } else {
-        set CXXOption [string range $CXXStr 0 [expr {[string last $CXXCOMMON $CXXStr] - 1}]]
-      }
-      if {$CXXOption != " " && $CXXOption != "" && $CXXOption != "  " && $CXXOption != "   "} {
-        set FoundList [split $CXXOption " "]
-        foreach elem $FoundList {
-          if {$elem != ""} {
-            if {[string first "-I" $elem] == "-1"  } {
-              if {[string first $elem $FoundFlag] == "-1"} {
-                set FoundFlag "$FoundFlag $elem"
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-  return $FoundFlag
-}
-
-# Create in dir the Makefile.am associated with toolkit tkloc.
-# Returns the full path of the created file.
-proc osutils:tk:mkam { dir tkloc } {
-  global path
-  set pkgs $path/src/${tkloc}/PACKAGES
-  if { ![file exists $pkgs] } {
-    puts stderr "osutils:tk:mkam : Error. File PACKAGES not found for toolkit $tkloc."
-    return {}
-  }
-
-  set tmplat [osutils:readtemplate mam "Makefile.am"]
-  set lpkgs  [osutils:justunix [wokUtils:FILES:FileToList $pkgs]]
-  set close  [wokUtils:LIST:Purge [osutils:tk:close $tkloc]]
-  set lsrc   [lsort [osutils:tk:files $tkloc osutils:compilable 1 osutils:justunix]]
-  set lobj   [wokUtils:LIST:sanspoint $lsrc]
-
-  set lcsf   [osutils:tk:hascsf $path/src/${tkloc}/EXTERNLIB]
-
-  set final 0
-  set externinc ""
-  set externlib ""
-  if { $lcsf != {} } {
-    set final 1
-    set fmtinc "\$(%s_INCLUDES) "
-    set fmtlib "\$(%s_LIB) "
-    set externinc [wokUtils:EASY:FmtSimple1 $fmtinc $lcsf 0]
-    set externlib [wokUtils:EASY:FmtSimple1 $fmtlib $lcsf 0]
-  }
-
-  regsub -all -- {__TKNAM__} $tmplat $tkloc tmplat
-  set vpath [osutils:am:__VPATH__ $lpkgs]
-  regsub -all -- {__VPATH__} $tmplat $vpath tmplat
-  set inclu [osutils:am:__INCLUDES__ $lpkgs]
-  regsub -all -- {__INCLUDES__} $tmplat $inclu tmplat
-  if { $close != {} } {
-    set libadd [osutils:am:__LIBADD__ $close $final]
-  } else {
-    set libadd ""
-  }
-  regsub -all -- {__LIBADD__} $tmplat $libadd tmplat
-  set source [osutils:am:__SOURCES__ $lsrc]
-  regsub -all -- {__SOURCES__} $tmplat $source tmplat
-  regsub -all -- {__EXTERNINC__} $tmplat $externinc tmplat
-  set CXXFl [osutils:am:__CXXFLAG__ $lpkgs]
-  regsub -all -- {__CXXFLAG__} $tmplat $CXXFl tmplat
-  set CFl [osutils:am:__CFLAG__ $lpkgs]
-  regsub -all -- {__CFLAG__} $tmplat $CFl tmplat
-
-  regsub -all -- {__EXTERNLIB__} $tmplat $externlib tmplat
-
-  wokUtils:FILES:StringToFile $tmplat [set fmam [file join $dir Makefile.am]]
-  return [list $fmam]
-}
-
-# Write a string in a file
-proc wokUtils:FILES:StringToFile { str path } {
-    if { [catch { set out [ open $path w ] } errout] == 0 } {
-       puts -nonewline $out $str
-       close $out
-       return 1
-    } else {
-       return {}
-    }
-}
-
-# Create in dir the Makefile.am associated with toolkit tkloc.
-# Returns the full path of the created file.
-proc osutils:tk:mkamx { dir tkloc } {
-  global path
-  set src_files [_get_used_files $tkloc false]
-  set only_src_files {}
-  foreach s $src_files { 
-    regexp {source ([^\s]+)} $s dummy name
-    lappend only_src_files $name
-  }
-  if { [lsearch $only_src_files ${tkloc}_WOKSteps.edl] != "-1"} {
-    set pkgs "$path/src/${tkloc}/EXTERNLIB"
-    if { $pkgs == {} } {
-      puts stderr "osutils:tk:mkamx : Error. File EXTERNLIB not found for executable $tkloc."
-      #return {}
-    }
-    set tmplat [osutils:readtemplate mamx "Makefile.am (executable)"]
-    set close  [wokUtils:LIST:Purge [osutils:tk:close $tkloc]]
-    set lsrc   [lsort [osutils:tk:files $tkloc osutils:compilable 1 osutils:justunix]]
-    set lobj   [wokUtils:LIST:sanspoint $lsrc]
-    set CXXList {}
-    foreach SourceFile $only_src_files {
-      if {[file extension $SourceFile] == ".cxx"} {
-        lappend CXXList [file rootname $SourceFile]
-      }
-    }
-    set pkgs [LibToLinkX $tkloc [lindex $CXXList 0]]
-    set lpkgs  [osutils:justunix [wokUtils:FILES:FileToList $pkgs]]
-    puts "pkgs $pkgs"
-    #set lcsf   [osutils:tk:hascsf [woklocate -p ${tkloc}:source:EXTERNLIB [wokcd]]]
-
-    set lcsf {}
-    foreach tk $pkgs {
-      foreach element [osutils:tk:hascsf "$path/src/${tk}/EXTERNLIB"] {
-        if {[lsearch $lcsf $element] == "-1"} {
-          set lcsf [concat $lcsf $element]
-        }
-      }
-    }
-    set final 0
-    set externinc ""
-    set externlib ""
-    if { $lcsf != {} } {
-      set final 1
-      set fmtinc "\$(%s_INCLUDES) "
-      set fmtlib "\$(%s_LIB) "
-      set externinc [wokUtils:EASY:FmtSimple1 $fmtinc $lcsf 0]
-      set externlib [wokUtils:EASY:FmtSimple1 $fmtlib $lcsf 0]
-    }
-    regsub -all -- {__XQTNAM__} $tmplat $tkloc tmplat
-    set tmplat "$tmplat \nlib_LTLIBRARIES="
-    foreach entity $CXXList {
-      set tmplat "$tmplat lib${entity}.la"
-    }
-    set tmplat "$tmplat\n"
-    set inclu [osutils:am:__INCLUDES__ $lpkgs]
-    regsub -all -- {__INCLUDES__} $tmplat $inclu tmplat
-    if { $pkgs != {} } {
-      set libadd [osutils:am:__LIBADD__ $pkgs $final]
-    } else {
-      set libadd ""
-    }
-    regsub -all -- {__LIBADD__} $tmplat $libadd tmplat
-    set source [osutils:am:__SOURCES__ $CXXList]
-    regsub -all -- {__SOURCES__} $tmplat $source tmplat
-    regsub -all -- {__EXTERNINC__} $tmplat $externinc tmplat
-    foreach entity $CXXList {
-      set tmplat "$tmplat lib${entity}_la_SOURCES = @top_srcdir@/src/${tkloc}/${entity}.cxx \n"
-    }
-    foreach entity $CXXList {
-      set tmplat "$tmplat lib${entity}_la_LIBADD = $libadd $externlib \n"
-    }
-    wokUtils:FILES:StringToFile $tmplat [set fmam [file join $dir Makefile.am]]
-
-    unset tmplat
-
-    return [list $fmam]
-
-  } else {
-    set pkgs "$path/src/${tkloc}/EXTERNLIB"
-    if { $pkgs == {} } {
-      puts stderr "osutils:tk:mkamx : Error. File EXTERNLIB not found for executable $tkloc."
-      #return {}
-    }
-    set tmplat [osutils:readtemplate mamx "Makefile.am (executable)"]
-    set close  [wokUtils:LIST:Purge [osutils:tk:close $tkloc]]
-    set lsrc   [lsort [osutils:tk:files $tkloc osutils:compilable 1 osutils:justunix]]
-    set lobj   [wokUtils:LIST:sanspoint $lsrc]
-    set CXXList {}
-    foreach SourceFile $only_src_files {
-      if {[file extension $SourceFile] == ".cxx"} {
-        lappend CXXList [file rootname $SourceFile]
-      }
-    }
-    set pkgs [LibToLinkX $tkloc [lindex $CXXList 0]]
-    set lpkgs  [osutils:justunix [wokUtils:FILES:FileToList $pkgs]]
-    set lcsf   [osutils:tk:hascsf "$path/src/${tkloc}/EXTERNLIB"]
-
-    set lcsf {}
-    foreach tk $pkgs {
-      foreach element [osutils:tk:hascsf "$path/src/${tk}/EXTERNLIB"] {
-        if {[lsearch $lcsf $element] == "-1"} {
-          set lcsf [concat $lcsf $element]
-        }
-      }
-    }
-    set final 0
-    set externinc ""
-    set externlib ""
-    if { $lcsf != {} } {
-      set final 1
-      set fmtinc "\$(%s_INCLUDES) "
-      set fmtlib "\$(%s_LIB) "
-      set externinc [wokUtils:EASY:FmtSimple1 $fmtinc $lcsf 0]
-      set externlib [wokUtils:EASY:FmtSimple1 $fmtlib $lcsf 0]
-    }
-    regsub -all -- {__XQTNAM__} $tmplat $tkloc tmplat
-    set tmplat "$tmplat \nbin_PROGRAMS="
-    foreach entity $CXXList {
-      set tmplat "${tmplat} ${entity}"
-    }
-
-    set tmplat "${tmplat}\n"
-    set inclu [osutils:am:__INCLUDES__ $lpkgs]
-    regsub -all -- {__INCLUDES__} $tmplat $inclu tmplat
-    if { $pkgs != {} } {
-      set libadd [osutils:am:__LIBADD__ $pkgs $final]
-    } else {
-      set libadd ""
-    }
-    set source [osutils:am:__SOURCES__ $CXXList]
-    regsub -all -- {__SOURCES__} $tmplat $source tmplat
-    regsub -all -- {__EXTERNINC__} $tmplat $externinc tmplat
-    foreach entity $CXXList {
-      set tmplat "$tmplat ${entity}_SOURCES = @top_srcdir@/src/${tkloc}/${entity}.cxx \n"
-    }
-    foreach entity $CXXList {
-      set tmplat "$tmplat ${entity}_LDADD = $libadd $externlib \n"
-    }
-    wokUtils:FILES:StringToFile $tmplat [set fmam [file join $dir Makefile.am]]
-
-    return [list $fmam]
-  }
-}
-
-# Create in dir the Makefile.am in $dir directory.
-# Returns the full path of the created file.
-proc osutils:am:adm { dir {lesmodules {}} } {
-  set amstring "srcdir = @srcdir@\n\n"
-  set subdirs "SUBDIRS ="
-  set vpath "VPATH = @srcdir@ ${dir}: "
-  set make ""
-  set phony ".PHONY:"
-  foreach theModule $lesmodules {
-    set units [osutils:tk:sort [$theModule:toolkits]]
-    set units [concat $units [OS:executable $theModule]]
-    append amstring "${theModule}_PKGS ="
-    append vpath "\\\n"
-    foreach unit $units {
-      append amstring " ${unit}"
-      append vpath "${dir}/${unit}: "
-    }
-    set up ${theModule}
-    if { [info procs ${theModule}:alias] != "" } {
-      set up [${theModule}:alias]
-    }
-    set up [string toupper ${up}]
-    append amstring "\n\nif ENABLE_${up}\n"
-    append amstring "  ${theModule}_DIRS = \$(${theModule}_PKGS)\n"
-    append amstring "else\n"
-    append amstring "  ${theModule}_DIRS = \n"
-    append amstring "endif\n\n"
-    append subdirs " \$(${theModule}_DIRS)"
-    append make "${theModule}:\n"
-    append make "\tfor d in \$(${theModule}_PKGS); do \\\n"
-    append make "\t\tcd \$\$d; \$(MAKE) \$(AM_MAKEFLAGS) lib\$\$d.la; cd ..; \\\n"
-    append make "\tdone\n\n"
-    append phony " ${theModule}"
-  }
-  append amstring "$subdirs\n\n"
-  append amstring "$vpath\n\n"
-  append amstring $make
-  append amstring $phony
-  wokUtils:FILES:StringToFile $amstring [set fmam [file join $dir Makefile.am]]
-  return [list $fmam]
-}
-
-# retourne la liste de dependances de module.
-proc OS:lsdep { m } {
-    set res {}
-    set l [${m}:depends]
-    if { $l != {} } {
-       set res [concat $res $l]
-       foreach h $l {
-           set res [concat $res [OS:lsdep ${h}]]
-       }
-    }
-    return $res
-}
-
-# Create in dir the Makefile.am and configure.ac in CASROOT directory.
-# Returns the full path of the created file.
-proc osutils:am:root { dir theSubPath {lesmodules {}} } {
-  global path
-  set amstring "srcdir = @srcdir@\n\n"
-  append amstring "SUBDIRS = ${theSubPath}\n\n"
-  append amstring "VPATH = @srcdir@ @top_srcdir@/${theSubPath}: @top_srcdir@/${theSubPath}:\n\n"
-
-  set phony ".PHONY:"
-
-  set acstring [osutils:readtemplate ac "Makefile.am"]
-  set enablestr ""
-  set confstr ""
-  set condstr ""
-  set repstr ""
-  set acconfstr ""
-
-  set exelocal "install-exec-local:\n"
-  append exelocal "\t"
-  append exelocal {$(INSTALL) -d $(prefix)/$(platform)}
-  append exelocal "\n"
-  foreach d {bin lib} {
-    append exelocal "\t"
-    append exelocal "if \[ -e \$(prefix)/${d} -a ! -e \$(prefix)/\$(platform)/${d} \]; then \\\n"
-    append exelocal "\t\tcd \$(prefix)/\$(platform) && ln -s ../${d} ${d}; \\\n"
-    append exelocal "\tfi\n"
-  }
-  append exelocal "\t"
-  append exelocal {buildd=`pwd`; cd $(top_srcdir); sourced=`pwd`; cd $(prefix); installd=`pwd`; cd $$buildd;}
-  append exelocal " \\\n"
-  append exelocal "\t"
-  append exelocal {if [ "$$installd" != "$$sourced" ]; then}
-  append exelocal " \\\n"
-  append exelocal "\t\t"
-  append exelocal {$(INSTALL) -d $(prefix)/src;}
-  append exelocal " \\\n"
-  append exelocal "\t\t"
-  append exelocal {cp -frL $(top_srcdir)/src $(prefix);}
-  append exelocal " \\\n"
-  append exelocal "\t\t"
-  append exelocal {cp -frL $$buildd/config.h $(prefix);}
-  append exelocal " \\\n"
-  append exelocal "\t\tfor d in "
-
-  foreach theModule $lesmodules {
-    append amstring "${theModule}_PKGS ="
-    foreach r [${theModule}:ressources] {
-      if { "[lindex $r 1]" == "r" } {
-       append amstring " [lindex $r 2]"
-      }
-    }
-    set up ${theModule}
-    if { [info procs ${theModule}:alias] != "" } {
-      set up [${theModule}:alias]
-    }
-    set up [string toupper ${up}]
-    set lower ${theModule}
-    if { [info procs ${theModule}:alias] != "" } {
-      set lower [${theModule}:alias]
-    }
-    set lower [string tolower ${lower}]
-
-    append amstring "\n\nif ENABLE_${up}\n"
-    append amstring "  ${theModule}_DIRS = \$(${theModule}_PKGS)\n"
-    append amstring "else\n"
-    append amstring "  ${theModule}_DIRS = \n"
-    append amstring "endif\n\n"
-    append amstring "${theModule}:\n"
-    append amstring "\tcd \$(top_builddir)/${theSubPath} && \$(MAKE) \$(AM_MAKEFLAGS) ${theModule}\n\n"
-    append phony " ${theModule}"
-
-    append exelocal " \$(${theModule}_DIRS)"
-
-    append enablestr "AC_ARG_ENABLE(\[${lower}\],\n"
-    append enablestr "  \[AS_HELP_STRING(\[--disable-${lower}\],\[Disable ${theModule} components\])\],\n"
-    append enablestr "  \[ENABLE_${up}=\${enableval}\],\[ENABLE_${up}=yes\])\n"
-
-    set deplist [OS:lsdep ${theModule}]
-    set acdeplist {}
-    if { [info procs ${theModule}:acdepends] != "" } {
-      set acdeplist [${theModule}:acdepends]
-    }
-
-    if { [llength $deplist] > 0 || [llength $acdeplist] > 0} {
-      append confstr "if test \"xyes\" = \"x\$ENABLE_${up}\"; then\n"
-    } else {
-      append confstr "if test \"xyes\" != \"x\$ENABLE_${up}\"; then\n"
-    }
-    foreach dep $deplist {
-      set dup ${dep}
-      if { [info procs ${dep}:alias] != "" } {
-       set dup [${dep}:alias]
-      }
-      set dup [string toupper ${dup}]
-      append confstr "  if test \"xyes\" = \"x\$ENABLE_${up}\" -a \"xyes\" != \"x\$ENABLE_${dup}\"; then\n"
-      append confstr "    AC_MSG_NOTICE(\[Disabling ${theModule}: not building ${dep} component\])\n"
-      append confstr "    DISABLE_${up}_REASON=\"(${dep} component disabled)\"\n"
-      append confstr "    ENABLE_${up}=no\n"
-      append confstr "  fi\n"
-    }
-    foreach dep $acdeplist {
-      append confstr "  if test \"xyes\" = \"x\$ENABLE_${up}\" -a \"xyes\" != \"x\$HAVE_${dep}\"; then\n"
-      append confstr "    AC_MSG_NOTICE(\[Disabling ${theModule}: ${dep} not found\])\n"
-      append confstr "    DISABLE_${up}_REASON=\"(${dep} not found)\"\n"
-      append confstr "    ENABLE_${up}=no\n"
-      append confstr "  fi\n"
-    }
-    if { [llength $deplist] > 0 || [llength $acdeplist] > 0 } {
-      append confstr "else\n"
-    }
-    append confstr "  DISABLE_${up}_REASON=\"(Disabled)\"\n"
-    append confstr "fi\n"
-
-    append condstr "AM_CONDITIONAL(\[ENABLE_${up}\], \[test \"xyes\" = \"x\$ENABLE_${up}\"\])\n"
-    append repstr [format "echo \"%-*s  \$ENABLE_${up} \$DISABLE_${up}_REASON\"" 26 ${theModule}]
-    append repstr "\n"
-
-    set units [$theModule:toolkits]
-    set units [concat $units [OS:executable $theModule]]
-    foreach unit $units {
-      append acconfstr "${theSubPath}/${unit}/Makefile \\\n"
-    }
-  }
-
-  append exelocal "; do \\\n"
-  append exelocal "\t\t\t"
-  append exelocal {$(INSTALL) -d $(prefix)/src/$$d;}
-  append exelocal " \\\n"
-  append exelocal "\t\t\t"
-  append exelocal {cp -frL $(top_srcdir)/src/$$d $(prefix)/src;}
-  append exelocal " \\\n"
-  append exelocal "\t\tdone; \\\n"
-  append exelocal "\tfi\n"
-  append exelocal "\t"
-  append exelocal {if [ -e $(prefix)/src/config.h ]; then}
-  append exelocal " \\\n"
-  append exelocal "\t\t"
-  append exelocal {unlink $(prefix)/src/config.h;}
-  append exelocal " \\\n"
-  append exelocal "\tfi\n"
-  append exelocal "\t"
-  append exelocal {cd $(prefix)/src && ln -s ../config.h config.h}
-  append exelocal "\n"
-  append exelocal "\t"
-  append exelocal {cd $(top_srcdir) && cp *.sh $(prefix)}
-  append exelocal "\n"
-  append exelocal "\n"
-
-  append amstring $exelocal
-  append amstring $phony
-
-  regsub -all -- {__ENABLEMODULES__} $acstring $enablestr acstring
-  regsub -all -- {__CONFMODULES__} $acstring $confstr acstring
-  regsub -all -- {__CONDMODULES__} $acstring $condstr acstring
-  regsub -all -- {__REPMODULES__} $acstring $repstr acstring
-  regsub -all -- {__ACCONFMODULES__} $acstring $acconfstr acstring
-
-  wokUtils:FILES:StringToFile $amstring [set fmam [file join $dir Makefile.am]]
-  wokUtils:FILES:StringToFile $acstring [set fmam [file join $dir configure.ac]]
-  file copy -force -- [file join $path/adm/templates build_configure] [file join $dir build_configure]
-  file copy -force -- [file join $path/adm/templates acinclude.m4] [file join $dir acinclude.m4]
-  file copy -force -- [file join $path/adm/templates custom.sh.in] [file join $dir custom.sh.in]
-  return [list $fmam]
-}
-
-proc wokUtils:EASY:FmtString1 { fmt l {yes_for_last 0} {edit_last {}} } {
-    set ldeb [lrange $l 0 [expr [llength $l] -2]]
-    set last [lrange $l end end]
-    foreach e $ldeb {
-       append str [format $fmt $e] " \\" "\n"
-    }
-
-    if {$edit_last != {} } {
-       set slast [$edit_last [format $fmt $last]]
-    } else {
-       set slast [format $fmt $last]
-    }
-
-    if { $yes_for_last } {
-       append str $slast " \\" "\n" 
-    } else {
-       append str $slast "\n"
-    }
-    return $str
-}
-
-# Used to replace the string __CFLAG__ in Makefile.am
-# l is the list of all compilable files in a toolkit.
-proc osutils:am:__CFLAG__ { l } {
-  set fmt "%s"
-  return [wokUtils:EASY:FmtString1 $fmt [osutils:am:PkCOption $l]]
-}
-
-proc osutils:am:PkCOption { ppk } {
-  global path
-  #puts "\t\t $ppk"
-  #puts "\t 5 [lindex [wokparam -e  %CMPLRS_C_Options [wokcd]] 0]"
-  set CCOMMON [_get_options lin cmplrs_c b]
-  #puts "\t 6 [lindex [wokparam -v %CMPLRS_C_Options [w_info -f]] 0]"
-  set FoundFlag "[lindex [osutils:intersect3 [split [_get_options lin cmplrs_c f]] [split [_get_options lin cmplrs_c b]]] 2]"
-  foreach pk $ppk {
-    if {![file isdirectory $path/src/$pk]} {
-         continue
-       }
-       set src_files [_get_used_files $pk false]
-    set only_src_files {}
-    foreach s $src_files {
-      regexp {source ([^\s]+)} $s dummy name
-      lappend only_src_files $name
-    }
-    if {[lsearch $src_files ${pk}_CMPLRS.edl] != "-1"} {
-         #puts "\t 7 [lindex [wokparam -e %CMPLRS_C_Options [woklocate -u $pk]] 0] $pk"
-      set aPkList   [split "[_get_options lin cmplrs_c $pk]" " "]
-      set aCcomList [split "$CCOMMON" " "]
-
-      foreach aPkItem $aPkList {
-        if { [lsearch aCcomList $aPkItem] != -1 } {
-          if {[string first "-I" $aPkItem] == "-1"  } {
-            set FoundFlag "$FoundFlag $aPkItem"
-          }
-        }
-      }
-    }
-  }
-  return $FoundFlag
-}
-
-proc osutils:tksrcfiles { theUnits  theRelatedPath {theCompatible {}} } {
-  set aTKSrcFiles [list]
-
-  if [array exists written] { unset written }
-  foreach anUnit $theUnits {
-    set xlo       $anUnit
-    set aSrcFiles [osutils:tk:files $xlo osutils:compilable 0]
-
-    if { $theCompatible != {} } {
-      set aSrcFiles [osutils:tk:files $xlo $theCompatible 0]
-    }
-
-    foreach aSrcFile [lsort $aSrcFiles] {
-      if { ![info exists written([file tail $aSrcFile])] } {
-        set written([file tail $aSrcFile]) 1
-        lappend aTKSrcFiles "${theRelatedPath}/[wokUtils:FILES:wtail $aSrcFile 3]"
-      } else {
-        puts "Warning : more than one occurences for [file tail $aSrcFile]"
-      }
-    }
-  }
-
-  return $aTKSrcFiles
-}
-
-proc osutils:mm_compilable { } {
-  return [list .mm]
-}
-
-proc osutils:tkdefs { theUnits } {
-  set aTKDefines [list]
-
-  foreach anUnit $theUnits {
-    lappend aTKDefines "__${anUnit}_DLL"
-  }
-
-  return $aTKDefines
-}
-
-proc osutils:fileGroupName { theSrcFile } {
-  set path [file dirname [file normalize ${theSrcFile}]]
-  regsub -all [file normalize "${path}/.."] ${path} "" aGroupName
-
-  return $aGroupName
-}
-
 
 ####### CODEBLOCK ###################################################################
 # Function to generate Code Blocks workspace and project files
-proc OS:MKCBP { theOutDir {theModules {}} {theAllSolution ""} } {
+proc OS:MKCBP { theOutDir theModules theAllSolution thePlatform theCmpl } {
   puts stderr "Generating project files for Code Blocks"
 
   # Generate projects for toolkits and separate workspace for each module
   foreach aModule $theModules {
-    OS:cworkspace $aModule $aModule $theOutDir
-    OS:cbp        $aModule          $theOutDir
+    OS:cworkspace          $aModule $aModule $theOutDir
+    OS:cbp        $theCmpl $aModule          $theOutDir $thePlatform
   }
 
   # Generate single workspace "OCCT" containing projects from all modules
@@ -2534,30 +2147,66 @@ proc OS:MKCBP { theOutDir {theModules {}} {theAllSolution ""} } {
 }
 
 # Generate Code Blocks projects
-proc OS:cbp { theModules theOutDir } {
+proc OS:cbp { theCmpl theModules theOutDir thePlatform } {
   set aProjectFiles {}
   foreach aModule $theModules {
     foreach aToolKit [${aModule}:toolkits] {
-      lappend aProjectFiles [osutils:cbptk $theOutDir $aToolKit ]
+      lappend aProjectFiles [osutils:cbptk $theCmpl $theOutDir $aToolKit $thePlatform]
     }
     foreach anExecutable [OS:executable ${aModule}] {
-      lappend aProjectFiles [osutils:cbpx  $theOutDir $anExecutable]
+      lappend aProjectFiles [osutils:cbpx  $theCmpl $theOutDir $anExecutable $thePlatform]
     }
   }
   return $aProjectFiles
 }
 
 # Generate Code::Blocks project file for ToolKit
-proc osutils:cbptk { theOutDir theToolKit } {
-  set aUsedToolKits [list]
+proc osutils:cbptk { theCmpl theOutDir theToolKit thePlatform} {
+  set aUsedLibs     [list]
   set aFrameworks   [list]
   set anIncPaths    [list]
   set aTKDefines    [list]
   set aTKSrcFiles   [list]
 
-  osutils:tkinfo "../../.." $theToolKit aUsedToolKits aFrameworks anIncPaths aTKDefines aTKSrcFiles
+  # collect list of referred libraries to link with
+  osutils:usedOsLibs $theToolKit $thePlatform aUsedLibs aFrameworks
+  set aDepToolkits [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
+  foreach tkx $aDepToolkits {
+    lappend aUsedLibs "${tkx}"
+  }
+
+  lappend anIncPaths "../../../inc"
+  set listloc [osutils:tk:units $theToolKit]
+
+  if { [llength $listloc] == 0 } {
+    set listloc $theToolKit
+  }
+
+  if { $thePlatform == "wnt" || $thePlatform == "uwp" } {
+    set resultloc [osutils:justwnt  $listloc]
+  } else {
+    set resultloc [osutils:justunix $listloc]
+  }
+  if [array exists written] { unset written }
+  foreach fxlo $resultloc {
+    set xlo       $fxlo
+    set aSrcFiles [osutils:tk:cxxfiles $xlo $thePlatform]
+    foreach aSrcFile [lsort $aSrcFiles] {
+      if { ![info exists written([file tail $aSrcFile])] } {
+        set written([file tail $aSrcFile]) 1
+        lappend aTKSrcFiles "../../../[wokUtils:FILES:wtail $aSrcFile 3]"
+      } else {
+        puts "Warning : more than one occurences for [file tail $aSrcFile]"
+      }
+    }
+
+    # macros for correct DLL exports
+#    if { $thePlatform == "wnt" || $thePlatform == "uwp" } {
+#      lappend aTKDefines "__${xlo}_DLL"
+#    }
+  }
 
-  return [osutils:cbp $theOutDir $theToolKit $aTKSrcFiles $aUsedToolKits $aFrameworks $anIncPaths $aTKDefines]
+  return [osutils:cbp $theCmpl $theOutDir $theToolKit $thePlatform $aTKSrcFiles $aUsedLibs $aFrameworks $anIncPaths $aTKDefines]
 }
 
 # Generates Code Blocks workspace.
@@ -2630,62 +2279,29 @@ proc OS:cworkspace { theSolName theModules theOutDir } {
 }
 
 # Generate Code::Blocks project file for Executable
-proc osutils:cbpx { theOutDir theToolKit } {
-  global path targetStation
-  set aWokStation "$targetStation"
+proc osutils:cbpx { theCmpl theOutDir theToolKit thePlatform } {
+  global path
   set aWokArch    "$::env(ARCH)"
 
   set aCbpFiles {}
-  foreach aSrcFile [osutils:tk:files $theToolKit osutils:compilable 0] {
+  foreach aSrcFile [osutils:tk:cxxfiles $theToolKit $thePlatform] {
     # collect list of referred libraries to link with
-    set aUsedToolKits [list]
+    set aUsedLibs     [list]
     set aFrameworks   [list]
     set anIncPaths    [list]
     set aTKDefines    [list]
     set aTKSrcFiles   [list]
     set aProjName [file rootname [file tail $aSrcFile]]
 
+    osutils:usedOsLibs $theToolKit $thePlatform aUsedLibs aFrameworks
+
     set aDepToolkits [LibToLinkX $theToolKit $aProjName]
     foreach tkx $aDepToolkits {
       if {[_get_type $tkx] == "t"} {
-        lappend aUsedToolKits "${tkx}"
+        lappend aUsedLibs "${tkx}"
       }
       if {[lsearch [glob -tails -directory "$path/src" -types d *] $tkx] == "-1"} {
-        lappend aUsedToolKits "${tkx}"
-      }
-    }
-
-    #wokparam -l CSF
-
-    foreach tk $aDepToolkits {
-      foreach element [osutils:tk:hascsf $path/src/${tk}/EXTERNLIB] {
-        if {[_get_options lin csf $element] == ""} {
-          continue
-        }
-        set isFrameworkNext 0
-        foreach fl [split [_get_options lin csf $element]] {
-          if {[string first "-libpath" $fl] != "-1"} {
-            # this is library search path, not the library name
-            continue
-          } elseif {[string first "-framework" $fl] != "-1"} {
-            set isFrameworkNext 1
-            continue
-          }
-
-          set felem [file tail $fl]
-          if {$isFrameworkNext == 1} {
-            if {[lsearch $aFrameworks $felem] == "-1"} {
-              lappend aFrameworks "${felem}"
-            }
-            set isFrameworkNext 0
-          } elseif {[lsearch $aUsedToolKits $felem] == "-1"} {
-            if {$felem != "\{\}" & $felem != "lib"} {
-              if {[lsearch -nocase [osutils:optinal_libs] $felem] == -1} {
-                lappend aUsedToolKits [string trimleft "${felem}" "-l"]
-              }
-            }
-          }
-        }
+        lappend aUsedLibs "${tkx}"
       }
     }
 
@@ -2698,45 +2314,27 @@ proc osutils:cbpx { theOutDir theToolKit } {
 
     if { ![info exists written([file tail $aSrcFile])] } {
       set written([file tail $aSrcFile]) 1
-      lappend aTKSrcFiles $aSrcFile
+      lappend aTKSrcFiles "../../../[wokUtils:FILES:wtail $aSrcFile 3]"
     } else {
       puts "Warning : in cbp there are more than one occurences for [file tail $aSrcFile]"
     }
 
     # macros for correct DLL exports
-    if { "$aWokStation" == "wnt" } {
-      lappend aTKDefines "__${theToolKit}_DLL"
-    }
+#    if { $thePlatform == "wnt" || $thePlatform == "uwp" } {
+#      lappend aTKDefines "__${theToolKit}_DLL"
+#    }
 
     # common include paths
     lappend anIncPaths "../../../inc"
 
-    # macros for UNIX to use config.h file
-    lappend aTKDefines "CSFDB"
-    if { "$aWokStation" == "wnt" } {
-      lappend aTKDefines "WNT"
-      lappend aTKDefines "_CRT_SECURE_NO_DEPRECATE"
-    } else {
-      lappend aTKDefines "HAVE_WOK_CONFIG_H"
-      lappend aTKDefines "HAVE_CONFIG_H"
-      if { "$aWokStation" == "lin" } {
-        lappend aTKDefines "LIN"
-      }
-      lappend aTKDefines "OCC_CONVERT_SIGNALS"
-      #lappend aTKDefines "_GNU_SOURCE=1"
-    }
-
-    lappend aCbpFiles [osutils:cbp $theOutDir $aProjName $aTKSrcFiles $aUsedToolKits $aFrameworks $anIncPaths $aTKDefines $isExecutable]
+    lappend aCbpFiles [osutils:cbp $theCmpl $theOutDir $aProjName $thePlatform $aTKSrcFiles $aUsedLibs $aFrameworks $anIncPaths $aTKDefines $isExecutable]
   }
 
   return $aCbpFiles
 }
 
-proc osutils:optinal_libs { } {
-  return [list tbb.lib tbbmalloc.lib FreeImage.lib FreeImagePlus.lib gl2ps.lib]
-}
-
 # This function intended to generate Code::Blocks project file
+# @param theCmpl       - the compiler (gcc or msvc)
 # @param theOutDir     - output directory to place project file
 # @param theProjName   - project name
 # @param theSrcFiles   - list of source files
@@ -2745,12 +2343,62 @@ proc osutils:optinal_libs { } {
 # @param theIncPaths   - header search paths
 # @param theDefines    - compiler macro definitions
 # @param theIsExe      - flag to indicate executable / library target
-proc osutils:cbp { theOutDir theProjName theSrcFiles theLibsList theFrameworks theIncPaths theDefines {theIsExe "false"} } {
-  global targetStation
-  set aWokStation "$targetStation"
+proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibsList theFrameworks theIncPaths theDefines {theIsExe "false"} } {
   set aWokArch    "$::env(ARCH)"
 
-  set aCbpFilePath "${theOutDir}/${theProjName}.cbp"
+  set aCmplCbp "gcc"
+  set aCmplFlags        [list]
+  set aCmplFlagsRelease [list]
+  set aCmplFlagsDebug   [list]
+  set toPassArgsByFile 0
+  set aLibPrefix "lib"
+  set aPlatformAndCompiler "${thePlatform}/gcc"
+  if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } {
+    set aPlatformAndCompiler "${thePlatform}/clang"
+  }
+  if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" || "$thePlatform" == "qnx" } {
+    set toPassArgsByFile 1
+  }
+  if { "$theCmpl" == "msvc" } {
+    set aCmplCbp "msvc8"
+    set aLibPrefix ""
+  }
+
+  if { "$theCmpl" == "msvc" } {
+    set aCmplFlags        "-arch:SSE2 -EHsc -W4 -MP"
+    set aCmplFlagsRelease "-MD  -O2"
+    set aCmplFlagsDebug   "-MDd -Od -Zi"
+    lappend aCmplFlags    "-D_CRT_SECURE_NO_WARNINGS"
+    lappend aCmplFlags    "-D_CRT_NONSTDC_NO_DEPRECATE"
+  } elseif { "$theCmpl" == "gcc" } {
+    if { "$thePlatform" != "qnx" } {
+      set aCmplFlags      "-mmmx -msse -msse2 -mfpmath=sse"
+    }
+    set aCmplFlagsRelease "-O2"
+    set aCmplFlagsDebug   "-O0 -g"
+    if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
+      lappend aCmplFlags "-std=gnu++0x"
+      lappend aCmplFlags "-D_WIN32_WINNT=0x0501"
+    } else {
+      lappend aCmplFlags "-std=c++0x"
+      lappend aCmplFlags "-fPIC"
+      lappend aCmplFlags "-DOCC_CONVERT_SIGNALS"
+    }
+    lappend aCmplFlags   "-Wall"
+    lappend aCmplFlags   "-fexceptions"
+  }
+  lappend aCmplFlagsRelease "-DNDEBUG"
+  lappend aCmplFlagsRelease "-DNo_Exception"
+  lappend aCmplFlagsDebug   "-D_DEBUG"
+  if { "$thePlatform" == "qnx" } {
+    lappend aCmplFlags "-D_QNX_SOURCE"
+  }
+
+  set aCbpFilePath    "${theOutDir}/${theProjName}.cbp"
+  set aLnkFileName    "${theProjName}_obj.link"
+  set aLnkDebFileName "${theProjName}_objd.link"
+  set aLnkFilePath    "${theOutDir}/${aLnkFileName}"
+  set aLnkDebFilePath "${theOutDir}/${aLnkDebFileName}"
   set aFile [open $aCbpFilePath "w"]
   puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
   puts $aFile "<CodeBlocks_project_file>"
@@ -2758,65 +2406,55 @@ proc osutils:cbp { theOutDir theProjName theSrcFiles theLibsList theFrameworks t
   puts $aFile "\t<Project>"
   puts $aFile "\t\t<Option title=\"$theProjName\" />"
   puts $aFile "\t\t<Option pch_mode=\"2\" />"
-  if { "$aWokStation" == "wnt" } {
-    puts $aFile "\t\t<Option compiler=\"msvc8\" />"
-  } else {
-    puts $aFile "\t\t<Option compiler=\"gcc\" />"
-  }
+  puts $aFile "\t\t<Option compiler=\"$aCmplCbp\" />"
   puts $aFile "\t\t<Build>"
 
   # Release target configuration
   puts $aFile "\t\t\t<Target title=\"Release\">"
   if { "$theIsExe" == "true" } {
-    puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bin/${theProjName}\" prefix_auto=\"1\" extension_auto=\"1\" />"
+    puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/bin/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
     puts $aFile "\t\t\t\t<Option type=\"1\" />"
   } else {
-    if { "$aWokStation" == "wnt" } {
-      puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/lib/${theProjName}\" prefix_auto=\"1\" extension_auto=\"1\" />"
+    if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
+      puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/bin/${aLibPrefix}${theProjName}\" imp_lib=\"../../../${aPlatformAndCompiler}/lib/\$(TARGET_OUTPUT_BASENAME)\" prefix_auto=\"1\" extension_auto=\"1\" />"
     } else {
-      puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/lib/lib${theProjName}\" prefix_auto=\"1\" extension_auto=\"1\" />"
+      puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/lib/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
     }
     puts $aFile "\t\t\t\t<Option type=\"3\" />"
   }
-  puts $aFile "\t\t\t\t<Option object_output=\"../../../${aWokStation}/cbp/obj\" />"
-  if { "$aWokStation" == "wnt" } {
-    puts $aFile "\t\t\t\t<Option compiler=\"msvc8\" />"
+  puts $aFile "\t\t\t\t<Option object_output=\"../../../${aPlatformAndCompiler}/obj\" />"
+  puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
+  puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
+  if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
+    puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
   } else {
-    puts $aFile "\t\t\t\t<Option compiler=\"gcc\" />"
+    puts $aFile "\t\t\t\t<Option createStaticLib=\"0\" />"
   }
-  puts $aFile "\t\t\t\t<Option createDefFile=\"1\" />"
-  puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
 
   # compiler options per TARGET (including defines)
   puts $aFile "\t\t\t\t<Compiler>"
-  if { "$aWokStation" == "wnt" } {
-    puts $aFile "\t\t\t\t\t<Add option=\"-MD\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-arch:SSE2\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-EHsc\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-O2\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-W4\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-MP\" />"
-  } else {
-    puts $aFile "\t\t\t\t\t<Add option=\"-O2\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-mmmx\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-msse\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-msse2\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-mfpmath=sse\" />"
+  foreach aFlagIter $aCmplFlagsRelease {
+    puts $aFile "\t\t\t\t\t<Add option=\"$aFlagIter\" />"
   }
   foreach aMacro $theDefines {
     puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
   }
-  puts $aFile "\t\t\t\t\t<Add option=\"-DNDEBUG\" />"
-  puts $aFile "\t\t\t\t\t<Add option=\"-DNo_Exception\" />"
-
   puts $aFile "\t\t\t\t</Compiler>"
 
   puts $aFile "\t\t\t\t<Linker>"
-  puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aWokStation}/cbp/lib\" />"
-  if { "$aWokStation" == "mac" && [ lsearch $theLibsList X11 ] >= 0} {
-    puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
+  if { $toPassArgsByFile == 1 } {
+    puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkFileName\" />"
+  }
+  puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aPlatformAndCompiler}/lib\" />"
+  if { "$thePlatform" == "mac" } {
+    if { [ lsearch $theLibsList X11 ] >= 0} {
+      puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
+    }
   }
   puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch})\" />"
+  if { "$thePlatform" == "lin" } {
+    puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${aPlatformAndCompiler}/lib\" />"
+  }
   puts $aFile "\t\t\t\t</Linker>"
 
   puts $aFile "\t\t\t</Target>"
@@ -2824,56 +2462,49 @@ proc osutils:cbp { theOutDir theProjName theSrcFiles theLibsList theFrameworks t
   # Debug target configuration
   puts $aFile "\t\t\t<Target title=\"Debug\">"
   if { "$theIsExe" == "true" } {
-    puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bind/${theProjName}\" prefix_auto=\"1\" extension_auto=\"1\" />"
+    puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/bind/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
     puts $aFile "\t\t\t\t<Option type=\"1\" />"
   } else {
-    if { "$aWokStation" == "wnt" } {
-      puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/libd/${theProjName}\" prefix_auto=\"1\" extension_auto=\"1\" />"
+    if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
+      puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/bind/${aLibPrefix}${theProjName}\" imp_lib=\"../../../${aPlatformAndCompiler}/libd/\$(TARGET_OUTPUT_BASENAME)\" prefix_auto=\"1\" extension_auto=\"1\" />"
     } else {
-      puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/libd/lib${theProjName}\" prefix_auto=\"1\" extension_auto=\"1\" />"
+      puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/libd/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
     }
     puts $aFile "\t\t\t\t<Option type=\"3\" />"
   }
-  puts $aFile "\t\t\t\t<Option object_output=\"../../../${aWokStation}/cbp/objd\" />"
-  if { "$aWokStation" == "wnt" } {
-    puts $aFile "\t\t\t\t<Option compiler=\"msvc8\" />"
+  puts $aFile "\t\t\t\t<Option object_output=\"../../../${aPlatformAndCompiler}/objd\" />"
+  puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
+  puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
+  if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
+    puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
   } else {
-    puts $aFile "\t\t\t\t<Option compiler=\"gcc\" />"
+    puts $aFile "\t\t\t\t<Option createStaticLib=\"0\" />"
   }
-  puts $aFile "\t\t\t\t<Option createDefFile=\"1\" />"
-  puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
 
   # compiler options per TARGET (including defines)
   puts $aFile "\t\t\t\t<Compiler>"
-  if { "$aWokStation" == "wnt" } {
-    puts $aFile "\t\t\t\t\t<Add option=\"-MDd\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-arch:SSE2\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-EHsc\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-Od\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-Zi\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-W4\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-MP\" />"
-  } else {
-    puts $aFile "\t\t\t\t\t<Add option=\"-O0\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-g\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-mmmx\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-msse\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-msse2\" />"
-    puts $aFile "\t\t\t\t\t<Add option=\"-mfpmath=sse\" />"
+  foreach aFlagIter $aCmplFlagsDebug {
+    puts $aFile "\t\t\t\t\t<Add option=\"$aFlagIter\" />"
   }
   foreach aMacro $theDefines {
     puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
   }
-  puts $aFile "\t\t\t\t\t<Add option=\"-D_DEBUG\" />"
-  puts $aFile "\t\t\t\t\t<Add option=\"-DDEB\" />"
   puts $aFile "\t\t\t\t</Compiler>"
 
   puts $aFile "\t\t\t\t<Linker>"
-  puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aWokStation}/cbp/libd\" />"
-  if { "$aWokStation" == "mac" && [ lsearch $theLibsList X11 ] >= 0} {
-    puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
+  if { $toPassArgsByFile == 1 } {
+    puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkDebFileName\" />"
+  }
+  puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aPlatformAndCompiler}/libd\" />"
+  if { "$thePlatform" == "mac" } {
+    if { [ lsearch $theLibsList X11 ] >= 0} {
+      puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
+    }
   }
   puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch}D)\" />"
+  if { "$thePlatform" == "lin" } {
+    puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${aPlatformAndCompiler}/libd\" />"
+  }
   puts $aFile "\t\t\t\t</Linker>"
 
   puts $aFile "\t\t\t</Target>"
@@ -2882,9 +2513,9 @@ proc osutils:cbp { theOutDir theProjName theSrcFiles theLibsList theFrameworks t
 
   # COMMON compiler options
   puts $aFile "\t\t<Compiler>"
-  puts $aFile "\t\t\t<Add option=\"-Wall\" />"
-  puts $aFile "\t\t\t<Add option=\"-fexceptions\" />"
-  puts $aFile "\t\t\t<Add option=\"-fPIC\" />"
+  foreach aFlagIter $aCmplFlags {
+    puts $aFile "\t\t\t<Add option=\"$aFlagIter\" />"
+  }
   puts $aFile "\t\t\t<Add option=\"\$(CSF_OPT_CMPL)\" />"
   foreach anIncPath $theIncPaths {
     puts $aFile "\t\t\t<Add directory=\"$anIncPath\" />"
@@ -2893,6 +2524,9 @@ proc osutils:cbp { theOutDir theProjName theSrcFiles theLibsList theFrameworks t
 
   # COMMON linker options
   puts $aFile "\t\t<Linker>"
+  if { "$thePlatform" == "wnt" && "$theCmpl" == "gcc" } {
+    puts $aFile "\t\t\t<Add option=\"-Wl,--export-all-symbols\" />"
+  }
   foreach aFrameworkName $theFrameworks {
     if { "$aFrameworkName" != "" } {
       puts $aFile "\t\t\t<Add option=\"-framework $aFrameworkName\" />"
@@ -2900,12 +2534,25 @@ proc osutils:cbp { theOutDir theProjName theSrcFiles theLibsList theFrameworks t
   }
   foreach aLibName $theLibsList {
     if { "$aLibName" != "" } {
-      puts $aFile "\t\t\t<Add library=\"$aLibName\" />"
+      if { "$theCmpl" == "msvc" } {
+        puts $aFile "\t\t\t<Add library=\"${aLibName}.lib\" />"
+      } else {
+        puts $aFile "\t\t\t<Add library=\"${aLibName}\" />"
+      }
     }
   }
   puts $aFile "\t\t</Linker>"
 
   # list of sources
+
+  set aFileLnkObj ""
+  set aFileLnkObjd ""
+  set isFirstSrcFile 1
+  if { $toPassArgsByFile == 1 } {
+    set aFileLnkObj  [open $aLnkFilePath    "w"]
+    set aFileLnkObjd [open $aLnkDebFilePath "w"]
+  }
+
   foreach aSrcFile $theSrcFiles {
     if {[string equal -nocase [file extension $aSrcFile] ".mm"]} {
       puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
@@ -2916,11 +2563,28 @@ proc osutils:cbp { theOutDir theProjName theSrcFiles theLibsList theFrameworks t
       puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
       puts $aFile "\t\t\t<Option compilerVar=\"CC\" />"
       puts $aFile "\t\t</Unit>"
+    } elseif { $toPassArgsByFile == 1 && $isFirstSrcFile == 0 && [string equal -nocase [file extension $aSrcFile] ".cxx" ] } {
+      # pass at list single source file to Code::Blocks as is
+      # and pack the list of other files into the dedicated file to workaround process arguments limits on systems like Windows
+      puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
+      puts $aFile "\t\t\t<Option link=\"0\" />"
+      puts $aFile "\t\t</Unit>"
+
+      set aFileObj  [string map {.cxx .o} [string map [list "/src/" "/${aPlatformAndCompiler}/obj/src/"]  $aSrcFile]]
+      set aFileObjd [string map {.cxx .o} [string map [list "/src/" "/${aPlatformAndCompiler}/objd/src/"] $aSrcFile]]
+      puts -nonewline $aFileLnkObj  "$aFileObj "
+      puts -nonewline $aFileLnkObjd "$aFileObjd "
     } else {
       puts $aFile "\t\t<Unit filename=\"$aSrcFile\" />"
+      set isFirstSrcFile 0
     }
   }
 
+  if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
+    close $aFileLnkObj
+    close $aFileLnkObjd
+  }
+
   puts $aFile "\t</Project>"
   puts $aFile "</CodeBlocks_project_file>"
   close $aFile
@@ -2928,119 +2592,873 @@ proc osutils:cbp { theOutDir theProjName theSrcFiles theLibsList theFrameworks t
   return $aCbpFilePath
 }
 
-# Auxiliary function to achieve complete information to build Toolkit
-# @param theRelativePath - relative path to CASROOT
-# @param theToolKit      - Toolkit name
-# @param theUsedLib      - dependencies (libraries  list)
-# @param theFrameworks   - dependencies (frameworks list, Mac OS X specific)
-# @param theIncPaths     - header search paths
-# @param theTKDefines    - compiler macro definitions
-# @param theTKSrcFiles   - list of source files
-proc osutils:tkinfo { theRelativePath theToolKit theUsedLib theFrameworks theIncPaths theTKDefines theTKSrcFiles } {
-  global path targetStation
-  set aWokStation "$targetStation"
+# Define libraries to link using only EXTERNLIB file
+proc LibToLinkX {thePackage theDummyName} {
+  set aToolKits [LibToLink $thePackage]
+  return $aToolKits
+}
 
-  # collect list of referred libraries to link with
-  upvar $theUsedLib    aUsedLibs
-  upvar $theFrameworks aFrameworks
-  upvar $theIncPaths   anIncPaths
-  upvar $theTKDefines  aTKDefines
-  upvar $theTKSrcFiles aTKSrcFiles
+# Function to generate Xcode workspace and project files
+proc OS:MKXCD { theOutDir {theModules {}} {theAllSolution ""} {theLibType "dynamic"} {thePlatform ""} } {
 
-  set aDepToolkits [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
-  foreach tkx $aDepToolkits {
-    lappend aUsedLibs "${tkx}"
+  puts stderr "Generating project files for Xcode"
+
+  # Generate projects for toolkits and separate workspace for each module
+  foreach aModule $theModules {
+    OS:xcworkspace $aModule $aModule $theOutDir
+    OS:xcodeproj   $aModule          $theOutDir ::THE_GUIDS_LIST $theLibType $thePlatform
   }
 
- # wokparam -l CSF
+  # Generate single workspace "OCCT" containing projects from all modules
+  if { "$theAllSolution" != "" } {
+    OS:xcworkspace $theAllSolution $theModules $theOutDir
+  }
+}
 
-  foreach tk [lappend aDepToolkits $theToolKit] {
-    foreach element [osutils:tk:hascsf $path/src/${tk}/EXTERNLIB] {
-      if {[_get_options lin csf $element] == ""} {
-        continue
-      }
-      set isFrameworkNext 0
-      foreach fl [split [_get_options lin csf $element]] {
-        if {[string first "-libpath" $fl] != "-1"} {
-          # this is library search path, not the library name
-          continue
-        } elseif {[string first "-framework" $fl] != "-1"} {
-          set isFrameworkNext 1
-          continue
-        }
+# Generates toolkits sections for Xcode workspace file.
+proc OS:xcworkspace:toolkits { theModule } {
+  set aBuff ""
 
-        set felem [file tail $fl]
-        if {$isFrameworkNext == 1} {
-          if {[lsearch $aFrameworks $felem] == "-1"} {
-            lappend aFrameworks "${felem}"
-          }
-          set isFrameworkNext 0
-        } elseif {[lsearch $aUsedLibs $felem] == "-1"} {
-          if {$felem != "\{\}" & $felem != "lib"} {
-            if {[lsearch -nocase [osutils:optinal_libs] $felem] == -1} {
-              lappend aUsedLibs [string trimleft "${felem}" "-l"]
-            }
-          }
-        }
+  # Adding toolkits for module in workspace.
+  foreach aToolKit [osutils:tk:sort [${theModule}:toolkits]] {
+    append aBuff "         <FileRef\n"
+    append aBuff "            location = \"group:${aToolKit}.xcodeproj\">\n"
+    append aBuff "         </FileRef>\n"
+  }
+
+  # Adding executables for module, assume one project per cxx file...
+  foreach aUnit [OS:executable ${theModule}] {
+    set aUnitLoc $aUnit
+    set src_files [_get_used_files $aUnit false]
+    set aSrcFiles {}
+    foreach s $src_files {
+      regexp {source ([^\s]+)} $s dummy name
+      lappend aSrcFiles $name
+    }
+    foreach aSrcFile $aSrcFiles {
+      set aFileExtension [file extension $aSrcFile]
+      if { $aFileExtension == ".cxx" } {
+        set aPrjName [file rootname $aSrcFile]
+        append aBuff "         <FileRef\n"
+        append aBuff "            location = \"group:${aPrjName}.xcodeproj\">\n"
+        append aBuff "         </FileRef>\n"
       }
     }
   }
 
-  lappend anIncPaths "$theRelativePath/inc"
-  set listloc [osutils:tk:units $theToolKit]
+  # Removing unnecessary newline character from the end.
+  set aBuff [string replace $aBuff end end]
+  return $aBuff
+}
 
-  if { [llength $listloc] == 0 } {
-    set listloc $theToolKit
+# Generates workspace files for Xcode.
+proc OS:xcworkspace { theWorkspaceName theModules theOutDir } {
+  # Creating workspace directory for Xcode.
+  set aWorkspaceDir "${theOutDir}/${theWorkspaceName}.xcworkspace"
+  wokUtils:FILES:mkdir $aWorkspaceDir
+  if { ! [file exists $aWorkspaceDir] } {
+    puts stderr "Error: Could not create workspace directory \"$aWorkspaceDir\""
+    return
   }
 
-  if { "$aWokStation" == "wnt" } {
-    set resultloc [osutils:justwnt  $listloc]
+  # Creating workspace file.
+  set aWsFilePath "${aWorkspaceDir}/contents.xcworkspacedata"
+  set aFile [open $aWsFilePath "w"]
+
+  # Adding header and section for main Group.
+  puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+  puts $aFile "<Workspace"
+  puts $aFile "   version = \"1.0\">"
+  puts $aFile "   <Group"
+  puts $aFile "      location = \"container:\""
+  puts $aFile "      name = \"${theWorkspaceName}\">"
+
+  # Adding modules.
+  if { [llength "$theModules"] > 1 } {
+    foreach aModule $theModules {
+      puts $aFile "      <Group"
+      puts $aFile "         location = \"container:\""
+      puts $aFile "         name = \"${aModule}\">"
+      puts $aFile [OS:xcworkspace:toolkits $aModule]
+      puts $aFile "      </Group>"
+    }
   } else {
-    set resultloc [osutils:justunix $listloc]
+    puts $aFile [OS:xcworkspace:toolkits $theModules]
   }
-  if [array exists written] { unset written }
-  foreach fxlo $resultloc {
+
+  # Adding footer.
+  puts $aFile "   </Group>"
+  puts $aFile "</Workspace>"
+  close $aFile
+}
+
+# Generates Xcode project files.
+proc OS:xcodeproj { theModules theOutDir theGuidsMap theLibType thePlatform} {
+  upvar $theGuidsMap aGuidsMap
+
+  set isStatic 0
+  if { "$theLibType" == "static" } {
+    set isStatic 1
+  } elseif { "$thePlatform" == "ios" } {
+    set isStatic 1
+  }
+
+  set aProjectFiles {}
+  foreach aModule $theModules {
+    foreach aToolKit [${aModule}:toolkits] {
+      lappend aProjectFiles [osutils:xcdtk $theOutDir $aToolKit     aGuidsMap $isStatic $thePlatform "dylib"]
+    }
+    foreach anExecutable [OS:executable ${aModule}] {
+      lappend aProjectFiles [osutils:xcdtk $theOutDir $anExecutable aGuidsMap $isStatic $thePlatform "executable"]
+    }
+  }
+  return $aProjectFiles
+}
+
+# Generates dependencies section for Xcode project files.
+proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection theDepsGuids theDepsRefGuids thePlatform theIsStatic} {
+  upvar $theGuidsMap         aGuidsMap
+  upvar $theFileRefSection   aFileRefSection
+  upvar $theDepsGuids        aDepsGuids
+  upvar $theDepsRefGuids     aDepsRefGuids
+
+  set aBuildFileSection ""
+  set aUsedLibs         [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
+  set aDepToolkits      [lappend [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]] $theToolKit]
+
+  if { "$theTargetType" == "executable" } {
+    set aFile [osutils:tk:cxxfiles $theToolKit mac]
+    set aProjName [file rootname [file tail $aFile]]
+    set aDepToolkits [LibToLinkX $theToolKit $aProjName]
+  }
+
+  set aLibExt "dylib"
+  if { $theIsStatic == 1 } {
+    set aLibExt "a"
+    if { "$theTargetType" != "executable" } {
+      return $aBuildFileSection
+    }
+  }
+
+  osutils:usedOsLibs $theToolKit $thePlatform aLibs aFrameworks
+  set aUsedLibs [concat $aUsedLibs $aLibs]
+  set aUsedLibs [concat $aUsedLibs $aFrameworks]
+  foreach tkx $aUsedLibs {
+    set aDepLib    "${tkx}_Dep"
+    set aDepLibRef "${tkx}_DepRef"
+
+    if { ! [info exists aGuidsMap($aDepLib)] } {
+      set aGuidsMap($aDepLib) [OS:genGUID "xcd"]
+    }
+    if { ! [info exists aGuidsMap($aDepLibRef)] } {
+      set aGuidsMap($aDepLibRef) [OS:genGUID "xcd"]
+    }
+
+    append aBuildFileSection "\t\t$aGuidsMap($aDepLib) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aDepLibRef) ; \};\n"
+    if {[lsearch -nocase $aFrameworks $tkx] == -1} {
+      append aFileRefSection   "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = file; name = lib${tkx}.${aLibExt}; path = lib${tkx}.${aLibExt}; sourceTree = \"<group>\"; \};\n"
+    } else {
+      append aFileRefSection   "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ${tkx}.framework; path = /System/Library/Frameworks/${tkx}.framework; sourceTree = \"<absolute>\"; \};\n"
+    }
+    append aDepsGuids        "\t\t\t\t$aGuidsMap($aDepLib) ,\n"
+    append aDepsRefGuids     "\t\t\t\t$aGuidsMap($aDepLibRef) ,\n"
+  }
+
+  return $aBuildFileSection
+}
+
+# Generates PBXBuildFile and PBXGroup sections for project file.
+proc osutils:xcdtk:sources {theToolKit theTargetType theSrcFileRefSection theGroupSection thePackageGuids theSrcFileGuids theGuidsMap theIncPaths} {
+  upvar $theSrcFileRefSection aSrcFileRefSection
+  upvar $theGroupSection      aGroupSection
+  upvar $thePackageGuids      aPackagesGuids
+  upvar $theSrcFileGuids      aSrcFileGuids
+  upvar $theGuidsMap          aGuidsMap
+  upvar $theIncPaths          anIncPaths
+
+  set listloc [osutils:tk:units $theToolKit]
+  set resultloc [osutils:justunix $listloc]
+  set aBuildFileSection ""
+  set aPackages [lsort -nocase $resultloc]
+  if { "$theTargetType" == "executable" } {
+    set aPackages [list "$theToolKit"]
+  }
+
+  # Generating PBXBuildFile, PBXGroup sections and groups for each package.
+  foreach fxlo $aPackages {
     set xlo       $fxlo
-    set aSrcFiles [osutils:tk:files $xlo osutils:compilable 0]
+    set aPackage "${xlo}_Package"
+    set aSrcFileRefGuids ""
+    if { ! [info exists aGuidsMap($aPackage)] } {
+      set aGuidsMap($aPackage) [OS:genGUID "xcd"]
+    }
+
+    set aSrcFiles [osutils:tk:cxxfiles $xlo mac]
     foreach aSrcFile [lsort $aSrcFiles] {
-      if { ![info exists written([file tail $aSrcFile])] } {
+      set aFileExt "sourcecode.cpp.cpp"
+
+      if { [file extension $aSrcFile] == ".c" } {
+        set aFileExt "sourcecode.c.c"
+      } elseif { [file extension $aSrcFile] == ".mm" } {
+        set aFileExt "sourcecode.cpp.objcpp"
+      }
+
+      if { ! [info exists aGuidsMap($aSrcFile)] } {
+        set aGuidsMap($aSrcFile) [OS:genGUID "xcd"]
+      }
+      set aSrcFileRef "${aSrcFile}_Ref"
+      if { ! [info exists aGuidsMap($aSrcFileRef)] } {
+        set aGuidsMap($aSrcFileRef) [OS:genGUID "xcd"]
+      }
+      if { ! [info exists written([file tail $aSrcFile])] } {
         set written([file tail $aSrcFile]) 1
-        lappend aTKSrcFiles "${theRelativePath}/[wokUtils:FILES:wtail $aSrcFile 3]"
+        append aBuildFileSection  "\t\t$aGuidsMap($aSrcFile) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aSrcFileRef) ;\};\n"
+        append aSrcFileRefSection "\t\t$aGuidsMap($aSrcFileRef) = \{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = ${aFileExt}; name = [wokUtils:FILES:wtail $aSrcFile 1]; path = ../../../[wokUtils:FILES:wtail $aSrcFile 3]; sourceTree = \"<group>\"; \};\n"
+        append aSrcFileGuids      "\t\t\t\t$aGuidsMap($aSrcFile) ,\n"
+        append aSrcFileRefGuids   "\t\t\t\t$aGuidsMap($aSrcFileRef) ,\n"
       } else {
         puts "Warning : more than one occurences for [file tail $aSrcFile]"
       }
     }
 
-    # macros for correct DLL exports
-    if { "$aWokStation" == "wnt" } {
-      lappend aTKDefines "__${xlo}_DLL"
-    }
+    append aGroupSection "\t\t$aGuidsMap($aPackage) = \{\n"
+    append aGroupSection "\t\t\tisa = PBXGroup;\n"
+    append aGroupSection "\t\t\tchildren = (\n"
+    append aGroupSection $aSrcFileRefGuids
+    append aGroupSection "\t\t\t);\n"
+    append aGroupSection "\t\t\tname = $xlo;\n"
+    append aGroupSection "\t\t\tsourceTree = \"<group>\";\n"
+    append aGroupSection "\t\t\};\n"
 
-    # common include paths
-#    lappend anIncPaths "${theRelativePath}/src/${xlo}"
+    # Storing packages IDs for adding them later as a child of toolkit
+    append aPackagesGuids "\t\t\t\t$aGuidsMap($aPackage) ,\n"
+  }
+
+  # Removing unnecessary newline character from the end.
+  set aPackagesGuids [string replace $aPackagesGuids end end]
+
+  return $aBuildFileSection
+}
+
+# Creates folders structure and all necessary files for Xcode project.
+proc osutils:xcdtk { theOutDir theToolKit theGuidsMap theIsStatic thePlatform {theTargetType "dylib"} } {
+  set aPBXBuildPhase "Headers"
+  set aRunOnlyForDeployment "0"
+  set aProductType "library.dynamic"
+  set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = dylib;"
+  set anExecPrefix "\t\t\t\tEXECUTABLE_PREFIX = lib;"
+  set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = dylib;"
+  set aTKDefines [list "OCC_CONVERT_SIGNALS"]
+  if { $theIsStatic == 1 } {
+    lappend aTKDefines "OCCT_NO_PLUGINS"
+  }
+
+  if { "$theTargetType" == "executable" } {
+    set aPBXBuildPhase "CopyFiles"
+    set aRunOnlyForDeployment "1"
+    set aProductType "tool"
+    set anExecExtension ""
+    set anExecPrefix ""
+    set aWrapperExtension ""
+  } elseif { $theIsStatic == 1 } {
+    set aProductType "library.static"
+    set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = a;"
+    set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = a;"
+  }
+
+  set aUsername [exec whoami]
+
+  # Creation of folders for Xcode projectP.
+  set aToolkitDir "${theOutDir}/${theToolKit}.xcodeproj"
+  wokUtils:FILES:mkdir $aToolkitDir
+  if { ! [file exists $aToolkitDir] } {
+    puts stderr "Error: Could not create project directory \"$aToolkitDir\""
+    return
+  }
+
+  set aUserDataDir "${aToolkitDir}/xcuserdata"
+  wokUtils:FILES:mkdir $aUserDataDir
+  if { ! [file exists $aUserDataDir] } {
+    puts stderr "Error: Could not create xcuserdata directorty in \"$aToolkitDir\""
+    return
+  }
+
+  set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
+  wokUtils:FILES:mkdir $aUserDataDir
+  if { ! [file exists $aUserDataDir] } {
+    puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$aToolkitDir\"/xcuserdata"
+    return
+  }
+
+  set aSchemesDir "${aUserDataDir}/xcschemes"
+  wokUtils:FILES:mkdir $aSchemesDir
+  if { ! [file exists $aSchemesDir] } {
+    puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
+    return
+  }
+  # End of folders creation.
+
+  # Generating GUID for tookit.
+  upvar $theGuidsMap aGuidsMap
+  if { ! [info exists aGuidsMap($theToolKit)] } {
+    set aGuidsMap($theToolKit) [OS:genGUID "xcd"]
   }
 
-  # macros for UNIX to use config.h file
-  lappend aTKDefines "CSFDB"
-  if { "$aWokStation" == "wnt" } {
-    lappend aTKDefines "WNT"
-    lappend aTKDefines "_CRT_SECURE_NO_DEPRECATE"
+  # Creating xcscheme file for toolkit from template.
+  set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcd"]
+  regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theToolKit aXcschemeTmpl
+  regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theToolKit) aXcschemeTmpl
+  set aXcschemeFile [open "$aSchemesDir/${theToolKit}.xcscheme"  "w"]
+  puts $aXcschemeFile $aXcschemeTmpl
+  close $aXcschemeFile
+
+  # Creating xcschememanagement.plist file for toolkit from template.
+  set aPlistTmpl [osutils:readtemplate "plist" "xcd"]
+  regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theToolKit aPlistTmpl
+  regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theToolKit) aPlistTmpl
+  set aPlistFile [open "$aSchemesDir/xcschememanagement.plist"  "w"]
+  puts $aPlistFile $aPlistTmpl
+  close $aPlistFile
+
+  # Creating project.pbxproj file for toolkit.
+  set aPbxprojFile [open "$aToolkitDir/project.pbxproj" "w"]
+  puts $aPbxprojFile "// !\$*UTF8*\$!"
+  puts $aPbxprojFile "\{"
+  puts $aPbxprojFile "\tarchiveVersion = 1;"
+  puts $aPbxprojFile "\tclasses = \{"
+  puts $aPbxprojFile "\t\};"
+  puts $aPbxprojFile "\tobjectVersion = 46;"
+  puts $aPbxprojFile "\tobjects = \{\n"
+
+  # Begin PBXBuildFile section
+  set aPackagesGuids ""
+  set aGroupSection ""
+  set aSrcFileRefSection ""
+  set aSrcFileGuids ""
+  set aDepsFileRefSection ""
+  set aDepsGuids ""
+  set aDepsRefGuids ""
+  set anIncPaths [list "../../../inc"]
+  set anLibPaths ""
+
+  if { [info exists ::env(CSF_OPT_INC)] } {
+    set anIncCfg [split "$::env(CSF_OPT_INC)" ":"]
+    foreach anIncCfgPath $anIncCfg {
+      lappend anIncPaths $anIncCfgPath
+    }
+  }
+  if { [info exists ::env(CSF_OPT_LIB64)] } {
+    set anLibCfg [split "$::env(CSF_OPT_LIB64)" ":"]
+    foreach anLibCfgPath $anLibCfg {
+      lappend anLibPaths $anLibCfgPath
+    }
+  }
+
+  puts $aPbxprojFile [osutils:xcdtk:sources $theToolKit $theTargetType aSrcFileRefSection aGroupSection aPackagesGuids aSrcFileGuids aGuidsMap anIncPaths]
+  puts $aPbxprojFile [osutils:xcdtk:deps    $theToolKit $theTargetType aGuidsMap aDepsFileRefSection aDepsGuids aDepsRefGuids $thePlatform $theIsStatic]
+  # End PBXBuildFile section
+
+  # Begin PBXFileReference section
+  set aToolkitLib "lib${theToolKit}.dylib"
+  set aPath "$aToolkitLib"
+  if { "$theTargetType" == "executable" } {
+    set aPath "$theToolKit"
+  } elseif { $theIsStatic == 1 } {
+    set aToolkitLib "lib${theToolKit}.a"
+  }
+
+  if { ! [info exists aGuidsMap($aToolkitLib)] } {
+    set aGuidsMap($aToolkitLib) [OS:genGUID "xcd"]
+  }
+
+  puts $aPbxprojFile "\t\t$aGuidsMap($aToolkitLib) = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.${theTargetType}\"; includeInIndex = 0; path = $aPath; sourceTree = BUILT_PRODUCTS_DIR; };\n"
+  puts $aPbxprojFile $aSrcFileRefSection
+  puts $aPbxprojFile $aDepsFileRefSection
+  # End PBXFileReference section
+
+
+  # Begin PBXFrameworksBuildPhase section
+  set aTkFrameworks "${theToolKit}_Frameworks"
+  if { ! [info exists aGuidsMap($aTkFrameworks)] } {
+    set aGuidsMap($aTkFrameworks) [OS:genGUID "xcd"]
+  }
+
+  puts $aPbxprojFile "\t\t$aGuidsMap($aTkFrameworks) = \{"
+  puts $aPbxprojFile "\t\t\tisa = PBXFrameworksBuildPhase;"
+  puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
+  puts $aPbxprojFile "\t\t\tfiles = ("
+  puts $aPbxprojFile $aDepsGuids
+  puts $aPbxprojFile "\t\t\t);"
+  puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
+  puts $aPbxprojFile "\t\t\};\n"
+  # End PBXFrameworksBuildPhase section
+
+  # Begin PBXGroup section
+  set aTkPBXGroup "${theToolKit}_PBXGroup"
+  if { ! [info exists aGuidsMap($aTkPBXGroup)] } {
+    set aGuidsMap($aTkPBXGroup) [OS:genGUID "xcd"]
+  }
+
+  set aTkSrcGroup "${theToolKit}_SrcGroup"
+  if { ! [info exists aGuidsMap($aTkSrcGroup)] } {
+    set aGuidsMap($aTkSrcGroup) [OS:genGUID "xcd"]
+  }
+
+  puts $aPbxprojFile $aGroupSection
+  puts $aPbxprojFile "\t\t$aGuidsMap($aTkPBXGroup) = \{"
+  puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
+  puts $aPbxprojFile "\t\t\tchildren = ("
+  puts $aPbxprojFile $aDepsRefGuids
+  puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSrcGroup) ,"
+  puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aToolkitLib) ,"
+  puts $aPbxprojFile "\t\t\t);"
+  puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
+  puts $aPbxprojFile "\t\t\};"
+  puts $aPbxprojFile "\t\t$aGuidsMap($aTkSrcGroup) = \{"
+  puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
+  puts $aPbxprojFile "\t\t\tchildren = ("
+  puts $aPbxprojFile $aPackagesGuids
+  puts $aPbxprojFile "\t\t\t);"
+  puts $aPbxprojFile "\t\t\tname = \"Source files\";"
+  puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
+  puts $aPbxprojFile "\t\t\};\n"
+  # End PBXGroup section
+
+  # Begin PBXHeadersBuildPhase section
+  set aTkHeaders "${theToolKit}_Headers"
+  if { ! [info exists aGuidsMap($aTkHeaders)] } {
+    set aGuidsMap($aTkHeaders) [OS:genGUID "xcd"]
+  }
+
+  puts $aPbxprojFile "\t\t$aGuidsMap($aTkHeaders) = \{"
+  puts $aPbxprojFile "\t\t\tisa = PBX${aPBXBuildPhase}BuildPhase;"
+  puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
+  puts $aPbxprojFile "\t\t\tfiles = ("
+  puts $aPbxprojFile "\t\t\t);"
+  puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = ${aRunOnlyForDeployment};"
+  puts $aPbxprojFile "\t\t\};\n"
+  # End PBXHeadersBuildPhase section
+
+  # Begin PBXNativeTarget section
+  set aTkBuildCfgListNativeTarget "${theToolKit}_BuildCfgListNativeTarget"
+  if { ! [info exists aGuidsMap($aTkBuildCfgListNativeTarget)] } {
+    set aGuidsMap($aTkBuildCfgListNativeTarget) [OS:genGUID "xcd"]
+  }
+
+  set aTkSources "${theToolKit}_Sources"
+  if { ! [info exists aGuidsMap($aTkSources)] } {
+    set aGuidsMap($aTkSources) [OS:genGUID "xcd"]
+  }
+
+  puts $aPbxprojFile "\t\t$aGuidsMap($theToolKit) = \{"
+  puts $aPbxprojFile "\t\t\tisa = PBXNativeTarget;"
+  puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListNativeTarget) ;"
+  puts $aPbxprojFile "\t\t\tbuildPhases = ("
+  puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSources) ,"
+  puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkFrameworks) ,"
+  puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkHeaders) ,"
+  puts $aPbxprojFile "\t\t\t);"
+  puts $aPbxprojFile "\t\t\tbuildRules = ("
+  puts $aPbxprojFile "\t\t\t);"
+  puts $aPbxprojFile "\t\t\tdependencies = ("
+  puts $aPbxprojFile "\t\t\t);"
+  puts $aPbxprojFile "\t\t\tname = $theToolKit;"
+  puts $aPbxprojFile "\t\t\tproductName = $theToolKit;"
+  puts $aPbxprojFile "\t\t\tproductReference = $aGuidsMap($aToolkitLib) ;"
+  puts $aPbxprojFile "\t\t\tproductType = \"com.apple.product-type.${aProductType}\";"
+  puts $aPbxprojFile "\t\t\};\n"
+  # End PBXNativeTarget section
+
+  # Begin PBXProject section
+  set aTkProjectObj "${theToolKit}_ProjectObj"
+  if { ! [info exists aGuidsMap($aTkProjectObj)] } {
+    set aGuidsMap($aTkProjectObj) [OS:genGUID "xcd"]
+  }
+
+  set aTkBuildCfgListProj "${theToolKit}_BuildCfgListProj"
+  if { ! [info exists aGuidsMap($aTkBuildCfgListProj)] } {
+    set aGuidsMap($aTkBuildCfgListProj) [OS:genGUID "xcd"]
+  }
+
+  puts $aPbxprojFile "\t\t$aGuidsMap($aTkProjectObj) = \{"
+  puts $aPbxprojFile "\t\t\tisa = PBXProject;"
+  puts $aPbxprojFile "\t\t\tattributes = \{"
+  puts $aPbxprojFile "\t\t\t\tLastUpgradeCheck = 0430;"
+  puts $aPbxprojFile "\t\t\t\};"
+  puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListProj) ;"
+  puts $aPbxprojFile "\t\t\tcompatibilityVersion = \"Xcode 3.2\";"
+  puts $aPbxprojFile "\t\t\tdevelopmentRegion = English;"
+  puts $aPbxprojFile "\t\t\thasScannedForEncodings = 0;"
+  puts $aPbxprojFile "\t\t\tknownRegions = ("
+  puts $aPbxprojFile "\t\t\t\ten,"
+  puts $aPbxprojFile "\t\t\t);"
+  puts $aPbxprojFile "\t\t\tmainGroup = $aGuidsMap($aTkPBXGroup);"
+  puts $aPbxprojFile "\t\t\tproductRefGroup = $aGuidsMap($aTkPBXGroup);"
+  puts $aPbxprojFile "\t\t\tprojectDirPath = \"\";"
+  puts $aPbxprojFile "\t\t\tprojectRoot = \"\";"
+  puts $aPbxprojFile "\t\t\ttargets = ("
+  puts $aPbxprojFile "\t\t\t\t$aGuidsMap($theToolKit) ,"
+  puts $aPbxprojFile "\t\t\t);"
+  puts $aPbxprojFile "\t\t\};\n"
+  # End PBXProject section
+
+  # Begin PBXSourcesBuildPhase section
+  puts $aPbxprojFile "\t\t$aGuidsMap($aTkSources) = \{"
+  puts $aPbxprojFile "\t\t\tisa = PBXSourcesBuildPhase;"
+  puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
+  puts $aPbxprojFile "\t\t\tfiles = ("
+  puts $aPbxprojFile $aSrcFileGuids
+  puts $aPbxprojFile "\t\t\t);"
+  puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
+  puts $aPbxprojFile "\t\t\};\n"
+  # End PBXSourcesBuildPhase section
+
+  # Begin XCBuildConfiguration section
+  set aTkDebugProject "${theToolKit}_DebugProject"
+  if { ! [info exists aGuidsMap($aTkDebugProject)] } {
+    set aGuidsMap($aTkDebugProject) [OS:genGUID "xcd"]
+  }
+
+  set aTkReleaseProject "${theToolKit}_ReleaseProject"
+  if { ! [info exists aGuidsMap($aTkReleaseProject)] } {
+    set aGuidsMap($aTkReleaseProject) [OS:genGUID "xcd"]
+  }
+
+  set aTkDebugNativeTarget "${theToolKit}_DebugNativeTarget"
+  if { ! [info exists aGuidsMap($aTkDebugNativeTarget)] } {
+    set aGuidsMap($aTkDebugNativeTarget) [OS:genGUID "xcd"]
+  }
+
+  set aTkReleaseNativeTarget "${theToolKit}_ReleaseNativeTarget"
+  if { ! [info exists aGuidsMap($aTkReleaseNativeTarget)] } {
+    set aGuidsMap($aTkReleaseNativeTarget) [OS:genGUID "xcd"]
+  }
+
+  # Debug target
+  puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugProject) = \{"
+  puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
+  puts $aPbxprojFile "\t\t\tbuildSettings = \{"
+
+  puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;"
+  puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
+  if { "$thePlatform" == "ios" } {
+    puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
+    puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
+    puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
+    puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
+  }
+  puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
+  puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
+  puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"c++0x\";"
+  puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = NO;"
+  puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
+  puts $aPbxprojFile "\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;"
+  puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
+  puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;"
+  puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
+  puts $aPbxprojFile "\t\t\t\t\t\"DEBUG=1\","
+  puts $aPbxprojFile "\t\t\t\t\t\"\$\(inherited\)\","
+  puts $aPbxprojFile "\t\t\t\t);"
+  puts $aPbxprojFile "\t\t\t\tGCC_SYMBOLS_PRIVATE_EXTERN = NO;"
+  puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
+  puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
+  puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
+  puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
+  puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
+  puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64D)\"; "
+  if { "$thePlatform" == "ios" } {
+    puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = NO;"
+    puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
   } else {
-    lappend aTKDefines "HAVE_WOK_CONFIG_H"
-    lappend aTKDefines "HAVE_CONFIG_H"
-    if { "$aWokStation" == "lin" } {
-      lappend aTKDefines "LIN"
+    puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = YES;"
+  }
+  puts $aPbxprojFile "\t\t\t\};"
+
+  puts $aPbxprojFile "\t\t\tname = Debug;"
+  puts $aPbxprojFile "\t\t\};"
+
+  # Release target
+  puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseProject) = \{"
+  puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
+  puts $aPbxprojFile "\t\t\tbuildSettings = \{"
+
+  puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";"
+  puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
+  if { "$thePlatform" == "ios" } {
+    puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
+    puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
+    puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
+    puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
+  }
+  puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
+  puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
+  puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"c++0x\";"
+  puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = YES;"
+  puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
+  puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
+  puts $aPbxprojFile "\t\t\t\tDEAD_CODE_STRIPPING = NO;"
+  puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 2;"
+  puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
+  puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
+  puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
+  puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
+  puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
+  puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64)\";"
+  if { "$thePlatform" == "ios" } {
+    puts $aPbxprojFile "\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 7.0;"
+    puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
+  }
+  puts $aPbxprojFile "\t\t\t\};"
+  puts $aPbxprojFile "\t\t\tname = Release;"
+  puts $aPbxprojFile "\t\t\};"
+  puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugNativeTarget) = \{"
+  puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
+  puts $aPbxprojFile "\t\t\tbuildSettings = \{"
+  puts $aPbxprojFile "${anExecExtension}"
+  puts $aPbxprojFile "${anExecPrefix}"
+  puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
+  foreach aMacro $aTKDefines {
+    puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
+  }
+  puts $aPbxprojFile "\t\t\t\t);"
+
+  puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
+  foreach anIncPath $anIncPaths {
+    puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
+  }
+  puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
+  puts $aPbxprojFile "\t\t\t\t);"
+
+  puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
+  foreach anLibPath $anLibPaths {
+    puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
+  }
+  puts $aPbxprojFile "\t\t\t\t);"
+
+  puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
+  puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
+  puts $aPbxprojFile "\t\t\t\t);"
+  puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
+  puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
+  puts $aPbxprojFile "\t\t\t\t);"
+  puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
+  set anUserHeaderSearchPath "\t\t\t\tUSER_HEADER_SEARCH_PATHS = \""
+  foreach anIncPath $anIncPaths {
+    append anUserHeaderSearchPath " ${anIncPath}"
+  }
+  append anUserHeaderSearchPath "\";"
+  puts $aPbxprojFile $anUserHeaderSearchPath
+  puts $aPbxprojFile "${aWrapperExtension}"
+  puts $aPbxprojFile "\t\t\t\};"
+  puts $aPbxprojFile "\t\t\tname = Debug;"
+  puts $aPbxprojFile "\t\t\};"
+  puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseNativeTarget) = \{"
+  puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
+  puts $aPbxprojFile "\t\t\tbuildSettings = \{"
+  puts $aPbxprojFile "${anExecExtension}"
+  puts $aPbxprojFile "${anExecPrefix}"
+  puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
+  foreach aMacro $aTKDefines {
+    puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
+  }
+  puts $aPbxprojFile "\t\t\t\t);"
+  puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
+  foreach anIncPath $anIncPaths {
+    puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
+  }
+  puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
+  puts $aPbxprojFile "\t\t\t\t);"
+
+  puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
+  foreach anLibPath $anLibPaths {
+    puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
+  }
+  puts $aPbxprojFile "\t\t\t\t);"
+
+  puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
+  puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
+  puts $aPbxprojFile "\t\t\t\t);"
+  puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
+  puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
+  puts $aPbxprojFile "\t\t\t\t);"
+  puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
+  puts $aPbxprojFile $anUserHeaderSearchPath
+  puts $aPbxprojFile "${aWrapperExtension}"
+  puts $aPbxprojFile "\t\t\t\};"
+  puts $aPbxprojFile "\t\t\tname = Release;"
+  puts $aPbxprojFile "\t\t\};\n"
+  # End XCBuildConfiguration section
+
+  # Begin XCConfigurationList section
+  puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListProj) = \{"
+  puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
+  puts $aPbxprojFile "\t\tbuildConfigurations = ("
+  puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugProject) ,"
+  puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseProject) ,"
+  puts $aPbxprojFile "\t\t\t);"
+  puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
+  puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
+  puts $aPbxprojFile "\t\t\};"
+  puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListNativeTarget) = \{"
+  puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
+  puts $aPbxprojFile "\t\t\tbuildConfigurations = ("
+  puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugNativeTarget) ,"
+  puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseNativeTarget) ,"
+  puts $aPbxprojFile "\t\t\t);"
+  puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
+  puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
+  puts $aPbxprojFile "\t\t\};\n"
+  # End XCConfigurationList section
+
+  puts $aPbxprojFile "\t\};"
+  puts $aPbxprojFile "\trootObject = $aGuidsMap($aTkProjectObj) ;"
+  puts $aPbxprojFile "\}"
+
+  close $aPbxprojFile
+}
+
+proc osutils:xcdx { theOutDir theExecutable theGuidsMap } {
+  set aUsername [exec whoami]
+
+  # Creating folders for Xcode project file.
+  set anExecutableDir "${theOutDir}/${theExecutable}.xcodeproj"
+  wokUtils:FILES:mkdir $anExecutableDir
+  if { ! [file exists $anExecutableDir] } {
+    puts stderr "Error: Could not create project directory \"$anExecutableDir\""
+    return
+  }
+
+  set aUserDataDir "${anExecutableDir}/xcuserdata"
+  wokUtils:FILES:mkdir $aUserDataDir
+  if { ! [file exists $aUserDataDir] } {
+    puts stderr "Error: Could not create xcuserdata directorty in \"$anExecutableDir\""
+    return
+  }
+
+  set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
+  wokUtils:FILES:mkdir $aUserDataDir
+  if { ! [file exists $aUserDataDir] } {
+    puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$anExecutableDir\"/xcuserdata"
+    return
+  }
+
+  set aSchemesDir "${aUserDataDir}/xcschemes"
+  wokUtils:FILES:mkdir $aSchemesDir
+  if { ! [file exists $aSchemesDir] } {
+    puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
+    return
+  }
+  # End folders creation.
+
+  # Generating GUID for tookit.
+  upvar $theGuidsMap aGuidsMap
+  if { ! [info exists aGuidsMap($theExecutable)] } {
+    set aGuidsMap($theExecutable) [OS:genGUID "xcd"]
+  }
+
+  # Creating xcscheme file for toolkit from template.
+  set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcode"]
+  regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theExecutable aXcschemeTmpl
+  regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theExecutable) aXcschemeTmpl
+  set aXcschemeFile [open "$aSchemesDir/${theExecutable}.xcscheme"  "w"]
+  puts $aXcschemeFile $aXcschemeTmpl
+  close $aXcschemeFile
+
+  # Creating xcschememanagement.plist file for toolkit from template.
+  set aPlistTmpl [osutils:readtemplate "plist" "xcode"]
+  regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theExecutable aPlistTmpl
+  regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theExecutable) aPlistTmpl
+  set aPlistFile [open "$aSchemesDir/xcschememanagement.plist"  "w"]
+  puts $aPlistFile $aPlistTmpl
+  close $aPlistFile
+}
+
+# Returns available Windows SDKs versions
+proc osutils:sdk { theSdkMajorVer {isQuietMode false} {theSdkDirectories {}} } {
+  if { ![llength ${theSdkDirectories}] } {
+    foreach anEnvVar { "ProgramFiles" "ProgramFiles\(x86\)" "ProgramW6432" } {
+      if {[ info exists ::env(${anEnvVar}) ]} {
+        lappend theSdkDirectories "$::env(${anEnvVar})/Windows Kits/${theSdkMajorVer}/Include"
+      }
     }
-    lappend aTKDefines "OCC_CONVERT_SIGNALS"
-    #lappend aTKDefines "_GNU_SOURCE=1"
   }
+
+  set sdk_versions {}
+  foreach sdk_dir ${theSdkDirectories} {
+    if { [file isdirectory ${sdk_dir}] } {
+      lappend sdk_versions [glob -tails -directory "${sdk_dir}" -type d *]
+    }
+  }
+
+  if {![llength ${sdk_versions}] && !${isQuietMode}} {
+    error "Error : Could not find Windows SDK ${theSdkMajorVer}"
+  }
+
+  return [join [lsort -unique ${sdk_versions}] " "]
 }
 
-# Define libraries to link using only EXTERNLIB file
-proc LibToLinkX {thePackage theDummyName} {
-  set aToolKits [LibToLink $thePackage]
-  return $aToolKits
+# Generate global properties to Visual Studio project file for UWP solution
+proc osutils:uwp:proj { isUWP theProjTmpl } {
+
+  set uwp_properties ""
+  set uwp_generate_metadata ""
+  set uwp_app_container ""
+
+  set format_template ""
+
+  if { $isUWP } {
+    set sdk_versions [osutils:sdk 10]
+    set sdk_max_ver [lindex ${sdk_versions} end]
+
+    set uwp_properties "<DefaultLanguage>en-US</DefaultLanguage>\n   \
+<ApplicationType>Windows Store</ApplicationType>\n   \
+<ApplicationTypeRevision>10.0</ApplicationTypeRevision>\n   \
+<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>\n   \
+<AppContainerApplication>true</AppContainerApplication>\n   \
+<WindowsTargetPlatformVersion>${sdk_max_ver}</WindowsTargetPlatformVersion>\n   \
+<WindowsTargetPlatformMinVersion>${sdk_max_ver}</WindowsTargetPlatformMinVersion>"
+
+    set uwp_generate_metadata        "<GenerateWindowsMetadata>false</GenerateWindowsMetadata>"
+
+    regsub -all -- {[\r\n\s]*<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>} ${theProjTmpl} "" theProjTmpl
+  } else {
+    set format_template "\[\\r\\n\\s\]*"
+  }
+
+  regsub -all -- "${format_template}__UWP_PROPERTIES__"        ${theProjTmpl} "${uwp_properties}" theProjTmpl
+  regsub -all -- "${format_template}__UWP_GENERATE_METADATA__" ${theProjTmpl} "${uwp_generate_metadata}" theProjTmpl
+
+  return ${theProjTmpl}
 }
 
-# launch generation
-genproj {*}$::argv
+# Report all files found in package directory but not listed in FILES
+proc osutils:checksrcfiles { theUnit } {
+  global path
+  set aCasRoot [file normalize ${path}]
+
+  if {![file isdirectory ${aCasRoot}]} {
+    puts "OCCT directory is not defined correctly: ${aCasRoot}"
+    return
+  }
+
+  set anUnitAbsPath [file normalize "${aCasRoot}/src/${theUnit}"]
+
+  if {[file exists "${anUnitAbsPath}/FILES"]} {
+    set aFilesFile [open "${anUnitAbsPath}/FILES" rb]
+    set aFilesFileList [split [read ${aFilesFile}] "\n"]
+    close ${aFilesFile}
+
+    set aFilesFileList [lsearch -inline -all -not -exact ${aFilesFileList} ""]
+
+    # report all files not listed in FILES
+    set anAllFiles [glob -tails -nocomplain -dir ${anUnitAbsPath} "*"]
+    foreach aFile ${anAllFiles} {
+      if { "${aFile}" == "FILES" } {
+        continue
+      }
+      if { [lsearch -exact ${aFilesFileList} ${aFile}] == -1 } {
+        puts "Warning: file ${anUnitAbsPath}/${aFile} is not listed in ${anUnitAbsPath}/FILES!"
+      }
+    }
+  }
+}