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