Debian Codegraph @

configure.ac

raw
1 #
2 # Copyright (C) 2013 Red Hat, Inc.
3 # SPDX-License-Identifier: LGPL-2.1-or-later
4
5
6 m4_include([version.m4])
7 AC_INIT([Cockpit],
8 [VERSION_NUMBER],
9 [[email protected]],
10 [cockpit],
11 [https://cockpit-project.org/])
12
13 AC_CONFIG_SRCDIR([src])
14 AC_CONFIG_HEADERS([config.h])
15 AC_CONFIG_AUX_DIR([tools])
16
17 AM_INIT_AUTOMAKE([1.11 foreign dist-xz no-dist-gzip subdir-objects])
18 # we want tar-ustar to avoid introducing extra metadata (ctime, atime) which
19 # only adds useless non-determinism to the result. we also want to sort.
20 am__tar='tar --format=ustar --sort=name --owner=root:0 --group=root:0 -chf - "$$tardir"'
21
22 AC_USE_SYSTEM_EXTENSIONS
23 AC_SYS_LARGEFILE
24 AC_PROG_RANLIB
25
26 # This is required to find the correct `ar` for cross-compiling
27 AC_CHECK_TOOL(AR, ar)
28
29 AC_CHECK_FUNCS(pidfd_getpid)
30
31 AM_SILENT_RULES([yes])
32
33 AC_MSG_CHECKING([whether to install to prefix only])
34 AC_ARG_ENABLE([prefix-only],
35 [AS_HELP_STRING([--enable-prefix-only], [Whether to install to prefix only])],
36 [], [enable_prefix_only=no])
37 AC_MSG_RESULT($enable_prefix_only)
38
39
40 # --enable-selinux-policy=[type]
41 AC_MSG_CHECKING([whether to build selinux policy, and which])
42 AC_ARG_ENABLE([selinux-policy], [AS_HELP_STRING([--enable-selinux-policy=type], [Whether to build selinux policy, and which])])
43 if test "${enable_selinux_policy:=no}" = 'yes'; then
44 AC_MSG_ERROR([--enable-selinux-policy requires a type (eg: targeted)])
45 fi
46 AM_CONDITIONAL(SELINUX_POLICY_ENABLED, test "$enable_selinux_policy" != "no")
47 AC_SUBST(SELINUX_POLICY_TYPE, [${enable_selinux_policy}])
48 AC_MSG_RESULT($enable_selinux_policy)
49
50 AC_SEARCH_LIBS([argp_parse], [argp])
51 case "$ac_cv_search_argp_parse" in
52 no) AC_MSG_FAILURE([failed to find argp_parse]) ;;
53 -l*) argp_LIBS="$ac_cv_search_argp_parse" ;;
54 *) argp_LIBS= ;;
55 esac
56 AC_SUBST([argp_LIBS])
57
58 AC_SEARCH_LIBS([fts_close], [fts])
59 case "$ac_cv_search_fts_close" in
60 no) AC_MSG_FAILURE([failed to find fts_close]) ;;
61 -l*) fts_LIBS="$ac_cv_search_fts_close" ;;
62 *) fts_LIBS= ;;
63 esac
64 AC_SUBST([fts_LIBS])
65
66 # pkg-config
67 GLIB_API_VERSION="GLIB_VERSION_2_68"
68 PKG_CHECK_MODULES(glib, [gio-2.0 >= 2.68 gio-unix-2.0])
69 glib_CFLAGS="${glib_CFLAGS} -DGLIB_VERSION_MIN_REQUIRED=$GLIB_API_VERSION"
70 glib_CFLAGS="${glib_CFLAGS} -DGLIB_VERSION_MAX_ALLOWED=$GLIB_API_VERSION"
71
72 PKG_CHECK_MODULES(libsystemd, [libsystemd >= 235])
73 PKG_CHECK_MODULES(json_glib, [json-glib-1.0 >= 1.4])
74 PKG_CHECK_MODULES(gnutls, [gnutls >= 3.6.0])
75 PKG_CHECK_MODULES(krb5, [krb5-gssapi >= 1.11 krb5 >= 1.11])
76
77 # pam
78 AC_CHECK_HEADER([security/pam_appl.h], ,
79 [AC_MSG_ERROR([Couldn't find PAM headers. Try installing pam-devel])]
80 )
81 PAM_LIBS="-lpam"
82 COCKPIT_SESSION_LIBS="$COCKPIT_SESSION_LIBS $PAM_LIBS"
83
84 # pam module directory
85 AC_ARG_WITH([pamdir],
86 [AS_HELP_STRING([--with-pamdir=DIR],
87 [directory to install pam modules in])],
88 [], [with_pamdir='${libdir}/security'])
89 pamdir=$with_pamdir
90 AC_SUBST(pamdir)
91
92 # crypt
93 AC_CHECK_HEADER([crypt.h], ,
94 [AC_MSG_ERROR([Couldn't find crypt headers. Try installing glibc-headers])]
95 )
96 AC_CHECK_LIB(crypt, crypt_r, [ true ],
97 [AC_MSG_ERROR([Couldn't find crypt library. Try installing glibc-devel])]
98 )
99 COCKPIT_WS_LIBS="$COCKPIT_WS_LIBS -lcrypt"
100
101 # systemd
102 AC_ARG_WITH([systemdunitdir], [AS_HELP_STRING([--with-systemdunitdir=DIR],
103 [directory to install systemd unit files in])])
104
105 if test ! -z "$with_systemdunitdir"; then
106 systemdunitdir=$with_systemdunitdir
107 elif test "$enable_prefix_only" = "yes"; then
108 systemdunitdir='${prefix}/lib/systemd/system'
109 else
110 PKG_CHECK_MODULES(SYSTEMD, [systemd])
111 AC_MSG_CHECKING(for systemd unit dir)
112 systemdunitdir=$($PKG_CONFIG systemd --variable=systemdsystemunitdir)
113 if test "$systemdunitdir" = ""; then
114 AC_MSG_ERROR([systemd's pkg-config file doesn't contain 'systemdsystemunitdir' variable])
115 fi
116 AC_MSG_RESULT($systemdunitdir)
117 fi
118 AC_SUBST([systemdunitdir], [$systemdunitdir])
119
120 # We need msgcat, msgfmt, and xgettext, but they're all in the same
121 # package as xgettext, and we find them by PATH, so just check for the one.
122 AC_PATH_PROG([XGETTEXT], [xgettext], [no])
123 if test "$XGETTEXT" = "no"; then
124 AC_MSG_ERROR([Please install gettext tools])
125 fi
126
127 # ssh-add
128 AC_PATH_PROG([SSH_ADD], [ssh-add], [/usr/bin/ssh-add], [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
129 AC_DEFINE_UNQUOTED([PATH_SSH_ADD], ["$SSH_ADD"], [Location of ssh-add binary])
130
131 # ssh-agent
132 AC_PATH_PROG([SSH_AGENT], [ssh-agent], [/usr/bin/ssh-agent], [$PATH:/usr/local/bin:/usr/bin:/bin])
133 AC_DEFINE_UNQUOTED([PATH_SSH_AGENT], ["$SSH_AGENT"], [Location of ssh-agent binary])
134
135 # Address sanitizer
136 AC_MSG_CHECKING([for asan flags])
137 AC_ARG_ENABLE(asan,
138 AS_HELP_STRING([--enable-asan=no/yes],
139 [Turn the Address Sanitizer on or off])
140 )
141
142 if test "$enable_asan" = "yes"; then
143 CFLAGS="$CFLAGS -fsanitize=address -O1 -fno-omit-frame-pointer -g"
144 asan_status="yes"
145 else
146 asan_status="no"
147 fi
148 AM_CONDITIONAL(WITH_ASAN, test "$enable_asan" = "yes")
149 AC_MSG_RESULT($asan_status)
150
151 # admin users group
152 AC_ARG_WITH([admin-group],
153 [AS_HELP_STRING([--with-admin-group=GROUP],
154 [system group to which admin users belong])],
155 [admin_group=$withval],
156 [
157 AC_MSG_CHECKING([for system group to which admin users belong])
158 CANDIDATE_GROUPS="wheel sudo root"
159 admin_group="$(getent group ${CANDIDATE_GROUPS} | head -n1 | cut -f1 -d:)"
160 if test -n "$admin_group"; then
161 AC_MSG_RESULT([$admin_group])
162 else
163 AC_MSG_RESULT([unable to detect])
164 AC_MSG_ERROR([none of '${CANDIDATE_GROUPS}' exist: please specify a group with --with-admin-group=])
165 fi
166 ])
167 AC_SUBST(admin_group)
168
169 # Default PATH for cockpit-session
170 AC_ARG_WITH([default-session-path],
171 [AS_HELP_STRING([--with-default-session-path=PATH],
172 [The value for the PATH environment variable in a session started by cockpit-session])],
173 [default_session_path=$withval],
174 [
175 AC_MSG_CHECKING([for cockpit-session PATH value])
176 if test "$(readlink /sbin)" == "usr/bin"; then
177 # This is Arch where "sbin" is symlinked to "bin" and
178 # "/bin" is symlinked to "/usr/bin". We use the
179 # normal Arch PATH which omits "sbin" and "/bin" for
180 # those reasons. Otherwise "pkexec" will find
181 # cockpit-bridge in "/usr/sbin" and our rule won't
182 # match.
183 default_session_path=/usr/local/sbin:/usr/local/bin:/usr/bin
184 else
185 default_session_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
186 fi
187 AC_MSG_RESULT([$default_session_path])
188 ])
189 AC_DEFINE_UNQUOTED([DEFAULT_SESSION_PATH], ["$default_session_path"], [Default value of PATH for cockpit-session])
190
191 # Documentation
192
193 AC_MSG_CHECKING([whether to build documentation])
194 AC_ARG_ENABLE(doc,
195 AS_HELP_STRING([--disable-doc],
196 [Disable building documentation])
197 )
198
199 if test "$enable_doc" = "no"; then
200 AC_MSG_RESULT($enable_doc)
201
202 else
203 if test "$enable_doc" = ""; then
204 disable_msg="(perhaps --disable-doc)"
205 fi
206
207 enable_doc="yes"
208 AC_MSG_RESULT($enable_doc)
209
210 has_asciidoctor="no"
211 AC_MSG_RESULT($has_asciidoctor)
212
213 AC_PATH_PROG([ASCIIDOCTOR], [asciidoctor], [no])
214 if test "$ASCIIDOCTOR" != "no"; then
215 has_asciidoctor="yes"
216 AC_SUBST(ASCIIDOCTOR)
217 fi
218
219 fi
220
221 AM_CONDITIONAL([ENABLE_DOC], [test "$enable_doc" = "yes"])
222 AM_CONDITIONAL([HAS_ASCIIDOCTOR], [test "$has_asciidoctor" = "yes"])
223
224 # Default for AllowMultiHost
225
226 AC_MSG_CHECKING([for AllowMultiHost default])
227 AC_ARG_ENABLE(multihost,
228 AS_HELP_STRING([--enable-multihost],
229 [Set AllowMultiHost to true by default]),
230 [], [enable_multihost=no])
231 AC_MSG_RESULT($enable_multihost)
232 if test "$enable_multihost" = "no"; then
233 multihost_def=0
234 else
235 multihost_def=1
236 fi
237 AC_DEFINE_UNQUOTED(ALLOW_MULTIHOST_DEFAULT, [$multihost_def], [default for AllowMultiHost configuration setting])
238
239 # cockpit-client
240 AC_MSG_CHECKING([whether to install cockpit-client])
241 AC_ARG_ENABLE([cockpit-client],
242 [AS_HELP_STRING([--enable-cockpit-client], [Whether to install cockpit-client])],
243 [], [enable_cockpit_client=no])
244 AC_MSG_RESULT($enable_cockpit_client)
245 AM_CONDITIONAL([ENABLE_COCKPIT_CLIENT], [test "$enable_cockpit_client" = "yes"])
246
247 # Debug
248
249 AC_MSG_CHECKING([for debug mode])
250 AC_ARG_ENABLE(debug,
251 AS_HELP_STRING([--enable-debug=no/default/yes],
252 [Turn on or off debugging])
253 )
254
255 if test "$enable_debug" != "no"; then
256 AC_DEFINE_UNQUOTED(WITH_DEBUG, 1, [Print debug output])
257 AC_DEFINE_UNQUOTED(_DEBUG, 1, [In debug mode])
258 CFLAGS="$CFLAGS -g"
259 fi
260 debugdir='${prefix}/src/debug'
261 if test "$enable_debug" = "yes"; then
262 debug_status="yes"
263 debugdir=
264 CFLAGS="$CFLAGS -O0"
265 NODE_ENV="development"
266 elif test "$enable_debug" = "no"; then
267 debug_status="no"
268 CFLAGS="$CFLAGS -O2"
269 NODE_ENV="production"
270 else
271 debug_status="default"
272 NODE_ENV="${NODE_ENV:-production}"
273 fi
274 AM_CONDITIONAL(WITH_DEBUG, test "$enable_debug" = "yes")
275 AC_MSG_RESULT($debug_status)
276 AC_SUBST(NODE_ENV)
277 AC_SUBST(debugdir)
278
279 # Coverage
280
281 AC_MSG_CHECKING([whether to build with coverage])
282 AC_ARG_ENABLE([coverage],
283 [AS_HELP_STRING([--enable-coverage], [Whether to enable coverage testing])],
284 [],
285 [enable_coverage=no])
286
287 if test "$enable_coverage" = "yes"; then
288 if test "$GCC" != "yes"; then
289 AC_MSG_ERROR(Coverage testing requires GCC)
290 fi
291
292 CFLAGS="$CFLAGS -O0 -g --coverage"
293 LDFLAGS="$LDFLAGS --coverage"
294 fi
295
296 AM_CONDITIONAL([WITH_COVERAGE], [test "$enable_coverage" = "yes"])
297 AC_MSG_RESULT([$enable_coverage])
298
299 # Strict
300
301 AC_ARG_ENABLE(strict, [
302 AS_HELP_STRING([--enable-strict], [Strict code compilation])
303 ])
304
305 AC_MSG_CHECKING([build strict])
306 if test "$enable_strict" = "yes"; then
307 CFLAGS="$CFLAGS -Werror"
308 else
309 enable_strict="no"
310 fi
311 AC_MSG_RESULT($enable_strict)
312
313 AM_PATH_PYTHON([3.6])
314
315 # Generate
316 #
317
318 AC_SUBST(PAM_LIBS)
319
320 AC_CONFIG_FILES([
321 Makefile
322 src/tls/cockpit-certificate-helper
323 src/ws/cockpit-desktop
324 ])
325 AC_OUTPUT
326
327
328 dnl ==========================================================================
329 echo "
330 Cockpit $VERSION
331 ================
332
333 prefix: ${prefix}
334 exec_prefix: ${exec_prefix}
335 libdir: ${libdir}
336 libexecdir: ${libexecdir}
337 bindir: ${bindir}
338 sbindir: ${sbindir}
339 datarootdir: ${datarootdir}
340 datadir: ${datadir}
341 sysconfdir: ${sysconfdir}
342 localstatedir: ${localstatedir}
343 pamdir: ${pamdir}
344 systemd unit dir: ${systemdunitdir}
345
346 compiler: ${CC}
347 cflags: ${CFLAGS}
348 cppflags: ${CPPFLAGS}
349
350 admin group: ${admin_group}
351 cockpit-session PATH: ${default_session_path}
352
353 Building docs: ${enable_doc}
354 Has asciidoctor: ${has_asciidoctor}
355
356 Debug mode: ${debug_status}
357 Node environment: ${NODE_ENV}
358 With coverage: ${enable_coverage}
359 With address sanitizer: ${asan_status}
360 SELinux Policy: ${enable_selinux_policy}
361
362 cockpit-client: ${enable_cockpit_client}
363
364 ssh-add: ${SSH_ADD}
365 ssh-agent: ${SSH_AGENT}
366
367 Now type 'make' to compile cockpit."