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