Salome HOME
Merge from V6_4_BR 05/12/2011
[modules/smesh.git] / src / Tools / padder / resources / appligen / genenv.sh
1 #!/bin/bash
2
3 # This script creates a source file that defines a SALOME shell
4 # environment. We assume here that the SALOME environment has been
5 # previously set, so that the env command get all environment
6 # variables required for building and executing SALOME. We talk
7 # about third party software programs and libraries. The environment
8 # variables defining SALOME module are exluded (i.e. *_ROOT_DIR)
9 # because they are automatically set when generating a SALOME application..
10 #
11 # The argument is the filepath to be created.
12 #
13
14 if [ $# == 1 ]; then
15     ENVAPPLI_SH=$1
16 else
17     ENVAPPLI_SH=envappli.sh
18 fi
19
20 function header {
21     echo "#"
22     echo "# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
23     echo "# THIS FILE IS GENERATED from the shell environment used to build the SALOME module."
24     echo "# IT SHOULD NOT BE EDITED, it is generated for the need of the SALOME application   "
25     echo "# that embeds the module (for test purposes).                                       "
26     echo "# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
27     echo "#"
28 }
29 header > $ENVAPPLI_SH
30 env | grep -v -e PWD -e SalomeAppConfig -e _ROOT_DIR | while read f; do
31     key=$(echo $f | cut -d"=" -f1)
32     value=$(echo $f | cut -d"=" -f2-)
33
34     # if the key is a path (LD_LIBRARY_PATH, PATH and PYTHONPATH) then
35     # we must extends the variable.
36     if [ $key == "LD_LIBRARY_PATH" -o $key == "PATH" -o $key == "PYTHONPATH" ]; then
37         echo export $key=\"$value:\$$key\"
38     else
39         echo export $key=\"$value\"
40     fi
41 done >> $ENVAPPLI_SH