1dnl  This file is part of MED.
2dnl
3dnl  COPYRIGHT (C) 1999 - 2019  EDF R&D, CEA/DEN
4dnl  MED is free software: you can redistribute it and/or modify
5dnl  it under the terms of the GNU Lesser General Public License as published by
6dnl  the Free Software Foundation, either version 3 of the License, or
7dnl  (at your option) any later version.
8dnl
9dnl  MED is distributed in the hope that it will be useful,
10dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
11dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12dnl  GNU Lesser General Public License for more details.
13dnl
14dnl  You should have received a copy of the GNU Lesser General Public License
15dnl  along with MED.  If not, see <http://www.gnu.org/licenses/>.
16dnl
17
18AC_DEFUN([MED_CHECK_TYPEOF_MEDINT], [
19
20## Guess where as med_int type is provided by --with-med_int option
21## or auto-detection must be used
22
23AC_ARG_WITH([med_int],
24            AC_HELP_STRING([--with-med_int=<C type>],
25	                   [Use <C type int or long> for med_int]),
26	    [],
27	    [withval=no])
28
29test x"$withval" = xno && test x"$enable_fortran" = xno && withval=int
30
31dnl Si aucune directive n'est donnée, test par compilation c/f quel
32dnl type d'entier il faut utiliser pour med_int en utilisant les flags fortran
33dnl Pour la cross-compilation, il ne faut pas lancer un test de compilation
34dnl  -> l'utilisateur spécifie le type à utiliser : int ou long
35if test x"$withval" = xno
36then
37
38  ## Guess the fortran int size
39  AC_CHECK_SIZEOF_FORTRAN(integer)
40  if test "x$ac_cv_sizeof_fortran_integer" = "x8" ; then
41     AC_DEFINE(HAVE_F77INT64,[],
42                       [The size of a Fortran integer, as computed by sizeof.])
43     AC_CHECK_SIZEOF(long)
44     test "x$ac_cv_sizeof_long" = "x8" || AC_MSG_ERROR([Size of C type long expected to be eight bytes])
45     LONG_OR_INT="long"
46     #pour le module python qui est le meme pour int/long on a besoin des deux définitions
47     AC_CHECK_SIZEOF(int)
48  elif test "x$ac_cv_sizeof_fortran_integer" = "x4" ; then
49     AC_CHECK_SIZEOF(int)
50     test "x$ac_cv_sizeof_int" = "x4" || AC_MSG_ERROR([Size of C type int expected to be four bytes])
51     LONG_OR_INT="int"
52     #pour le module python qui est le meme pour int/long on a besoin des deux définitions
53     AC_CHECK_SIZEOF(long)
54  else
55     AC_MSG_ERROR([Size of Fortran type integer is neither four nor eigth bytes])
56  fi
57
58else
59  if test "x$withval" = "xlong" ; then
60    AC_DEFINE(HAVE_F77INT64,[],
61                       [The size of a Fortran integer, as computed by sizeof.])
62    AC_MSG_WARN([Be careful that --with-med_int=long implies some FFLAGS && FCFLAGS settings for using integer*8 fortran integers.])
63  elif test ! "x$withval" = "xint" ; then
64     AC_MSG_ERROR([--with-med_int must be equal to int or long !])
65  fi
66  LONG_OR_INT="$withval"
67  AC_MSG_NOTICE([Using type $withval for med_int])
68fi
69
70AC_SUBST(LONG_OR_INT)
71
72])
73