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