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

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

Merge from trunk to kumudb r4748:r4869

Line 
1dnl
2dnl Fixes to bugs in AC_xxx macros
3dnl
4dnl (AC_TRY_COMPILE is missing a newline after the end in the Fortran
5dnl branch; that has been fixed in-place)
6dnl
7dnl (AC_PROG_CC makes many dubious assumptions.  One is that -O is safe
8dnl with -g, even with gcc.  This isn't true; gcc will eliminate dead code
9dnl when -O is used, even if you added code explicitly for debugging
10dnl purposes.  -O shouldn't do dead code elimination when -g is selected,
11dnl unless a specific option is selected.  Unfortunately, there is no
12dnl documented option to turn off dead code elimination.
13dnl
14dnl
15dnl (AC_CHECK_HEADER and AC_CHECK_HEADERS both make the erroneous assumption
16dnl that the C-preprocessor and the C (or C++) compilers are the same program
17dnl and have the same search paths.  In addition, CHECK_HEADER looks for
18dnl error messages to decide that the file is not available; unfortunately,
19dnl it also interprets messages such as "evaluation copy" and warning messages
20dnl from broken CPP programs (such as IBM's xlc -E, which often warns about
21dnl "lm not a valid option").  Instead, we try a compilation step with the
22dnl C compiler.
23dnl
24dnl AC_CONFIG_AUX_DIRS only checks for install-sh, but assumes other
25dnl values are present.  Also doesn't provide a way to override the
26dnl sources of the various configure scripts.  This replacement
27dnl version of AC_CONFIG_AUX_DIRS overcomes this.
28dnl Internal subroutine.
29dnl Search for the configuration auxiliary files in directory list $1.
30dnl We look only for install-sh, so users of AC_PROG_INSTALL
31dnl do not automatically need to distribute the other auxiliary files.
32dnl AC_CONFIG_AUX_DIRS(DIR ...)
33dnl Also note that since AC_CONFIG_AUX_DIR_DEFAULT calls this, there
34dnl isn't a easy way to fix it other than replacing it completely.
35dnl This fix applies to 2.13
36dnl/*D
37dnl AC_CONFIG_AUX_DIRS - Find the directory containing auxillery scripts
38dnl for configure
39dnl
40dnl Synopsis:
41dnl AC_CONFIG_AUX_DIRS( [ directories to search ] )
42dnl
43dnl Output Effect:
44dnl Sets 'ac_config_guess' to location of 'config.guess', 'ac_config_sub'
45dnl to location of 'config.sub', 'ac_install_sh' to the location of
46dnl 'install-sh' or 'install.sh', and 'ac_configure' to the location of a
47dnl Cygnus-style 'configure'.  Only 'install-sh' is guaranteed to exist,
48dnl since the other scripts are needed only by some special macros.
49dnl
50dnl The environment variable 'CONFIG_AUX_DIR', if set, overrides the
51dnl directories listed.  This is an extension to the 'autoconf' version of
52dnl this macro.
53dnl D*/
54undefine([AC_CONFIG_AUX_DIRS])
55AC_DEFUN([AC_CONFIG_AUX_DIRS],
56[if test -f $CONFIG_AUX_DIR/install-sh ; then ac_aux_dir=$CONFIG_AUX_DIR
57else
58ac_aux_dir=
59# We force the test to use the absolute path to ensure that the install
60# program can be used if we cd to a different directory before using
61# install.
62for ac_dir in $1; do
63  if test -f $ac_dir/install-sh; then
64    ac_aux_dir=$ac_dir
65    abs_ac_aux_dir=`(cd $ac_aux_dir && pwd)`
66    ac_install_sh="$abs_ac_aux_dir/install-sh -c"
67    break
68  elif test -f $ac_dir/install.sh; then
69    ac_aux_dir=$ac_dir
70    abs_ac_aux_dir=`(cd $ac_aux_dir && pwd)`
71    ac_install_sh="$abs_ac_aux_dir/install.sh -c"
72    break
73  fi
74done
75fi
76if test -z "$ac_aux_dir"; then
77  AC_MSG_ERROR([can not find install-sh or install.sh in $1])
78fi
79ac_config_guess=$ac_aux_dir/config.guess
80ac_config_sub=$ac_aux_dir/config.sub
81ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
82AC_PROVIDE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
83])
84
85dnl
86dnl Added complication:  We want to check for a header EVEN IF WE CAN'T
87dnl COMPILE IT.  E.g., if the header requires another header, we want
88dnl this to still work.  To make this slightly more robust, if the
89dnl CPP is the compiler, just use the CPP test.  Otherwise, fall
90dnl back into the compilation test.  Since autoconf uses /lib/cpp
91dnl only if it can't figure out how to use the compiler, we
92dnl test for that specific cast, then use CPP if we can.
93dnl However, on failure, we still test to see if, even though CPP
94dnl failed, the compiler accepts it (this avoids some of the "evaluation
95dnl copy" problems.
96dnl
97dnl undefine([AC_CHECK_HEADER])
98AC_DEFUN([PAC_OLD_CHECK_HEADER],
99[dnl Do the transliteration at runtime so arg 1 can be a shell variable.
100ac_safe=`echo "$1" | sed 'y%./+-%__p_%'`
101AC_MSG_CHECKING([for $1])
102AC_CACHE_VAL(ac_cv_header_$ac_safe,
103[
104pac_found_header=no
105if test "$CPP" != "/lib/cpp" ; then
106    AC_TRY_CPP([#include <$1>], pac_found_header=yes)
107fi
108# If cpp failed, see if the compiler accepts the header.
109if test "$pac_found_header" != "yes" ; then
110    cat >conftest.c<<EOF
111[#]line __oline__ "configure"
112#include "confdefs.h"
113#include <$1>
114int conftest() {return 0;}
115EOF
116    ac_compile_for_cpp='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.c 1>&AC_FD_CC'
117    if AC_TRY_EVAL(ac_compile_for_cpp); then
118        pac_found_header=yes
119    else
120        echo "configure: failed program was:" >&AC_FD_CC
121        cat conftest.c >&AC_FD_CC
122    fi
123    # This is needed for Mac OSX 10.5
124    rm -rf conftest.dSYM
125    rm -f conftest*
126fi
127# Finally, set the ac variable.
128if test "$pac_found_header" = "yes" ; then
129    eval "ac_cv_header_$ac_safe=yes"
130else
131    eval "ac_cv_header_$ac_safe=no"
132fi
133])dnl
134if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
135  AC_MSG_RESULT(yes)
136  ifelse([$2], , :, [$2])
137else
138  AC_MSG_RESULT(no)
139ifelse([$3], , , [$3
140])dnl
141fi
142])
143
144dnl
145dnl This internal macro fails to work properly with OTHER internal macros.
146dnl Basically, if the prologue is [], then no message should be generated.
147dnl This macro is in autoconf 2.52
148m4_define([AC_LANG_PROGRAM(Fortran 77)],
149[m4_if([$1],[[[]]],,[m4_ifval([$1],
150       [m4_warn([syntax], [$0: ignoring PROLOGUE: $1])])])dnl
151      program main
152$2
153      end])
154
155
156dnl/*D
157dnl PAC_PROG_CHECK_INSTALL_WORKS - Check whether the install program in INSTALL
158dnl works.
159dnl
160dnl Synopsis:
161dnl PAC_PROG_CHECK_INSTALL_WORKS
162dnl
163dnl Output Effect:
164dnl   Sets the variable 'INSTALL' to the value of 'ac_sh_install' if
165dnl   a file cannot be installed into a local directory with the 'INSTALL'
166dnl   program
167dnl
168dnl Notes:
169dnl   The 'AC_PROG_INSTALL' scripts tries to avoid broken versions of
170dnl   install by avoiding directories such as '/usr/sbin' where some
171dnl   systems are known to have bad versions of 'install'.  Unfortunately,
172dnl   this is exactly the sort of test-on-name instead of test-on-capability
173dnl   that 'autoconf' is meant to eliminate.  The test in this script
174dnl   is very simple but has been adequate for working around problems
175dnl   on Solaris, where the '/usr/sbin/install' program (known by
176dnl   autoconf to be bad because it is in /usr/sbin) is also reached by a
177dnl   soft link through /bin, which autoconf believes is good.
178dnl
179dnl   No variables are cached to ensure that we do not make a mistake in
180dnl   our choice of install program.
181dnl
182dnl   The Solaris configure requires the directory name to immediately
183dnl   follow the '-c' argument, rather than the more common
184dnl.vb
185dnl      args sourcefiles destination-dir
186dnl.ve
187dnl D*/
188AC_DEFUN([PAC_PROG_CHECK_INSTALL_WORKS],[
189if test -z "$INSTALL" ; then
190    AC_MSG_RESULT([No install program available])
191else
192    # Check that this install really works
193    rm -f conftest
194    echo "Test file" > conftest
195    if test ! -d .conftest ; then mkdir .conftest ; fi
196    AC_MSG_CHECKING([whether install works])
197    if $INSTALL conftest .conftest >/dev/null 2>&1 ; then
198        installOk=yes
199    else
200        installOk=no
201    fi
202    rm -rf .conftest conftest
203    AC_MSG_RESULT($installOk)
204    if test "$installOk" = no ; then
205        if test -n "$ac_install_sh" ; then
206            INSTALL=$ac_install_sh
207        else
208            AC_MSG_ERROR([Unable to find working install])
209        fi
210    fi
211fi
212])
Note: See TracBrowser for help on using the browser.