Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/med.git] / adm_local / unix / config_files / ac_check_sizeof_fortran.m4
1 AC_DEFUN([AC_CHECK_SIZEOF_FORTRAN], [
2   AC_REQUIRE([AC_F77_WRAPPERS])
3   AC_CACHE_CHECK([size of Fortran [$1]], [ac_cv_sizeof_fortran_[]translit($1, [A-Z *], [a-z_p])],[
4     AC_LANG_SAVE()
5     AC_LANG([Fortran 77])
6     AC_COMPILE_IFELSE([
7       AC_LANG_SOURCE([
8         subroutine fsize()
9         $1 i(2)
10         call csize(i(1), i(2))
11         end
12       ])
13     ],[
14       AC_LANG([C])
15       cp conftest.$ac_objext conftestf.$ac_objext
16       old_LDFLAGS="$LDFLAGS"
17       LDFLAGS="conftestf.$ac_objext $LDFLAGS"
18       AC_TRY_RUN([
19 #       include <stdio.h>
20 #         define CSIZE F77_FUNC(csize,CSIZE)
21 #         define FSIZE F77_FUNC(fsize,FSIZE)
22         static long size_val;
23         /* Called by Fortran */
24         void CSIZE (i1p, i2p)
25         char *i1p, *i2p;
26         {
27           size_val = (i2p - i1p);
28         }
29         main() {
30           FILE *f=fopen ("conftestval","w");
31           if (!f) return 1;
32           /* Call the Fortran function */
33           FSIZE ();
34           fprintf (f, "%d\n", size_val);
35           return 0;
36         }
37      ])
38      LDFLAGS="$old_LDFLAGS"
39      ac_cv_sizeof_fortran_[]translit($1, [A-Z *], [a-z_p])=`cat conftestval`
40      rm -f conftestval conftestf.$ac_objext
41     ])
42     AC_LANG_RESTORE()
43   ])
44   AC_DEFINE_UNQUOTED(SIZEOF_FORTRAN_[]translit($1, [a-z *], [A-Z_p]),
45                      [$ac_cv_sizeof_fortran_[]translit($1, [A-Z *], [a-z_p])],
46                      [The size of a Fortran `$1', as computed by sizeof.])
47
48 ])