package ELYSE
version v7r0

#//////////////////////////////////////////////////
#/// Uses needed to build this package ////////////
#//////////////////////////////////////////////////

use OpenScientist v16r0 Interfaces

#use Geant4 v2r* Interfaces

set G4RADIOACTIVEDATA "${OSC_G4RADIOACTIVEDATA}"
set G4LEVELGAMMADATA "${OSC_G4LEVELGAMMADATA}"
set G4LEDATA "${OSC_G4LEDATA}"
set NeutronHPCrossSections "${OSC_NeutronHPCrossSections}"

#////////////////////////////////////////////////////////////
#/// From Interfaces/Platform ///////////////////////////////
#////////////////////////////////////////////////////////////

macro Platform_bin "${CMTCONFIG}"
#set PLATFORMBIN "${Platform_bin}"

pattern Platform_paths \
  path_remove LD_LIBRARY_PATH "$(<PACKAGE>ROOT)/$(Platform_bin)" WIN32 "" Darwin "" ;\
  path_append LD_LIBRARY_PATH "$(<PACKAGE>ROOT)/$(Platform_bin)" WIN32 "" Darwin "" ;\
  path_remove DYLD_LIBRARY_PATH "" Darwin "$(<PACKAGE>ROOT)/$(Platform_bin)" ;\
  path_append DYLD_LIBRARY_PATH "" Darwin "$(<PACKAGE>ROOT)/$(Platform_bin)" ;\
  path_remove PATH "$(<PACKAGE>ROOT)/$(Platform_bin)" WIN32 "$(<PACKAGE>ROOT)\$(Platform_bin)" ;\
  path_append PATH "$(<PACKAGE>ROOT)/$(Platform_bin)" WIN32 "$(<PACKAGE>ROOT)\$(Platform_bin)"

# Darwin : to build dlls properly :
macro make_shlib "$(make_shlib)" Darwin "$(ELYSEROOT)/cmt/cmt_make_shlib_common.sh extract"

#//////////////////////////////////////////////////
#//////////////////////////////////////////////////
#//////////////////////////////////////////////////

branches run

build_strategy no_prototypes
include_path none

include_dirs $(ELYSEROOT)

# With Geant4 global libs :
macro ELYSE_Geant4_incs "${OSC_Geant4_incs}"
macro ELYSE_Geant4_linkopts "-L${OSC_Geant4_lib} -lG4physicslists -lG4readout -lG4run -lG4event -lG4tracking -lG4processes -lG4digits_hits -lG4track -lG4particles -lG4geometry -lG4graphics_reps -lG4materials -lG4intercoms -lG4global -lCLHEP"

# Waiting Geant4 DLL on Windows...
# Darwin : problem too with dylibs.
macro ELYSE_libopts "" WIN32 " -no_share" Darwin " -no_share"
#macro ELYSE_libopts "" WIN32 ""

#//////////////////////////////////////////////////
#/// Over Geant4 kernel and AIDA interfaces only //
#//////////////////////////////////////////////////

# Over Geant4 and AIDA only :
library ELYSECore ${ELYSE_libopts} -s=../source *.cxx

#JEC 17/11/05 add the G4readout_incs to manage G4DigiManager
macro ELYSECore_cppflags "${OSC_AIDA_incs} ${ELYSE_Geant4_incs}"
#macro ELYSECore_shlibflags "${ELYSE_Geant4_linkopts}"
macro ELYSECore_linkopts "-L${ELYSEROOT}/$(Platform_bin) -lELYSECore" WIN32 "${ELYSEROOT}\$(Platform_bin)\ELYSECore.lib"

#//////////////////////////////////////////////////
#/// DLD callbacks ////////////////////////////////
#//////////////////////////////////////////////////

# Must not use Geant4 singletons if having not Geant4 shared libs.
macro ELYSE_kind "dll"
library ELYSE -s=../source/Callbacks Callbacks.cxx InventorCallbacks.cxx
#macro ELYSE_cppflags "${ELYSE_Geant4_incs} ${OSC_OnX_incs}"
macro ELYSE_cppflags "${OSC_G4Lab_incs} ${OSC_AIDA_incs} ${OSC_OnX_incs} ${OSC_Inventor_incs}"
macro ELYSE_shlibflags "${OSC_Inventor_linkopts} ${OSC_OnX_linkopts}"

