#---------------------------------------------------------------
#    Copyright 2006, 2007 Sandia Corporation.
#    Under the terms of Contract DE-AC04-94AL85000, there is a
#    non-exclusive license for use of this work by or on behalf
#    of the U.S. Government.  Export of this program may require
#    a license from the United States Government.
#---------------------------------------------------------------

#
# The signature for Boost.build rules is described here:
#
# http://www.boost.org/build/doc/html/bbv2/overview/targets.html
#
#function-name main-target-name
#    : sources
#    : requirements
#    : default-build
#    : usage-requirements
#    ;
#
#    * "main-target-name" is the name used to request the target
#            on command line and to use it from other main targets.
#            Main target name may contain alphanumeric characters and symbols '-' and '_';
#    * "sources" is the list of source files and other main targets that must be combined.
#    * "requirements" is the list of properties that must always be present
#            when this main target is built.
#    * "default-build" is the list of properties that will be used unless
#            some other value of the same feature is already specified.
#    * "usage-requirements" is the list of properties that will be propagated
#            to all main targets that use this one, i.e. to all dependedents.
#
#
# SECTION 1: Project definition
#

import set ;
import path ;


project votd
  : requirements
    $(sierra-warnings)
    <define>STK_BUILT_IN_SIERRA
    <include>$(stk_simd-root)
    <define>USE_STK_SIMD_AUTO
    <architecture>fat_x86:<define>USE_STK_SIMD_SSE
    <architecture>generic_x86:<define>USE_STK_SIMD_SSE
    <architecture>nehalem:<define>USE_STK_SIMD_SSE
    <architecture>sandybridge:<define>USE_STK_SIMD_AVX
    <architecture>haswell:<define>USE_STK_SIMD_AVX
    <architecture>knc:<define>USE_STK_SIMD_NONE
    <architecture>knl:<define>USE_STK_SIMD_AVX512
    <architecture>cray,<toolset>intel:<define>USE_STK_SIMD_AUTO
    <architecture>cray,<toolset>gcc:<define>USE_STK_SIMD_NONE
    <architecture>cray,<toolset>cray:<define>USE_STK_SIMD_NONE
    <cuda>on:<define>KOKKOS_CUDA_USE_LAMBDA=1
  : usage-requirements
    <include>$(stk_simd-root)
    <define>USE_STK_SIMD_AUTO
    <architecture>fat_x86:<define>USE_STK_SIMD_SSE
    <architecture>generic_x86:<define>USE_STK_SIMD_SSE
    <architecture>nehalem:<define>USE_STK_SIMD_SSE
    <architecture>sandybridge:<define>USE_STK_SIMD_AVX
    <architecture>haswell:<define>USE_STK_SIMD_AVX
    <architecture>knc:<define>USE_STK_SIMD_NONE
    <architecture>knl:<define>USE_STK_SIMD_AVX512
    <architecture>cray,<toolset>intel:<define>USE_STK_SIMD_AUTO
    <architecture>cray,<toolset>gcc:<define>USE_STK_SIMD_NONE
    <architecture>cray,<toolset>cray:<define>USE_STK_SIMD_NONE
  : build-dir $(stk_simd-builddir)
  ;

#
# SECTION 2: Development install
#
explicit install-serial-targets ;
alias install-serial-targets ;

explicit install-targets ;
alias install-targets
  : stk_simd_unit 
    stk_simd_docs_tests
  ;

#
# SECTION 3: End-user install
#
explicit install-user-env ;
alias install-user-env : install-user-jamfile
                         install-user-include ;

# This rule copies build-system related files for this product to the install-root.
explicit install-user-jamfile ;
install install-user-jamfile
  : [ glob $(stk_simd-root)/Jamfile ]
  : <location>$(install-root)/stk/stk_simd
    <install-source-root>$(stk_simd-root)
  ;

explicit install-user-include ;
install install-user-include
  : [ path.glob-tree $(stk_simd-root) : *.hpp no_simd/*hpp sse/*hpp avx/*hpp avx_512/*hpp  ]
  : <location>$(install-root)/stk/stk_simd
    <install-source-root>$(stk_simd-root)
  ;

explicit install-exe-targets ;
alias install-exe-targets : ;

alias stk_simd_headers
  : # No sources defined for header-only libraries
  : # No build requirements
  : # No default build
  :
    <include>$(stk_simd-root)
  ;


#
# SECTION 4: Build configuration
#

obj stk_simd_test_main 
  :
    $(stk_simd-root)/unit_test_main/SimdUnitTestMain.cpp
    /tpl/trilinos-kokkoscore//kokkoscore
    /tpl/gtest//gtest
  :
  ;

exe stk_simd_unit
  :
    [ glob $(stk_simd-root)/unit_tests/*.cpp ]
    stk_simd_test_main
    /tpl/trilinos-kokkoscore//kokkoscore
    /tpl/gtest//gtest
  : <tag>@sierra-exec-tag
    <target-os>linux,<toolset>gcc,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>gcc,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>clang,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>clang,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>intel,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>intel,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>pgi,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>pgi,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>vacpp,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>vacpp,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>cray,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>cray,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>nvidia,<runtime-link>shared:<linkflags>"-Xlinker --export-dynamic"
    <target-os>linux,<toolset>nvidia,<runtime-link>shared:<linkflags>"-Xlinker --export-dynamic"
    <target-os>darwin,<runtime-link>shared:<linkflags>"-Wl,-dynamic"
  ;

exe stk_simd_docs_tests
  :
    [ glob $(stk_simd-root)/../stk_doc_tests/stk_simd/*.cpp ]
    stk_simd_test_main
    /tpl/trilinos-kokkoscore//kokkoscore
    /tpl/gtest//gtest
  : <tag>@sierra-exec-tag
    <include>$(stk_simd-root)/../stk_doc_tests/stk_simd
    <target-os>linux,<toolset>gcc,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>gcc,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>clang,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>clang,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>intel,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>intel,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>pgi,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>pgi,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>vacpp,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>vacpp,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>cray,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>cray,<runtime-link>shared:<linkflags>-Wl,-E
    <target-os>linux,<toolset>nvidia,<runtime-link>shared:<linkflags>"-Xlinker --export-dynamic"
    <target-os>linux,<toolset>nvidia,<runtime-link>shared:<linkflags>"-Xlinker --export-dynamic"
    <target-os>darwin,<runtime-link>shared:<linkflags>"-Wl,-dynamic"
  ;
