gnu: curl: Enable more verbose test output.
[jackhill/guix/guix.git] / m4 / guix.m4
CommitLineData
2357f850 1dnl GNU Guix --- Functional package management for GNU
49e6291a 2dnl Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
d388c2c4 3dnl
2357f850 4dnl This file is part of GNU Guix.
d388c2c4 5dnl
2357f850 6dnl GNU Guix is free software; you can redistribute it and/or modify it
d388c2c4
LC
7dnl under the terms of the GNU General Public License as published by
8dnl the Free Software Foundation; either version 3 of the License, or (at
9dnl your option) any later version.
10dnl
2357f850 11dnl GNU Guix is distributed in the hope that it will be useful, but
d388c2c4
LC
12dnl WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14dnl GNU General Public License for more details.
15dnl
16dnl You should have received a copy of the GNU General Public License
2357f850 17dnl along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
d388c2c4
LC
18
19dnl GUIX_ASSERT_LIBGCRYPT_USABLE
20dnl
21dnl Assert that GNU libgcrypt is usable from Guile.
22AC_DEFUN([GUIX_ASSERT_LIBGCRYPT_USABLE],
23 [AC_CACHE_CHECK([whether $LIBGCRYPT can be dynamically loaded],
24 [guix_cv_libgcrypt_usable_p],
25 [GUILE_CHECK([retval],
26 [(dynamic-func \"gcry_md_hash_buffer\" (dynamic-link \"$LIBGCRYPT\"))])
27 if test "$retval" = 0; then
28 guix_cv_libgcrypt_usable_p="yes"
29 else
30 guix_cv_libgcrypt_usable_p="no"
31 fi])
32
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])
c2033df4
LC
36
37dnl GUIX_SYSTEM_TYPE
38dnl
39dnl Determine the Guix host system type, and store it in the
40dnl `guix_system' variable.
41AC_DEFUN([GUIX_SYSTEM_TYPE], [
42 AC_REQUIRE([AC_CANONICAL_HOST])
eb25a30a
LC
43 AC_PATH_PROG([SED], [sed])
44
c2033df4
LC
45 AC_ARG_WITH(system, AC_HELP_STRING([--with-system=SYSTEM],
46 [Platform identifier (e.g., `i686-linux').]),
47 [guix_system="$withval"],
48 [case "$host_cpu" in
49 i*86)
50 machine_name="i686";;
51 amd64)
52 machine_name="x86_64";;
53 *)
54 machine_name="$host_cpu";;
55 esac
56
57 case "$host_os" in
58 linux-gnu*)
59 # For backward compatibility, strip the `-gnu' part.
60 guix_system="$machine_name-linux";;
61 *)
62 # Strip the version number from names such as `gnu0.3',
63 # `darwin10.2.0', etc.
eb25a30a 64 guix_system="$machine_name-`echo $host_os | "$SED" -e's/[0-9.]*$//g'`";;
c2033df4 65 esac])
5fedc65b
LC
66
67 AC_MSG_CHECKING([for the Guix system type])
68 AC_MSG_RESULT([$guix_system])
69
d8eea3d2 70 AC_SUBST([guix_system])
c2033df4 71])
9c7dd33a 72
b97556d7
LC
73dnl GUIX_ASSERT_SUPPORTED_SYSTEM
74dnl
75dnl Assert that this is a system to which the distro is ported.
76AC_DEFUN([GUIX_ASSERT_SUPPORTED_SYSTEM], [
77 AC_REQUIRE([GUIX_SYSTEM_TYPE])
78
79 AC_ARG_WITH([courage], [AC_HELP_STRING([--with-courage],
80 [Assert that even if this platform is unsupported, you will be
81courageous and port the GNU System distribution to it (see
82"GNU Distribution" in the manual.)])],
83 [guix_courageous="$withval"],
84 [guix_courageous="no"])
85
86 # Currently only Linux-based systems are supported, and only on some
87 # platforms.
88 case "$guix_system" in
2ebab8e9 89 x86_64-linux|i686-linux|mips64el-linux)
b97556d7
LC
90 ;;
91 *)
92 if test "x$guix_courageous" = "xyes"; then
93 AC_MSG_WARN([building Guix on `$guix_system', which is not supported])
94 else
95 AC_MSG_ERROR([`$guix_system' is not a supported platform.
96See "GNU Distribution" in the manual, or try `--with-courage'.])
97 fi
98 ;;
99 esac
100])
101
9c7dd33a
LC
102dnl GUIX_ASSERT_GUILE_FEATURES FEATURES
103dnl
104dnl Assert that FEATURES are provided by $GUILE.
105AC_DEFUN([GUIX_ASSERT_GUILE_FEATURES], [
106 for guix_guile_feature in $1
107 do
108 AC_MSG_CHECKING([whether $GUILE provides feature '$guix_guile_feature'])
109 if "$GUILE" -c "(exit (provided? '$guix_guile_feature))"
110 then
111 AC_MSG_RESULT([yes])
112 else
113 AC_MSG_RESULT([no])
114 AC_MSG_ERROR([$GUILE does not support feature '$guix_guile_feature', which is required.])
115 fi
116 done
117])
1959fb04
LC
118
119dnl GUIX_CHECK_SRFI_37
120dnl
121dnl Check whether SRFI-37 suffers from <http://bugs.gnu.org/13176>.
122dnl This bug was fixed in Guile 2.0.9.
123AC_DEFUN([GUIX_CHECK_SRFI_37], [
124 AC_CACHE_CHECK([whether (srfi srfi-37) is affected by http://bugs.gnu.org/13176],
125 [ac_cv_guix_srfi_37_broken],
126 [if "$GUILE" -c "(use-modules (srfi srfi-37)) \
127 (sigaction SIGALRM (lambda _ (primitive-exit 1))) \
128 (alarm 1) \
129 (define opts (list (option '(#\I) #f #t (lambda _ #t)))) \
130 (args-fold '(\"-I\") opts (lambda _ (error)) (lambda _ #f) '())"
131 then
132 ac_cv_guix_srfi_37_broken=no
133 else
134 ac_cv_guix_srfi_37_broken=yes
135 fi])
136])
49e6291a
LC
137
138dnl GUIX_CHECK_UNBUFFERED_CBIP
139dnl
140dnl Check whether 'setbvuf' works on custom binary input ports (CBIPs), as is
141dnl the case starting with Guile 2.0.10.
142AC_DEFUN([GUIX_CHECK_UNBUFFERED_CBIP], [
143 AC_CACHE_CHECK([whether Guile's custom binary input ports support 'setvbuf'],
144 [ac_cv_guix_cbips_support_setvbuf],
145 [if "$GUILE" -c "(use-modules (rnrs io ports)) \
146 (let ((p (make-custom-binary-input-port \"cbip\" pk #f #f #f))) \
147 (setvbuf p _IONBF))" >&5 2>&1
148 then
149 ac_cv_guix_cbips_support_setvbuf=yes
150 else
151 ac_cv_guix_cbips_support_setvbuf=no
152 fi])
153])