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