config.m4 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # Nathan's Common Config -*- mode:autoconf -*-
  2. # Copyright (C) 2020 Nathan Sidwell, nathan@acm.org
  3. # License: Apache v2.0
  4. # Note: VAR+=... is not dashing, despite its looks
  5. AC_DEFUN([NMS_MAINTAINER_MODE],
  6. [AC_ARG_ENABLE([maintainer-mode],
  7. AS_HELP_STRING([--enable-maintainer-mode],
  8. [enable maintainer mode. Add rules to rebuild configurey bits]),,
  9. [enable_maintainer_mode=no])
  10. AS_CASE([$enable_maintainer_mode],
  11. [yes], [maintainer_mode=yes],
  12. [no], [maintainer=no],
  13. [AC_MSG_ERROR([unknown maintainer mode $enable_maintainer_mode])])
  14. AC_MSG_CHECKING([maintainer-mode])
  15. AC_MSG_RESULT([$maintainer_mode])
  16. test "$maintainer_mode" = yes && MAINTAINER=yes
  17. AC_SUBST(MAINTAINER)])
  18. AC_DEFUN([NMS_CXX_COMPILER],
  19. [AC_ARG_WITH([compiler],
  20. AS_HELP_STRING([--with-compiler=NAME],[which compiler to use]),
  21. AC_MSG_CHECKING([C++ compiler])
  22. if test "$withval" = "yes" ; then
  23. AC_MSG_ERROR([NAME not specified])
  24. elif test "$withval" = "no" ; then
  25. AC_MSG_ERROR([Gonna need a C++ compiler!])
  26. else
  27. CXX="${withval}"
  28. AC_MSG_RESULT([$CXX])
  29. fi)])
  30. AC_DEFUN([NMS_CXX_11],
  31. [AC_MSG_CHECKING([whether $CXX is for C++11])
  32. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
  33. [#if __cplusplus != 201103
  34. #error "C++11 is required"
  35. #endif
  36. ]])],
  37. [AC_MSG_RESULT([yes])],
  38. [CXX_ORIG="$CXX"
  39. CXX="$CXX -std=c++11"
  40. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
  41. [#if __cplusplus != 201103
  42. #error "C++11 is required"
  43. #endif
  44. ]])],
  45. AC_MSG_RESULT([adding -std=c++11]),
  46. [CXX="$CXX_ORIG"
  47. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
  48. [#if __cplusplus > 201103
  49. #error "C++11 is required"
  50. #endif
  51. ]])],
  52. AC_MSG_RESULT([> C++11]),
  53. AC_MSG_RESULT([no])
  54. AC_MSG_ERROR([C++11 is required])]))
  55. unset CXX_ORIG])])
  56. AC_DEFUN([NMS_ENABLE_EXCEPTIONS],
  57. [AC_ARG_ENABLE([exceptions],
  58. AS_HELP_STRING([--enable-exceptions],
  59. [enable exceptions & rtti]),,
  60. [enable_exceptions="no"])
  61. AS_CASE([$enable_exceptions],
  62. [yes], [nms_exceptions=yes],
  63. [no], [nms_exceptions=no],
  64. [AC_MSG_ERROR([unknown exceptions $enable_exceptions])])
  65. AC_MSG_CHECKING([exceptions])
  66. AC_MSG_RESULT([$nms_exceptions])
  67. if test "$nms_exceptions" != no ; then
  68. EXCEPTIONS=yes
  69. fi
  70. AC_SUBST(EXCEPTIONS)])
  71. AC_DEFUN([NMS_LINK_OPT],
  72. [AC_MSG_CHECKING([adding $1 to linker])
  73. ORIG_LDFLAGS="$LDFLAGS"
  74. LDFLAGS="$LDFLAGS $1"
  75. AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
  76. [AC_MSG_RESULT([ok])],
  77. [LDFLAGS="$ORIG_LDFLAGS"
  78. AC_MSG_RESULT([no])])
  79. unset ORIG_LDFLAGS])
  80. AC_DEFUN([NMS_ENABLE_CHECKING],
  81. [AC_ARG_ENABLE([checking],
  82. AS_HELP_STRING([--enable-checking],
  83. [enable run-time checking]),,
  84. [enable_checking="yes"])
  85. AS_CASE([$enable_checking],
  86. [yes|all|yes,*], [nms_checking=yes],
  87. [no|none|release], [nms_checking=],
  88. [AC_MSG_ERROR([unknown check "$enable_checking"])])
  89. AC_MSG_CHECKING([checking])
  90. AC_MSG_RESULT([${nms_checking:-no}])
  91. if test "$nms_checking" = yes ; then
  92. AC_DEFINE_UNQUOTED([NMS_CHECKING], [0${nms_checking:+1}], [Enable checking])
  93. fi])