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