home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lzo100.zip / lzo-1.00 / acinclude.m4 < prev    next >
Text File  |  1997-07-13  |  7KB  |  247 lines

  1. # Local additions to Autoconf 2.12 macros.
  2. #
  3. #
  4. # Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
  5. # Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
  6. #
  7.  
  8. ## --------------------------------------------------------- ##
  9. ## Includes <stdlib.h> and <stddef.h> if available.          ##
  10. ## Adapted from AC_CHECK_SIZEOF (Autoconf 2.12).             ##
  11. ## --------------------------------------------------------- ##
  12.  
  13. dnl mfx_CHECK_SIZEOF(TYPE [, CROSS-SIZE])
  14. AC_DEFUN(mfx_CHECK_SIZEOF,
  15. [changequote(<<, >>)dnl
  16. dnl The name to #define.
  17. define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
  18. dnl The cache variable name.
  19. define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
  20. changequote([, ])dnl
  21. AC_MSG_CHECKING(size of $1)
  22. AC_CACHE_VAL(AC_CV_NAME,
  23. [AC_TRY_RUN([#include <stdio.h>
  24. #if STDC_HEADERS
  25. #include <stdlib.h>
  26. #include <stddef.h>
  27. #endif
  28. main()
  29. {
  30.   FILE *f=fopen("conftestval", "w");
  31.   if (!f) exit(1);
  32.   fprintf(f, "%d\n", sizeof($1));
  33.   exit(0);
  34. }], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$2], , , AC_CV_NAME=$2))])dnl
  35. AC_MSG_RESULT($AC_CV_NAME)
  36. AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
  37. undefine([AC_TYPE_NAME])dnl
  38. undefine([AC_CV_NAME])dnl
  39. ])
  40.  
  41.  
  42. ## --------------------------------------------------------- ##
  43. ## Check if gcc accepts '-pipe'.                             ##
  44. ## Adapted from AC_PROG_CC and AC_PROG_GCC_TRADITIONAL.      ##
  45. ## --------------------------------------------------------- ##
  46.  
  47. AC_DEFUN(mfx_PROG_GCC_PIPE,
  48. [AC_REQUIRE([AC_PROG_CC])dnl
  49. AC_REQUIRE([AC_PROG_CPP])dnl
  50. if test $ac_cv_prog_gcc = yes; then
  51. AC_CACHE_CHECK(whether ${CC-cc} accepts -pipe, mfx_cv_prog_gcc_pipe,
  52. [echo 'main() { return 0; }' > conftest.c
  53. if test -z "`${CC-cc} -pipe -c conftest.c 2>&1`"; then
  54.   mfx_cv_prog_gcc_pipe=yes
  55. else
  56.   mfx_cv_prog_gcc_pipe=no
  57. fi
  58. rm -f conftest*
  59. ])
  60.   if test $mfx_cv_prog_gcc_pipe = yes; then
  61.     CC="$CC -pipe"
  62.   fi
  63. fi
  64. ])
  65.  
  66.  
  67. ## --------------------------------------------------------- ##
  68. ## Check if gcc suffers the '-fstrength-reduce' bug.         ##
  69. ## --------------------------------------------------------- ##
  70.  
  71. AC_DEFUN(mfx_PROG_GCC_BUG_STRENGTH_REDUCE,
  72. [AC_REQUIRE([AC_PROG_CC])dnl
  73. AC_REQUIRE([AC_PROG_CPP])dnl
  74. if test $ac_cv_prog_gcc = yes; then
  75. mfx_save_cflags=$CFLAGS
  76. CFLAGS="$CFLAGS -O2 -fstrength-reduce"
  77. AC_CACHE_CHECK(whether ${CC-cc} suffers the -fstrength-reduce bug,
  78. mfx_cv_prog_gcc_bug_strength_reduce,
  79. [AC_TRY_RUN([
  80. /* gcc strength-reduce optimization bug on Intel platforms.
  81.  * Adapted from bug-report by John E. Davis <davis@space.mit.edu>
  82.  * Compile and run it using gcc -O2 -fno-strength-reduce and
  83.  * gcc -O2 -fstrength-reduce.
  84.  */
  85. int a[3];
  86. unsigned an = 3;
  87. int strength_reduce_bug();
  88. main()
  89. {
  90.   unsigned j;
  91.   for (j = 0; j < an; j++)
  92.     a[j] = (int)j - 3;
  93.   exit(strength_reduce_bug() ? 1 : 0);
  94. }
  95. int strength_reduce_bug()
  96. {
  97.   return a[0] != -3 || a[1] != -2 || a[2] != -1;
  98. }], mfx_cv_prog_gcc_bug_strength_reduce=no, mfx_cv_prog_gcc_bug_strength_reduce=yes)])
  99. CFLAGS=$mfx_save_cflags
  100. fi
  101. MFX_PROG_GCC_BUG_STRENGTH_REDUCE=$mfx_cv_prog_gcc_bug_strength_reduce
  102. AC_SUBST(MFX_PROG_GCC_BUG_STRENGTH_REDUCE)dnl
  103. ])
  104.  
  105.  
  106. ## --------------------------------------------------------- ##
  107. ## Check if gcc suffers the '-fschedule-insns' bug.          ##
  108. ## --------------------------------------------------------- ##
  109.  
  110. AC_DEFUN(mfx_PROG_GCC_BUG_SCHEDULE_INSNS,
  111. [AC_REQUIRE([AC_PROG_CC])dnl
  112. AC_REQUIRE([AC_PROG_CPP])dnl
  113. if test $ac_cv_prog_gcc = yes; then
  114. mfx_save_cflags=$CFLAGS
  115. CFLAGS="$CFLAGS -O2 -fschedule-insns -fschedule-insns2"
  116. AC_CACHE_CHECK(whether ${CC-cc} suffers the -fschedule-insns bug,
  117. mfx_cv_prog_gcc_bug_schedule_insns,
  118. [AC_TRY_RUN([
  119. /* gcc schedule-insns optimization bug on RS6000 platforms.
  120.  * Adapted from bug-report by Assar Westerlund <assar@sics.se>
  121.  * Compile and run it using gcc -O2 -fno-schedule-insns and
  122.  * gcc -O2 -fschedule-insns.
  123.  */
  124. main()
  125. {
  126.   const int clone[] = {1, 2, 0};
  127.   const int *q;
  128.   q = clone;
  129.   if (*q) {
  130.     return 0;
  131.   }
  132.   return 1;
  133. }], mfx_cv_prog_gcc_bug_schedule_insns=no, mfx_cv_prog_gcc_bug_schedule_insns=yes)])
  134. CFLAGS=$mfx_save_cflags
  135. fi
  136. MFX_PROG_GCC_BUG_SCHEDULE_INSNS=$mfx_cv_prog_gcc_bug_schedule_insns
  137. AC_SUBST(MFX_PROG_GCC_BUG_SCHEDULE_INSNS)dnl
  138. ])
  139.  
  140.  
  141. ## --------------------------------------------------------- ##
  142. ## Adapted from zsh.                                         ##
  143. ## --------------------------------------------------------- ##
  144.  
  145. dnl  Checking if compiler correctly cast signed to unsigned.
  146. AC_DEFUN(mfx_PROG_CC_BUG_SIGNED_TO_UNSIGNED_CASTING,
  147. [AC_REQUIRE([AC_PROG_CC])dnl
  148. AC_REQUIRE([AC_PROG_CPP])dnl
  149. AC_CACHE_CHECK(whether signed to unsigned casting is broken,
  150. mfx_cv_prog_cc_bug_signed_to_unsigned_casting,
  151. [AC_TRY_RUN([main(){return((int)(unsigned char)((char) -1) != 255);}],
  152.   mfx_cv_prog_cc_bug_signed_to_unsigned_casting=no,
  153.   mfx_cv_prog_cc_bug_signed_to_unsigned_casting=yes)])
  154. MFX_PROC_CC_BUG_SIGNED_TO_UNSIGNED_CASTING=$mfx_cv_prog_cc_bug_signed_to_unsigned_casting
  155. AC_SUBST(MFX_PROC_CC_BUG_SIGNED_TO_UNSIGNED_CASTING)dnl
  156. if test "$mfx_cv_prog_cc_bug_signed_to_unsigned_casting" = yes; then
  157.   AC_DEFINE(MFX_PROG_CC_BUG_SIGNED_TO_UNSIGNED_CASTING)
  158. fi
  159. ])
  160.  
  161.  
  162. ## --------------------------------------------------------- ##
  163. ## Check for 8-bit clean memcmp.                             ##
  164. ## Adapted from AC_FUNC_MEMCMP.                              ##
  165. ## --------------------------------------------------------- ##
  166.  
  167. AC_DEFUN(mfx_FUNC_MEMCMP,
  168. [AC_CACHE_CHECK(for 8-bit clean memcmp, mfx_cv_func_memcmp,
  169. [AC_TRY_RUN([
  170. main()
  171. {
  172.   char c0 = 0x40, c1 = 0x80, c2 = 0x81;
  173.   exit(memcmp(&c0, &c2, 1) < 0 && memcmp(&c1, &c2, 1) < 0 ? 0 : 1);
  174. }
  175. ], mfx_cv_func_memcmp=yes, mfx_cv_func_memcmp=no, mfx_cv_func_memcmp=no)])
  176. if test "$mfx_cv_func_memcmp" = no; then
  177.   AC_DEFINE(MFX_MEMCMP_BROKEN)
  178. fi
  179. ])
  180.  
  181.  
  182. ## --------------------------------------------------------- ##
  183. ## Check the byte order.                                     ##
  184. ## Adapted from AC_C_BIGENDIAN.                              ##
  185. ## --------------------------------------------------------- ##
  186.  
  187. AC_DEFUN(mfx_C_BYTE_ORDER,
  188. [AC_CACHE_CHECK(the byte order, mfx_cv_c_byte_order,
  189. [mfx_cv_c_byte_order=unknown
  190. AC_TRY_RUN([main () {
  191.   /* Are we little or big endian?  From Harbison&Steele.  */
  192.   union
  193.   {
  194.     long l;
  195.     char c[sizeof (long)];
  196.   } u;
  197.   u.l = 1;
  198.   exit (u.c[sizeof (long) - 1] == 1);
  199. }], mfx_cv_c_byte_order=1234, mfx_cv_c_byte_order=4321)
  200. ])
  201. if test $mfx_cv_c_byte_order = 1234; then
  202.   AC_DEFINE_UNQUOTED(MFX_BYTE_ORDER,1234)
  203. fi
  204. if test $mfx_cv_c_byte_order = 4321; then
  205.   AC_DEFINE_UNQUOTED(MFX_BYTE_ORDER,4321)
  206. fi
  207. ])
  208.  
  209.  
  210. ## --------------------------------------------------------- ##
  211. ## Check the alignment of the assembler.                     ##
  212. ## Adapted from AC_CHECK_SIZEOF.                             ##
  213. ## --------------------------------------------------------- ##
  214.  
  215. AC_DEFUN(mfx_ASM_ALIGN,
  216. [AC_CACHE_CHECK(the alignment of the assembler, mfx_cv_asm_align,
  217. [AC_TRY_RUN([#include <stdio.h>
  218. main()
  219. {
  220. #if defined(__GNUC__)
  221.   extern char mfx_a1 __asm__("mfx_a1");
  222.   extern char mfx_a2 __asm__("mfx_a2");
  223.   long l = &mfx_a2 - &mfx_a1;
  224.   FILE *f = fopen("conftestval", "w");
  225.   if (!f) exit(1);
  226.   fprintf(f, "%ld\n", l);
  227.   exit(0);
  228.   __asm__ __volatile__ ("
  229.   .align 4
  230. mfx_a1:
  231.   .byte 0
  232.   .align 4
  233. mfx_a2:
  234.   ");
  235. #else
  236.   exit(2);
  237. #endif
  238. }], mfx_cv_asm_align=`cat conftestval`, mfx_cv_asm_align=0)
  239. ])
  240. if test $mfx_cv_asm_align = 16; then
  241.   AC_DEFINE(MFX_ASM_ALIGN_PTWO)
  242. else
  243.   AC_DEFINE(MFX_ASM_ALIGN_BYTES)
  244. fi
  245. ])
  246.  
  247.