4
0

ccstdc.m4 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # The following is taken from automake 1.4,
  2. # except that it prefers the compiler option -Ae to "-Aa -D_HPUX_SOURCE"
  3. # because only the former supports 64-bit integral types on HP-UX 10.20.
  4. ## ----------------------------------------- ##
  5. ## ANSIfy the C compiler whenever possible. ##
  6. ## From Franc,ois Pinard ##
  7. ## ----------------------------------------- ##
  8. # serial 2
  9. # @defmac AC_PROG_CC_STDC
  10. # @maindex PROG_CC_STDC
  11. # @ovindex CC
  12. # If the C compiler in not in ANSI C mode by default, try to add an option
  13. # to output variable @code{CC} to make it so. This macro tries various
  14. # options that select ANSI C on some system or another. It considers the
  15. # compiler to be in ANSI C mode if it handles function prototypes correctly.
  16. #
  17. # If you use this macro, you should check after calling it whether the C
  18. # compiler has been set to accept ANSI C; if not, the shell variable
  19. # @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source
  20. # code in ANSI C, you can make an un-ANSIfied copy of it by using the
  21. # program @code{ansi2knr}, which comes with Ghostscript.
  22. # @end defmac
  23. AC_DEFUN(AM_PROG_CC_STDC,
  24. [AC_REQUIRE([AC_PROG_CC])
  25. AC_BEFORE([$0], [AC_C_INLINE])
  26. AC_BEFORE([$0], [AC_C_CONST])
  27. dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require
  28. dnl a magic option to avoid problems with ANSI preprocessor commands
  29. dnl like #elif.
  30. dnl FIXME: can't do this because then AC_AIX won't work due to a
  31. dnl circular dependency.
  32. dnl AC_BEFORE([$0], [AC_PROG_CPP])
  33. AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
  34. AC_CACHE_VAL(am_cv_prog_cc_stdc,
  35. [am_cv_prog_cc_stdc=no
  36. ac_save_CC="$CC"
  37. # Don't try gcc -ansi; that turns off useful extensions and
  38. # breaks some systems' header files.
  39. # AIX -qlanglvl=ansi
  40. # Ultrix and OSF/1 -std1
  41. # HP-UX -Aa -D_HPUX_SOURCE
  42. # SVR4 -Xc -D__EXTENSIONS__
  43. for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
  44. do
  45. CC="$ac_save_CC $ac_arg"
  46. AC_TRY_COMPILE(
  47. [#include <stdarg.h>
  48. #include <stdio.h>
  49. #include <sys/types.h>
  50. #include <sys/stat.h>
  51. /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
  52. struct buf { int x; };
  53. FILE * (*rcsopen) (struct buf *, struct stat *, int);
  54. static char *e (p, i)
  55. char **p;
  56. int i;
  57. {
  58. return p[i];
  59. }
  60. static char *f (char * (*g) (char **, int), char **p, ...)
  61. {
  62. char *s;
  63. va_list v;
  64. va_start (v,p);
  65. s = g (p, va_arg (v,int));
  66. va_end (v);
  67. return s;
  68. }
  69. int test (int i, double x);
  70. struct s1 {int (*f) (int a);};
  71. struct s2 {int (*f) (double a);};
  72. int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
  73. int argc;
  74. char **argv;
  75. ], [
  76. return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
  77. ],
  78. [am_cv_prog_cc_stdc="$ac_arg"; break])
  79. done
  80. CC="$ac_save_CC"
  81. ])
  82. if test -z "$am_cv_prog_cc_stdc"; then
  83. AC_MSG_RESULT([none needed])
  84. else
  85. AC_MSG_RESULT($am_cv_prog_cc_stdc)
  86. fi
  87. case "x$am_cv_prog_cc_stdc" in
  88. x|xno) ;;
  89. *) CC="$CC $am_cv_prog_cc_stdc" ;;
  90. esac
  91. ])