0024816: Tool for upgrading OCCT and dependent code
[occt.git] / adm / templates / env.sh
CommitLineData
910970ab 1#!/bin/bash
2
3# go to the script directory
4aScriptPath=${BASH_SOURCE%/*}; if [ -d "${aScriptPath}" ]; then cd "$aScriptPath"; fi; aScriptPath="$PWD";
5
6export CASROOT="__CASROOT__"
7
8if [ "${CASROOT}" != "" ] && [ -d "${aScriptPath}/${CASROOT}" ]; then
9 export CASROOT="${aScriptPath}/${CASROOT}"
10fi
11if [ "${CASROOT}" == "" ]; then
12 export CASROOT="${aScriptPath}"
13fi
14
15# Reset values
16export CASDEB=""
c7d774c5 17export TARGET="";
910970ab 18export HAVE_TBB="false";
19export HAVE_OPENCL="false";
20export HAVE_FREEIMAGE="false";
21export HAVE_GL2PS="false";
22export HAVE_VTK="false";
23export MACOSX_USE_GLX="false";
24export CSF_OPT_INC=""
25export CSF_OPT_LIB32=""
26export CSF_OPT_LIB64=""
27export CSF_OPT_BIN32=""
28export CSF_OPT_BIN64=""
29
30# ----- Set local settings -----
31if [ -e "${aScriptPath}/custom.sh" ]; then source "${aScriptPath}/custom.sh"; fi
32
33# Read script arguments
34shopt -s nocasematch
c7d774c5 35for i in $*
36do
37 if [ "$i" == "d" ] || [ "$i" == "debug" ]; then
38 export CASDEB="d"
39 elif [ "$i" == "cbp" ]; then
40 export TARGET="cbp";
41 elif [ "$i" == "xcd" ] || [ "$i" == "xcode" ]; then
42 export TARGET="xcd";
43 fi
44done
910970ab 45shopt -u nocasematch
46
47# ----- Setup Environment Variables -----
48anArch=`uname -m`
49if [ "$anArch" != "x86_64" ] && [ "$anArch" != "ia64" ]; then
50 export ARCH="32";
51else
52 export ARCH="64";
53fi
54
55aSystem=`uname -s`
56if [ "$aSystem" == "Darwin" ]; then
57 export WOKSTATION="mac";
58 export ARCH="64";
59else
60 export WOKSTATION="lin";
61fi
62
63export CASBIN=""
64if [ "${TARGET}" == "cbp" ]; then
65 export CASBIN="${WOKSTATION}/cbp"
66elif [ "${TARGET}" == "xcd" ]; then
67 export CASBIN="adm/mac/xcd/build"
68fi
69
70export CSF_OPT_INC="${CSF_OPT_INC}:${CASROOT}/inc"
71
72if [ "${TARGET}" == "cbp" ]; then
73 export CSF_OPT_LIB32D="${CSF_OPT_LIB32}:${CASROOT}/${CASBIN}/libd"
74 export CSF_OPT_LIB64D="${CSF_OPT_LIB64}:${CASROOT}/${CASBIN}/libd"
75 export CSF_OPT_LIB32="${CSF_OPT_LIB32}:${CASROOT}/${CASBIN}/lib"
76 export CSF_OPT_LIB64="${CSF_OPT_LIB64}:${CASROOT}/${CASBIN}/lib"
77elif [ "${TARGET}" == "xcd" ]; then
78 export CSF_OPT_LIB32D="${CSF_OPT_LIB32}:${CASROOT}/${CASBIN}/Debug"
79 export CSF_OPT_LIB64D="${CSF_OPT_LIB64}:${CASROOT}/${CASBIN}/Debug"
80 export CSF_OPT_LIB32="${CSF_OPT_LIB32}:${CASROOT}/${CASBIN}/Release"
81 export CSF_OPT_LIB64="${CSF_OPT_LIB64}:${CASROOT}/${CASBIN}/Release"
82fi
83
84export CSF_OPT_CMPL=""
85
86# Optiona 3rd-parties should be enabled by HAVE macros
87if [ "$HAVE_TBB" == "true" ]; then
88 export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_TBB"
89fi
90if [ "$HAVE_OPENCL" == "true" ]; then
91 export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_OPENCL"
92fi
93if [ "$HAVE_FREEIMAGE" == "true" ]; then
94 export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_FREEIMAGE"
95fi
96if [ "$HAVE_GL2PS" == "true" ]; then
97 export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_GL2PS"
98fi
99if [ "$HAVE_VTK" == "true" ]; then
100 export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_VTK"
101fi
102# Option to compile OCCT with X11 libs on Mac OS X
103if [ "$MACOSX_USE_GLX" == "true" ]; then
104 export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DMACOSX_USE_GLX"
105fi
106
107# To split string into array
108aDelimBack=$IFS
109IFS=":"
110
111# 3rd-parties additional include paths
112set -- "$CSF_OPT_INC"
113declare -a aPartiesIncs=($*)
114for anItem in ${aPartiesIncs[*]}
115do
116 export CSF_OPT_CMPL="${CSF_OPT_CMPL} -I${anItem}";
117done
118
119# Append 3rd-parties to LD_LIBRARY_PATH
120if [ "$ARCH" == "32" ]; then
121 set -- "$CSF_OPT_LIB32"
122 declare -a aPartiesLibs=($*)
123 set -- "$CSF_OPT_LIB32D"
124 declare -a aPartiesLibsDeb=($*)
125else
126 set -- "$CSF_OPT_LIB64"
127 declare -a aPartiesLibs=($*)
128 set -- "$CSF_OPT_LIB64D"
129 declare -a aPartiesLibsDeb=($*)
130fi
131
132# Turn back value
133IFS=$aDelimBack
134
135OPT_LINKER_OPTIONS_DEB=""
136for anItem in ${aPartiesLibsDeb[*]}
137do
138 OPT_LINKER_OPTIONS_DEB="${OPT_LINKER_OPTIONS_DEB} -L${anItem}"
139done
140
141OPT_LINKER_OPTIONS=""
142for anItem in ${aPartiesLibs[*]}
143do
144 if [ "${LD_LIBRARY_PATH}" == "" ]; then
145 export LD_LIBRARY_PATH="${anItem}"
146 else
147 export LD_LIBRARY_PATH="${anItem}:${LD_LIBRARY_PATH}"
148 fi
149 OPT_LINKER_OPTIONS="${OPT_LINKER_OPTIONS} -L${anItem}"
150done
151
152if [ "$ARCH" == "64" ]; then
153 export CSF_OPT_LNK64="$OPT_LINKER_OPTIONS"
154 export CSF_OPT_LNK64D="$OPT_LINKER_OPTIONS_DEB"
155else
156 export CSF_OPT_LNK32="$OPT_LINKER_OPTIONS"
157 export CSF_OPT_LNK32D="$OPT_LINKER_OPTIONS_DEB"
158fi
159
160
161BIN_PATH="${CASBIN}/bin${CASDEB}"
162LIBS_PATH="${CASBIN}/lib${CASDEB}"
163if [ "${TARGET}" == "xcd" ]; then
164 [[ "${CASDEB}" == "d" ]] && BIN_PATH="${CASBIN}/Debug" || BIN_PATH="${CASBIN}/Release"
165 LIBS_PATH="$BIN_PATH"
166fi
167
168export PATH="${CASROOT}/${BIN_PATH}:${PATH}"
169export LD_LIBRARY_PATH="${CASROOT}/${LIBS_PATH}:${LD_LIBRARY_PATH}"
170if [ "$WOKSTATION" == "mac" ]; then
171 export DYLD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${DYLD_LIBRARY_PATH}"
172fi
173
174# Set envoronment variables used by OCCT
175export CSF_LANGUAGE="us"
176export MMGT_CLEAR="1"
177export CSF_EXCEPTION_PROMPT="1"
178export CSF_SHMessage="${CASROOT}/src/SHMessage"
179export CSF_MDTVTexturesDirectory="${CASROOT}/src/Textures"
180export CSF_ShadersDirectory="${CASROOT}/src/Shaders"
181export CSF_XSMessage="${CASROOT}/src/XSMessage"
182export CSF_TObjMessage="${CASROOT}/src/TObj"
183export CSF_StandardDefaults="${CASROOT}/src/StdResource"
184export CSF_PluginDefaults="${CASROOT}/src/StdResource"
185export CSF_XCAFDefaults="${CASROOT}/src/StdResource"
186export CSF_TObjDefaults="${CASROOT}/src/StdResource"
187export CSF_StandardLiteDefaults="${CASROOT}/src/StdResource"
188export CSF_UnitsLexicon="${CASROOT}/src/UnitsAPI/Lexi_Expr.dat"
189export CSF_UnitsDefinition="${CASROOT}/src/UnitsAPI/Units.dat"
190export CSF_IGESDefaults="${CASROOT}/src/XSTEPResource"
191export CSF_STEPDefaults="${CASROOT}/src/XSTEPResource"
192export CSF_XmlOcafResource="${CASROOT}/src/XmlOcafResource"
193export CSF_MIGRATION_TYPES="${CASROOT}/src/StdResource/MigrationSheet.txt"
194
195# Draw Harness special stuff
196if [ -e "${CASROOT}/src/DrawResources" ]; then
197 export DRAWHOME="${CASROOT}/src/DrawResources"
198 export CSF_DrawPluginDefaults="${DRAWHOME}"
199fi
200if [ -e "${aScriptPath}/src/DrawResourcesProducts" ]; then
201 export CSF_DrawPluginProductsDefaults="${aScriptPath}/src/DrawResourcesProducts"
202fi