#//////////////////////////////////////////////////
#/// Application "a la Geant4 examples" ///////////
#//////////////////////////////////////////////////

# Over Geant4 and AIDA only :
application ELYSE_batch ../applications/ELYSE_batch.cxx use_linkopts='"${ELYSECore_linkopts} ${ELYSE_Geant4_linkopts} ${OSC_AIDA_linkopts}"'
#macro ELYSE_batch_cppflags "${ELYSECore_cppflags} "
macro ELYSE_batch_cppflags "${ELYSECore_cppflags}"

# Over AIDA only :
application ELYSE_analysis ../applications/ELYSE_analysis.cxx use_linkopts='"$(OSC_AIDA_linkopts)"'

# Over G4Lab :
application ELYSE_session ../applications/ELYSE_session.cxx ../applications/HitsCollectionAccessor.cxx use_linkopts='"${ELYSECore_linkopts} ${OSC_G4Lab_linkopts} ${ELYSE_Geant4_linkopts} ${OSC_Inventor_linkopts} ${OSC_OnX_linkopts}"' 
macro ELYSE_session_cppflags "${ELYSE_Geant4_incs} ${ELYSE_batch_cppflags}"

application test -group=debug -s=../source test.cxx

#//////////////////////////////////////////////////
#/// Things using ROOT ////////////////////////////
#//////////////////////////////////////////////////
use ROOT v1r* Interfaces

# Example of ROOT program to work on a ELYSE.root file :
application ELYSE_analysis_ROOT -group=ROOT ../applications/ELYSE_analysis_ROOT.cxx use_linkopts='"${ROOT_Gpad_linkopts} ${ROOT_freetype_linkopts} ${ROOT_Graf_linkopts} ${ROOT_Tree_linkopts} ${ROOT_Hist_linkopts} ${ROOT_Matrix_linkopts} ${ROOT_Core_linkopts} ${ROOT_Cint_linkopts}"'

# Compiled version of scripts/ROOT/aida.C
application ELYSE_analysis_aida_ROOT -group=ROOT ../applications/ELYSE_analysis_aida_ROOT.cxx use_linkopts='"${OSC_AIDA_linkopts} ${ROOT_Gpad_linkopts} ${ROOT_freetype_linkopts} ${ROOT_Graf_linkopts} ${ROOT_Hist_linkopts} ${ROOT_Matrix_linkopts} ${ROOT_Core_linkopts} ${ROOT_Cint_linkopts}"'
macro ELYSE_analysis_aida_ROOT_cppflags "${OSC_AIDA_incs}"

# Declare AIDA to rootcint.
# See scripts/ROOT/aida.C for a usage example.

macro ELYSE_cint_cintflags "${OSC_AIDA_incs}"
macro ELYSE_cint_LinkDef_h "../source/ROOT/LinkDef.h"
document rootcint ELYSE_rootcint_AIDA -group=ROOT ${ELYSEROOT}/source/ROOT/ELYSE_cint.h

library ELYSEAIDADict -group=ROOT -import=ROOT ${dict}/ELYSE_cintDict.cpp
macro ELYSEAIDADict_shlibflags "$(OSC_AIDA_linkopts) ${ROOT_Core_linkopts} ${ROOT_Cint_linkopts}"

#//////////////////////////////////////////////////
#//////////////////////////////////////////////////
#//////////////////////////////////////////////////

private
macro build_library_links "true" WIN32 ""
macro remove_library_links "true" WIN32 ""

# WIN32 : /GR to enable RTTI and dynamic cast.
# WIN32 : /GX to enable exception handling (for STL).
macro_append cppflags "" WIN32 " /GX /GR" 

# DEBUG :
#macro_append cflags  " -g" WIN32 " /ZI /Od"
#macro_append cppflags  " -g" WIN32 " /ZI /Od"
#macro_append cpplinkflags  " -g" WIN32 " /DEBUG"

# OPTIMIZE :
macro_append cflags  " -O" WIN32 " /O2"
macro_append cppflags  " -O" WIN32 " /O2"
macro_append cpplinkflags  " -O" WIN32 ""
public

#//////////////////////////////////////////////////
#// Run time //////////////////////////////////////
#//////////////////////////////////////////////////

apply_pattern Platform_paths

