root/mpich2/branches/dev/kumudb/confdb/aclocal_cross.m4 @ 4870

Revision 4870, 6.9 KB (checked in by kumudb, 5 months ago)

Merge from trunk to kumudb r4748:r4869

Line 
1dnl
2dnl/*D
3dnl PAC_LANG_PUSH_COMPILERS - Replace all compilers with test versions
4dnl
5dnl Synopsis:
6dnl PAC_LANG_PUSH_COMPILERS
7dnl
8dnl Output Effects:
9dnl The values of 'CC', 'CXX', 'F77', 'F90', and 'CPP' are replaced with
10dnl the values of 'TESTCC' etc.  The old values are saved (see
11dnl 'PAC_LANG_POP_COMPILERS').
12dnl
13dnl Calls to this macro may be nested, but only the outer-most calls have
14dnl any effect.
15dnl
16dnl See also:
17dnl PAC_LANG_POP_COMPILERS
18dnl D*/
19dnl
20dnl These two name allow you to use TESTCC for CC, etc, in all of the
21dnl autoconf compilation tests.  This is useful, for example, when the
22dnl compiler needed at the end cannot be used to build programs that can
23dnl be run, for example, as required by some parallel computing systems.
24dnl Instead, define TESTCC, TESTCXX, TESTF77, and TESTF90 as the "local"
25dnl compilers.  Because autoconf insists on calling cpp for the header
26dnl checks, we use TESTCPP for the CPP test as well.  And if no TESTCPP
27dnl is defined, we create one using TESTCC.
28dnl
29dnl 2.52 does not have try_compiler, which is like try_compile, but
30dnl it doesn't force a main program
31dnl Not quite correct, but adequate for here
32ifdef([AC_TRY_COMPILER],,[AC_DEFUN([AC_TRY_COMPILER],
33[cat > conftest.$ac_ext <<EOF
34ifelse(_AC_LANG, [Fortran 77], ,
35[
36[#]line __oline__ "configure"
37#include "confdefs.h"
38])
39[$1]
40EOF
41if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
42  [$2]=yes
43  # If we can't run a trivial program, we are probably using a cross compiler.
44  if (./conftest; exit) 2>/dev/null; then
45    [$3]=no
46  else
47    [$3]=yes
48  fi
49else
50  echo "configure: failed program was:" >&AC_FD_CC
51  cat conftest.$ac_ext >&AC_FD_CC
52  [$2]=no
53fi
54# This is needed for Mac OSX 10.5
55rm -rf conftest.dSYM
56rm -fr conftest*])
57])
58dnl
59dnl pac_cross_compiling overrides all tests if set to yes.  This allows
60dnl us to test the cross-compilation branches of the code, and to use
61dnl compilers that can both cross-compile and build code for the current
62dnl platform
63dnl
64AC_DEFUN([PAC_LANG_PUSH_COMPILERS],[
65if test "X$pac_save_level" = "X" ; then
66    pac_save_CC="$CC"
67    pac_save_CXX="$CXX"
68    pac_save_F77="$F77"
69    pac_save_F90="$F90"
70    pac_save_prog_cc_cross="$ac_cv_prog_cc_cross"
71    pac_save_prog_f77_cross="$ac_cv_prog_f77_cross"
72    pac_save_prog_cxx_cross="$ac_cv_prog_cxx_cross"
73    pac_save_prog_f90_cross="$pac_cv_prog_f90_cross"
74    if test "X$CPP" = "X" ; then
75        AC_PROG_CPP
76    fi
77    pac_save_CPP="$CPP"
78    CC="${TESTCC:=$CC}"
79    CXX="${TESTCXX:=$CXX}"
80    F77="${TESTF77:=$F77}"
81    F90="${TESTF90:=$F90}"
82    if test -z "$TESTCPP" ; then
83        PAC_PROG_TESTCPP
84    fi
85    CPP="${TESTCPP:=$CPP}"
86    pac_save_level="0"
87    # Recompute cross_compiling values and set for the current language
88    # This is just:
89    AC_LANG_SAVE
90    AC_LANG_C
91    if test "$pac_cross_compiling" = "yes" ; then
92        ac_cv_prog_cc_cross=yes
93        ac_cv_prog_cc_works=yes
94    else
95        AC_TRY_COMPILER([main(){return(0);}], ac_cv_prog_cc_works, ac_cv_prog_cc_cross)
96    fi
97    AC_LANG_RESTORE
98    # Ignore Fortran if we aren't using it.
99    if test -n "$F77" ; then
100        AC_LANG_SAVE
101        AC_LANG_FORTRAN77
102        if test "$pac_cross_compiling" = "yes" ; then
103            ac_cv_prog_f77_cross=yes
104            ac_cv_prog_f77_works=yes
105        else
106            AC_TRY_COMPILER(dnl
107[      program conftest
108      end
109], ac_cv_prog_f77_works, ac_cv_prog_f77_cross)
110        fi
111        AC_LANG_RESTORE
112    fi
113    # Ignore C++ if we aren't using it.
114    if test -n "$CXX" ; then
115        AC_LANG_SAVE
116        AC_LANG_CPLUSPLUS
117        if test "$pac_cross_compiling" = "yes" ; then
118            ac_cv_prog_cxx_cross=yes
119            ac_cv_prog_cxx_works=yes
120        else
121            AC_TRY_COMPILER([int main(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross)
122        fi   
123        AC_LANG_RESTORE
124    fi
125    # Ignore Fortran 90 if we aren't using it.
126    if test -n "$F90" ; then
127        AC_LANG_SAVE
128        PAC_LANG_FORTRAN90
129        dnl We can't use AC_TRY_COMPILER because it doesn't know about
130        dnl Fortran 90
131        if test "$pac_cross_compiling" = "yes" ; then
132            ac_cv_prog_f90_cross=yes
133            ac_cv_prog_f90_works=yes
134        else
135            cat > conftest.$ac_ext << EOF
136      program conftest
137      end
138EOF
139            if { (eval echo configure:2324: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
140              ac_cv_prog_f90_works=yes
141              # If we can't run a trivial program, we are probably using a cross compiler.
142              if (./conftest; exit) 2>/dev/null; then
143                  ac_cv_prog_f90_cross=no
144              else
145                  ac_cv_prog_f90_cross=yes
146              fi
147            else
148              echo "configure: failed program was:" >&5
149              cat conftest.$ac_ext >&5
150              ac_cv_prog_f90_works=no
151            fi
152        fi
153        pac_cv_prog_f90_cross="$ac_cv_prog_f90_cross"
154        pac_cv_prog_f90_works="$ac_cv_prog_f90_works"
155        # This is needed for Mac OSX 10.5
156        rm -rf conftest.dSYM
157        rm -fr conftest*
158        AC_LANG_RESTORE
159    fi
160fi
161pac_save_level=`expr $pac_save_level + 1`
162])
163dnl/*D
164dnl PAC_LANG_POP_COMPILERS - Restore compilers that were displaced by
165dnl PAC_LANG_PUSH_COMPILERS
166dnl
167dnl Synopsis:
168dnl PAC_LANG_POP_COMPILERS
169dnl
170dnl Output Effects:
171dnl The values of 'CC', 'CXX', 'F77', 'F90', and 'CPP' are replaced with
172dnl their original values from the outermost call to 'PAC_LANG_PUSH_COMPILERS'.
173dnl
174dnl Calls to this macro may be nested, but only the outer-most calls have
175dnl any effect.
176dnl
177dnl See also:
178dnl PAC_LANG_PUSH_COMPILERS
179dnl D*/
180AC_DEFUN([PAC_LANG_POP_COMPILERS],[
181pac_save_level=`expr $pac_save_level - 1`
182if test "X$pac_save_level" = "X0" ; then
183    CC="$pac_save_CC"
184    CXX="$pac_save_CXX"
185    F77="$pac_save_F77"
186    F90="$pac_save_F90"
187    CPP="$pac_save_CPP"
188    ac_cv_prog_cc_cross="$pac_save_prog_cc_cross"
189    ac_cv_prog_f77_cross="$pac_save_prog_f77_cross"
190    ac_cv_prog_cxx_cross="$pac_save_prog_cxx_cross"
191    pac_cv_prog_f90_cross="$pac_save_prog_f90_cross"
192    pac_save_level=""
193fi
194])
195AC_DEFUN([PAC_PROG_TESTCPP],[
196if test -z "$TESTCPP"; then
197  AC_CACHE_VAL(pac_cv_prog_TESTCPP,[
198  rm -f conftest.*
199  cat > conftest.c <<EOF
200  #include <assert.h>
201  Syntax Error
202EOF
203  # On the NeXT, cc -E runs the code through the compiler's parser,
204  # not just through cpp.
205  TESTCPP="${TESTCC-cc} -E"
206  ac_try="$TESTCPP conftest.c >/dev/null 2>conftest.out"
207  if AC_TRY_EVAL(ac_try) ; then
208      pac_cv_prog_TESTCPP="$TESTCPP"
209  fi
210  if test "X$pac_cv_prog_TESTCPP" = "X" ; then
211      TESTCPP="${TESTCC-cc} -E -traditional-cpp"
212      ac_try="$TESTCPP conftest.c >/dev/null 2>conftest.out"
213      if AC_TRY_EVAL(ac_try) ; then
214          pac_cv_prog_TESTCPP="$TESTCPP"
215      fi
216  fi
217  if test "X$pac_cv_prog_TESTCPP" = "X" ; then
218      TESTCPP="${TESTCC-cc} -nologo -E"
219      ac_try="$TESTCPP conftest.c >/dev/null 2>conftest.out"
220      if AC_TRY_EVAL(ac_try) ; then
221          pac_cv_prog_TESTCPP="$TESTCPP"
222      fi
223  fi
224  if test "X$pac_cv_prog_TESTCPP" = "X" ; then
225      AC_PATH_PROG(TESTCPP,cpp)
226  fi
227  rm -f conftest.*
228  ])
229else
230  pac_cv_prog_TESTCPP="$TESTCPP"
231fi
232])
Note: See TracBrowser for help on using the browser.