# -*- Python -*-

import os

Import('*')
from CXL_init import *

libName = "CXLSharedProfiling"

env = CXL_env.Clone()

env.Append( CPPPATH = [ 
	"./",
	"./inc",
	env['CXL_commonproj_dir'],
	env['CXL_commonproj_dir'] + "/AMDTOSWrappers/Include",
	env['CXL_common_dir'] + "/Src/TSingleton",
        env['CXL_commonproj_dir'] + '/../../CodeXL',
        env['CXL_commonproj_dir'] + '/../../CodeXL/Components',
])

UseTinyXml(env)
UseQt4(env)

CXL_lib_common_amd_deps = (
)

initCommonLibAmd (env, CXL_lib_common_amd_deps)

moc_files = Split(
            " inc/ProfileApplicationTreeHandler.h"
            + " inc/SessionTreeNodeData.h"
            + " inc/SharedProfileManager.h"
            + " inc/SharedProfileSettingPage.h"
            + " inc/SharedSessionWindow.h"
            + " inc/SharedMenuActions.h"
            )
	
# Source files:
sources = \
[
	"src/AMDTSharedProfiling.cpp",
	"src/SessionTreeNodeData.cpp",
	"src/SharedMenuActions.cpp",
	"src/SharedProfileManager.cpp",
	"src/SharedProfileSettingPage.cpp",
	"src/SharedProfileSingletonsDelete.cpp",
	"src/SharedProfileProcessMonitor.cpp",
    "src/SharedSessionWindow.cpp",
    "src/ProfileApplicationTreeHandler.cpp"
]

commonLinkedLibraries = \
[
]

linuxVariantLinkedLibraries = \
[
	"libGL",
]

linkedLibraries = commonLinkedLibraries + linuxVariantLinkedLibraries
env.Prepend (LIBS = linkedLibraries)

# Set the ELF hash generation mode:
# - When building on new systems, we would like to generate both sysv and gnu ELF hashes.
#   This enables running the executable also on old systems, that support only the sysv ELF hash.
# - When building on old systems, we need to set the GR_GENERATE_ONLY_DEFAULT_ELF_HASH environment
#   variable (preferably in the .bashrc file). Otherwise the link will fail when trying to
#   generate an ELF hash type that the old linker does not recognize.
# [Yaki 7/7/2009]
linkerFlags = [] 
shouldGenerateOnlyDefaultELFHash = os.environ.get('GR_GENERATE_ONLY_DEFAULT_ELF_HASH')
if shouldGenerateOnlyDefaultELFHash is None:
	linkerFlags += [ "-Wl,--hash-style=both" ]

MOC_Generated = []
for moc_file in moc_files:
    MOC_Generated += env.MocBld(moc_file)

# Creating shared libraries
soFiles = env.SharedLibrary(
	target = libName, 
	source = sources + MOC_Generated,
	LINKFLAGS = linkerFlags)


# Installing libraries
libInstall = env.Install( 
	dir = env['CXL_lib_dir'], 
	source = (soFiles))

Return('libInstall')
