configure.ac 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. # -*- Autoconf -*-
  2. # configure.ac - template used by autoconf to generate the `configure' script
  3. # Copyright (C) 2015 Alex Vong
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software Foundation,
  17. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. # Process this file with autoconf to produce a configure script.
  19. AC_PREREQ([2.69])
  20. AC_INIT([Mlucas], [14.1], [ewmayer@aol.com], [mlucas],
  21. [http://hogranch.com/mayer/README.html])
  22. AM_INIT_AUTOMAKE([-Wall -Werror gnu])
  23. AM_SILENT_RULES([yes])
  24. AC_CONFIG_SRCDIR([src/rng_isaac.c])
  25. AC_CONFIG_HEADERS([config.h])
  26. # Checks for programs.
  27. : ${CFLAGS=""}
  28. AC_PROG_CC
  29. # Checks for libraries.
  30. AC_SEARCH_LIBS([ceil, log, pow, sqrt, sincos, floor, lrint, atan], [m], [],
  31. [
  32. AC_MSG_ERROR([cannot find ceil(), log(), pow(), sqrt(), sincos(), floor(), dnl
  33. lrint() or atan() in libm])
  34. ]
  35. )
  36. # Checks for header files.
  37. AC_CHECK_HEADERS([fenv.h limits.h mach/mach.h stddef.h stdlib.h string.h dnl
  38. sys/time.h unistd.h])
  39. # Checks for typedefs, structures, and compiler characteristics.
  40. AC_CHECK_HEADER_STDBOOL
  41. AC_C_INLINE
  42. AC_TYPE_PID_T
  43. AC_TYPE_SIZE_T
  44. AC_TYPE_UINT64_T
  45. # Checks for library functions.
  46. AC_FUNC_MALLOC
  47. AC_FUNC_REALLOC
  48. AC_CHECK_FUNCS([clock_gettime gethrtime gettimeofday memset pow sqrt dnl
  49. strerror strstr strtoul])
  50. # Enable Large File Support, useful on 32-bit systems.
  51. AC_CHECK_DECL([_LARGEFILE_SOURCE],
  52. [AC_SUBST([LFSCPPFLAGS], [['-D_FILE_OFFSET_BITS=64']])],
  53. [AC_SUBST([LFSCPPFLAGS], [['-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64']])]
  54. )
  55. # Notify the user the existence of custom options.
  56. AC_ARG_ENABLE([foo],
  57. AS_HELP_STRING([[
  58. Custom Options:
  59. (please note that all options mentioned below does NOT override one another)]],
  60. []))
  61. # Adding options for user specified NORMAL-CFLAGS and TRICKY-CFLAGS.
  62. AC_ARG_ENABLE([NORMAL-CFLAGS],
  63. AS_HELP_STRING([[--enable-NORMAL-CFLAGS='FOO' or --disable-NORMAL-CFLAGS]],
  64. [set CFLAGS for normal source files to FOO or nothing ['-Os']]))
  65. AC_ARG_ENABLE([TRICKY-CFLAGS],
  66. AS_HELP_STRING([[--enable-TRICKY-CFLAGS='FOO' or --disable-TRICKY-CFLAGS]],
  67. [set CFLAGS for optimization-sensitive source files to FOO or] dnl
  68. [nothing ['-O1']]))
  69. # Check if the user set NORMAL-CFLAGS and TRICKY-CFLAGS.
  70. AS_IF([test "x$enable_NORMAL_CFLAGS" = "x"],
  71. [AC_SUBST([NORMALCFLAGS], [['-Os']])],
  72. [test "x$enable_NORMAL_CFLAGS" = "xno"],
  73. [AC_SUBST([NORMALCFLAGS], [[]])],
  74. [AC_SUBST([NORMALCFLAGS], [[$enable_NORMAL_CFLAGS]])]
  75. )
  76. AS_IF([test "x$enable_TRICKY_CFLAGS" = "x"],
  77. [AC_SUBST([TRICKYCFLAGS], [['-O1']])],
  78. [test "x$enable_NORMAL_CFLAGS" = "xno"],
  79. [AC_SUBST([NORMALCFLAGS], [[]])],
  80. [AC_SUBST([TRICKYCFLAGS], [[$enable_TRICKY_CFLAGS]])]
  81. )
  82. # Notify the user CFLAGS, CPPFLAGS and LDFLAGS are honored.
  83. AC_ARG_ENABLE([foo],
  84. AS_HELP_STRING([[CFLAGS='FOO']],
  85. [set CFLAGS for all source files to FOO ['']]))
  86. AC_ARG_ENABLE([foo],
  87. AS_HELP_STRING([[CPPFLAGS='FOO']],
  88. [set CPPFLAGS for all source files to FOO ['']]))
  89. AC_ARG_ENABLE([foo],
  90. AS_HELP_STRING([[LDFLAGS='FOO']],
  91. [set LDFLAGS for all linking to FOO ['']]))
  92. # Notify the user --host is honored.
  93. AC_ARG_ENABLE([foo],
  94. AS_HELP_STRING([[--host='FOO']],
  95. [skip autodetection and force detecting host as FOO ]
  96. [(set --host=none to disable host-specific compilation flags)]))
  97. # Add appropriate flag if host cpu is i386, i486, i586, i686 or amd64.
  98. AC_CANONICAL_HOST
  99. AS_IF([test "x$host_cpu" = "xi386" ||
  100. test "x$host_cpu" = "xi486" ||
  101. test "x$host_cpu" = "xi586" ||
  102. test "x$host_cpu" = "xi686"],
  103. [
  104. AC_SUBST([ARCHCFLAGS], [['-m32']])
  105. AC_SUBST([ARCHCPPFLAGS], [['-DCPU_IS_X86']])
  106. ]
  107. )
  108. AS_IF([test "x$host_cpu" = "xx86_64"],
  109. [AC_SUBST([ARCHCFLAGS], [['-m64']])]
  110. )
  111. # Adding options for building with extended instruction sets support.
  112. AC_ARG_ENABLE([instruction],
  113. AS_HELP_STRING([[[--enable-instruction=[SSE2|AVX|AVX2] or]]] dnl
  114. [[[--disable-instruction]]],
  115. [build with SSE2, AVX, AVX2 or without extended instruction set]))
  116. # Checks for extended instruction sets.
  117. AS_IF([test "x$enable_instruction" = "xsse2" ||
  118. test "x$enable_instruction" = "xSSE2"],
  119. [
  120. AC_SUBST([INSTRUCTIONCFLAGS], [["-msse2"]])
  121. AC_SUBST([INSTRUCTIONCPPFLAGS], [["-DUSE_SSE2"]])
  122. ],
  123. [test "x$enable_instruction" = "xavx" ||
  124. test "x$enable_instruction" = "xAVX"],
  125. [
  126. AC_SUBST([INSTRUCTIONCFLAGS], [["-mavx"]])
  127. AC_SUBST([INSTRUCTIONCPPFLAGS], [["-DUSE_AVX"]])
  128. ],
  129. [test "x$enable_instruction" = "xavx2" ||
  130. test "x$enable_instruction" = "xAVX2"],
  131. [
  132. AC_SUBST([INSTRUCTIONCFLAGS], [["-mavx2"]])
  133. AC_SUBST([INSTRUCTIONCPPFLAGS], [["-DUSE_AVX2"]])
  134. ],
  135. [test "x$host_cpu" = "xx86_64"],
  136. [amd64_instruction_unspecified=true]
  137. )
  138. # Set AMD64_INSTRUCTION_UNSPECIFIED if amd64_instruction_unspecified is true.
  139. AM_CONDITIONAL([AMD64_INSTRUCTION_UNSPECIFIED],
  140. [test "x$amd64_instruction_unspecified" = "xtrue"])
  141. # Adding options for disabling multithread-support.
  142. AC_ARG_ENABLE([threads],
  143. AS_HELP_STRING([[--disable-threads]],
  144. [force building without multithread-support]))
  145. # Set USE_THREADS if the user wants thread-support.
  146. AM_CONDITIONAL([USE_THREADS],
  147. [test "x$enable_threads" != "xno"])
  148. # Adding options for setting MLUCAS_DEFAULT_PATH to "$HOME/.mlucas.d/".
  149. AC_ARG_ENABLE([MLUCAS-DEFAULT-PATH],
  150. AS_HELP_STRING([[--enable-MLUCAS-DEFAULT-PATH]],
  151. [set MLUCAS_DEFAULT_PATH (unset by default) to "$HOME/.mlucas.d/"]))
  152. # Check if the user set MLUCAS-DEFAULT-PATH.
  153. AS_IF([test "x$enable_MLUCAS_DEFAULT_PATH" = "xyes"],
  154. [AC_SUBST([PATHCPPFLAGS],
  155. [[-DMLUCAS_DEFAULT_PATH="'"'"'"'""'"'$$'"'"HOME/.mlucas.d/"'"'"'"'"]])]
  156. )
  157. # Notify the user --disable-silent-rules is honored.
  158. AC_ARG_ENABLE([foo],
  159. AS_HELP_STRING([[--disable-silent-rules]],
  160. [increase make verbosity]))
  161. # Adding options for enabaling verbose compiler.
  162. AC_ARG_ENABLE([verbose-compiler],
  163. AS_HELP_STRING([[--enable-verbose-compiler]],
  164. [enable verbose compiler]))
  165. # Check if the user wants the compiler to be verbose.
  166. AS_IF([test "x$enable_verbose_compiler" != "xyes"],
  167. [AC_SUBST([REDIRECTION], ['2> /dev/null'])]
  168. )
  169. # Notify the user the end of custom options.
  170. AC_ARG_ENABLE([foo],
  171. AS_HELP_STRING([[
  172. End of Custom Options]],
  173. []))
  174. # End of configuration.
  175. AC_CONFIG_FILES([Makefile])
  176. AC_OUTPUT