gnu: emacs: Check GUIX_ENVIRONMENT when autoloading packages.
[jackhill/guix/guix.git] / configure.ac
1 # -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ(2.68)
5 AC_INIT([GNU Guix],
6 [m4_esyscmd([build-aux/git-version-gen .tarball-version])],
7 [bug-guix@gnu.org], [guix],
8 [https://www.gnu.org/software/guix/])
9 AC_CONFIG_AUX_DIR([build-aux])
10
11 AM_INIT_AUTOMAKE([1.12 gnu silent-rules subdir-objects \
12 color-tests parallel-tests -Woverride -Wno-portability])
13
14 # Enable silent rules by default.
15 AM_SILENT_RULES([yes])
16
17 AC_CONFIG_SRCDIR([guix.scm])
18 AC_CONFIG_MACRO_DIR([m4])
19
20 dnl For the C++ code. This must be used early.
21 AC_USE_SYSTEM_EXTENSIONS
22
23 AM_GNU_GETTEXT([external])
24 AM_GNU_GETTEXT_VERSION([0.18.1])
25
26 GUIX_SYSTEM_TYPE
27 GUIX_ASSERT_SUPPORTED_SYSTEM
28
29 AC_ARG_WITH(store-dir,
30 AC_HELP_STRING([--with-store-dir=PATH],
31 [file name of the store (defaults to /gnu/store)]),
32 [storedir="$withval"],
33 [storedir="/gnu/store"])
34 AC_SUBST(storedir)
35
36 AC_ARG_WITH([bash-completion-dir],
37 AC_HELP_STRING([--with-bash-completion-dir=DIR],
38 [name of the Bash completion directory]),
39 [bashcompletiondir="$withval"],
40 [bashcompletiondir='${sysconfdir}/bash_completion.d'])
41 AC_SUBST([bashcompletiondir])
42
43 AC_ARG_WITH([zsh-completion-dir],
44 AC_HELP_STRING([--with-zsh-completion-dir=DIR],
45 [name of the Zsh completion directory]),
46 [zshcompletiondir="$withval"],
47 [zshcompletiondir='${datadir}/zsh/site-functions'])
48 AC_SUBST([zshcompletiondir])
49
50 dnl Better be verbose.
51 AC_MSG_CHECKING([for the store directory])
52 AC_MSG_RESULT([$storedir])
53
54 AC_ARG_ENABLE([daemon],
55 [AS_HELP_STRING([--disable-daemon], [build the Nix daemon (C++)])],
56 [guix_build_daemon="$enableval"],
57 [guix_build_daemon="yes"])
58
59 # Prepare a version of $localstatedir & co. that does not contain references
60 # to shell variables.
61 guix_prefix="`eval echo $prefix | sed -e"s|NONE|/usr/local|g"`"
62 guix_localstatedir="`eval echo $localstatedir | sed -e "s|NONE|$guix_prefix|g"`"
63 guix_sysconfdir="`eval echo $sysconfdir | sed -e "s|NONE|$guix_prefix|g"`"
64 guix_sbindir="`eval echo $sbindir | sed -e "s|NONE|$guix_prefix|g"`"
65 AC_SUBST([guix_localstatedir])
66 AC_SUBST([guix_sysconfdir])
67 AC_SUBST([guix_sbindir])
68
69 GUIX_CHECK_FILE_NAME_LIMITS([can_run_tests])
70 AM_CONDITIONAL([CAN_RUN_TESTS], [test "x$can_run_tests" = "xyes"])
71
72 dnl We require pkg.m4 (from pkg-config) and guile.m4 (from Guile.)
73 dnl Make sure they are available.
74 m4_pattern_forbid([PKG_CHECK_MODULES])
75 m4_pattern_forbid([GUILE_MODULE_AVAILABLE])
76 m4_pattern_forbid([^GUILE_P$])
77
78 dnl Search for 'guile' and 'guild'. This macro defines
79 dnl 'GUILE_EFFECTIVE_VERSION'.
80 GUILE_PKG([2.2 2.0])
81 GUILE_PROGS
82 if test "x$GUILD" = "x"; then
83 AC_MSG_ERROR(['guild' binary not found; please check your guile-2.x installation.])
84 fi
85
86 if test "x$GUILE_EFFECTIVE_VERSION" = "x2.0"; then
87 PKG_CHECK_MODULES([GUILE], [guile-2.0 >= 2.0.9])
88 fi
89
90 dnl Installation directories for .scm and .go files.
91 guilemoduledir="${datarootdir}/guile/site/$GUILE_EFFECTIVE_VERSION"
92 guileobjectdir="${libdir}/guile/$GUILE_EFFECTIVE_VERSION/site-ccache"
93 AC_SUBST([guilemoduledir])
94 AC_SUBST([guileobjectdir])
95
96 dnl The GnuTLS bindings are necessary for substitutes over HTTPS and for 'guix
97 dnl pull', among other things.
98 GUILE_MODULE_AVAILABLE([have_gnutls], [(gnutls)])
99 if test "x$have_gnutls" != "xyes"; then
100 AC_MSG_ERROR([The Guile bindings of GnuTLS are missing; please install them.])
101 fi
102
103 dnl Guile-JSON is used in various places.
104 GUILE_MODULE_AVAILABLE([have_guile_json], [(json)])
105 AM_CONDITIONAL([HAVE_GUILE_JSON], [test "x$have_guile_json" = "xyes"])
106
107 dnl Check for Guile-Git.
108 GUILE_MODULE_AVAILABLE([have_guile_git], [(git)])
109 AM_CONDITIONAL([HAVE_GUILE_GIT], [test "x$have_guile_git" = "xyes"])
110
111 dnl Make sure we have a full-fledged Guile.
112 GUIX_ASSERT_GUILE_FEATURES([regex posix socket net-db threads])
113
114 dnl Decompressors, for use by the substituter and other modules.
115 AC_PATH_PROG([GZIP], [gzip])
116 AC_PATH_PROG([BZIP2], [bzip2])
117 AC_PATH_PROG([XZ], [xz])
118 AC_SUBST([GZIP])
119 AC_SUBST([BZIP2])
120 AC_SUBST([XZ])
121
122 AC_ARG_WITH([nix-prefix],
123 [AS_HELP_STRING([--with-nix-prefix=DIR],
124 [search for Nix in DIR (for testing purposes and '--disable-daemon' builds)])],
125 [case "$withval" in
126 yes|no) ;;
127 *)
128 NIX_PREFIX="$withval"
129 PATH="$NIX_PREFIX/bin:$PATH"; export PATH
130 AC_SUBST([NIX_PREFIX])
131 ;;
132 esac],
133 [])
134
135 AC_PATH_PROG([NIX_INSTANTIATE], [nix-instantiate])
136 AC_PATH_PROG([NIX_HASH], [nix-hash])
137 if test "x$guix_build_daemon$NIX_INSTANTIATE$NIX_HASH" = "xno"; then
138 AC_MSG_ERROR([Nix programs not found; please install Nix or use `--with-nix-prefix'.])
139 fi
140
141 if test "x$NIX_INSTANTIATE" = "x"; then
142 # This program is an optional dependency, so we just want it to be
143 # taken from $PATH if it's not available right now.
144 NIX_INSTANTIATE="nix-instantiate"
145 fi
146
147 AC_ARG_WITH([nixpkgs],
148 [AS_HELP_STRING([--with-nixpkgs=DIR],
149 [search for Nixpkgs in DIR (for testing purposes only)])],
150 [case "$withval" in
151 yes|no) AC_MSG_ERROR([Please use `--with-nixpkgs=DIR'.]);;
152 *) NIXPKGS="$withval";;
153 esac],
154 [])
155
156 AC_MSG_CHECKING([for Nixpkgs source tree])
157 if test -f "$NIXPKGS/default.nix"; then
158 AC_MSG_RESULT([$NIXPKGS])
159 AC_SUBST([NIXPKGS])
160 else
161 AC_MSG_RESULT([not found])
162 fi
163
164 LIBGCRYPT="libgcrypt"
165 LIBGCRYPT_LIBDIR="no"
166 LIBGCRYPT_PREFIX="no"
167
168 AC_ARG_WITH([libgcrypt-prefix],
169 [AS_HELP_STRING([--with-libgcrypt-prefix=DIR], [search for GNU libgcrypt in DIR])],
170 [case "$withval" in
171 yes|no)
172 ;;
173 *)
174 LIBGCRYPT="$withval/lib/libgcrypt"
175 LIBGCRYPT_PREFIX="$withval"
176 LIBGCRYPT_LIBDIR="$withval/lib"
177 ;;
178 esac])
179
180 AC_ARG_WITH([libgcrypt-libdir],
181 [AS_HELP_STRING([--with-libgcrypt-libdir=DIR],
182 [search for GNU libgcrypt's shared library in DIR])],
183 [case "$withval" in
184 yes|no)
185 LIBGCRYPT="libgcrypt"
186 LIBGCRYPT_LIBDIR="no"
187 ;;
188 *)
189 LIBGCRYPT="$withval/libgcrypt"
190 LIBGCRYPT_LIBDIR="$withval"
191 ;;
192 esac])
193
194 dnl If none of the --with-libgcrypt-* options was used, try to determine the
195 dnl absolute file name of libgcrypt.so.
196 case "x$LIBGCRYPT_PREFIX$LIBGCRYPT_LIBDIR" in
197 xnono)
198 GUIX_LIBGCRYPT_LIBDIR([LIBGCRYPT_LIBDIR])
199 if test "x$LIBGCRYPT_LIBDIR" != x; then
200 LIBGCRYPT="$LIBGCRYPT_LIBDIR/libgcrypt"
201 else
202 dnl 'config-daemon.ac' expects "no" in this case.
203 LIBGCRYPT_LIBDIR="no"
204 fi
205 ;;
206 esac
207
208 dnl Library name suitable for `dynamic-link'.
209 AC_MSG_CHECKING([for libgcrypt shared library name])
210 AC_MSG_RESULT([$LIBGCRYPT])
211 AC_SUBST([LIBGCRYPT])
212 AC_SUBST([LIBGCRYPT_PREFIX])
213 AC_SUBST([LIBGCRYPT_LIBDIR])
214
215 GUIX_ASSERT_LIBGCRYPT_USABLE
216
217 dnl Library name of zlib suitable for 'dynamic-link'.
218 GUIX_LIBZ_LIBDIR([libz_libdir])
219 if test "x$libz_libdir" = "x"; then
220 LIBZ="libz"
221 else
222 LIBZ="$libz_libdir/libz"
223 fi
224 AC_MSG_CHECKING([for zlib's shared library name])
225 AC_MSG_RESULT([$LIBZ])
226 AC_SUBST([LIBZ])
227
228 dnl Check for Guile-SSH, for the (guix ssh) module.
229 GUIX_CHECK_GUILE_SSH
230 AM_CONDITIONAL([HAVE_GUILE_SSH],
231 [test "x$guix_cv_have_recent_guile_ssh" = "xyes"])
232
233 AC_CACHE_SAVE
234
235 m4_include([config-daemon.ac])
236
237 dnl `dot' (from the Graphviz package) is only needed for maintainers.
238 dnl See `Building from Git' in the manual for more info.
239 AM_MISSING_PROG([DOT], [dot])
240
241 dnl Manual pages.
242 AM_MISSING_PROG([HELP2MAN], [help2man])
243
244 dnl Emacs (optional), for 'etc/indent-package.el'.
245 AC_PATH_PROG([EMACS], [emacs], [/usr/bin/emacs])
246 AC_SUBST([EMACS])
247
248 case "$storedir" in
249 /gnu/store)
250 ;;
251 *)
252 AC_MSG_WARN([Using a store directory other than '/gnu/store' will prevent you])
253 AC_MSG_WARN([from downloading substitutes from gnu.org.])
254 ;;
255 esac
256
257 AC_CONFIG_FILES([Makefile
258 po/guix/Makefile.in
259 po/packages/Makefile.in
260 guix/config.scm])
261
262 AC_CONFIG_FILES([scripts/guix], [chmod +x scripts/guix])
263 AC_CONFIG_FILES([test-env:build-aux/test-env.in], [chmod +x test-env])
264 AC_CONFIG_FILES([pre-inst-env:build-aux/pre-inst-env.in],
265 [chmod +x pre-inst-env])
266 AC_CONFIG_FILES([etc/indent-code.el], [chmod +x etc/indent-code.el])
267
268 AC_OUTPUT