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