Commit | Line | Data |
---|---|---|
2357f850 | 1 | dnl GNU Guix --- Functional package management for GNU |
c1dc50ab | 2 | dnl Copyright © 2012, 2013, 2014, 2015, 2016, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org> |
aa1e1947 | 3 | dnl Copyright © 2014 Mark H Weaver <mhw@netris.org> |
3b88f376 | 4 | dnl Copyright © 2017 Efraim Flashner <efraim@flashner.co.il> |
d388c2c4 | 5 | dnl |
2357f850 | 6 | dnl This file is part of GNU Guix. |
d388c2c4 | 7 | dnl |
2357f850 | 8 | dnl GNU Guix is free software; you can redistribute it and/or modify it |
d388c2c4 LC |
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 | |
2357f850 | 13 | dnl GNU Guix is distributed in the hope that it will be useful, but |
d388c2c4 LC |
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 | |
2357f850 | 19 | dnl along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
d388c2c4 | 20 | |
c2033df4 LC |
21 | dnl GUIX_SYSTEM_TYPE |
22 | dnl | |
23 | dnl Determine the Guix host system type, and store it in the | |
24 | dnl `guix_system' variable. | |
25 | AC_DEFUN([GUIX_SYSTEM_TYPE], [ | |
26 | AC_REQUIRE([AC_CANONICAL_HOST]) | |
eb25a30a LC |
27 | AC_PATH_PROG([SED], [sed]) |
28 | ||
c2033df4 LC |
29 | AC_ARG_WITH(system, AC_HELP_STRING([--with-system=SYSTEM], |
30 | [Platform identifier (e.g., `i686-linux').]), | |
31 | [guix_system="$withval"], | |
32 | [case "$host_cpu" in | |
33 | i*86) | |
34 | machine_name="i686";; | |
35 | amd64) | |
968ae903 | 36 | machine_name="x86_64";; |
dfdb15d9 | 37 | arm|armv[[7-9]]*) |
968ae903 LC |
38 | # Here we want to exclude CPUs such as "armv6l". On ARMv7 |
39 | # machines, we normally get "armv7l". However, in Guix, we | |
40 | # configure with --build=arm-unknown-linux-gnueabihf, leading | |
41 | # to just "arm", so we also have to allow it. | |
42 | # | |
aa1e1947 MW |
43 | # TODO: If not cross-compiling, add a sanity check to make |
44 | # sure this build machine has the needed features to | |
45 | # support executables compiled using our armhf gcc, | |
46 | # configured with: | |
47 | # --with-arch=armv7-a | |
48 | # --with-float=hard | |
49 | # --with-mode=thumb | |
50 | # --with-fpu=vfpv3-d16 | |
51 | machine_name="armhf";; | |
c2033df4 LC |
52 | *) |
53 | machine_name="$host_cpu";; | |
54 | esac | |
55 | ||
56 | case "$host_os" in | |
57 | linux-gnu*) | |
58 | # For backward compatibility, strip the `-gnu' part. | |
59 | guix_system="$machine_name-linux";; | |
4ed40a3e MR |
60 | gnu*) |
61 | # Always use i586 for GNU/Hurd. | |
62 | guix_system="i586-gnu";; | |
c2033df4 LC |
63 | *) |
64 | # Strip the version number from names such as `gnu0.3', | |
65 | # `darwin10.2.0', etc. | |
eb25a30a | 66 | guix_system="$machine_name-`echo $host_os | "$SED" -e's/[0-9.]*$//g'`";; |
c2033df4 | 67 | esac]) |
5fedc65b LC |
68 | |
69 | AC_MSG_CHECKING([for the Guix system type]) | |
70 | AC_MSG_RESULT([$guix_system]) | |
71 | ||
d8eea3d2 | 72 | AC_SUBST([guix_system]) |
c2033df4 | 73 | ]) |
9c7dd33a | 74 | |
b97556d7 LC |
75 | dnl GUIX_ASSERT_SUPPORTED_SYSTEM |
76 | dnl | |
77 | dnl Assert that this is a system to which the distro is ported. | |
78 | AC_DEFUN([GUIX_ASSERT_SUPPORTED_SYSTEM], [ | |
79 | AC_REQUIRE([GUIX_SYSTEM_TYPE]) | |
80 | ||
81 | AC_ARG_WITH([courage], [AC_HELP_STRING([--with-courage], | |
82 | [Assert that even if this platform is unsupported, you will be | |
83 | courageous and port the GNU System distribution to it (see | |
84 | "GNU Distribution" in the manual.)])], | |
85 | [guix_courageous="$withval"], | |
86 | [guix_courageous="no"]) | |
87 | ||
88 | # Currently only Linux-based systems are supported, and only on some | |
89 | # platforms. | |
90 | case "$guix_system" in | |
03e64049 | 91 | x86_64-linux|i686-linux|armhf-linux|aarch64-linux) |
b97556d7 LC |
92 | ;; |
93 | *) | |
94 | if test "x$guix_courageous" = "xyes"; then | |
95 | AC_MSG_WARN([building Guix on `$guix_system', which is not supported]) | |
96 | else | |
97 | AC_MSG_ERROR([`$guix_system' is not a supported platform. | |
98 | See "GNU Distribution" in the manual, or try `--with-courage'.]) | |
99 | fi | |
100 | ;; | |
101 | esac | |
102 | ]) | |
103 | ||
9c7dd33a LC |
104 | dnl GUIX_ASSERT_GUILE_FEATURES FEATURES |
105 | dnl | |
106 | dnl Assert that FEATURES are provided by $GUILE. | |
107 | AC_DEFUN([GUIX_ASSERT_GUILE_FEATURES], [ | |
108 | for guix_guile_feature in $1 | |
109 | do | |
110 | AC_MSG_CHECKING([whether $GUILE provides feature '$guix_guile_feature']) | |
111 | if "$GUILE" -c "(exit (provided? '$guix_guile_feature))" | |
112 | then | |
113 | AC_MSG_RESULT([yes]) | |
114 | else | |
115 | AC_MSG_RESULT([no]) | |
116 | AC_MSG_ERROR([$GUILE does not support feature '$guix_guile_feature', which is required.]) | |
117 | fi | |
118 | done | |
119 | ]) | |
1959fb04 | 120 | |
21531add LC |
121 | dnl GUIX_CHECK_GUILE_SSH |
122 | dnl | |
123 | dnl Check whether a recent-enough Guile-SSH is available. | |
124 | AC_DEFUN([GUIX_CHECK_GUILE_SSH], [ | |
e8088f0b LDB |
125 | dnl Check whether '#:nodelay' paramater to 'make-session' (introduced in |
126 | dnl 0.13.0) is present. | |
21531add LC |
127 | AC_CACHE_CHECK([whether Guile-SSH is available and recent enough], |
128 | [guix_cv_have_recent_guile_ssh], | |
129 | [GUILE_CHECK([retval], | |
130 | [(and (@ (ssh channel) channel-send-eof) | |
131 | (@ (ssh popen) open-remote-pipe) | |
37891872 | 132 | (@ (ssh dist node) node-eval) |
e8088f0b LDB |
133 | (@ (ssh auth) userauth-gssapi!) |
134 | ((@ (ssh session) make-session) #:nodelay #t))]) | |
21531add LC |
135 | if test "$retval" = 0; then |
136 | guix_cv_have_recent_guile_ssh="yes" | |
137 | else | |
138 | guix_cv_have_recent_guile_ssh="no" | |
139 | fi]) | |
140 | ]) | |
141 | ||
d59e75f3 LC |
142 | dnl GUIX_CHECK_GUILE_SQLITE3 |
143 | dnl | |
144 | dnl Check whether a recent-enough Guile-Sqlite3 is available. | |
145 | AC_DEFUN([GUIX_CHECK_GUILE_SQLITE3], [ | |
146 | dnl Check whether 'sqlite-bind-arguments' is available. It was introduced | |
147 | dnl in February 2018: | |
60e1c109 | 148 | dnl <https://notabug.org/guile-sqlite3/guile-sqlite3/commit/1cd1dec96a9999db48c0ff45bab907efc637247f>. |
d59e75f3 LC |
149 | AC_CACHE_CHECK([whether Guile-Sqlite3 is available and recent enough], |
150 | [guix_cv_have_recent_guile_sqlite3], | |
151 | [GUILE_CHECK([retval], | |
152 | [(@ (sqlite3) sqlite-bind-arguments)]) | |
153 | if test "$retval" = 0; then | |
154 | guix_cv_have_recent_guile_sqlite3="yes" | |
155 | else | |
156 | guix_cv_have_recent_guile_sqlite3="no" | |
157 | fi]) | |
158 | ]) | |
159 | ||
81c3dc32 LC |
160 | dnl GUIX_CHECK_GUILE_JSON |
161 | dnl | |
162 | dnl Check whether a recent-enough Guile-JSON is available. | |
163 | AC_DEFUN([GUIX_CHECK_GUILE_JSON], [ | |
164 | dnl Check whether we're using Guile-JSON 3.x, which uses a JSON-to-Scheme | |
165 | dnl mapping different from that of earlier versions. | |
166 | AC_CACHE_CHECK([whether Guile-JSON is available and recent enough], | |
167 | [guix_cv_have_recent_guile_json], | |
168 | [GUILE_CHECK([retval], | |
169 | [(use-modules (json) (ice-9 match)) | |
611a64bd LC |
170 | (match (json-string->scm \"[[ { \\\"a\\\": 42 } ]]\") |
171 | (#((("a" . 42))) #t))]) | |
81c3dc32 LC |
172 | if test "$retval" = 0; then |
173 | guix_cv_have_recent_guile_json="yes" | |
174 | else | |
175 | guix_cv_have_recent_guile_json="no" | |
176 | fi]) | |
177 | ]) | |
178 | ||
c1dc50ab LC |
179 | dnl GUIX_CHECK_GUILE_GCRYPT |
180 | dnl | |
181 | dnl Check whether a recent-enough Guile-Gcrypt is available. | |
182 | AC_DEFUN([GUIX_CHECK_GUILE_GCRYPT], [ | |
183 | dnl Check whether we're using Guile-Gcrypt 0.2.x or later. 0.2.0 | |
184 | dnl introduced the 'hash-algorithm' macro and related code. | |
185 | AC_CACHE_CHECK([whether Guile-Gcrypt is available and recent enough], | |
186 | [guix_cv_have_recent_guile_gcrypt], | |
187 | [GUILE_CHECK([retval], | |
188 | [(use-modules (gcrypt hash)) | |
189 | (equal? (hash-algorithm sha256) | |
190 | (lookup-hash-algorithm 'sha256))]) | |
191 | if test "$retval" = 0; then | |
192 | guix_cv_have_recent_guile_gcrypt="yes" | |
193 | else | |
194 | guix_cv_have_recent_guile_gcrypt="no" | |
195 | fi]) | |
196 | ]) | |
81c3dc32 | 197 | |
2178ed66 LC |
198 | dnl GUIX_TEST_ROOT_DIRECTORY |
199 | AC_DEFUN([GUIX_TEST_ROOT_DIRECTORY], [ | |
200 | AC_CACHE_CHECK([for unit test root directory], | |
201 | [ac_cv_guix_test_root], | |
202 | [ac_cv_guix_test_root="`pwd`/test-tmp"]) | |
203 | ]) | |
204 | ||
93ce8a8e LC |
205 | dnl 'BINPRM_BUF_SIZE' constant in Linux (we leave room for the trailing zero.) |
206 | dnl The Hurd has a limit of about a page (see exec/hashexec.c.) | |
207 | m4_define([LINUX_HASH_BANG_LIMIT], 127) | |
2178ed66 LC |
208 | |
209 | dnl Hardcoded 'sun_path' length in <sys/un.h>. | |
210 | m4_define([SOCKET_FILE_NAME_LIMIT], 108) | |
211 | ||
212 | dnl GUIX_SOCKET_FILE_NAME_LENGTH | |
213 | AC_DEFUN([GUIX_SOCKET_FILE_NAME_LENGTH], [ | |
214 | AC_CACHE_CHECK([the length of the installed socket file name], | |
215 | [ac_cv_guix_socket_file_name_length], | |
216 | [ac_cv_guix_socket_file_name_length="`echo -n "$guix_localstatedir/guix/daemon-socket/socket" | wc -c`"]) | |
217 | ]) | |
218 | ||
219 | dnl GUIX_TEST_SOCKET_FILE_NAME_LENGTH | |
220 | AC_DEFUN([GUIX_TEST_SOCKET_FILE_NAME_LENGTH], [ | |
221 | AC_REQUIRE([GUIX_TEST_ROOT_DIRECTORY]) | |
222 | AC_CACHE_CHECK([the length of the socket file name used in tests], | |
223 | [ac_cv_guix_test_socket_file_name_length], | |
224 | [ac_cv_guix_test_socket_file_name_length="`echo -n "$ac_cv_guix_test_root/var/123456/daemon-socket/socket" | wc -c`"]) | |
225 | ]) | |
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 | ||
27ab3cee LC |
234 | dnl GUIX_TEST_HASH_BANG_LENGTH |
235 | AC_DEFUN([GUIX_TEST_HASH_BANG_LENGTH], [ | |
236 | AC_REQUIRE([GUIX_TEST_ROOT_DIRECTORY]) | |
237 | AC_CACHE_CHECK([the length of a hash bang line used in tests], | |
238 | [ac_cv_guix_test_hash_bang_length], | |
239 | [ac_cv_guix_test_hash_bang_length=`echo -n "$ac_cv_guix_test_root/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bootstrap-binaries-0/bin/bash" | wc -c`]) | |
240 | ]) | |
241 | ||
2178ed66 LC |
242 | dnl GUIX_CHECK_FILE_NAME_LIMITS |
243 | dnl | |
244 | dnl GNU/Linux has a couple of silly limits that we can easily run into. | |
bb251307 LC |
245 | dnl Make sure everything is fine with the current settings. Set $1 to |
246 | dnl 'yes' if tests can run, 'no' otherwise. | |
2178ed66 LC |
247 | AC_DEFUN([GUIX_CHECK_FILE_NAME_LIMITS], [ |
248 | AC_REQUIRE([GUIX_SOCKET_FILE_NAME_LENGTH]) | |
249 | AC_REQUIRE([GUIX_TEST_SOCKET_FILE_NAME_LENGTH]) | |
250 | AC_REQUIRE([GUIX_HASH_BANG_LENGTH]) | |
27ab3cee | 251 | AC_REQUIRE([GUIX_TEST_HASH_BANG_LENGTH]) |
2178ed66 LC |
252 | |
253 | if test "$ac_cv_guix_socket_file_name_length" -ge ]SOCKET_FILE_NAME_LIMIT[; then | |
254 | AC_MSG_ERROR([socket file name would exceed the maxium allowed length]) | |
255 | fi | |
256 | if test "$ac_cv_guix_test_socket_file_name_length" -ge ]SOCKET_FILE_NAME_LIMIT[; then | |
257 | AC_MSG_WARN([socket file name limit may be exceeded when running tests]) | |
258 | fi | |
bb251307 LC |
259 | |
260 | $1=yes | |
2178ed66 | 261 | if test "$ac_cv_guix_hash_bang_length" -ge ]LINUX_HASH_BANG_LIMIT[; then |
bb251307 | 262 | $1=no |
2178ed66 LC |
263 | AC_MSG_ERROR([store directory '$storedir' would lead to overly long hash-bang lines]) |
264 | fi | |
27ab3cee | 265 | if test "$ac_cv_guix_test_hash_bang_length" -ge ]LINUX_HASH_BANG_LIMIT[; then |
bb251307 | 266 | $1=no |
27ab3cee LC |
267 | AC_MSG_WARN([test directory '$ac_cv_guix_test_root' may lead to overly long hash-bang lines]) |
268 | fi | |
2178ed66 | 269 | ]) |
368d08f7 LC |
270 | |
271 | dnl GUIX_CHECK_CXX11 | |
272 | dnl | |
273 | dnl Check whether the C++ compiler can compile a typical C++11 program. | |
274 | AC_DEFUN([GUIX_CHECK_CXX11], [ | |
275 | AC_REQUIRE([AC_PROG_CXX]) | |
276 | AC_CACHE_CHECK([whether $CXX supports C++11], | |
277 | [ac_cv_guix_cxx11_support], | |
278 | [save_CXXFLAGS="$CXXFLAGS" | |
279 | CXXFLAGS="-std=c++11 $CXXFLAGS" | |
280 | AC_COMPILE_IFELSE([ | |
281 | AC_LANG_SOURCE([ | |
282 | #include <functional> | |
283 | ||
284 | std::function<int(int)> | |
285 | return_plus_lambda (int x) | |
286 | { | |
287 | auto result = [[&]](int y) { | |
288 | return x + y; | |
289 | }; | |
290 | ||
291 | return result; | |
292 | } | |
293 | ])], | |
294 | [ac_cv_guix_cxx11_support=yes], | |
295 | [ac_cv_guix_cxx11_support=no]) | |
296 | CXXFLAGS="$save_CXXFLAGS" | |
297 | ]) | |
298 | ]) | |
299 | ||
300 | dnl GUIX_ASSERT_CXX11 | |
301 | dnl | |
302 | dnl Error out if the C++ compiler cannot compile C++11 code. | |
303 | AC_DEFUN([GUIX_ASSERT_CXX11], [ | |
304 | GUIX_CHECK_CXX11 | |
305 | if test "x$ac_cv_guix_cxx11_support" != "xyes"; then | |
306 | AC_MSG_ERROR([C++ compiler '$CXX' does not support the C++11 standard]) | |
307 | fi | |
308 | ]) | |
12e5b266 | 309 | |
dd01fecd LC |
310 | dnl GUIX_LIBGCRYPT_LIBDIR VAR |
311 | dnl | |
312 | dnl Attempt to determine libgcrypt's LIBDIR; store the result in VAR. | |
313 | AC_DEFUN([GUIX_LIBGCRYPT_LIBDIR], [ | |
314 | AC_PATH_PROG([LIBGCRYPT_CONFIG], [libgcrypt-config]) | |
315 | AC_CACHE_CHECK([libgcrypt's library directory], | |
316 | [guix_cv_libgcrypt_libdir], | |
317 | [if test "x$LIBGCRYPT_CONFIG" != "x"; then | |
ca34fc31 | 318 | guix_cv_libgcrypt_libdir=`$LIBGCRYPT_CONFIG --libs | grep -e -L | sed -e "s/.*-L\([[^ ]]\+\)[[[:blank:]]]\+-lgcrypt.*/\1/g"` |
dd01fecd LC |
319 | else |
320 | guix_cv_libgcrypt_libdir="" | |
321 | fi]) | |
322 | $1="$guix_cv_libgcrypt_libdir" | |
323 | ]) | |
ef5f5c86 LC |
324 | |
325 | dnl GUIX_CURRENT_LOCALSTATEDIR | |
326 | dnl | |
327 | dnl Determine the localstatedir of an existing Guix installation and set | |
328 | dnl 'guix_cv_current_localstatedir' accordingly. Set it to "none" if no | |
329 | dnl existing installation was found. | |
330 | AC_DEFUN([GUIX_CURRENT_LOCALSTATEDIR], [ | |
331 | AC_PATH_PROG([GUILE], [guile]) | |
332 | AC_CACHE_CHECK([the current installation's localstatedir], | |
333 | [guix_cv_current_localstatedir], | |
334 | [dnl Call 'dirname' because (guix config) appends "/guix" to LOCALSTATEDIR. | |
335 | guix_cv_current_localstatedir="`"$GUILE" \ | |
336 | -c '(use-modules (guix config)) | |
337 | (when (string=? %store-directory "'$storedir'") | |
338 | (display (dirname %state-directory)))' \ | |
339 | 2>/dev/null`" | |
340 | if test "x$guix_cv_current_localstatedir" = "x"; then | |
341 | guix_cv_current_localstatedir=none | |
342 | fi])]) | |
343 | ||
344 | dnl GUIX_CHECK_LOCALSTATEDIR | |
345 | dnl | |
346 | dnl Check that the LOCALSTATEDIR value is consistent with that of the existing | |
347 | dnl Guix installation, if any. Error out or warn if they do not match. | |
348 | AC_DEFUN([GUIX_CHECK_LOCALSTATEDIR], [ | |
349 | AC_REQUIRE([GUIX_CURRENT_LOCALSTATEDIR]) | |
350 | if test "x$guix_cv_current_localstatedir" != "xnone"; then | |
351 | if test "$guix_cv_current_localstatedir" != "$guix_localstatedir"; then | |
352 | case "$localstatedir" in | |
353 | NONE|\${prefix}*) | |
354 | # User kept the default value---i.e., did not pass '--localstatedir'. | |
355 | AC_MSG_ERROR([chosen localstatedir '$guix_localstatedir' does not match \ | |
356 | that of the existing installation '$guix_cv_current_localstatedir' | |
357 | Installing may corrupt $storedir! | |
358 | Use './configure --localstatedir=$guix_cv_current_localstatedir'.]) | |
359 | ;; | |
360 | *) | |
361 | # User passed an explicit '--localstatedir'. Assume they know what | |
362 | # they're doing. | |
363 | AC_MSG_WARN([chosen localstatedir '$guix_localstatedir' does not match \ | |
364 | that of the existing installation '$guix_cv_current_localstatedir']) | |
365 | AC_MSG_WARN([installing may corrupt $storedir!]) | |
366 | ;; | |
367 | esac | |
368 | fi | |
369 | fi]) |