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