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