there was an #include directive missing
[openmpi-llc.git] / config / ompi_config_solaris_threads.m4
blob42497bbfebb392e1c4be962cc5ecc3acacc893a4
1 dnl
2 dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3 dnl                         University Research and Technology
4 dnl                         Corporation.  All rights reserved.
5 dnl Copyright (c) 2004-2005 The University of Tennessee and The University
6 dnl                         of Tennessee Research Foundation.  All rights
7 dnl                         reserved.
8 dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
9 dnl                         University of Stuttgart.  All rights reserved.
10 dnl Copyright (c) 2004-2005 The Regents of the University of California.
11 dnl                         All rights reserved.
12 dnl $COPYRIGHT$
13 dnl 
14 dnl Additional copyrights may follow
15 dnl 
16 dnl $HEADER$
17 dnl
18 dnl OMPI_CONFIG_SOLARIS_THREADS()
19 dnl
21 # ********************************************************************
23 # Internal macros - do not call from outside OMPI_CONFIG_SOLARIS_THREADS
25 # ********************************************************************
27 AC_DEFUN([OMPI_INTL_SOLARIS_TRY_LINK], [
28 # BEGIN: OMPI_INTL_SOLARIS_TRY_LINK
30 # Make sure that we can run a small application in C or C++, which
31 # ever is the current language.  Do make sure that C or C++ is the
32 # current language.
33     AC_TRY_LINK([#include <thread.h>],
34                  [thread_t th; thr_join(th, 0, 0);
35                  thr_create(0,0,0,0,0,0); ],
36                  [$1], [$2])
37 # END: OMPI_INTL_SOLARIS_TRY_LINK
38 ])dnl
41 AC_DEFUN([OMPI_INTL_SOLARIS_TRY_LINK_F77], [
42 # BEGIN: OMPI_INTL_SOLARIS_TRY_LINK_F77
44 # Make sure that we can run a small application in Fortran, with
45 # pthreads living in a C object file
47 # Fortran module
48 cat > conftestf.f <<EOF
49       program fpthread
50       INTEGER i
51       i = 1
52       end
53 EOF
55 # C module
56 if test -f conftest.h; then
57     ompi_conftest_h="#include \"conftest.h\""
58 else
59     ompi_conftest_h=""
61 cat > conftest.c <<EOF
62 #include <stdio.h>
63 #include <stdlib.h>
64 #include <thread.h>
65 $ompi_conftest_h
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70 void ompi_pthread()
72   thread_t th;
73   thr_join(th, 0, 0);
74   thr_create(0,0,0,0,0,0);
76 #ifdef __cplusplus
78 #endif
79 EOF
81 # Try the compile
82 OMPI_LOG_COMMAND(
83     [$CC $CFLAGS -I. -c conftest.c],
84     OMPI_LOG_COMMAND(
85         [$F77 $FFLAGS conftestf.f conftest.o -o conftest $LDFLAGS $LIBS],
86         [HAPPY=1],
87         [HAPPY=0]),
88     [HAPPY=0])
90 if test "$HAPPY" = "1"; then
91    $1
92 else
93     OMPI_LOG_MSG([here is the C program:], 1)
94     OMPI_LOG_FILE([conftest.c])
95     if test -f conftest.h; then
96         OMPI_LOG_MSG([here is contest.h:], 1)
97         OMPI_LOG_FILE([conftest.h])
98     fi
99     OMPI_LOG_MSG([here is the fortran program:], 1)
100     OMPI_LOG_FILE([conftestf.f])
101     $2
104 unset HAPPY ompi_conftest_h
105 /bin/rm -f conftest*
106 # END: OMPI_INTL_SOLARIS_TRY_LINK_F77
107 ])dnl
110 AC_DEFUN([OMPI_CONFIG_SOLARIS_THREADS_C], [
111 if test "$BASECC" = "cc"; then
112     STHREAD_CFLAGS="-mt"
113     style="Workshop/Forte"
114 else
115     STHREAD_CPPFLAGS="-D_REENTRANT"
116     STHREAD_LIBS="-lthread"
117     style="-lthread"
119 AC_MSG_CHECKING([if C compiler and Solaris threads work])
120 CFLAGS="$STHREAD_CFLAGS $CFLAGS_orig"
121 CPPFLAGS="$STHREAD_CPPFLAGS $CPPFLAGS_orig"
122 LDFLAGS="$STHREAD_LDFLAGS $LDFLAGS_orig"
123 LIBS="$STHREAD_LIBS $LIBS_orig"
124 AC_LANG_PUSH(C)
125 OMPI_INTL_SOLARIS_TRY_LINK(ompi_sthread_c_success=1,
126                           ompi_sthread_c_success=0)
127 AC_LANG_POP(C)
128 if test "$ompi_sthread_c_success" = "1"; then
129     AC_MSG_RESULT([yes - $style])
130 else
131     AC_MSG_RESULT([no])
133 ])dnl
136 AC_DEFUN([OMPI_CONFIG_SOLARIS_THREADS_CXX], [
137 if test "$BASECXX" = "CC"; then
138     STHREAD_CXXFLAGS="-mt"
139     style="Workshop/Forte"
140 elif test "$BASECXX" = "KCC"; then
141     STHREAD_CXXFLAGS="--backend -mt"
142     style="KCC"
143 else
144     STHREAD_CXXCPPFLAGS="-D_REENTRANT"
145     STHREAD_LIBS="-lthread"
146     style="-lthread"
148 CXXFLAGS="$STHREAD_CXXFLAGS $CXXFLAGS_orig"
149 CXXCPPFLAGS="$STHREAD_CXXPPFLAGS $CXXPPFLAGS_orig"
150 LDFLAGS="$STHREAD_LDFLAGS $LDFLAGS_orig"
151 LIBS="$STHREAD_LIBS $LIBS_orig"
152 AC_MSG_CHECKING([if C++ compiler and Solaris threads work])
153 AC_LANG_PUSH(C++)
154 OMPI_INTL_SOLARIS_TRY_LINK(ompi_sthread_cxx_success=1, 
155                           ompi_sthread_cxx_success=0)
156 AC_LANG_POP(C++)
157 if test "$ompi_sthread_cxx_success" = "1"; then
158     AC_MSG_RESULT([yes - $style])
159 else
160     AC_MSG_RESULT([no])
162 ])dnl
165 AC_DEFUN([OMPI_CONFIG_SOLARIS_THREADS_FC], [
166 if test "$OMPI_WANT_F77_BINDINGS" = "1"; then
167     if test "$BASEFC" = "f77"; then
168         STHREAD_FFLAGS="-mt"
169         style="Workshop/Forte"
170     else
171         STHREAD_LIBS="-lthread"
172         style="-lthread"
173     fi
174     FFLAGS="$STHREAD_FFLAGS $FFLAGS_orig"
175     CFLAGS="$STHREAD_CFLAGS $CFLAGS_orig"
176     CPPFLAGS="$STHREAD_CPPFLAGS $CPPFLAGS_orig"
177     LDFLAGS="$STHREAD_LDFLAGS $LDFLAGS_orig"
178     LIBS="$STHREAD_LIBS $LIBS_orig"
179     AC_MSG_CHECKING([if F77 compiler and Solaris threads work])
180     AC_LANG_PUSH(C)
181     OMPI_INTL_SOLARIS_TRY_LINK_F77(ompi_sthread_f77_success=1, 
182                                   ompi_sthread_f77_success=0)
183     AC_LANG_POP(C)
184     if test "$ompi_sthread_f77_success" = "1"; then
185         AC_MSG_RESULT([yes - $style])
186      else
187         AC_MSG_RESULT([no])
188      fi
189 else
190   ompi_sthread_f77_success=1
192 ])dnl
195 AC_DEFUN([OMPI_CONFIG_SOLARIS_THREADS],[
196 ompi_sthread_c_success=0
197 ompi_sthread_f77_success=0
198 ompi_sthread_cxx_success=0
200 orig_CFLAGS="$CFLAGS"
201 orig_FFLAGS="$FFLAGS"
202 orig_CXXFLAGS="$CXXFLAGS"
203 orig_CPPFLAGS="$CPPFLAGS"
204 orig_CXXCPPFLAGS="$CXXCPPFLAGS"
205 orig_LDFLAGS="$LDFLAGS"
206 orig_LIBS="$LIBS"
208 STHREAD_CFLAGS=
209 STHREAD_FFLAGS=
210 STHREAD_CXXFLAGS=
211 STHREAD_CPPFLAGS=
212 STHREAD_CXXCPPFLAGS=
213 STHREAD_LDFLAGS=
214 STHREAD_LIBS=
216 # Only run C++ and Fortran if those compilers already configured
217 AC_PROVIDE_IFELSE([AC_PROG_CC], 
218                   [OMPI_CONFIG_SOLARIS_THREADS_C],
219                   [ompi_sthread_c_success=1])
221 AC_PROVIDE_IFELSE([AC_PROG_CXX], 
222                   [OMPI_CONFIG_SOLARIS_THREADS_CXX],
223                   [ompi_sthread_cxx_success=1])
225 AC_PROVIDE_IFELSE([AC_PROG_F77], 
226                   [OMPI_CONFIG_SOLARIS_THREADS_FC],
227                   [ompi_sthread_f77_success=1])
229 CFLAGS="$orig_CFLAGS"
230 FFLAGS="$orig_FFLAGS"
231 CXXFLAGS="$orig_CXXFLAGS"
232 CPPFLAGS="$orig_CPPFLAGS"
233 CXXCPPFLAGS="$orig_CXXCPPFLAGS"
234 LDFLAGS="$orig_LDFLAGS"
235 LIBS="$orig_LIBS"
237 if test "$ompi_sthread_c_success" = "1" -a \
238         "$ompi_sthread_cxx_success" = "1" -a \
239        "$ompi_sthread_f77_success" = "1"; then
240   internal_useless=1
241   $1
242 else
243   internal_useless=1
244   $2
247 unset ompi_sthread_c_success ompi_sthread_f77_success ompi_sthread_cxx_success
248 unset internal_useless
249 ])dnl