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