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