lean.m4 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. # autotools lean macros
  2. # hg 2012-09-01 05a8d3fa4611
  3. # Copyright (c) 2012 Gregor Richards
  4. #
  5. # Permission to use, copy, modify, and/or distribute this software for any
  6. # purpose with or without fee is hereby granted, provided that the above
  7. # copyright notice and this permission notice appear in all copies.
  8. #
  9. # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
  10. # TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  11. # FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
  12. # OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  13. # USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  15. # OF THIS SOFTWARE.
  16. # These macros make auto* tests faster by removing some of autoconf's most
  17. # absurd defaults. The basic principle is to not check for things that have no
  18. # alternatives. That is, don't perform a test if it's either going to pass and
  19. # affect nothing, or fail and just prevent you from building. These tests
  20. # provide very little real value since modern systems that they fail on are few
  21. # and far between.
  22. # automake's sanity checks provide nothing useful, since all they can do is
  23. # fail, sometimes spuriously, and prevent builds which may otherwise have
  24. # succeeded.
  25. AC_DEFUN([AM_SANITY_CHECK], [ ])
  26. # Checking for C89 compliance nowadays is just plain silly.
  27. AC_DEFUN([_AC_PROG_CC_C89], [ ])
  28. # For the same reason, checking for C standard headers is usually stupid.
  29. # However, we simply avoid checking for them in the most ridiculous cases.
  30. m4_define([ACX_PRELEAN_AC_CHECK_HEADER], m4_defn([AC_CHECK_HEADER]))
  31. AC_DEFUN([AC_CHECK_HEADER], [
  32. m4_case([$4],
  33. [], [ACX_PRELEAN_AC_CHECK_HEADER([$1], [$2], [$3], [ ])],
  34. [m4_indir([ACX_PRELEAN_AC_CHECK_HEADER], $@)])
  35. ])
  36. m4_define([_AC_HEADERS_EXPANSION], [
  37. m4_divert_text([DEFAULTS], [ac_header_list=])
  38. AC_CHECK_HEADERS([$ac_header_list], [], [], [ ])
  39. m4_define([_AC_HEADERS_EXPANSION], [])
  40. ])
  41. m4_define([ACX_PRELEAN_AC_CHECK_SIZEOF], m4_defn([AC_CHECK_SIZEOF]))
  42. AC_DEFUN([AC_CHECK_SIZEOF], [
  43. m4_case([$3],
  44. [], [ACX_PRELEAN_AC_CHECK_SIZEOF([$1], [], [ ])],
  45. [m4_indir([ACX_PRELEAN_AC_CHECK_SIZEOF])], $@)])
  46. # And add warnings for known-nasty builtin checks
  47. m4_define([ACX_UNLEAN_AC_FUNC_MMAP], m4_defn([AC_FUNC_MMAP]))
  48. AC_DEFUN([AC_FUNC_MMAP], [
  49. AC_DIAGNOSE([syntax], [$0: AC_FUNC_MMAP does not work in cross environments and incurs high costs. Check for mmap directly if you aren't concerned about enormously-broken implementations. Use ACX_LEAN_AC_FUNC_MMAP to silence this warning.])
  50. ACX_LEAN_AC_FUNC_MMAP
  51. ])
  52. # POSIX says that make sets $(MAKE). That's good enough for me.
  53. AC_DEFUN([AC_PROG_MAKE_SET], [
  54. ac_cv_prog_make_make_set=yes
  55. SET_MAKE=
  56. AC_SUBST([SET_MAKE])
  57. ])
  58. # configure will simply fail, often spuriously, if you don't tell it that
  59. # you're cross compiling, so there's very little reason to explicitly check.
  60. AC_DEFUN([_AC_COMPILER_EXEEXT_CROSS], [
  61. if test "$cross_compiling" = "maybe"; then
  62. cross_compiling=yes
  63. fi
  64. ])
  65. # Allow the default GCC-and-compatible CFLAGS to be changed
  66. GCC_DEFAULT_CFLAGS="-g -O2"
  67. # The builtin -g test is simplified by avoiding rechecks for GCC (of course GCC
  68. # supports -g)
  69. m4_define([ACX_PRELEAN__AC_PROG_CC_G], m4_defn([_AC_PROG_CC_G]))
  70. m4_define([_AC_PROG_CC_G], [
  71. if test "$GCC" = "yes"; then
  72. acx_lean_CFLAGS_set=${CFLAGS+set}
  73. ac_cv_prog_cc_g=yes
  74. if test "$acx_lean_CFLAGS_set" != "set"; then
  75. CFLAGS="$GCC_DEFAULT_CFLAGS"
  76. fi
  77. else
  78. ACX_PRELEAN__AC_PROG_CC_G
  79. fi
  80. ])
  81. # Option to force caching
  82. AC_DEFUN([ACX_LEAN_FORCE_CACHE], [
  83. m4_define([acx_lean_forced_cache], [yes])
  84. if test "$cache_file" = "/dev/null"; then
  85. cache_file=config.cache
  86. touch config.cache
  87. fi
  88. ])
  89. # Force the use of a cache file if we use subdirectories, as otherwise we
  90. # retest things in the subdirs.
  91. m4_define([ACX_PRELEAN_AC_CONFIG_SUBDIRS], m4_defn([AC_CONFIG_SUBDIRS]))
  92. AC_DEFUN([AC_CONFIG_SUBDIRS], [
  93. m4_ifdef([acx_lean_forced_cache], [], [
  94. AC_DIAGNOSE([syntax], [$0: Use ACX_LEAN_FORCE_CACHE after initialization to avoid extra costs with configure subdirs.])
  95. ])
  96. ACX_PRELEAN_AC_CONFIG_SUBDIRS($1)
  97. ])