Mirror of GNU Guix
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.

415 lines
15 KiB

maint: Switch to Guile-JSON 3.x. Guile-JSON 3.x is incompatible with Guile-JSON 1.x, which we relied on until now: it maps JSON dictionaries to alists (instead of hash tables), and JSON arrays to vectors (instead of lists). This commit is about adjusting all the existing code to this new mapping. * m4/guix.m4 (GUIX_CHECK_GUILE_JSON): New macro. * configure.ac: Use it. * doc/guix.texi (Requirements): Mention the Guile-JSON version. * guix/git-download.scm (git-fetch)[guile-json]: Use GUILE-JSON-3. * guix/import/cpan.scm (string->license): Expect vectors instead of lists. (module->dist-name): Use 'json-fetch' instead of 'json-fetch-alist'. (cpan-fetch): Likewise. * guix/import/crate.scm (crate-fetch): Likewise, and call 'vector->list' for DEPS. * guix/import/gem.scm (rubygems-fetch): Likewise. * guix/import/json.scm (json-fetch-alist): Remove. * guix/import/pypi.scm (pypi-fetch): Use 'json-fetch' instead of 'json-fetch-alist'. (latest-source-release, latest-wheel-release): Call 'vector->list' on RELEASES. * guix/import/stackage.scm (stackage-lts-info-fetch): Use 'json-fetch' instead of 'json-fetch-alist'. (lts-package-version): Use 'vector->list'. * guix/import/utils.scm (hash-table->alist): Remove. (alist->package): Pass 'vector->list' on the inputs fields, and default to the empty vector. * guix/scripts/import/json.scm (guix-import-json): Remove call to 'hash-table->alist'. * guix/swh.scm (define-json-reader): Expect pair? or null? instead of hash-table?. [extract-field]: Use 'assoc-ref' instead of 'hash-ref'. (json->branches): Use 'map' instead of 'hash-map->list'. (json->checksums): Likewise. (json->directory-entries, origin-visits): Call 'vector->list' on the result of 'json->scm'. * tests/import-utils.scm ("alist->package with dependencies"): New test. * gnu/installer.scm (build-compiled-file)[builder]: Use GUILE-JSON-3. * gnu/installer.scm (installer-program)[installer-builder]: Likewise. * gnu/installer/locale.scm (iso639->iso639-languages): Use 'assoc-ref' instead of 'hash-ref', and pass vectors through 'vector->list'. (iso3166->iso3166-territories): Likewise. * gnu/system/vm.scm (system-docker-image)[build]: Use GUILE-JSON-3. * guix/docker.scm (manifest, config): Adjust for Guile-JSON 3. * guix/scripts/pack.scm (docker-image)[build]: Use GUILE-JSON-3. * guix/import/github.scm (fetch-releases-or-tags): Update docstring. (latest-released-version): Use 'assoc-ref' instead of 'hash-ref'. Pass the result of 'fetch-releases-or-tags' to 'vector->list'. * guix/import/launchpad.scm (latest-released-version): Likewise.
2 years ago
maint: Switch to Guile-JSON 3.x. Guile-JSON 3.x is incompatible with Guile-JSON 1.x, which we relied on until now: it maps JSON dictionaries to alists (instead of hash tables), and JSON arrays to vectors (instead of lists). This commit is about adjusting all the existing code to this new mapping. * m4/guix.m4 (GUIX_CHECK_GUILE_JSON): New macro. * configure.ac: Use it. * doc/guix.texi (Requirements): Mention the Guile-JSON version. * guix/git-download.scm (git-fetch)[guile-json]: Use GUILE-JSON-3. * guix/import/cpan.scm (string->license): Expect vectors instead of lists. (module->dist-name): Use 'json-fetch' instead of 'json-fetch-alist'. (cpan-fetch): Likewise. * guix/import/crate.scm (crate-fetch): Likewise, and call 'vector->list' for DEPS. * guix/import/gem.scm (rubygems-fetch): Likewise. * guix/import/json.scm (json-fetch-alist): Remove. * guix/import/pypi.scm (pypi-fetch): Use 'json-fetch' instead of 'json-fetch-alist'. (latest-source-release, latest-wheel-release): Call 'vector->list' on RELEASES. * guix/import/stackage.scm (stackage-lts-info-fetch): Use 'json-fetch' instead of 'json-fetch-alist'. (lts-package-version): Use 'vector->list'. * guix/import/utils.scm (hash-table->alist): Remove. (alist->package): Pass 'vector->list' on the inputs fields, and default to the empty vector. * guix/scripts/import/json.scm (guix-import-json): Remove call to 'hash-table->alist'. * guix/swh.scm (define-json-reader): Expect pair? or null? instead of hash-table?. [extract-field]: Use 'assoc-ref' instead of 'hash-ref'. (json->branches): Use 'map' instead of 'hash-map->list'. (json->checksums): Likewise. (json->directory-entries, origin-visits): Call 'vector->list' on the result of 'json->scm'. * tests/import-utils.scm ("alist->package with dependencies"): New test. * gnu/installer.scm (build-compiled-file)[builder]: Use GUILE-JSON-3. * gnu/installer.scm (installer-program)[installer-builder]: Likewise. * gnu/installer/locale.scm (iso639->iso639-languages): Use 'assoc-ref' instead of 'hash-ref', and pass vectors through 'vector->list'. (iso3166->iso3166-territories): Likewise. * gnu/system/vm.scm (system-docker-image)[build]: Use GUILE-JSON-3. * guix/docker.scm (manifest, config): Adjust for Guile-JSON 3. * guix/scripts/pack.scm (docker-image)[build]: Use GUILE-JSON-3. * guix/import/github.scm (fetch-releases-or-tags): Update docstring. (latest-released-version): Use 'assoc-ref' instead of 'hash-ref'. Pass the result of 'fetch-releases-or-tags' to 'vector->list'. * guix/import/launchpad.scm (latest-released-version): Likewise.
2 years ago
maint: Switch to Guile-JSON 3.x. Guile-JSON 3.x is incompatible with Guile-JSON 1.x, which we relied on until now: it maps JSON dictionaries to alists (instead of hash tables), and JSON arrays to vectors (instead of lists). This commit is about adjusting all the existing code to this new mapping. * m4/guix.m4 (GUIX_CHECK_GUILE_JSON): New macro. * configure.ac: Use it. * doc/guix.texi (Requirements): Mention the Guile-JSON version. * guix/git-download.scm (git-fetch)[guile-json]: Use GUILE-JSON-3. * guix/import/cpan.scm (string->license): Expect vectors instead of lists. (module->dist-name): Use 'json-fetch' instead of 'json-fetch-alist'. (cpan-fetch): Likewise. * guix/import/crate.scm (crate-fetch): Likewise, and call 'vector->list' for DEPS. * guix/import/gem.scm (rubygems-fetch): Likewise. * guix/import/json.scm (json-fetch-alist): Remove. * guix/import/pypi.scm (pypi-fetch): Use 'json-fetch' instead of 'json-fetch-alist'. (latest-source-release, latest-wheel-release): Call 'vector->list' on RELEASES. * guix/import/stackage.scm (stackage-lts-info-fetch): Use 'json-fetch' instead of 'json-fetch-alist'. (lts-package-version): Use 'vector->list'. * guix/import/utils.scm (hash-table->alist): Remove. (alist->package): Pass 'vector->list' on the inputs fields, and default to the empty vector. * guix/scripts/import/json.scm (guix-import-json): Remove call to 'hash-table->alist'. * guix/swh.scm (define-json-reader): Expect pair? or null? instead of hash-table?. [extract-field]: Use 'assoc-ref' instead of 'hash-ref'. (json->branches): Use 'map' instead of 'hash-map->list'. (json->checksums): Likewise. (json->directory-entries, origin-visits): Call 'vector->list' on the result of 'json->scm'. * tests/import-utils.scm ("alist->package with dependencies"): New test. * gnu/installer.scm (build-compiled-file)[builder]: Use GUILE-JSON-3. * gnu/installer.scm (installer-program)[installer-builder]: Likewise. * gnu/installer/locale.scm (iso639->iso639-languages): Use 'assoc-ref' instead of 'hash-ref', and pass vectors through 'vector->list'. (iso3166->iso3166-territories): Likewise. * gnu/system/vm.scm (system-docker-image)[build]: Use GUILE-JSON-3. * guix/docker.scm (manifest, config): Adjust for Guile-JSON 3. * guix/scripts/pack.scm (docker-image)[build]: Use GUILE-JSON-3. * guix/import/github.scm (fetch-releases-or-tags): Update docstring. (latest-released-version): Use 'assoc-ref' instead of 'hash-ref'. Pass the result of 'fetch-releases-or-tags' to 'vector->list'. * guix/import/launchpad.scm (latest-released-version): Likewise.
2 years ago
  1. dnl GNU Guix --- Functional package management for GNU
  2. dnl Copyright © 2012, 2013, 2014, 2015, 2016, 2018, 2019, 2020 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_SYSTEM_TYPE
  21. dnl
  22. dnl Determine the Guix host system type, and store it in the
  23. dnl `guix_system' variable.
  24. AC_DEFUN([GUIX_SYSTEM_TYPE], [
  25. AC_REQUIRE([AC_CANONICAL_HOST])
  26. AC_PATH_PROG([SED], [sed])
  27. AC_ARG_WITH(system, AC_HELP_STRING([--with-system=SYSTEM],
  28. [Platform identifier (e.g., `i686-linux').]),
  29. [guix_system="$withval"],
  30. [case "$host_cpu" in
  31. i*86)
  32. machine_name="i686";;
  33. amd64)
  34. machine_name="x86_64";;
  35. arm|armv[[7-9]]*)
  36. # Here we want to exclude CPUs such as "armv6l". On ARMv7
  37. # machines, we normally get "armv7l". However, in Guix, we
  38. # configure with --build=arm-unknown-linux-gnueabihf, leading
  39. # to just "arm", so we also have to allow it.
  40. #
  41. # TODO: If not cross-compiling, add a sanity check to make
  42. # sure this build machine has the needed features to
  43. # support executables compiled using our armhf gcc,
  44. # configured with:
  45. # --with-arch=armv7-a
  46. # --with-float=hard
  47. # --with-mode=thumb
  48. # --with-fpu=vfpv3-d16
  49. machine_name="armhf";;
  50. *)
  51. machine_name="$host_cpu";;
  52. esac
  53. case "$host_os" in
  54. linux-gnu*)
  55. # For backward compatibility, strip the `-gnu' part.
  56. guix_system="$machine_name-linux";;
  57. gnu*)
  58. # Always use i586 for GNU/Hurd.
  59. guix_system="i586-gnu";;
  60. *)
  61. # Strip the version number from names such as `gnu0.3',
  62. # `darwin10.2.0', etc.
  63. guix_system="$machine_name-`echo $host_os | "$SED" -e's/[0-9.]*$//g'`";;
  64. esac])
  65. AC_MSG_CHECKING([for the Guix system type])
  66. AC_MSG_RESULT([$guix_system])
  67. AC_SUBST([guix_system])
  68. ])
  69. dnl GUIX_ASSERT_SUPPORTED_SYSTEM
  70. dnl
  71. dnl Assert that this is a system to which the distro is ported.
  72. AC_DEFUN([GUIX_ASSERT_SUPPORTED_SYSTEM], [
  73. AC_REQUIRE([GUIX_SYSTEM_TYPE])
  74. AC_ARG_WITH([courage], [AC_HELP_STRING([--with-courage],
  75. [Assert that even if this platform is unsupported, you will be
  76. courageous and port the GNU System distribution to it (see
  77. "GNU Distribution" in the manual.)])],
  78. [guix_courageous="$withval"],
  79. [guix_courageous="no"])
  80. # Currently only Linux-based systems are supported, and only on some
  81. # platforms.
  82. case "$guix_system" in
  83. x86_64-linux|i686-linux|armhf-linux|aarch64-linux)
  84. ;;
  85. *)
  86. if test "x$guix_courageous" = "xyes"; then
  87. AC_MSG_WARN([building Guix on `$guix_system', which is not supported])
  88. else
  89. AC_MSG_ERROR([`$guix_system' is not a supported platform.
  90. See "GNU Distribution" in the manual, or try `--with-courage'.])
  91. fi
  92. ;;
  93. esac
  94. ])
  95. dnl GUIX_ASSERT_GUILE_FEATURES FEATURES
  96. dnl
  97. dnl Assert that FEATURES are provided by $GUILE.
  98. AC_DEFUN([GUIX_ASSERT_GUILE_FEATURES], [
  99. for guix_guile_feature in $1
  100. do
  101. AC_MSG_CHECKING([whether $GUILE provides feature '$guix_guile_feature'])
  102. if "$GUILE" -c "(exit (provided? '$guix_guile_feature))"
  103. then
  104. AC_MSG_RESULT([yes])
  105. else
  106. AC_MSG_RESULT([no])
  107. AC_MSG_ERROR([$GUILE does not support feature '$guix_guile_feature', which is required.])
  108. fi
  109. done
  110. ])
  111. dnl GUIX_ASSERT_SYNTAX_OBJECT_EQUAL
  112. dnl
  113. dnl Guile 2.2.1 was a brown-paper-bag release where 'equal?' wouldn't work
  114. dnl for syntax objects, which broke gexps. Unfortunately Fedora 25 provides it.
  115. dnl Reject it.
  116. AC_DEFUN([GUIX_ASSERT_SYNTAX_OBJECT_EQUAL], [
  117. AC_CACHE_CHECK([whether 'equal?' works for syntax objects],
  118. [ac_cv_guix_syntax_object_equal],
  119. [if "$GUILE" -c '(exit (equal? (syntax x) (syntax x)))'
  120. then
  121. ac_cv_guix_syntax_object_equal=yes
  122. else
  123. ac_cv_guix_syntax_object_equal=no
  124. fi])
  125. if test "x$ac_cv_guix_syntax_object_equal" != xyes; then
  126. # This bug was present in Guile 2.2.1 only.
  127. AC_MSG_ERROR(['equal?' does not work for syntax object; upgrade to Guile 2.2.2 or later.])
  128. fi
  129. ])
  130. dnl GUIX_CHECK_GUILE_SSH
  131. dnl
  132. dnl Check whether a recent-enough Guile-SSH is available.
  133. AC_DEFUN([GUIX_CHECK_GUILE_SSH], [
  134. dnl Check whether '#:nodelay' paramater to 'make-session' (introduced in
  135. dnl 0.13.0) is present.
  136. AC_CACHE_CHECK([whether Guile-SSH is available and recent enough],
  137. [guix_cv_have_recent_guile_ssh],
  138. [GUILE_CHECK([retval],
  139. [(and (@ (ssh channel) channel-send-eof)
  140. (@ (ssh popen) open-remote-pipe)
  141. (@ (ssh dist node) node-eval)
  142. (@ (ssh auth) userauth-gssapi!)
  143. ((@ (ssh session) make-session) #:nodelay #t))])
  144. if test "$retval" = 0; then
  145. guix_cv_have_recent_guile_ssh="yes"
  146. else
  147. guix_cv_have_recent_guile_ssh="no"
  148. fi])
  149. ])
  150. dnl GUIX_CHECK_GUILE_SQLITE3
  151. dnl
  152. dnl Check whether a recent-enough Guile-Sqlite3 is available.
  153. AC_DEFUN([GUIX_CHECK_GUILE_SQLITE3], [
  154. dnl Check whether 'sqlite-bind-arguments' is available. It was introduced
  155. dnl in February 2018:
  156. dnl <https://notabug.org/guile-sqlite3/guile-sqlite3/commit/1cd1dec96a9999db48c0ff45bab907efc637247f>.
  157. AC_CACHE_CHECK([whether Guile-Sqlite3 is available and recent enough],
  158. [guix_cv_have_recent_guile_sqlite3],
  159. [GUILE_CHECK([retval],
  160. [(@ (sqlite3) sqlite-bind-arguments)])
  161. if test "$retval" = 0; then
  162. guix_cv_have_recent_guile_sqlite3="yes"
  163. else
  164. guix_cv_have_recent_guile_sqlite3="no"
  165. fi])
  166. ])
  167. dnl GUIX_CHECK_GUILE_JSON
  168. dnl
  169. dnl Check whether a recent-enough Guile-JSON is available.
  170. AC_DEFUN([GUIX_CHECK_GUILE_JSON], [
  171. dnl Check whether we're using Guile-JSON 3.x, which uses a JSON-to-Scheme
  172. dnl mapping different from that of earlier versions.
  173. AC_CACHE_CHECK([whether Guile-JSON is available and recent enough],
  174. [guix_cv_have_recent_guile_json],
  175. [GUILE_CHECK([retval],
  176. [(use-modules (json) (ice-9 match))
  177. (match (json-string->scm \"[[ { \\\"a\\\": 42 } ]]\")
  178. (#((("a" . 42))) #t))])
  179. if test "$retval" = 0; then
  180. guix_cv_have_recent_guile_json="yes"
  181. else
  182. guix_cv_have_recent_guile_json="no"
  183. fi])
  184. ])
  185. dnl GUIX_CHECK_GUILE_GCRYPT
  186. dnl
  187. dnl Check whether a recent-enough Guile-Gcrypt is available.
  188. AC_DEFUN([GUIX_CHECK_GUILE_GCRYPT], [
  189. dnl Check whether we're using Guile-Gcrypt 0.2.x or later. 0.2.0
  190. dnl introduced the 'hash-algorithm' macro and related code.
  191. AC_CACHE_CHECK([whether Guile-Gcrypt is available and recent enough],
  192. [guix_cv_have_recent_guile_gcrypt],
  193. [GUILE_CHECK([retval],
  194. [(use-modules (gcrypt hash))
  195. (equal? (hash-algorithm sha256)
  196. (lookup-hash-algorithm 'sha256))])
  197. if test "$retval" = 0; then
  198. guix_cv_have_recent_guile_gcrypt="yes"
  199. else
  200. guix_cv_have_recent_guile_gcrypt="no"
  201. fi])
  202. ])
  203. dnl GUIX_TEST_ROOT_DIRECTORY
  204. AC_DEFUN([GUIX_TEST_ROOT_DIRECTORY], [
  205. AC_CACHE_CHECK([for unit test root directory],
  206. [ac_cv_guix_test_root],
  207. [ac_cv_guix_test_root="`pwd`/test-tmp"])
  208. ])
  209. dnl 'BINPRM_BUF_SIZE' constant in Linux (we leave room for the trailing zero.)
  210. dnl The Hurd has a limit of about a page (see exec/hashexec.c.)
  211. m4_define([LINUX_HASH_BANG_LIMIT], 127)
  212. dnl Hardcoded 'sun_path' length in <sys/un.h>.
  213. m4_define([SOCKET_FILE_NAME_LIMIT], 108)
  214. dnl GUIX_SOCKET_FILE_NAME_LENGTH
  215. AC_DEFUN([GUIX_SOCKET_FILE_NAME_LENGTH], [
  216. AC_CACHE_CHECK([the length of the installed socket file name],
  217. [ac_cv_guix_socket_file_name_length],
  218. [ac_cv_guix_socket_file_name_length="`echo -n "$guix_localstatedir/guix/daemon-socket/socket" | wc -c`"])
  219. ])
  220. dnl GUIX_TEST_SOCKET_FILE_NAME_LENGTH
  221. AC_DEFUN([GUIX_TEST_SOCKET_FILE_NAME_LENGTH], [
  222. AC_REQUIRE([GUIX_TEST_ROOT_DIRECTORY])
  223. AC_CACHE_CHECK([the length of the socket file name used in tests],
  224. [ac_cv_guix_test_socket_file_name_length],
  225. [ac_cv_guix_test_socket_file_name_length="`echo -n "$ac_cv_guix_test_root/var/123456/daemon-socket/socket" | wc -c`"])
  226. ])
  227. dnl GUIX_HASH_BANG_LENGTH
  228. AC_DEFUN([GUIX_HASH_BANG_LENGTH], [
  229. AC_CACHE_CHECK([the length of a typical hash bang line],
  230. [ac_cv_guix_hash_bang_length],
  231. [ac_cv_guix_hash_bang_length=`echo -n "$storedir/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bootstrap-binaries-0/bin/bash" | wc -c`])
  232. ])
  233. dnl GUIX_TEST_HASH_BANG_LENGTH
  234. AC_DEFUN([GUIX_TEST_HASH_BANG_LENGTH], [
  235. AC_REQUIRE([GUIX_TEST_ROOT_DIRECTORY])
  236. AC_CACHE_CHECK([the length of a hash bang line used in tests],
  237. [ac_cv_guix_test_hash_bang_length],
  238. [ac_cv_guix_test_hash_bang_length=`echo -n "$ac_cv_guix_test_root/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bootstrap-binaries-0/bin/bash" | wc -c`])
  239. ])
  240. dnl GUIX_CHECK_FILE_NAME_LIMITS
  241. dnl
  242. dnl GNU/Linux has a couple of silly limits that we can easily run into.
  243. dnl Make sure everything is fine with the current settings. Set $1 to
  244. dnl 'yes' if tests can run, 'no' otherwise.
  245. AC_DEFUN([GUIX_CHECK_FILE_NAME_LIMITS], [
  246. AC_REQUIRE([GUIX_SOCKET_FILE_NAME_LENGTH])
  247. AC_REQUIRE([GUIX_TEST_SOCKET_FILE_NAME_LENGTH])
  248. AC_REQUIRE([GUIX_HASH_BANG_LENGTH])
  249. AC_REQUIRE([GUIX_TEST_HASH_BANG_LENGTH])
  250. if test "$ac_cv_guix_socket_file_name_length" -ge ]SOCKET_FILE_NAME_LIMIT[; then
  251. AC_MSG_ERROR([socket file name would exceed the maxium allowed length])
  252. fi
  253. if test "$ac_cv_guix_test_socket_file_name_length" -ge ]SOCKET_FILE_NAME_LIMIT[; then
  254. AC_MSG_WARN([socket file name limit may be exceeded when running tests])
  255. fi
  256. $1=yes
  257. if test "$ac_cv_guix_hash_bang_length" -ge ]LINUX_HASH_BANG_LIMIT[; then
  258. $1=no
  259. AC_MSG_ERROR([store directory '$storedir' would lead to overly long hash-bang lines])
  260. fi
  261. if test "$ac_cv_guix_test_hash_bang_length" -ge ]LINUX_HASH_BANG_LIMIT[; then
  262. $1=no
  263. AC_MSG_WARN([test directory '$ac_cv_guix_test_root' may lead to overly long hash-bang lines])
  264. fi
  265. ])
  266. dnl GUIX_CHECK_CXX11
  267. dnl
  268. dnl Check whether the C++ compiler can compile a typical C++11 program.
  269. AC_DEFUN([GUIX_CHECK_CXX11], [
  270. AC_REQUIRE([AC_PROG_CXX])
  271. AC_CACHE_CHECK([whether $CXX supports C++11],
  272. [ac_cv_guix_cxx11_support],
  273. [save_CXXFLAGS="$CXXFLAGS"
  274. CXXFLAGS="-std=c++11 $CXXFLAGS"
  275. AC_COMPILE_IFELSE([
  276. AC_LANG_SOURCE([
  277. #include <functional>
  278. std::function<int(int)>
  279. return_plus_lambda (int x)
  280. {
  281. auto result = [[&]](int y) {
  282. return x + y;
  283. };
  284. return result;
  285. }
  286. ])],
  287. [ac_cv_guix_cxx11_support=yes],
  288. [ac_cv_guix_cxx11_support=no])
  289. CXXFLAGS="$save_CXXFLAGS"
  290. ])
  291. ])
  292. dnl GUIX_ASSERT_CXX11
  293. dnl
  294. dnl Error out if the C++ compiler cannot compile C++11 code.
  295. AC_DEFUN([GUIX_ASSERT_CXX11], [
  296. GUIX_CHECK_CXX11
  297. if test "x$ac_cv_guix_cxx11_support" != "xyes"; then
  298. AC_MSG_ERROR([C++ compiler '$CXX' does not support the C++11 standard])
  299. fi
  300. ])
  301. dnl GUIX_LIBGCRYPT_LIBDIR VAR
  302. dnl
  303. dnl Attempt to determine libgcrypt's LIBDIR; store the result in VAR.
  304. AC_DEFUN([GUIX_LIBGCRYPT_LIBDIR], [
  305. AC_PATH_PROG([LIBGCRYPT_CONFIG], [libgcrypt-config])
  306. AC_CACHE_CHECK([libgcrypt's library directory],
  307. [guix_cv_libgcrypt_libdir],
  308. [if test "x$LIBGCRYPT_CONFIG" != "x"; then
  309. guix_cv_libgcrypt_libdir=`$LIBGCRYPT_CONFIG --libs | grep -e -L | sed -e "s/.*-L\([[^ ]]\+\)[[[:blank:]]]\+-lgcrypt.*/\1/g"`
  310. else
  311. guix_cv_libgcrypt_libdir=""
  312. fi])
  313. $1="$guix_cv_libgcrypt_libdir"
  314. ])
  315. dnl GUIX_LIBZ_LIBDIR VAR
  316. dnl
  317. dnl Attempt to determine libz's LIBDIR; store the result in VAR.
  318. AC_DEFUN([GUIX_LIBZ_LIBDIR], [
  319. AC_REQUIRE([PKG_PROG_PKG_CONFIG])
  320. AC_CACHE_CHECK([zlib's library directory],
  321. [guix_cv_libz_libdir],
  322. [guix_cv_libz_libdir="`$PKG_CONFIG zlib --variable=libdir 2> /dev/null`"])
  323. $1="$guix_cv_libz_libdir"
  324. ])
  325. dnl GUIX_LIBLZ_FILE_NAME VAR
  326. dnl
  327. dnl Attempt to determine liblz's absolute file name; store the result in VAR.
  328. AC_DEFUN([GUIX_LIBLZ_FILE_NAME], [
  329. AC_REQUIRE([PKG_PROG_PKG_CONFIG])
  330. AC_CACHE_CHECK([lzlib's file name],
  331. [guix_cv_liblz_libdir],
  332. [old_LIBS="$LIBS"
  333. LIBS="-llz"
  334. AC_LINK_IFELSE([AC_LANG_SOURCE([int main () { return LZ_decompress_open(); }])],
  335. [guix_cv_liblz_libdir="`ldd conftest$EXEEXT | grep liblz | sed '-es/.*=> \(.*\) .*$/\1/g'`"])
  336. LIBS="$old_LIBS"])
  337. $1="$guix_cv_liblz_libdir"
  338. ])
  339. dnl GUIX_CURRENT_LOCALSTATEDIR
  340. dnl
  341. dnl Determine the localstatedir of an existing Guix installation and set
  342. dnl 'guix_cv_current_localstatedir' accordingly. Set it to "none" if no
  343. dnl existing installation was found.
  344. AC_DEFUN([GUIX_CURRENT_LOCALSTATEDIR], [
  345. AC_PATH_PROG([GUILE], [guile])
  346. AC_CACHE_CHECK([the current installation's localstatedir],
  347. [guix_cv_current_localstatedir],
  348. [dnl Call 'dirname' because (guix config) appends "/guix" to LOCALSTATEDIR.
  349. guix_cv_current_localstatedir="`"$GUILE" \
  350. -c '(use-modules (guix config))
  351. (when (string=? %store-directory "'$storedir'")
  352. (display (dirname %state-directory)))' \
  353. 2>/dev/null`"
  354. if test "x$guix_cv_current_localstatedir" = "x"; then
  355. guix_cv_current_localstatedir=none
  356. fi])])
  357. dnl GUIX_CHECK_LOCALSTATEDIR
  358. dnl
  359. dnl Check that the LOCALSTATEDIR value is consistent with that of the existing
  360. dnl Guix installation, if any. Error out or warn if they do not match.
  361. AC_DEFUN([GUIX_CHECK_LOCALSTATEDIR], [
  362. AC_REQUIRE([GUIX_CURRENT_LOCALSTATEDIR])
  363. if test "x$guix_cv_current_localstatedir" != "xnone"; then
  364. if test "$guix_cv_current_localstatedir" != "$guix_localstatedir"; then
  365. case "$localstatedir" in
  366. NONE|\${prefix}*)
  367. # User kept the default value---i.e., did not pass '--localstatedir'.
  368. AC_MSG_ERROR([chosen localstatedir '$guix_localstatedir' does not match \
  369. that of the existing installation '$guix_cv_current_localstatedir'
  370. Installing may corrupt $storedir!
  371. Use './configure --localstatedir=$guix_cv_current_localstatedir'.])
  372. ;;
  373. *)
  374. # User passed an explicit '--localstatedir'. Assume they know what
  375. # they're doing.
  376. AC_MSG_WARN([chosen localstatedir '$guix_localstatedir' does not match \
  377. that of the existing installation '$guix_cv_current_localstatedir'])
  378. AC_MSG_WARN([installing may corrupt $storedir!])
  379. ;;
  380. esac
  381. fi
  382. fi])