1dnl--------------------------------------------------------------------------------
2dnl
3dnl This file is part of Code_Saturne, a general-purpose CFD tool.
4dnl
5dnl Copyright (C) 1998-2021 EDF S.A.
6dnl
7dnl This program is free software; you can redistribute it and/or modify it under
8dnl the terms of the GNU General Public License as published by the Free Software
9dnl Foundation; either version 2 of the License, or (at your option) any later
10dnl version.
11dnl
12dnl This program is distributed in the hope that it will be useful, but WITHOUT
13dnl ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14dnl FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
15dnl details.
16dnl
17dnl You should have received a copy of the GNU General Public License along with
18dnl this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
19dnl Street, Fifth Floor, Boston, MA 02110-1301, USA.
20dnl
21dnl--------------------------------------------------------------------------------
22
23# CS_AC_SALOME_ENV
24#-----------------
25# Macro determining the presence of a Salome environment
26
27AC_DEFUN([CS_AC_SALOME_ENV], [
28
29AC_ARG_WITH(salome,
30            [AS_HELP_STRING([--with-salome=PATH],
31                            [specify prefix directory for SALOME])],
32            [if test "x$withval" = "x"; then
33               if test "x$ROOT_SALOME" != "x"; then
34                 with_salome=$ROOT_SALOME
35               elif test "x$INST_ROOT" != "x" -a "x$KERNEL_ROOT_DIR" != "x"; then
36                 with_salome=$INST_ROOT
37                 ROOT_SALOME=$INST_ROOT
38               else
39                 with_salome=no
40               fi
41             else
42               if test "x$ROOT_SALOME" = "x"; then
43                 ROOT_SALOME=$with_salome
44               fi
45             fi],
46            [if test "x$ROOT_SALOME" = "x"; then
47               with_salome=no
48             else
49               with_salome=$ROOT_SALOME
50             fi])
51
52if test "x$with_salome" != "xno" ; then
53
54  if test ! -d "$with_salome" ; then
55    AC_MSG_FAILURE([directory specified by --with-salome=$with_salome does not exist!])
56  fi
57
58  # Recommended environment file for salome-platform.org installer builds
59  if test "x$SALOMEENVCMD" = "x"; then
60    salome_env=$(find $with_salome -maxdepth 2 -name salome.sh | tail -1 2>/dev/null)
61    if test "x$salome_env" != "x"; then
62      SALOMEENVCMD="source $salome_env"
63    fi
64  fi
65
66  # Environment for EDF or "universal binaries" type build for Salome
67  # Note that ROOT_SALOME is required but not exported in all cases.
68  if test "x$SALOMEENVCMD" = "x"; then
69    salome_env=$(find $with_salome -maxdepth 1 -name salome_modules.sh 2>/dev/null)
70    if test "x$salome_env" != "x"; then
71      salome_pre=$(find $with_salome -maxdepth 1 -name salome_prerequisites.sh 2>/dev/null)
72      if test "x$salome_pre" != "x"; then
73        SALOMEENVCMD="source $salome_pre; export ROOT_SALOME=$with_salome; source $salome_env"
74      fi
75    fi
76  fi
77
78  # Environment for CAS (salome-platform.org) builds for Salome
79  if test "x$SALOMEENVCMD" = "x"; then
80    salome_env="${with_salome}/env_launch.sh"
81    if test -f "$salome_env" ; then
82      SALOMEENVCMD="source $salome_env"
83    fi
84  fi
85
86  unset salome_pre
87  unset salome_env
88
89  # Paths for libraries provided by SALOME distibution, for automatic checks
90
91  if test "x$SALOMEENVCMD" != "x" ; then
92
93    (/bin/bash -c "$SALOMEENVCMD ; env > conftest.salome_env")
94
95    if test -z "$MEDCOUPLING_ROOT_DIR" ; then
96      MEDCOUPLING_ROOT_DIR=$(grep MEDCOUPLING_ROOT_DIR conftest.salome_env | cut -f2 -d'=')
97    fi
98
99    if test -z "$HDF5HOME" ; then
100      HDF5HOME=$(grep HDF5HOME conftest.salome_env | cut -f2 -d'=')
101    fi
102
103    if test -z "$MEDHOME" ; then
104      MEDHOME=$(grep MEDHOME conftest.salome_env | cut -f2 -d'=')
105    fi
106
107    if test -z "$CGNSHOME" ; then
108      CGNSHOME=$(grep CGNSHOME conftest.salome_env | cut -f2 -d'=')
109    fi
110
111    if test -z "$CATALYST_ROOT_DIR" ; then
112      CATALYST_ROOT_DIR=$(grep CATALYST_ROOT_DIR conftest.salome_env | cut -f2 -d'=')
113    fi
114
115    if test -z "$COOLPROPHOME" ; then
116      COOLPROPHOME=$(grep COOLPROPHOME conftest.salome_env | cut -f2 -d'=')
117    fi
118
119    if test -z "$METISDIR" ; then
120      METISDIR=$(grep METISDIR conftest.salome_env | cut -f2 -d'=')
121    fi
122
123    if test -z "$SCOTCHDIR" ; then
124      SCOTCHDIR=$(grep SCOTCHDIR conftest.salome_env | cut -f2 -d'=')
125    fi
126
127    \rm -rf conftest.salome_env
128
129  fi
130
131  AC_ARG_VAR([SALOMEENVCMD], [SALOME environment setting commands])
132
133fi
134
135])dnl
136