configure.ac 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. # https://www.gnu.org/software/automake/manual/automake.html
  2. # https://www.gnu.org/software/autoconf/manual/autoconf.html
  3. AC_PREREQ([2.63])
  4. AC_INIT([libtomcrypt],[1.18.1])
  5. AC_SUBST([ABI_VERSION],[1:1:1])
  6. AC_LANG([C])
  7. AC_CONFIG_HEADERS([config.h])
  8. AC_CONFIG_MACRO_DIR([m4])
  9. AC_CONFIG_AUX_DIR(aux-dist)
  10. AM_INIT_AUTOMAKE([1.11.1 no-define])
  11. LT_PREREQ([2.2.6])
  12. LT_INIT
  13. AC_CONFIG_FILES([Makefile libtomcrypt.pc])
  14. AC_MSG_CHECKING([for compiler warning level (--enable-warnings)])
  15. AC_ARG_ENABLE([warnings],
  16. [AS_HELP_STRING([--enable-warnings[[=0-9]]],[Enable compiler warnings. DEFAULT=0 (for development use 3)])],
  17. [AS_CASE([$enableval],
  18. [yes],[wlevel=1],
  19. [no],[wlevel=0],
  20. [[[0-9]]],[wlevel="$enableval"],
  21. [wlevel=0]
  22. )],
  23. [wlevel=0])
  24. AC_MSG_RESULT([$wlevel])
  25. AS_CASE([$wlevel],
  26. [0],[WARNING_FLAGS=""],
  27. [1],[WARNING_FLAGS="-Wall"],
  28. [2],[WARNING_FLAGS="-Wall -Wextra"],
  29. [3],[WARNING_FLAGS="-Wall -Wextra -Werror"],
  30. # --enable-warnings=6 requires gcc v6
  31. [6],[WARNING_FLAGS="-Wall -Wextra -Werror -Wdeclaration-after-statement -Wmissing-declarations -Wmissing-prototypes -Wmissing-noreturn -Woverflow -Wnonnull -Wunused-const-variable -Wundef -Wshift-negative-value -Wshift-overflow -Wtautological-compare -Wmisleading-indentation -Woverride-init-side-effects -Wnonnull-compare -Wnull-dereference -Wwrite-strings -Wshadow -Wjump-misses-init -Wlogical-op -Wduplicated-cond -Wformat=2 -Wmaybe-uninitialized -Wunused-parameter -Wbad-function-cast -Wcast-align -Wchar-subscripts -Wcomment -Wfloat-equal -Wimplicit -Wnormalized=id -Woverride-init -Wparentheses -Wpointer-arith -Wstrict-prototypes"],
  32. # --enable-warnings=7 requires gcc v7
  33. [7],[WARNING_FLAGS="-Wall -Wextra -Werror -Wdeclaration-after-statement -Wimplicit-fallthrough -Wmissing-declarations -Wmissing-prototypes -Wmissing-noreturn -Woverflow -Wnonnull -Walloc-zero -Wdangling-else -Wswitch-unreachable -Wrestrict -Wduplicated-branches -Wpointer-compare -Wunused-const-variable -Wundef -Wshift-negative-value -Wshift-overflow -Wtautological-compare -Wmisleading-indentation -Woverride-init-side-effects -Wnonnull-compare -Wnull-dereference -Wwrite-strings -Wshadow -Wjump-misses-init -Wlogical-op -Wduplicated-cond -Wformat=2 -Wmaybe-uninitialized -Wunused-parameter -Wbad-function-cast -Wcast-align -Wchar-subscripts -Wcomment -Wfloat-equal -Wimplicit -Wnormalized=id -Woverride-init -Wparentheses -Wpointer-arith -Wstrict-prototypes"],
  34. )
  35. AC_SUBST(WARNING_FLAGS)
  36. # Check for LTM
  37. AC_MSG_CHECKING([whether to build libtomcrypt with libtommath (--with-ltm)])
  38. AC_ARG_WITH([ltm],
  39. [AS_HELP_STRING(
  40. [--with-ltm[[=ARG]]],
  41. [Use libtommath to build libtomcrypt. Optional ARG is the libtommath installation prefix (if not given libtommath is detected via pkg-config). DEFAULT=enabled]
  42. )],
  43. [AS_CASE([$with_ltm],
  44. [yes],[with_ltm_result=yes],
  45. [no],[with_ltm_result=no],
  46. [with_ltm_result=yes;with_ltm_path="$with_ltm"]
  47. )],
  48. [with_ltm_result=yes]
  49. )
  50. AC_MSG_RESULT([$with_ltm_result])
  51. AS_VAR_IF([with_ltm_result],[yes],[
  52. AS_VAR_SET_IF([with_ltm_path],
  53. [
  54. extra_inc="-I$with_ltm_path/include"
  55. extra_lib="-L$with_ltm_path/lib"
  56. ],
  57. [
  58. extra_inc=`pkg-config --cflags-only-I libtommath 2>/dev/null`
  59. extra_lib=`pkg-config --libs-only-L libtommath 2>/dev/null`
  60. ]
  61. )
  62. CPPFLAGS="$CPPFLAGS $extra_inc"
  63. LDFLAGS="$LDFLAGS $extra_lib"
  64. AC_CHECK_HEADER([tommath.h],[extra_cppflags="$extra_inc -DLTM_DESC"],[AC_MSG_ERROR([libtommath is not usable.])])
  65. AC_CHECK_LIB([tommath],[mp_add],[extra_ldflags="$extra_lib -ltommath"],[AC_MSG_ERROR([libtommath is not usable.])])
  66. CPPFLAGS="$temp_cppflags"
  67. LDFLAGS="$temp_ldflags"
  68. AC_SUBST([LTM_CPPFLAGS],[$extra_cppflags])
  69. AC_SUBST([LTM_LDFLAGS],[$extra_ldflags])
  70. AC_MSG_RESULT([ Build with ltm: yes])
  71. AC_MSG_RESULT([ LTM_CPPFLAGS=$extra_cppflags])
  72. AC_MSG_RESULT([ LTM_LDFLAGS=$extra_ldflags])
  73. ])
  74. # Check for GMP
  75. AC_MSG_CHECKING([whether to build libtomcrypt with GMP (--with-gmp)])
  76. AC_ARG_WITH([gmp],
  77. [AS_HELP_STRING(
  78. [--with-gmp[[=ARG]]],
  79. [Use GMP to build libtomcrypt. Optional ARG is the GMP installation prefix (if not given GMP is detected via pkg-config). DEFAULT=disabled]
  80. )],
  81. [AS_CASE([$with_gmp],
  82. [yes],[with_gmp_result=yes],
  83. [no],[with_gmp_result=no],
  84. [with_gmp_result=yes;with_gmp_path="$with_gmp"]
  85. )],
  86. [with_gmp_result=no]
  87. )
  88. AC_MSG_RESULT([$with_gmp_result])
  89. AS_VAR_IF([with_gmp_result],[yes],[
  90. AS_VAR_SET_IF([with_gmp_path],
  91. [
  92. extra_inc="-I$with_gmp_path/include"
  93. extra_lib="-L$with_gmp_path/lib"
  94. ],
  95. [
  96. extra_inc=`pkg-config --cflags-only-I gmp 2>/dev/null`
  97. extra_lib=`pkg-config --libs-only-L gmp 2>/dev/null`
  98. ]
  99. )
  100. CPPFLAGS="$CPPFLAGS $extra_inc"
  101. LDFLAGS="$LDFLAGS $extra_lib"
  102. AC_CHECK_HEADER([gmp.h],[extra_cppflags="$extra_inc -DGMP_DESC"],[AC_MSG_ERROR([gmp is not usable.])])
  103. AC_CHECK_LIB([gmp],[ __gmpz_init],[extra_ldflags="$extra_lib -lgmp"],[AC_MSG_ERROR([gmp is not usable.])])
  104. CPPFLAGS="$temp_cppflags"
  105. LDFLAGS="$temp_ldflags"
  106. AC_SUBST([GMP_CPPFLAGS],[$extra_cppflags])
  107. AC_SUBST([GMP_LDFLAGS],[$extra_ldflags])
  108. AC_MSG_RESULT([ Build with gmp: yes])
  109. AC_MSG_RESULT([ GMP_CPPFLAGS=$extra_cppflags])
  110. AC_MSG_RESULT([ GMP_LDFLAGS=$extra_ldflags])
  111. ])
  112. # Check for TFM
  113. AC_MSG_CHECKING([whether to build libtomcrypt with tomsfastmath (--with-tfm)])
  114. AC_ARG_WITH([tfm],
  115. [AS_HELP_STRING(
  116. [--with-tfm[[=ARG]]],
  117. [Use tomsfastmath to build libtomcrypt. Optional ARG is the tfm installation prefix (if not given tfm is detected via pkg-config). DEFAULT=disabled]
  118. )],
  119. [AS_CASE([$with_tfm],
  120. [yes],[with_tfm_result=yes],
  121. [no],[with_tfm_result=no],
  122. [with_tfm_result=yes;with_tfm_path="$with_tfm"]
  123. )],
  124. [with_tfm_result=no]
  125. )
  126. AC_MSG_RESULT([$with_tfm_result])
  127. AS_VAR_IF([with_tfm_result],[yes],[
  128. AS_VAR_SET_IF([with_tfm_path],
  129. [
  130. extra_inc="-I$with_tfm_path/include"
  131. extra_lib="-L$with_tfm_path/lib"
  132. ],
  133. [
  134. extra_inc=`pkg-config --cflags-only-I tomsfastmath 2>/dev/null`
  135. extra_lib=`pkg-config --libs-only-L tomsfastmath 2>/dev/null`
  136. ]
  137. )
  138. CPPFLAGS="$CPPFLAGS $extra_inc"
  139. LDFLAGS="$LDFLAGS $extra_lib"
  140. AC_CHECK_HEADER([tfm.h],[extra_cppflags="$extra_inc -DTFM_DESC"],[AC_MSG_ERROR([tomsfastmath is not usable.])])
  141. AC_CHECK_LIB([tfm],[fp_add],[extra_ldflags="$extra_lib -ltfm"],[AC_MSG_ERROR([tomsfastmath is not usable.])])
  142. CPPFLAGS="$temp_cppflags"
  143. LDFLAGS="$temp_ldflags"
  144. AC_SUBST([TFM_CPPFLAGS],[$extra_cppflags])
  145. AC_SUBST([TFM_LDFLAGS],[$extra_ldflags])
  146. AC_MSG_RESULT([ Build with ltm: yes])
  147. AC_MSG_RESULT([ TFM_CPPFLAGS=$extra_cppflags])
  148. AC_MSG_RESULT([ TFM_LDFLAGS=$extra_ldflags])
  149. ])
  150. AC_ARG_WITH(tools,AC_HELP_STRING([--with-tools],[Build and install libtomcrypt tools. DEFAULT=disabled]),build_tools=$withval,build_tools=no)
  151. AC_ARG_WITH(demos,AC_HELP_STRING([--with-demos],[Build libtomcrypt demos. DEFAULT=disabled]),build_demos=$withval,build_demos=no)
  152. AM_CONDITIONAL([WITH_DEMOS],[test "x$build_demos" = "xyes"])
  153. AM_CONDITIONAL([WITH_TOOLS],[test "x$build_tools" = "xyes"])
  154. AM_CONDITIONAL([WITH_LTM],[test -n "$LTM_LDFLAGS"])
  155. AM_CONDITIONAL([WITH_GMP],[test -n "$GMP_LDFLAGS"])
  156. AM_CONDITIONAL([WITH_TFM],[test -n "$TFM_LDFLAGS"])
  157. AM_CONDITIONAL([WITH_NOMATH],[test -z "$LTM_LDFLAGS$GMP_LDFLAGS$TFM_LDFLAGS"])
  158. AC_MSG_RESULT([ Build demos: $build_demos])
  159. AC_MSG_RESULT([ Build tools: $build_tools])
  160. AC_OUTPUT