gnu: evas-generic-loaders: Update to 1.14.0.
[guix.git] / m4 / guix.m4
blobfa5a4023ba02a599a2f6cd57565216c16476de73
1 dnl GNU Guix --- Functional package management for GNU
2 dnl Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
3 dnl Copyright © 2014 Mark H Weaver <mhw@netris.org>
4 dnl
5 dnl This file is part of GNU Guix.
6 dnl
7 dnl GNU Guix is free software; you can redistribute it and/or modify it
8 dnl under the terms of the GNU General Public License as published by
9 dnl the Free Software Foundation; either version 3 of the License, or (at
10 dnl your option) any later version.
11 dnl
12 dnl GNU Guix is distributed in the hope that it will be useful, but
13 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
14 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 dnl GNU General Public License for more details.
16 dnl
17 dnl You should have received a copy of the GNU General Public License
18 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])
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])
38 dnl GUIX_SYSTEM_TYPE
39 dnl
40 dnl Determine the Guix host system type, and store it in the
41 dnl `guix_system' variable.
42 AC_DEFUN([GUIX_SYSTEM_TYPE], [
43   AC_REQUIRE([AC_CANONICAL_HOST])
44   AC_PATH_PROG([SED], [sed])
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)
53           machine_name="x86_64";;
54        arm*)
55           # TODO: If not cross-compiling, add a sanity check to make
56           #       sure this build machine has the needed features to
57           #       support executables compiled using our armhf gcc,
58           #       configured with:
59           #         --with-arch=armv7-a
60           #         --with-float=hard
61           #         --with-mode=thumb
62           #         --with-fpu=vfpv3-d16
63           machine_name="armhf";;
64        *)
65           machine_name="$host_cpu";;
66      esac
68      case "$host_os" in
69        linux-gnu*)
70           # For backward compatibility, strip the `-gnu' part.
71           guix_system="$machine_name-linux";;
72        *)
73           # Strip the version number from names such as `gnu0.3',
74           # `darwin10.2.0', etc.
75           guix_system="$machine_name-`echo $host_os | "$SED" -e's/[0-9.]*$//g'`";;
76      esac])
78   AC_MSG_CHECKING([for the Guix system type])
79   AC_MSG_RESULT([$guix_system])
81   AC_SUBST([guix_system])
84 dnl GUIX_ASSERT_SUPPORTED_SYSTEM
85 dnl
86 dnl Assert that this is a system to which the distro is ported.
87 AC_DEFUN([GUIX_ASSERT_SUPPORTED_SYSTEM], [
88   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"])
97   # Currently only Linux-based systems are supported, and only on some
98   # platforms.
99   case "$guix_system" in
100     x86_64-linux|i686-linux|armhf-linux|mips64el-linux)
101       ;;
102     *)
103       if test "x$guix_courageous" = "xyes"; then
104         AC_MSG_WARN([building Guix on `$guix_system', which is not supported])
105       else
106         AC_MSG_ERROR([`$guix_system' is not a supported platform.
107 See "GNU Distribution" in the manual, or try `--with-courage'.])
108       fi
109       ;;
110   esac
113 dnl GUIX_ASSERT_GUILE_FEATURES FEATURES
115 dnl Assert that FEATURES are provided by $GUILE.
116 AC_DEFUN([GUIX_ASSERT_GUILE_FEATURES], [
117   for guix_guile_feature in $1
118   do
119     AC_MSG_CHECKING([whether $GUILE provides feature '$guix_guile_feature'])
120     if "$GUILE" -c "(exit (provided? '$guix_guile_feature))"
121     then
122       AC_MSG_RESULT([yes])
123     else
124       AC_MSG_RESULT([no])
125       AC_MSG_ERROR([$GUILE does not support feature '$guix_guile_feature', which is required.])
126     fi
127   done
130 dnl GUIX_CHECK_SRFI_37
132 dnl Check whether SRFI-37 suffers from <http://bugs.gnu.org/13176>.
133 dnl This bug was fixed in Guile 2.0.9.
134 AC_DEFUN([GUIX_CHECK_SRFI_37], [
135   AC_CACHE_CHECK([whether (srfi srfi-37) is affected by http://bugs.gnu.org/13176],
136     [ac_cv_guix_srfi_37_broken],
137     [if "$GUILE" -c "(use-modules (srfi srfi-37))                       \
138        (sigaction SIGALRM (lambda _ (primitive-exit 1)))                \
139        (alarm 1)                                                        \
140        (define opts (list (option '(#\I) #f #t (lambda _ #t))))         \
141        (args-fold '(\"-I\") opts (lambda _ (error)) (lambda _ #f) '())"
142      then
143        ac_cv_guix_srfi_37_broken=no
144      else
145        ac_cv_guix_srfi_37_broken=yes
146      fi])
149 dnl GUIX_CHECK_UNBUFFERED_CBIP
151 dnl Check whether 'setbvuf' works on custom binary input ports (CBIPs), as is
152 dnl the case starting with Guile 2.0.10.
153 AC_DEFUN([GUIX_CHECK_UNBUFFERED_CBIP], [
154   AC_CACHE_CHECK([whether Guile's custom binary input ports support 'setvbuf'],
155     [ac_cv_guix_cbips_support_setvbuf],
156     [if "$GUILE" -c "(use-modules (rnrs io ports))                      \
157        (let ((p (make-custom-binary-input-port \"cbip\" pk #f #f #f)))  \
158          (setvbuf p _IONBF))" >&5 2>&1
159      then
160        ac_cv_guix_cbips_support_setvbuf=yes
161      else
162        ac_cv_guix_cbips_support_setvbuf=no
163      fi])
166 dnl GUIX_TEST_ROOT_DIRECTORY
167 AC_DEFUN([GUIX_TEST_ROOT_DIRECTORY], [
168   AC_CACHE_CHECK([for unit test root directory],
169     [ac_cv_guix_test_root],
170     [ac_cv_guix_test_root="`pwd`/test-tmp"])
173 dnl 'BINPRM_BUF_SIZE' constant in Linux.  The Hurd has a limit
174 dnl of about a page (see exec/hashexec.c.)
175 m4_define([LINUX_HASH_BANG_LIMIT], 128)
177 dnl Hardcoded 'sun_path' length in <sys/un.h>.
178 m4_define([SOCKET_FILE_NAME_LIMIT], 108)
180 dnl GUIX_SOCKET_FILE_NAME_LENGTH
181 AC_DEFUN([GUIX_SOCKET_FILE_NAME_LENGTH], [
182   AC_CACHE_CHECK([the length of the installed socket file name],
183     [ac_cv_guix_socket_file_name_length],
184     [ac_cv_guix_socket_file_name_length="`echo -n "$guix_localstatedir/guix/daemon-socket/socket" | wc -c`"])
187 dnl GUIX_TEST_SOCKET_FILE_NAME_LENGTH
188 AC_DEFUN([GUIX_TEST_SOCKET_FILE_NAME_LENGTH], [
189   AC_REQUIRE([GUIX_TEST_ROOT_DIRECTORY])
190   AC_CACHE_CHECK([the length of the socket file name used in tests],
191     [ac_cv_guix_test_socket_file_name_length],
192     [ac_cv_guix_test_socket_file_name_length="`echo -n "$ac_cv_guix_test_root/var/123456/daemon-socket/socket" | wc -c`"])
195 dnl GUIX_HASH_BANG_LENGTH
196 AC_DEFUN([GUIX_HASH_BANG_LENGTH], [
197   AC_CACHE_CHECK([the length of a typical hash bang line],
198     [ac_cv_guix_hash_bang_length],
199     [ac_cv_guix_hash_bang_length=`echo -n "$storedir/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bootstrap-binaries-0/bin/bash" | wc -c`])
202 dnl GUIX_CHECK_FILE_NAME_LIMITS
204 dnl GNU/Linux has a couple of silly limits that we can easily run into.
205 dnl Make sure everything is fine with the current settings.
206 AC_DEFUN([GUIX_CHECK_FILE_NAME_LIMITS], [
207   AC_REQUIRE([GUIX_SOCKET_FILE_NAME_LENGTH])
208   AC_REQUIRE([GUIX_TEST_SOCKET_FILE_NAME_LENGTH])
209   AC_REQUIRE([GUIX_HASH_BANG_LENGTH])
211   if test "$ac_cv_guix_socket_file_name_length" -ge ]SOCKET_FILE_NAME_LIMIT[; then
212     AC_MSG_ERROR([socket file name would exceed the maxium allowed length])
213   fi
214   if test "$ac_cv_guix_test_socket_file_name_length" -ge ]SOCKET_FILE_NAME_LIMIT[; then
215     AC_MSG_WARN([socket file name limit may be exceeded when running tests])
216   fi
217   if test "$ac_cv_guix_hash_bang_length" -ge ]LINUX_HASH_BANG_LIMIT[; then
218     AC_MSG_ERROR([store directory '$storedir' would lead to overly long hash-bang lines])
219   fi
222 dnl GUIX_CHECK_CXX11
224 dnl Check whether the C++ compiler can compile a typical C++11 program.
225 AC_DEFUN([GUIX_CHECK_CXX11], [
226   AC_REQUIRE([AC_PROG_CXX])
227   AC_CACHE_CHECK([whether $CXX supports C++11],
228     [ac_cv_guix_cxx11_support],
229     [save_CXXFLAGS="$CXXFLAGS"
230      CXXFLAGS="-std=c++11 $CXXFLAGS"
231      AC_COMPILE_IFELSE([
232       AC_LANG_SOURCE([
233         #include <functional>
235         std::function<int(int)>
236         return_plus_lambda (int x)
237         {
238           auto result = [[&]](int y) {
239             return x + y;
240           };
242           return result;
243         }
244       ])],
245       [ac_cv_guix_cxx11_support=yes],
246       [ac_cv_guix_cxx11_support=no])
247     CXXFLAGS="$save_CXXFLAGS"
248   ])
251 dnl GUIX_ASSERT_CXX11
253 dnl Error out if the C++ compiler cannot compile C++11 code.
254 AC_DEFUN([GUIX_ASSERT_CXX11], [
255   GUIX_CHECK_CXX11
256   if test "x$ac_cv_guix_cxx11_support" != "xyes"; then
257     AC_MSG_ERROR([C++ compiler '$CXX' does not support the C++11 standard])
258   fi