gnu: kodi: Remove @acronym from description.
[jackhill/guix/guix.git] / m4 / guix.m4
CommitLineData
2357f850 1dnl GNU Guix --- Functional package management for GNU
27ab3cee 2dnl Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
aa1e1947 3dnl Copyright © 2014 Mark H Weaver <mhw@netris.org>
d388c2c4 4dnl
2357f850 5dnl This file is part of GNU Guix.
d388c2c4 6dnl
2357f850 7dnl GNU Guix is free software; you can redistribute it and/or modify it
d388c2c4
LC
8dnl under the terms of the GNU General Public License as published by
9dnl the Free Software Foundation; either version 3 of the License, or (at
10dnl your option) any later version.
11dnl
2357f850 12dnl GNU Guix is distributed in the hope that it will be useful, but
d388c2c4
LC
13dnl WITHOUT ANY WARRANTY; without even the implied warranty of
14dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15dnl GNU General Public License for more details.
16dnl
17dnl You should have received a copy of the GNU General Public License
2357f850 18dnl along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
d388c2c4
LC
19
20dnl GUIX_ASSERT_LIBGCRYPT_USABLE
21dnl
22dnl Assert that GNU libgcrypt is usable from Guile.
23AC_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
34 if test "x$guix_cv_libgcrypt_usable_p" != "xyes"; then
35 AC_MSG_ERROR([GNU libgcrypt does not appear to be usable; see `--with-libgcrypt-prefix' and `README'.])
36 fi])
c2033df4
LC
37
38dnl GUIX_SYSTEM_TYPE
39dnl
40dnl Determine the Guix host system type, and store it in the
41dnl `guix_system' variable.
42AC_DEFUN([GUIX_SYSTEM_TYPE], [
43 AC_REQUIRE([AC_CANONICAL_HOST])
eb25a30a
LC
44 AC_PATH_PROG([SED], [sed])
45
c2033df4
LC
46 AC_ARG_WITH(system, AC_HELP_STRING([--with-system=SYSTEM],
47 [Platform identifier (e.g., `i686-linux').]),
48 [guix_system="$withval"],
49 [case "$host_cpu" in
50 i*86)
51 machine_name="i686";;
52 amd64)
968ae903 53 machine_name="x86_64";;
dfdb15d9 54 arm|armv[[7-9]]*)
968ae903
LC
55 # Here we want to exclude CPUs such as "armv6l". On ARMv7
56 # machines, we normally get "armv7l". However, in Guix, we
57 # configure with --build=arm-unknown-linux-gnueabihf, leading
58 # to just "arm", so we also have to allow it.
59 #
aa1e1947
MW
60 # TODO: If not cross-compiling, add a sanity check to make
61 # sure this build machine has the needed features to
62 # support executables compiled using our armhf gcc,
63 # configured with:
64 # --with-arch=armv7-a
65 # --with-float=hard
66 # --with-mode=thumb
67 # --with-fpu=vfpv3-d16
68 machine_name="armhf";;
c2033df4
LC
69 *)
70 machine_name="$host_cpu";;
71 esac
72
73 case "$host_os" in
74 linux-gnu*)
75 # For backward compatibility, strip the `-gnu' part.
76 guix_system="$machine_name-linux";;
77 *)
78 # Strip the version number from names such as `gnu0.3',
79 # `darwin10.2.0', etc.
eb25a30a 80 guix_system="$machine_name-`echo $host_os | "$SED" -e's/[0-9.]*$//g'`";;
c2033df4 81 esac])
5fedc65b
LC
82
83 AC_MSG_CHECKING([for the Guix system type])
84 AC_MSG_RESULT([$guix_system])
85
d8eea3d2 86 AC_SUBST([guix_system])
c2033df4 87])
9c7dd33a 88
b97556d7
LC
89dnl GUIX_ASSERT_SUPPORTED_SYSTEM
90dnl
91dnl Assert that this is a system to which the distro is ported.
92AC_DEFUN([GUIX_ASSERT_SUPPORTED_SYSTEM], [
93 AC_REQUIRE([GUIX_SYSTEM_TYPE])
94
95 AC_ARG_WITH([courage], [AC_HELP_STRING([--with-courage],
96 [Assert that even if this platform is unsupported, you will be
97courageous and port the GNU System distribution to it (see
98"GNU Distribution" in the manual.)])],
99 [guix_courageous="$withval"],
100 [guix_courageous="no"])
101
102 # Currently only Linux-based systems are supported, and only on some
103 # platforms.
104 case "$guix_system" in
aa1e1947 105 x86_64-linux|i686-linux|armhf-linux|mips64el-linux)
b97556d7
LC
106 ;;
107 *)
108 if test "x$guix_courageous" = "xyes"; then
109 AC_MSG_WARN([building Guix on `$guix_system', which is not supported])
110 else
111 AC_MSG_ERROR([`$guix_system' is not a supported platform.
112See "GNU Distribution" in the manual, or try `--with-courage'.])
113 fi
114 ;;
115 esac
116])
117
9c7dd33a
LC
118dnl GUIX_ASSERT_GUILE_FEATURES FEATURES
119dnl
120dnl Assert that FEATURES are provided by $GUILE.
121AC_DEFUN([GUIX_ASSERT_GUILE_FEATURES], [
122 for guix_guile_feature in $1
123 do
124 AC_MSG_CHECKING([whether $GUILE provides feature '$guix_guile_feature'])
125 if "$GUILE" -c "(exit (provided? '$guix_guile_feature))"
126 then
127 AC_MSG_RESULT([yes])
128 else
129 AC_MSG_RESULT([no])
130 AC_MSG_ERROR([$GUILE does not support feature '$guix_guile_feature', which is required.])
131 fi
132 done
133])
1959fb04
LC
134
135dnl GUIX_CHECK_SRFI_37
136dnl
137dnl Check whether SRFI-37 suffers from <http://bugs.gnu.org/13176>.
138dnl This bug was fixed in Guile 2.0.9.
139AC_DEFUN([GUIX_CHECK_SRFI_37], [
140 AC_CACHE_CHECK([whether (srfi srfi-37) is affected by http://bugs.gnu.org/13176],
141 [ac_cv_guix_srfi_37_broken],
142 [if "$GUILE" -c "(use-modules (srfi srfi-37)) \
143 (sigaction SIGALRM (lambda _ (primitive-exit 1))) \
144 (alarm 1) \
145 (define opts (list (option '(#\I) #f #t (lambda _ #t)))) \
146 (args-fold '(\"-I\") opts (lambda _ (error)) (lambda _ #f) '())"
147 then
148 ac_cv_guix_srfi_37_broken=no
149 else
150 ac_cv_guix_srfi_37_broken=yes
151 fi])
152])
49e6291a
LC
153
154dnl GUIX_CHECK_UNBUFFERED_CBIP
155dnl
156dnl Check whether 'setbvuf' works on custom binary input ports (CBIPs), as is
157dnl the case starting with Guile 2.0.10.
158AC_DEFUN([GUIX_CHECK_UNBUFFERED_CBIP], [
159 AC_CACHE_CHECK([whether Guile's custom binary input ports support 'setvbuf'],
160 [ac_cv_guix_cbips_support_setvbuf],
161 [if "$GUILE" -c "(use-modules (rnrs io ports)) \
162 (let ((p (make-custom-binary-input-port \"cbip\" pk #f #f #f))) \
163 (setvbuf p _IONBF))" >&5 2>&1
164 then
165 ac_cv_guix_cbips_support_setvbuf=yes
166 else
167 ac_cv_guix_cbips_support_setvbuf=no
168 fi])
169])
2178ed66
LC
170
171dnl GUIX_TEST_ROOT_DIRECTORY
172AC_DEFUN([GUIX_TEST_ROOT_DIRECTORY], [
173 AC_CACHE_CHECK([for unit test root directory],
174 [ac_cv_guix_test_root],
175 [ac_cv_guix_test_root="`pwd`/test-tmp"])
176])
177
93ce8a8e
LC
178dnl 'BINPRM_BUF_SIZE' constant in Linux (we leave room for the trailing zero.)
179dnl The Hurd has a limit of about a page (see exec/hashexec.c.)
180m4_define([LINUX_HASH_BANG_LIMIT], 127)
2178ed66
LC
181
182dnl Hardcoded 'sun_path' length in <sys/un.h>.
183m4_define([SOCKET_FILE_NAME_LIMIT], 108)
184
185dnl GUIX_SOCKET_FILE_NAME_LENGTH
186AC_DEFUN([GUIX_SOCKET_FILE_NAME_LENGTH], [
187 AC_CACHE_CHECK([the length of the installed socket file name],
188 [ac_cv_guix_socket_file_name_length],
189 [ac_cv_guix_socket_file_name_length="`echo -n "$guix_localstatedir/guix/daemon-socket/socket" | wc -c`"])
190])
191
192dnl GUIX_TEST_SOCKET_FILE_NAME_LENGTH
193AC_DEFUN([GUIX_TEST_SOCKET_FILE_NAME_LENGTH], [
194 AC_REQUIRE([GUIX_TEST_ROOT_DIRECTORY])
195 AC_CACHE_CHECK([the length of the socket file name used in tests],
196 [ac_cv_guix_test_socket_file_name_length],
197 [ac_cv_guix_test_socket_file_name_length="`echo -n "$ac_cv_guix_test_root/var/123456/daemon-socket/socket" | wc -c`"])
198])
199
200dnl GUIX_HASH_BANG_LENGTH
201AC_DEFUN([GUIX_HASH_BANG_LENGTH], [
202 AC_CACHE_CHECK([the length of a typical hash bang line],
203 [ac_cv_guix_hash_bang_length],
204 [ac_cv_guix_hash_bang_length=`echo -n "$storedir/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bootstrap-binaries-0/bin/bash" | wc -c`])
205])
206
27ab3cee
LC
207dnl GUIX_TEST_HASH_BANG_LENGTH
208AC_DEFUN([GUIX_TEST_HASH_BANG_LENGTH], [
209 AC_REQUIRE([GUIX_TEST_ROOT_DIRECTORY])
210 AC_CACHE_CHECK([the length of a hash bang line used in tests],
211 [ac_cv_guix_test_hash_bang_length],
212 [ac_cv_guix_test_hash_bang_length=`echo -n "$ac_cv_guix_test_root/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bootstrap-binaries-0/bin/bash" | wc -c`])
213])
214
2178ed66
LC
215dnl GUIX_CHECK_FILE_NAME_LIMITS
216dnl
217dnl GNU/Linux has a couple of silly limits that we can easily run into.
bb251307
LC
218dnl Make sure everything is fine with the current settings. Set $1 to
219dnl 'yes' if tests can run, 'no' otherwise.
2178ed66
LC
220AC_DEFUN([GUIX_CHECK_FILE_NAME_LIMITS], [
221 AC_REQUIRE([GUIX_SOCKET_FILE_NAME_LENGTH])
222 AC_REQUIRE([GUIX_TEST_SOCKET_FILE_NAME_LENGTH])
223 AC_REQUIRE([GUIX_HASH_BANG_LENGTH])
27ab3cee 224 AC_REQUIRE([GUIX_TEST_HASH_BANG_LENGTH])
2178ed66
LC
225
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
bb251307
LC
232
233 $1=yes
2178ed66 234 if test "$ac_cv_guix_hash_bang_length" -ge ]LINUX_HASH_BANG_LIMIT[; then
bb251307 235 $1=no
2178ed66
LC
236 AC_MSG_ERROR([store directory '$storedir' would lead to overly long hash-bang lines])
237 fi
27ab3cee 238 if test "$ac_cv_guix_test_hash_bang_length" -ge ]LINUX_HASH_BANG_LIMIT[; then
bb251307 239 $1=no
27ab3cee
LC
240 AC_MSG_WARN([test directory '$ac_cv_guix_test_root' may lead to overly long hash-bang lines])
241 fi
2178ed66 242])
368d08f7
LC
243
244dnl GUIX_CHECK_CXX11
245dnl
246dnl Check whether the C++ compiler can compile a typical C++11 program.
247AC_DEFUN([GUIX_CHECK_CXX11], [
248 AC_REQUIRE([AC_PROG_CXX])
249 AC_CACHE_CHECK([whether $CXX supports C++11],
250 [ac_cv_guix_cxx11_support],
251 [save_CXXFLAGS="$CXXFLAGS"
252 CXXFLAGS="-std=c++11 $CXXFLAGS"
253 AC_COMPILE_IFELSE([
254 AC_LANG_SOURCE([
255 #include <functional>
256
257 std::function<int(int)>
258 return_plus_lambda (int x)
259 {
260 auto result = [[&]](int y) {
261 return x + y;
262 };
263
264 return result;
265 }
266 ])],
267 [ac_cv_guix_cxx11_support=yes],
268 [ac_cv_guix_cxx11_support=no])
269 CXXFLAGS="$save_CXXFLAGS"
270 ])
271])
272
273dnl GUIX_ASSERT_CXX11
274dnl
275dnl Error out if the C++ compiler cannot compile C++11 code.
276AC_DEFUN([GUIX_ASSERT_CXX11], [
277 GUIX_CHECK_CXX11
278 if test "x$ac_cv_guix_cxx11_support" != "xyes"; then
279 AC_MSG_ERROR([C++ compiler '$CXX' does not support the C++11 standard])
280 fi
281])
12e5b266
LC
282
283dnl GUIX_CHECK_LIBC_MOUNT
284dnl
285dnl Check whether libc provides 'mount'. On GNU/Hurd it doesn't (yet).
286AC_DEFUN([GUIX_CHECK_LIBC_MOUNT], [
287 AC_CACHE_CHECK([whether libc provides 'mount'], [guix_cv_libc_has_mount],
288 [GUILE_CHECK([retval], [(dynamic-func \"mount\" (dynamic-link))])
289 if test "$retval" = 0; then
290 guix_cv_libc_has_mount="yes"
291 else
292 guix_cv_libc_has_mount="no"
293 fi])
294])
dd01fecd
LC
295
296dnl GUIX_LIBGCRYPT_LIBDIR VAR
297dnl
298dnl Attempt to determine libgcrypt's LIBDIR; store the result in VAR.
299AC_DEFUN([GUIX_LIBGCRYPT_LIBDIR], [
300 AC_PATH_PROG([LIBGCRYPT_CONFIG], [libgcrypt-config])
301 AC_CACHE_CHECK([libgcrypt's library directory],
302 [guix_cv_libgcrypt_libdir],
303 [if test "x$LIBGCRYPT_CONFIG" != "x"; then
ca34fc31 304 guix_cv_libgcrypt_libdir=`$LIBGCRYPT_CONFIG --libs | grep -e -L | sed -e "s/.*-L\([[^ ]]\+\)[[[:blank:]]]\+-lgcrypt.*/\1/g"`
dd01fecd
LC
305 else
306 guix_cv_libgcrypt_libdir=""
307 fi])
308 $1="$guix_cv_libgcrypt_libdir"
309])