You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

377 lines
13 KiB

  1. dnl GNU Guix --- Functional package management for GNU
  2. dnl Copyright © 2012, 2013, 2014, 2015, 2016, 2018 Ludovic Courtès <ludo@gnu.org>
  3. dnl Copyright © 2014 Mark H Weaver <mhw@netris.org>
  4. dnl Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
  5. dnl
  6. dnl This file is part of GNU Guix.
  7. dnl
  8. dnl GNU Guix is free software; you can redistribute it and/or modify it
  9. dnl under the terms of the GNU General Public License as published by
  10. dnl the Free Software Foundation; either version 3 of the License, or (at
  11. dnl your option) any later version.
  12. dnl
  13. dnl GNU Guix is distributed in the hope that it will be useful, but
  14. dnl WITHOUT ANY WARRANTY; without even the implied warranty of
  15. dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. dnl GNU General Public License for more details.
  17. dnl
  18. dnl You should have received a copy of the GNU General Public License
  19. dnl along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  20. dnl GUIX_ASSERT_LIBGCRYPT_USABLE
  21. dnl
  22. dnl Assert that GNU libgcrypt is usable from Guile.
  23. AC_DEFUN([GUIX_ASSERT_LIBGCRYPT_USABLE],
  24. [AC_CACHE_CHECK([whether $LIBGCRYPT can be dynamically loaded],
  25. [guix_cv_libgcrypt_usable_p],
  26. [GUILE_CHECK([retval],
  27. [(dynamic-func \"gcry_md_hash_buffer\" (dynamic-link \"$LIBGCRYPT\"))])
  28. if test "$retval" = 0; then
  29. guix_cv_libgcrypt_usable_p="yes"
  30. else
  31. guix_cv_libgcrypt_usable_p="no"
  32. fi])
  33. if test "x$guix_cv_libgcrypt_usable_p" != "xyes"; then
  34. AC_MSG_ERROR([GNU libgcrypt does not appear to be usable; see `--with-libgcrypt-prefix' and `README'.])
  35. fi])
  36. dnl GUIX_SYSTEM_TYPE
  37. dnl
  38. dnl Determine the Guix host system type, and store it in the
  39. dnl `guix_system' variable.
  40. AC_DEFUN([GUIX_SYSTEM_TYPE], [
  41. AC_REQUIRE([AC_CANONICAL_HOST])
  42. AC_PATH_PROG([SED], [sed])
  43. AC_ARG_WITH(system, AC_HELP_STRING([--with-system=SYSTEM],
  44. [Platform identifier (e.g., `i686-linux').]),
  45. [guix_system="$withval"],
  46. [case "$host_cpu" in
  47. i*86)
  48. machine_name="i686";;
  49. amd64)
  50. machine_name="x86_64";;
  51. arm|armv[[7-9]]*)
  52. # Here we want to exclude CPUs such as "armv6l". On ARMv7
  53. # machines, we normally get "armv7l". However, in Guix, we
  54. # configure with --build=arm-unknown-linux-gnueabihf, leading
  55. # to just "arm", so we also have to allow it.
  56. #
  57. # TODO: If not cross-compiling, add a sanity check to make
  58. # sure this build machine has the needed features to
  59. # support executables compiled using our armhf gcc,
  60. # configured with:
  61. # --with-arch=armv7-a
  62. # --with-float=hard
  63. # --with-mode=thumb
  64. # --with-fpu=vfpv3-d16
  65. machine_name="armhf";;
  66. *)
  67. machine_name="$host_cpu";;
  68. esac
  69. case "$host_os" in
  70. linux-gnu*)
  71. # For backward compatibility, strip the `-gnu' part.
  72. guix_system="$machine_name-linux";;
  73. gnu*)
  74. # Always use i586 for GNU/Hurd.
  75. guix_system="i586-gnu";;
  76. *)
  77. # Strip the version number from names such as `gnu0.3',
  78. # `darwin10.2.0', etc.
  79. guix_system="$machine_name-`echo $host_os | "$SED" -e's/[0-9.]*$//g'`";;
  80. esac])
  81. AC_MSG_CHECKING([for the Guix system type])
  82. AC_MSG_RESULT([$guix_system])
  83. AC_SUBST([guix_system])
  84. ])
  85. dnl GUIX_ASSERT_SUPPORTED_SYSTEM
  86. dnl
  87. dnl Assert that this is a system to which the distro is ported.
  88. AC_DEFUN([GUIX_ASSERT_SUPPORTED_SYSTEM], [
  89. AC_REQUIRE([GUIX_SYSTEM_TYPE])
  90. AC_ARG_WITH([courage], [AC_HELP_STRING([--with-courage],
  91. [Assert that even if this platform is unsupported, you will be
  92. courageous and port the GNU System distribution to it (see
  93. "GNU Distribution" in the manual.)])],
  94. [guix_courageous="$withval"],
  95. [guix_courageous="no"])
  96. # Currently only Linux-based systems are supported, and only on some
  97. # platforms.
  98. case "$guix_system" in
  99. x86_64-linux|i686-linux|armhf-linux|aarch64-linux|mips64el-linux)
  100. ;;
  101. *)
  102. if test "x$guix_courageous" = "xyes"; then
  103. AC_MSG_WARN([building Guix on `$guix_system', which is not supported])
  104. else
  105. AC_MSG_ERROR([`$guix_system' is not a supported platform.
  106. See "GNU Distribution" in the manual, or try `--with-courage'.])
  107. fi
  108. ;;
  109. esac
  110. ])
  111. dnl GUIX_ASSERT_GUILE_FEATURES FEATURES
  112. dnl
  113. dnl Assert that FEATURES are provided by $GUILE.
  114. AC_DEFUN([GUIX_ASSERT_GUILE_FEATURES], [
  115. for guix_guile_feature in $1
  116. do
  117. AC_MSG_CHECKING([whether $GUILE provides feature '$guix_guile_feature'])
  118. if "$GUILE" -c "(exit (provided? '$guix_guile_feature))"
  119. then
  120. AC_MSG_RESULT([yes])
  121. else
  122. AC_MSG_RESULT([no])
  123. AC_MSG_ERROR([$GUILE does not support feature '$guix_guile_feature', which is required.])
  124. fi
  125. done
  126. ])
  127. dnl GUIX_CHECK_UNBUFFERED_CBIP
  128. dnl
  129. dnl Check whether 'setbvuf' works on custom binary input ports (CBIPs), as is
  130. dnl the case starting with Guile 2.0.10.
  131. AC_DEFUN([GUIX_CHECK_UNBUFFERED_CBIP], [
  132. AC_CACHE_CHECK([whether Guile's custom binary input ports support 'setvbuf'],
  133. [ac_cv_guix_cbips_support_setvbuf],
  134. [if "$GUILE" -c "(use-modules (rnrs io ports)) \
  135. (let ((p (make-custom-binary-input-port \"cbip\" pk #f #f #f))) \
  136. (setvbuf p _IONBF))" >&5 2>&1
  137. then
  138. ac_cv_guix_cbips_support_setvbuf=yes
  139. else
  140. ac_cv_guix_cbips_support_setvbuf=no
  141. fi])
  142. ])
  143. dnl GUIX_ASSERT_SYNTAX_OBJECT_EQUAL
  144. dnl
  145. dnl Guile 2.2.1 was a brown-paper-bag release where 'equal?' wouldn't work
  146. dnl for syntax objects, which broke gexps. Unfortunately Fedora 25 provides it.
  147. dnl Reject it.
  148. AC_DEFUN([GUIX_ASSERT_SYNTAX_OBJECT_EQUAL], [
  149. AC_CACHE_CHECK([whether 'equal?' works for syntax objects],
  150. [ac_cv_guix_syntax_object_equal],
  151. [if "$GUILE" -c '(exit (equal? (syntax x) (syntax x)))'
  152. then
  153. ac_cv_guix_syntax_object_equal=yes
  154. else
  155. ac_cv_guix_syntax_object_equal=no
  156. fi])
  157. if test "x$ac_cv_guix_syntax_object_equal" != xyes; then
  158. # This bug was present in Guile 2.2.1 only.
  159. AC_MSG_ERROR(['equal?' does not work for syntax object; upgrade to Guile 2.2.2 or later.])
  160. fi
  161. ])
  162. dnl GUIX_CHECK_GUILE_SSH
  163. dnl
  164. dnl Check whether a recent-enough Guile-SSH is available.
  165. AC_DEFUN([GUIX_CHECK_GUILE_SSH], [
  166. dnl Check whether 'channel-send-eof' (introduced in 0.10.2) is present.
  167. AC_CACHE_CHECK([whether Guile-SSH is available and recent enough],
  168. [guix_cv_have_recent_guile_ssh],
  169. [GUILE_CHECK([retval],
  170. [(and (@ (ssh channel) channel-send-eof)
  171. (@ (ssh popen) open-remote-pipe)
  172. (@ (ssh dist node) node-eval))])
  173. if test "$retval" = 0; then
  174. guix_cv_have_recent_guile_ssh="yes"
  175. else
  176. guix_cv_have_recent_guile_ssh="no"
  177. fi])
  178. ])
  179. dnl GUIX_TEST_ROOT_DIRECTORY
  180. AC_DEFUN([GUIX_TEST_ROOT_DIRECTORY], [
  181. AC_CACHE_CHECK([for unit test root directory],
  182. [ac_cv_guix_test_root],
  183. [ac_cv_guix_test_root="`pwd`/test-tmp"])
  184. ])
  185. dnl 'BINPRM_BUF_SIZE' constant in Linux (we leave room for the trailing zero.)
  186. dnl The Hurd has a limit of about a page (see exec/hashexec.c.)
  187. m4_define([LINUX_HASH_BANG_LIMIT], 127)
  188. dnl Hardcoded 'sun_path' length in <sys/un.h>.
  189. m4_define([SOCKET_FILE_NAME_LIMIT], 108)
  190. dnl GUIX_SOCKET_FILE_NAME_LENGTH
  191. AC_DEFUN([GUIX_SOCKET_FILE_NAME_LENGTH], [
  192. AC_CACHE_CHECK([the length of the installed socket file name],
  193. [ac_cv_guix_socket_file_name_length],
  194. [ac_cv_guix_socket_file_name_length="`echo -n "$guix_localstatedir/guix/daemon-socket/socket" | wc -c`"])
  195. ])
  196. dnl GUIX_TEST_SOCKET_FILE_NAME_LENGTH
  197. AC_DEFUN([GUIX_TEST_SOCKET_FILE_NAME_LENGTH], [
  198. AC_REQUIRE([GUIX_TEST_ROOT_DIRECTORY])
  199. AC_CACHE_CHECK([the length of the socket file name used in tests],
  200. [ac_cv_guix_test_socket_file_name_length],
  201. [ac_cv_guix_test_socket_file_name_length="`echo -n "$ac_cv_guix_test_root/var/123456/daemon-socket/socket" | wc -c`"])
  202. ])
  203. dnl GUIX_HASH_BANG_LENGTH
  204. AC_DEFUN([GUIX_HASH_BANG_LENGTH], [
  205. AC_CACHE_CHECK([the length of a typical hash bang line],
  206. [ac_cv_guix_hash_bang_length],
  207. [ac_cv_guix_hash_bang_length=`echo -n "$storedir/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bootstrap-binaries-0/bin/bash" | wc -c`])
  208. ])
  209. dnl GUIX_TEST_HASH_BANG_LENGTH
  210. AC_DEFUN([GUIX_TEST_HASH_BANG_LENGTH], [
  211. AC_REQUIRE([GUIX_TEST_ROOT_DIRECTORY])
  212. AC_CACHE_CHECK([the length of a hash bang line used in tests],
  213. [ac_cv_guix_test_hash_bang_length],
  214. [ac_cv_guix_test_hash_bang_length=`echo -n "$ac_cv_guix_test_root/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bootstrap-binaries-0/bin/bash" | wc -c`])
  215. ])
  216. dnl GUIX_CHECK_FILE_NAME_LIMITS
  217. dnl
  218. dnl GNU/Linux has a couple of silly limits that we can easily run into.
  219. dnl Make sure everything is fine with the current settings. Set $1 to
  220. dnl 'yes' if tests can run, 'no' otherwise.
  221. AC_DEFUN([GUIX_CHECK_FILE_NAME_LIMITS], [
  222. AC_REQUIRE([GUIX_SOCKET_FILE_NAME_LENGTH])
  223. AC_REQUIRE([GUIX_TEST_SOCKET_FILE_NAME_LENGTH])
  224. AC_REQUIRE([GUIX_HASH_BANG_LENGTH])
  225. AC_REQUIRE([GUIX_TEST_HASH_BANG_LENGTH])
  226. if test "$ac_cv_guix_socket_file_name_length" -ge ]SOCKET_FILE_NAME_LIMIT[; then
  227. AC_MSG_ERROR([socket file name would exceed the maxium allowed length])
  228. fi
  229. if test "$ac_cv_guix_test_socket_file_name_length" -ge ]SOCKET_FILE_NAME_LIMIT[; then
  230. AC_MSG_WARN([socket file name limit may be exceeded when running tests])
  231. fi
  232. $1=yes
  233. if test "$ac_cv_guix_hash_bang_length" -ge ]LINUX_HASH_BANG_LIMIT[; then
  234. $1=no
  235. AC_MSG_ERROR([store directory '$storedir' would lead to overly long hash-bang lines])
  236. fi
  237. if test "$ac_cv_guix_test_hash_bang_length" -ge ]LINUX_HASH_BANG_LIMIT[; then
  238. $1=no
  239. AC_MSG_WARN([test directory '$ac_cv_guix_test_root' may lead to overly long hash-bang lines])
  240. fi
  241. ])
  242. dnl GUIX_CHECK_CXX11
  243. dnl
  244. dnl Check whether the C++ compiler can compile a typical C++11 program.
  245. AC_DEFUN([GUIX_CHECK_CXX11], [
  246. AC_REQUIRE([AC_PROG_CXX])
  247. AC_CACHE_CHECK([whether $CXX supports C++11],
  248. [ac_cv_guix_cxx11_support],
  249. [save_CXXFLAGS="$CXXFLAGS"
  250. CXXFLAGS="-std=c++11 $CXXFLAGS"
  251. AC_COMPILE_IFELSE([
  252. AC_LANG_SOURCE([
  253. #include <functional>
  254. std::function<int(int)>
  255. return_plus_lambda (int x)
  256. {
  257. auto result = [[&]](int y) {
  258. return x + y;
  259. };
  260. return result;
  261. }
  262. ])],
  263. [ac_cv_guix_cxx11_support=yes],
  264. [ac_cv_guix_cxx11_support=no])
  265. CXXFLAGS="$save_CXXFLAGS"
  266. ])
  267. ])
  268. dnl GUIX_ASSERT_CXX11
  269. dnl
  270. dnl Error out if the C++ compiler cannot compile C++11 code.
  271. AC_DEFUN([GUIX_ASSERT_CXX11], [
  272. GUIX_CHECK_CXX11
  273. if test "x$ac_cv_guix_cxx11_support" != "xyes"; then
  274. AC_MSG_ERROR([C++ compiler '$CXX' does not support the C++11 standard])
  275. fi
  276. ])
  277. dnl GUIX_LIBGCRYPT_LIBDIR VAR
  278. dnl
  279. dnl Attempt to determine libgcrypt's LIBDIR; store the result in VAR.
  280. AC_DEFUN([GUIX_LIBGCRYPT_LIBDIR], [
  281. AC_PATH_PROG([LIBGCRYPT_CONFIG], [libgcrypt-config])
  282. AC_CACHE_CHECK([libgcrypt's library directory],
  283. [guix_cv_libgcrypt_libdir],
  284. [if test "x$LIBGCRYPT_CONFIG" != "x"; then
  285. guix_cv_libgcrypt_libdir=`$LIBGCRYPT_CONFIG --libs | grep -e -L | sed -e "s/.*-L\([[^ ]]\+\)[[[:blank:]]]\+-lgcrypt.*/\1/g"`
  286. else
  287. guix_cv_libgcrypt_libdir=""
  288. fi])
  289. $1="$guix_cv_libgcrypt_libdir"
  290. ])
  291. dnl GUIX_LIBZ_LIBDIR VAR
  292. dnl
  293. dnl Attempt to determine libz's LIBDIR; store the result in VAR.
  294. AC_DEFUN([GUIX_LIBZ_LIBDIR], [
  295. AC_REQUIRE([PKG_PROG_PKG_CONFIG])
  296. AC_CACHE_CHECK([zlib's library directory],
  297. [guix_cv_libz_libdir],
  298. [guix_cv_libz_libdir="`$PKG_CONFIG zlib --variable=libdir 2> /dev/null`"])
  299. $1="$guix_cv_libz_libdir"
  300. ])
  301. dnl GUIX_CURRENT_LOCALSTATEDIR
  302. dnl
  303. dnl Determine the localstatedir of an existing Guix installation and set
  304. dnl 'guix_cv_current_localstatedir' accordingly. Set it to "none" if no
  305. dnl existing installation was found.
  306. AC_DEFUN([GUIX_CURRENT_LOCALSTATEDIR], [
  307. AC_PATH_PROG([GUILE], [guile])
  308. AC_CACHE_CHECK([the current installation's localstatedir],
  309. [guix_cv_current_localstatedir],
  310. [dnl Call 'dirname' because (guix config) appends "/guix" to LOCALSTATEDIR.
  311. guix_cv_current_localstatedir="`"$GUILE" \
  312. -c '(use-modules (guix config))
  313. (when (string=? %store-directory "'$storedir'")
  314. (display (dirname %state-directory)))' \
  315. 2>/dev/null`"
  316. if test "x$guix_cv_current_localstatedir" = "x"; then
  317. guix_cv_current_localstatedir=none
  318. fi])])
  319. dnl GUIX_CHECK_LOCALSTATEDIR
  320. dnl
  321. dnl Check that the LOCALSTATEDIR value is consistent with that of the existing
  322. dnl Guix installation, if any. Error out or warn if they do not match.
  323. AC_DEFUN([GUIX_CHECK_LOCALSTATEDIR], [
  324. AC_REQUIRE([GUIX_CURRENT_LOCALSTATEDIR])
  325. if test "x$guix_cv_current_localstatedir" != "xnone"; then
  326. if test "$guix_cv_current_localstatedir" != "$guix_localstatedir"; then
  327. case "$localstatedir" in
  328. NONE|\${prefix}*)
  329. # User kept the default value---i.e., did not pass '--localstatedir'.
  330. AC_MSG_ERROR([chosen localstatedir '$guix_localstatedir' does not match \
  331. that of the existing installation '$guix_cv_current_localstatedir'
  332. Installing may corrupt $storedir!
  333. Use './configure --localstatedir=$guix_cv_current_localstatedir'.])
  334. ;;
  335. *)
  336. # User passed an explicit '--localstatedir'. Assume they know what
  337. # they're doing.
  338. AC_MSG_WARN([chosen localstatedir '$guix_localstatedir' does not match \
  339. that of the existing installation '$guix_cv_current_localstatedir'])
  340. AC_MSG_WARN([installing may corrupt $storedir!])
  341. ;;
  342. esac
  343. fi
  344. fi])