0027056: Configuration, genproj.tcl - fix generation of project files for Products
[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_GL2PS="false";
14 export HAVE_VTK="false";
15 export MACOSX_USE_GLX="false";
16 export CSF_OPT_INC=""
17 export CSF_OPT_LIB32=""
18 export CSF_OPT_LIB64=""
19 export CSF_OPT_BIN32=""
20 export CSF_OPT_BIN64=""
21
22 # ----- Set local settings -----
23 if [ "${CASROOT}" != "" ] && [ -e "${CASROOT}/custom.sh" ]; then source "${CASROOT}/custom.sh"; fi
24 if [ -e "${aScriptPath}/custom.sh" ]; then source "${aScriptPath}/custom.sh"; fi
25
26 if [ "${CASROOT}" != "" ] && [ -d "${aScriptPath}/${CASROOT}" ]; then
27   export CASROOT="${aScriptPath}/${CASROOT}"
28 fi
29 if [ "${CASROOT}" == "" ]; then
30   export CASROOT="${aScriptPath}"
31 fi
32
33 # Read script arguments
34 shopt -s nocasematch
35 for i in $*
36 do
37   if [ "$i" == "d" ] || [ "$i" == "debug" ]; then
38     export CASDEB="d"
39   elif [ "$i" == "i" ] || [ "$i" == "relwithdeb" ]; then
40     export CASDEB="i"
41   elif [ "$i" == "cbp" ]; then
42     export TARGET="cbp";
43   elif [ "$i" == "xcd" ] || [ "$i" == "xcode" ]; then
44     export TARGET="xcd";
45   fi
46 done
47 shopt -u nocasematch
48
49 # ----- Setup Environment Variables -----
50 anArch=`uname -m`
51 if [ "$anArch" != "x86_64" ] && [ "$anArch" != "ia64" ]; then
52   export ARCH="32";
53 else
54   export ARCH="64";
55 fi
56
57 aSystem=`uname -s`
58 if [ "$aSystem" == "Darwin" ]; then
59   export WOKSTATION="mac";
60   export ARCH="64";
61 else
62   export WOKSTATION="lin";
63 fi
64
65 export CASBIN=""
66 if [ "${TARGET}" == "cbp" ]; then
67   export CASBIN="${WOKSTATION}/cbp"
68 elif [ "${TARGET}" == "xcd" ]; then
69   export CASBIN="adm/mac/xcd/build"
70 fi
71
72 export CSF_OPT_INC="${CSF_OPT_INC}:${CASROOT}/inc"
73
74 if [ "${TARGET}" == "cbp" ]; then
75   export CSF_OPT_LIB32D="${CSF_OPT_LIB32}:${CASROOT}/${CASBIN}/libd"
76   export CSF_OPT_LIB64D="${CSF_OPT_LIB64}:${CASROOT}/${CASBIN}/libd"
77   export CSF_OPT_LIB32="${CSF_OPT_LIB32}:${CASROOT}/${CASBIN}/lib"
78   export CSF_OPT_LIB64="${CSF_OPT_LIB64}:${CASROOT}/${CASBIN}/lib"
79   export CSF_OPT_LIB32I="${CSF_OPT_LIB32}:${CASROOT}/${CASBIN}/libi"
80   export CSF_OPT_LIB64I="${CSF_OPT_LIB64}:${CASROOT}/${CASBIN}/libi"
81 elif [ "${TARGET}" == "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 fi
89
90 export CSF_OPT_CMPL=""
91
92 # Optiona 3rd-parties should be enabled by HAVE macros
93 if [ "$HAVE_TBB" == "true" ]; then
94   export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_TBB"
95 fi
96 if [ "$HAVE_OPENCL" == "true" ]; then
97   export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_OPENCL"
98 fi
99 if [ "$HAVE_FREEIMAGE" == "true" ]; then
100   export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_FREEIMAGE"
101 fi
102 if [ "$HAVE_GL2PS" == "true" ]; then
103   export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_GL2PS"
104 fi
105 if [ "$HAVE_VTK" == "true" ]; then
106   export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_VTK"
107 fi
108 # Option to compile OCCT with X11 libs on Mac OS X
109 if [ "$MACOSX_USE_GLX" == "true" ]; then
110   export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DMACOSX_USE_GLX"
111 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
179 BIN_PATH="${CASBIN}/bin${CASDEB}"
180 LIBS_PATH="${CASBIN}/lib${CASDEB}"
181 if [ "${TARGET}" == "xcd" ]; then
182   [[ "${CASDEB}" == "d" ]] && BIN_PATH="${CASBIN}/Debug" || BIN_PATH="${CASBIN}/Release"
183   LIBS_PATH="$BIN_PATH"
184 fi
185
186 export PATH="${CASROOT}/${BIN_PATH}:${PATH}"
187 export LD_LIBRARY_PATH="${CASROOT}/${LIBS_PATH}:${LD_LIBRARY_PATH}"
188 if [ "$WOKSTATION" == "mac" ]; then
189   export DYLD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${DYLD_LIBRARY_PATH}"
190 fi
191
192 # Set envoronment variables used by OCCT
193 export CSF_LANGUAGE="us"
194 export MMGT_CLEAR="1"
195 export CSF_EXCEPTION_PROMPT="1"
196 export CSF_SHMessage="${CASROOT}/src/SHMessage"
197 export CSF_MDTVTexturesDirectory="${CASROOT}/src/Textures"
198 export CSF_ShadersDirectory="${CASROOT}/src/Shaders"
199 export CSF_XSMessage="${CASROOT}/src/XSMessage"
200 export CSF_TObjMessage="${CASROOT}/src/TObj"
201 export CSF_StandardDefaults="${CASROOT}/src/StdResource"
202 export CSF_PluginDefaults="${CASROOT}/src/StdResource"
203 export CSF_XCAFDefaults="${CASROOT}/src/StdResource"
204 export CSF_TObjDefaults="${CASROOT}/src/StdResource"
205 export CSF_StandardLiteDefaults="${CASROOT}/src/StdResource"
206 export CSF_UnitsLexicon="${CASROOT}/src/UnitsAPI/Lexi_Expr.dat"
207 export CSF_UnitsDefinition="${CASROOT}/src/UnitsAPI/Units.dat"
208 export CSF_IGESDefaults="${CASROOT}/src/XSTEPResource"
209 export CSF_STEPDefaults="${CASROOT}/src/XSTEPResource"
210 export CSF_XmlOcafResource="${CASROOT}/src/XmlOcafResource"
211 export CSF_MIGRATION_TYPES="${CASROOT}/src/StdResource/MigrationSheet.txt"
212
213 # Draw Harness special stuff
214 if [ -e "${CASROOT}/src/DrawResources" ]; then
215   export DRAWHOME="${CASROOT}/src/DrawResources"
216   export CSF_DrawPluginDefaults="${DRAWHOME}"
217 fi
218 if [ -e "${aScriptPath}/src/DrawResourcesProducts" ]; then
219   export CSF_DrawPluginProductsDefaults="${aScriptPath}/src/DrawResourcesProducts"
220 fi