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