there was an #include directive missing
[openmpi-llc.git] / config / f77_get_sizeof.m4
blobee966503c8d6c1bba81c5cf6868950961d954389
1 dnl -*- shell-script -*-
2 dnl
3 dnl Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
4 dnl                         University Research and Technology
5 dnl                         Corporation.  All rights reserved.
6 dnl Copyright (c) 2004-2005 The University of Tennessee and The University
7 dnl                         of Tennessee Research Foundation.  All rights
8 dnl                         reserved.
9 dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
10 dnl                         University of Stuttgart.  All rights reserved.
11 dnl Copyright (c) 2004-2005 The Regents of the University of California.
12 dnl                         All rights reserved.
13 dnl $COPYRIGHT$
14 dnl 
15 dnl Additional copyrights may follow
16 dnl 
17 dnl $HEADER$
18 dnl
20 # OMPI_F77_GET_SIZEOF(type, variable to set)
21 # ------------------------------------------
22 AC_DEFUN([OMPI_F77_GET_SIZEOF],[
23     AS_VAR_PUSHDEF([type_var], [ompi_cv_f77_sizeof_$1])
24     
25     AC_CACHE_CHECK([size of Fortran 77 $1], type_var,
26         [OMPI_F77_MAKE_C_FUNCTION([ompi_ac_size_fn], [size])
27          # Fortran module
28          cat > conftestf.f <<EOF
29        program fsize
30        external size 
31        $1 x(2)
32        call size(x(1),x(2))
33        end
34 EOF
36          # C module
37          if test -f conftest.h; then
38              ompi_conftest_h="#include \"conftest.h\""
39          else
40              ompi_conftest_h=""
41          fi
42          cat > conftest.c <<EOF
43 #include <stdio.h>
44 #include <stdlib.h>
45 $ompi_conftest_h
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 void $ompi_ac_size_fn(char *a, char *b)
52     int diff = (int) (b - a);
53     FILE *f=fopen("conftestval", "w");
54     if (!f) exit(1);
55     fprintf(f, "%d\n", diff);
56     fclose(f);
58 #ifdef __cplusplus
60 #endif
61 EOF
63          OMPI_LOG_COMMAND([$CC $CFLAGS -I. -c conftest.c],
64              [OMPI_LOG_COMMAND([$F77 $FFLAGS conftestf.f conftest.o -o conftest $LDFLAGS $LIBS],
65                   [happy="yes"], [happy="no"])], [happy="no"])
67          if test "$happy" = "no" ; then
68              AC_MSG_ERROR([Could not determine size of $1])
69          fi
71          AS_IF([test "$cross_compiling" = "yes"],
72              [AC_MSG_ERROR([Can not determine size of $1 when cross-compiling])],
73              [OMPI_LOG_COMMAND([./conftest],
74                  [AS_IF([test -f conftestval],
75                       [AS_VAR_SET(type_var, [`cat conftestval`])],
76                       [OMPI_LOG_MSG([conftestval not found.], 1)
77                        AC_MSG_ERROR([Could not determine size of $1])])],
78                  [AC_MSG_ERROR([Could not determine size of $1])])])
80         unset happy ompi_conftest_h
81         rm -f conftest*])
83     $2=AS_VAR_GET(type_var)
84     AS_VAR_POPDEF([type_var])dnl
85 ])dnl