File: f77_find_ext_symbol_convention.m4

package info (click to toggle)
openmpi 1.6.5-9.1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 91,628 kB
  • ctags: 44,305
  • sloc: ansic: 408,966; cpp: 44,454; sh: 27,828; makefile: 10,486; asm: 3,882; python: 1,239; lex: 805; perl: 549; csh: 253; fortran: 232; f90: 126; tcl: 12
file content (154 lines) | stat: -rw-r--r-- 6,503 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
dnl -*- shell-script -*-
dnl
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
dnl                         University Research and Technology
dnl                         Corporation.  All rights reserved.
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
dnl                         of Tennessee Research Foundation.  All rights
dnl                         reserved.
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
dnl                         University of Stuttgart.  All rights reserved.
dnl Copyright (c) 2004-2005 The Regents of the University of California.
dnl                         All rights reserved.
dnl Copyright (c) 2009      Oak Ridge National Labs.  All rights reserved.
dnl Copyright (c) 2009      Cisco Systems, Inc.  All rights reserved.
dnl $COPYRIGHT$
dnl 
dnl Additional copyrights may follow
dnl 
dnl $HEADER$
dnl


AC_DEFUN([OMPI_F77_FIND_EXT_SYMBOL_CONVENTION], [
    AC_REQUIRE([AC_PROG_NM])
    AC_REQUIRE([AC_PROG_GREP])
    OMPI_VAR_SCOPE_PUSH([FFLAGS_NEW LDFLAGS_NEW FLAG])

    # invalidate cache if result came from a run where F77 was disabled
    if test "$ompi_cv_f77_external_symbol" = "skipped" ; then
        unset ompi_cv_f77_external_symbol
    fi

    AC_CACHE_CHECK([$F77 external symbol convention],
        [ompi_cv_f77_external_symbol],
        [if test "$F77" = "none" -o "$OMPI_WANT_F77_BINDINGS" = "0"; then
             ompi_cv_f77_external_symbol="skipped"
         else
             cat >conftest.f <<EOF
       subroutine FOO_bar(a)
       integer a
       a = 1
       return
       end
EOF
             # Try without certain optimization flags, which produce object
             # files without the required external symbols;
             # e.g. option -fast turns on -ipo on Intel Compilers 11.0
             FFLAGS_NEW=""
             LDFLAGS_NEW=""
             case $F77 in
                 ifort)
                     for FLAG in $FFLAGS ; do
                         case $FLAG in
                             -fast) ;;
                             -ipo*) ;;
                             *)     FFLAGS_NEW="$FFLAGS_NEW $FLAG" ;;
                         esac
                     done
                     for FLAG in $LDFLAGS ; do
                         case $FLAG in
                             -fast) ;;
                             -ipo*) ;;
                             *)     LDFLAGS_NEW="$LDFLAGS_NEW $FLAG" ;;
                         esac
                     done
                     OMPI_LOG_MSG([Try with new FFLAGS: $FFLAGS_NEW   and new LDFLAGS:$LDFLAGS_NEW])
                 ;;
                 *)
                     FFLAGS_NEW="$FFLAGS"
                     LDFLAGS_NEW="$LDFLAGS"
                 ;;
             esac

             happy=1
             OMPI_LOG_COMMAND([$F77 $FFLAGS_NEW -c conftest.f $LDFLAGS_NEW $LIBS],
                 [if $NM conftest.o | $GREP foo_bar__ >/dev/null 2>&1 ; then
                      ompi_cv_f77_external_symbol="double underscore"
                  elif $NM conftest.o | $GREP foo_bar_ >/dev/null 2>&1 ; then
                      ompi_cv_f77_external_symbol="single underscore"
                  elif $NM conftest.o | $GREP FOO_bar >/dev/null 2>&1 ; then
                      ompi_cv_f77_external_symbol="mixed case"
                  elif $NM conftest.o | $GREP foo_bar >/dev/null 2>&1 ; then
                      ompi_cv_f77_external_symbol="no underscore"
                  elif $NM conftest.o | $GREP FOO_BAR >/dev/null 2>&1 ; then
                      ompi_cv_f77_external_symbol="upper case"
                  else
                      $NM conftest.o >conftest.out 2>&1
                      OMPI_LOG_MSG([Could not determine Fortran naming convention. Output from $NM:])
                      OMPI_LOG_FILE([conftest.out])
                      happy=0
                  fi],
                 [AC_MSG_ERROR([Fortran compiler did not produce object file])])
         fi])

    ompi_fortran_double_underscore=0
    ompi_fortran_single_underscore=0
    ompi_fortran_caps=0
    ompi_fortran_plain=0

    if test "$ompi_cv_f77_external_symbol" = "double underscore" ; then
        ompi_fortran_double_underscore=1
    elif test "$ompi_cv_f77_external_symbol" = "single underscore" ; then
        ompi_fortran_single_underscore=1
    elif test "$ompi_cv_f77_external_symbol" = "mixed case" ; then
        ompi_fortran_caps=1
    elif test "$ompi_cv_f77_external_symbol" = "no underscore" ; then
        ompi_fortran_plain=1
    elif test "$ompi_cv_f77_external_symbol" = "upper case" ; then
        ompi_fortran_caps=1
    elif test "$ompi_cv_f77_external_symbol" != "skipped" ; then
        AC_MSG_ERROR([unknown naming convention: $ompi_cv_f77_external_symbol])
    fi

    AC_DEFINE_UNQUOTED([OMPI_F77_DOUBLE_UNDERSCORE],
        [$ompi_fortran_double_underscore], 
        [Whether fortran symbols have a trailing double underscore or not])
    AC_DEFINE_UNQUOTED([OMPI_F77_SINGLE_UNDERSCORE], 
        [$ompi_fortran_single_underscore],
        [Whether fortran symbols have a trailing underscore or not])
    AC_DEFINE_UNQUOTED([OMPI_F77_CAPS],
        [$ompi_fortran_caps],
        [Whether fortran symbols are all caps or not])
    AC_DEFINE_UNQUOTED([OMPI_F77_PLAIN], 
        [$ompi_fortran_plain],
        [Whether fortran symbols have no trailing underscore or not])

    OMPI_VAR_SCOPE_POP
    rm -rf conftest.*
])dnl


AC_DEFUN([OMPI_F77_MAKE_C_FUNCTION], [
    if test "$ompi_cv_f77_external_symbol" = "double underscore" ; then
        # so the general rule is that if there is an _ in the function
        # name, then there are two trailing underscores.  Otherwise,
        # there is only one trailing underscore.  Any idea how to do
        # that with m4_translit?
        if echo $2 | $GREP _ >/dev/null 2>&1 ; then
            $1[=]m4_translit([$2], [A-Z], [a-z])[__]
        else
            $1[=]m4_translit([$2], [A-Z], [a-z])[_]
        fi
    elif test "$ompi_cv_f77_external_symbol" = "single underscore" ; then
        $1[=]m4_translit([$2], [A-Z], [a-z])[_]
    elif test "$ompi_cv_f77_external_symbol" = "mixed case" ; then
        $1[=]$2
    elif test "$ompi_cv_f77_external_symbol" = "no underscore" ; then
        $1[=]m4_translit([$2], [A-Z], [a-z])
    elif test "$ompi_cv_f77_external_symbol" = "upper case" ; then
        $1[=]m4_translit([$2], [a-z], [A-Z])
    else
        AC_MSG_ERROR([unknown naming convention: $ompi_cv_f77_external_symbol])
    fi
])