Commit | Line | Data |
---|---|---|
2357f850 | 1 | dnl GNU Guix --- Functional package management for GNU |
2178ed66 | 2 | dnl Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org> |
aa1e1947 | 3 | dnl Copyright © 2014 Mark H Weaver <mhw@netris.org> |
d388c2c4 | 4 | dnl |
2357f850 | 5 | dnl This file is part of GNU Guix. |
d388c2c4 | 6 | dnl |
2357f850 | 7 | dnl GNU Guix is free software; you can redistribute it and/or modify it |
d388c2c4 LC |
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 | |
2357f850 | 12 | dnl GNU Guix is distributed in the hope that it will be useful, but |
d388c2c4 LC |
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 | |
2357f850 | 18 | dnl along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
d388c2c4 LC |
19 | |
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 | ||
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 | |
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]) | |
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 |
89 | dnl GUIX_ASSERT_SUPPORTED_SYSTEM |
90 | dnl | |
91 | dnl Assert that this is a system to which the distro is ported. | |
92 | AC_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 | |
97 | courageous 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. | |
112 | See "GNU Distribution" in the manual, or try `--with-courage'.]) | |
113 | fi | |
114 | ;; | |
115 | esac | |
116 | ]) | |
117 | ||
9c7dd33a LC |
118 | dnl GUIX_ASSERT_GUILE_FEATURES FEATURES |
119 | dnl | |
120 | dnl Assert that FEATURES are provided by $GUILE. | |
121 | AC_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 | |
135 | dnl GUIX_CHECK_SRFI_37 | |
136 | dnl | |
137 | dnl Check whether SRFI-37 suffers from <http://bugs.gnu.org/13176>. | |
138 | dnl This bug was fixed in Guile 2.0.9. | |
139 | AC_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 | |
154 | dnl GUIX_CHECK_UNBUFFERED_CBIP | |
155 | dnl | |
156 | dnl Check whether 'setbvuf' works on custom binary input ports (CBIPs), as is | |
157 | dnl the case starting with Guile 2.0.10. | |
158 | AC_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 | |
171 | dnl GUIX_TEST_ROOT_DIRECTORY | |
172 | AC_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 | ||
178 | dnl 'BINPRM_BUF_SIZE' constant in Linux. The Hurd has a limit | |
179 | dnl of about a page (see exec/hashexec.c.) | |
180 | m4_define([LINUX_HASH_BANG_LIMIT], 128) | |
181 | ||
182 | dnl Hardcoded 'sun_path' length in <sys/un.h>. | |
183 | m4_define([SOCKET_FILE_NAME_LIMIT], 108) | |
184 | ||
185 | dnl GUIX_SOCKET_FILE_NAME_LENGTH | |
186 | AC_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 | ||
192 | dnl GUIX_TEST_SOCKET_FILE_NAME_LENGTH | |
193 | AC_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 | ||
200 | dnl GUIX_HASH_BANG_LENGTH | |
201 | AC_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 | ||
207 | dnl GUIX_CHECK_FILE_NAME_LIMITS | |
208 | dnl | |
209 | dnl GNU/Linux has a couple of silly limits that we can easily run into. | |
210 | dnl Make sure everything is fine with the current settings. | |
211 | AC_DEFUN([GUIX_CHECK_FILE_NAME_LIMITS], [ | |
212 | AC_REQUIRE([GUIX_SOCKET_FILE_NAME_LENGTH]) | |
213 | AC_REQUIRE([GUIX_TEST_SOCKET_FILE_NAME_LENGTH]) | |
214 | AC_REQUIRE([GUIX_HASH_BANG_LENGTH]) | |
215 | ||
216 | if test "$ac_cv_guix_socket_file_name_length" -ge ]SOCKET_FILE_NAME_LIMIT[; then | |
217 | AC_MSG_ERROR([socket file name would exceed the maxium allowed length]) | |
218 | fi | |
219 | if test "$ac_cv_guix_test_socket_file_name_length" -ge ]SOCKET_FILE_NAME_LIMIT[; then | |
220 | AC_MSG_WARN([socket file name limit may be exceeded when running tests]) | |
221 | fi | |
222 | if test "$ac_cv_guix_hash_bang_length" -ge ]LINUX_HASH_BANG_LIMIT[; then | |
223 | AC_MSG_ERROR([store directory '$storedir' would lead to overly long hash-bang lines]) | |
224 | fi | |
225 | ]) | |
368d08f7 LC |
226 | |
227 | dnl GUIX_CHECK_CXX11 | |
228 | dnl | |
229 | dnl Check whether the C++ compiler can compile a typical C++11 program. | |
230 | AC_DEFUN([GUIX_CHECK_CXX11], [ | |
231 | AC_REQUIRE([AC_PROG_CXX]) | |
232 | AC_CACHE_CHECK([whether $CXX supports C++11], | |
233 | [ac_cv_guix_cxx11_support], | |
234 | [save_CXXFLAGS="$CXXFLAGS" | |
235 | CXXFLAGS="-std=c++11 $CXXFLAGS" | |
236 | AC_COMPILE_IFELSE([ | |
237 | AC_LANG_SOURCE([ | |
238 | #include <functional> | |
239 | ||
240 | std::function<int(int)> | |
241 | return_plus_lambda (int x) | |
242 | { | |
243 | auto result = [[&]](int y) { | |
244 | return x + y; | |
245 | }; | |
246 | ||
247 | return result; | |
248 | } | |
249 | ])], | |
250 | [ac_cv_guix_cxx11_support=yes], | |
251 | [ac_cv_guix_cxx11_support=no]) | |
252 | CXXFLAGS="$save_CXXFLAGS" | |
253 | ]) | |
254 | ]) | |
255 | ||
256 | dnl GUIX_ASSERT_CXX11 | |
257 | dnl | |
258 | dnl Error out if the C++ compiler cannot compile C++11 code. | |
259 | AC_DEFUN([GUIX_ASSERT_CXX11], [ | |
260 | GUIX_CHECK_CXX11 | |
261 | if test "x$ac_cv_guix_cxx11_support" != "xyes"; then | |
262 | AC_MSG_ERROR([C++ compiler '$CXX' does not support the C++11 standard]) | |
263 | fi | |
264 | ]) | |
12e5b266 LC |
265 | |
266 | dnl GUIX_CHECK_LIBC_MOUNT | |
267 | dnl | |
268 | dnl Check whether libc provides 'mount'. On GNU/Hurd it doesn't (yet). | |
269 | AC_DEFUN([GUIX_CHECK_LIBC_MOUNT], [ | |
270 | AC_CACHE_CHECK([whether libc provides 'mount'], [guix_cv_libc_has_mount], | |
271 | [GUILE_CHECK([retval], [(dynamic-func \"mount\" (dynamic-link))]) | |
272 | if test "$retval" = 0; then | |
273 | guix_cv_libc_has_mount="yes" | |
274 | else | |
275 | guix_cv_libc_has_mount="no" | |
276 | fi]) | |
277 | ]) | |
dd01fecd LC |
278 | |
279 | dnl GUIX_LIBGCRYPT_LIBDIR VAR | |
280 | dnl | |
281 | dnl Attempt to determine libgcrypt's LIBDIR; store the result in VAR. | |
282 | AC_DEFUN([GUIX_LIBGCRYPT_LIBDIR], [ | |
283 | AC_PATH_PROG([LIBGCRYPT_CONFIG], [libgcrypt-config]) | |
284 | AC_CACHE_CHECK([libgcrypt's library directory], | |
285 | [guix_cv_libgcrypt_libdir], | |
286 | [if test "x$LIBGCRYPT_CONFIG" != "x"; then | |
ca34fc31 | 287 | guix_cv_libgcrypt_libdir=`$LIBGCRYPT_CONFIG --libs | grep -e -L | sed -e "s/.*-L\([[^ ]]\+\)[[[:blank:]]]\+-lgcrypt.*/\1/g"` |
dd01fecd LC |
288 | else |
289 | guix_cv_libgcrypt_libdir="" | |
290 | fi]) | |
291 | $1="$guix_cv_libgcrypt_libdir" | |
292 | ]) |