home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / lzop-1.00.tar.gz / lzop-1.00.tar / lzop-1.00 / acconfig / m4 / ccansi.m4 < prev    next >
Text File  |  1998-04-20  |  3KB  |  117 lines

  1. ## ---------------------------------------------------------- ##
  2. ## ANSIfy the C compiler and preprocessor whenever possible.  ##
  3. ## From Franc,ois Pinard and Markus Oberhumer.                ##
  4. ## ---------------------------------------------------------- ##
  5.  
  6. # serial 1
  7.  
  8. # @defmac mfx_PROG_CC_ANSI
  9. # @maindex PROG_CC_ANSI
  10. # @ovindex CC
  11. # If the C compiler and preprocessor is not in ANSI C mode by default,
  12. # try to add an option to output variable @code{CC} to make it so.
  13. # This macro tries various options that select ANSI C on some system or another.
  14. #
  15. # Use this macro instead of @code{AM_PROG_CC_STDC} if your program
  16. # is a real ANSI C program that cannot get un-ANSIfied. You also
  17. # should use @code{AC_CONST}.
  18. #
  19. # If you use this macro, you should check after calling it whether the C
  20. # compiler has been set to accept ANSI C; if not, the shell variable
  21. # @code{mfx_cv_prog_cc_ansi} is set to @samp{no}.
  22. # @end defmac
  23.  
  24. AC_DEFUN(mfx_PROG_CC_ANSI,
  25. [AC_REQUIRE([AC_PROG_CC])
  26. AC_BEFORE([$0], [AC_C_INLINE])
  27. AC_BEFORE([$0], [AC_C_CONST])
  28. dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
  29. dnl a magic option to avoid problems with ANSI preprocessor commands
  30. dnl like #elif.
  31. AC_BEFORE([$0], [AC_PROG_CPP])
  32. AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
  33. AC_CACHE_VAL(mfx_cv_prog_cc_ansi,
  34. [mfx_cv_prog_cc_ansi=no
  35. ac_save_CC="$CC"
  36. # Don't try gcc -ansi; that turns off useful extensions and
  37. # breaks some systems' header files.
  38. # AIX                   -qlanglvl=ansi
  39. # Ultrix and OSF/1      -std1
  40. # HP-UX                 -Aa -D_HPUX_SOURCE
  41. # HP-UX 10.20           -Ae
  42. # SVR4                  -Xc -D__EXTENSIONS__
  43. for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Ae" "-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. # include <limits.h>  /* note the space */
  52. #if 1 && !defined(UINT_MAX)
  53. #  error "this is an error"
  54. #  include "choke me"
  55. #elif 0 || !defined(UINT_MAX)
  56. #  error "this is an error"
  57. #  include "choke me"
  58. #elif !defined(UINT_MAX)
  59. #  error "this is an error"
  60. #  include "choke me"
  61. #elif !(1-1)
  62. /* ok */
  63. #else
  64. #  error "this is an error"
  65. #  include "choke me"
  66. #endif
  67. #define STRINGIZE(x)        #x
  68. #define MACRO_EXPAND(x)     STRINGIZE(x)
  69. extern volatile signed char flag;
  70. extern char *s ( void );
  71. char *s ( void )
  72. {
  73.   static char n[] = MACRO_EXPAND(UINT_MAX);
  74.   return flag ? n : n + 1;
  75. }
  76. /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
  77. struct buf { int x; };
  78. FILE * (*rcsopen) (struct buf *, struct stat *, int);
  79. static char *e (p, i)
  80.      char **p;
  81.      int i;
  82. {
  83.   return p[i];
  84. }
  85. static char *f (char * (*g) (char **, int), char **p, ...)
  86. {
  87.   char *s;
  88.   va_list v;
  89.   va_start (v,p);
  90.   s = g (p, va_arg (v,int));
  91.   va_end (v);
  92.   return s;
  93. }
  94. int test (int i, double x);
  95. struct s1 {int (*f) (int a);};
  96. struct s2 {int (*f) (double a);};
  97. int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
  98. int argc;
  99. char **argv;
  100. ], [
  101. return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
  102. ],
  103. [mfx_cv_prog_cc_ansi="$ac_arg"; break])
  104. done
  105. CC="$ac_save_CC"
  106. ])
  107. if test -z "$mfx_cv_prog_cc_ansi"; then
  108.   AC_MSG_RESULT([none needed])
  109. else
  110.   AC_MSG_RESULT($mfx_cv_prog_cc_ansi)
  111. fi
  112. case "x$mfx_cv_prog_cc_ansi" in
  113.   x|xno) ;;
  114.   *) CC="$CC $mfx_cv_prog_cc_ansi" ;;
  115. esac
  116. ])
  117.