chiark / gitweb /
service: Don't crash because of double free when Arch services are disabled in rc...
[elogind.git] / configure.ac
1 #  This file is part of systemd.
2 #
3 #  Copyright 2010 Lennart Poettering
4 #
5 #  systemd is free software; you can redistribute it and/or modify it
6 #  under the terms of the GNU General Public License as published by
7 #  the Free Software Foundation; either version 2 of the License, or
8 #  (at your option) any later version.
9 #
10 #  systemd is distributed in the hope that it will be useful, but
11 #  WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 #  General Public License for more details.
14 #
15 #  You should have received a copy of the GNU General Public License
16 #  along with systemd; If not, see <http://www.gnu.org/licenses/>.
17
18 AC_PREREQ(2.63)
19
20 AC_INIT([systemd],[10],[systemd-devel@lists.freedesktop.org])
21 AC_CONFIG_SRCDIR([src/main.c])
22 AC_CONFIG_MACRO_DIR([m4])
23 AC_CONFIG_HEADERS([config.h])
24
25 AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability silent-rules tar-pax subdir-objects dist-bzip2])
26
27 AC_SUBST(PACKAGE_URL, [http://www.freedesktop.org/wiki/Software/systemd])
28
29 AC_CANONICAL_HOST
30 AC_DEFINE_UNQUOTED([CANONICAL_HOST], "$host", [Canonical host string.])
31
32 AM_SILENT_RULES([yes])
33
34 AC_CHECK_PROG([STOW], [stow], [yes], [no])
35
36 AS_IF([test "x$STOW" = "xyes" && test -d /usr/local/stow], [
37         AC_MSG_NOTICE([*** Found /usr/local/stow: default install prefix set to /usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION} ***])
38         ac_default_prefix="/usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION}"
39 ])
40
41 AC_PROG_MKDIR_P
42 AC_PROG_LN_S
43 AC_PROG_SED
44
45 AC_PROG_CC
46 AC_PROG_CC_C99
47 AM_PROG_CC_C_O
48 AC_PROG_GCC_TRADITIONAL
49 AC_USE_SYSTEM_EXTENSIONS
50
51 CC_CHECK_CFLAGS_APPEND([ \
52         -pipe \
53         -Wall \
54         -W \
55         -Wextra \
56         -Wno-inline \
57         -Wvla \
58         -Wundef \
59         -Wformat=2 \
60         -Wlogical-op \
61         -Wsign-compare \
62         -Wformat-security \
63         -Wmissing-include-dirs \
64         -Wformat-nonliteral \
65         -Wold-style-definition \
66         -Wpointer-arith \
67         -Winit-self \
68         -Wdeclaration-after-statement \
69         -Wfloat-equal \
70         -Wmissing-prototypes \
71         -Wstrict-prototypes \
72         -Wredundant-decls \
73         -Wmissing-declarations \
74         -Wmissing-noreturn \
75         -Wshadow \
76         -Wendif-labels \
77         -Wcast-align \
78         -Wstrict-aliasing=2 \
79         -Wwrite-strings \
80         -Wno-long-long \
81         -Wno-overlength-strings \
82         -Wno-unused-parameter \
83         -Wno-missing-field-initializers \
84         -Wno-unused-result \
85         -Wp,-D_FORTIFY_SOURCE=2 \
86         -ffast-math \
87         -fno-common \
88         -fdiagnostics-show-option \
89         -fno-strict-aliasing])
90
91 LT_PREREQ(2.2)
92 LT_INIT
93
94 AC_SEARCH_LIBS([clock_gettime], [rt], [], [AC_MSG_ERROR([*** POSIX RT library not found])])
95 AC_SEARCH_LIBS([dlsym], [dl], [], [AC_MSG_ERROR([*** Dynamic linking loader library not found])])
96 AC_SEARCH_LIBS([cap_init], [cap], [], [AC_MSG_ERROR([*** POSIX caps library not found])])
97 AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([*** POSIX caps headers not found])])
98
99 # This makes sure pkg.m4 is available.
100 m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-config])
101
102 PKG_CHECK_MODULES(UDEV, [ libudev >= 160 ])
103 AC_SUBST(UDEV_CFLAGS)
104 AC_SUBST(UDEV_LIBS)
105
106 PKG_CHECK_MODULES(DBUS, [ dbus-1 >= 1.3.2 ])
107 AC_SUBST(DBUS_CFLAGS)
108 AC_SUBST(DBUS_LIBS)
109
110 PKG_CHECK_MODULES(DBUSGLIB, [ dbus-glib-1 ])
111 AC_SUBST(DBUSGLIB_CFLAGS)
112 AC_SUBST(DBUSGLIB_LIBS)
113
114 have_selinux=no
115 AC_ARG_ENABLE(selinux, AS_HELP_STRING([--disable-selinux], [Disable optional SELINUX support]))
116 if test "x$enable_selinux" != "xno"; then
117         # not using PKG_CHECK_MODULES as for some reason libselinux didn't
118         # install any pkg-config modules here
119         AC_SEARCH_LIBS([getcon], [selinux],
120                 [AC_DEFINE(HAVE_SELINUX, 1, [Define if SELINUX is available]) have_selinux=yes],
121                 have_selinux=no)
122         AC_SUBST(SELINUX_CFLAGS)
123         AC_SUBST(SELINUX_LIBS)
124         if test "x$have_selinux" = xno -a "x$enable_selinux" = xyes; then
125                 AC_MSG_ERROR([*** selinux support requested but libraries not found])
126         fi
127 fi
128 AM_CONDITIONAL(HAVE_SELINUX, [test "$have_selinux" = "yes"])
129
130 AC_ARG_ENABLE([tcpwrap],
131         AS_HELP_STRING([--disable-tcpwrap],[Disable optional TCP wrappers support]),
132                 [case "${enableval}" in
133                         yes) have_tcpwrap=yes ;;
134                         no) have_tcpwrap=no ;;
135                         *) AC_MSG_ERROR(bad value ${enableval} for --disable-tcpwrap) ;;
136                 esac],
137                 [have_tcpwrap=auto])
138
139 if test "x${have_tcpwrap}" != xno ; then
140         ACX_LIBWRAP
141         if test "x${LIBWRAP_LIBS}" = x ; then
142                 if test "x$have_tcpwrap" = xyes ; then
143                         AC_MSG_ERROR([*** TCP wrappers support not found.])
144                 fi
145                 have_tcpwrap=no
146         else
147                 have_tcpwrap=yes
148         fi
149 else
150         LIBWRAP_LIBS=
151 fi
152 AC_SUBST(LIBWRAP_LIBS)
153
154 AC_ARG_ENABLE([pam],
155         AS_HELP_STRING([--disable-pam],[Disable optional PAM support]),
156                 [case "${enableval}" in
157                         yes) have_pam=yes ;;
158                         no) have_pam=no ;;
159                         *) AC_MSG_ERROR(bad value ${enableval} for --disable-pam) ;;
160                 esac],
161                 [have_pam=auto])
162
163 if test "x${have_pam}" != xno ; then
164         AC_CHECK_HEADERS(
165                 [security/pam_modules.h security/pam_modutil.h security/pam_ext.h],
166                 [have_pam=yes],
167                 [if test "x$have_pam" = xyes ; then
168                         AC_MSG_ERROR([*** PAM headers not found.])
169                 fi])
170
171         AC_CHECK_LIB(
172                 [pam],
173                 [pam_syslog],
174                 [have_pam=yes],
175                 [if test "x$have_pam" = xyes ; then
176                         AC_MSG_ERROR([*** libpam not found.])
177                 fi])
178
179         if test "x$have_pam" = xyes ; then
180                 PAM_LIBS="-lpam -lpam_misc"
181                 AC_DEFINE(HAVE_PAM, 1, [PAM available])
182         else
183                 have_pam=no
184         fi
185 else
186         PAM_LIBS=
187 fi
188 AC_SUBST(PAM_LIBS)
189 AM_CONDITIONAL([HAVE_PAM], [test "x$have_pam" != xno])
190
191 AC_ARG_ENABLE([audit],
192         AS_HELP_STRING([--disable-audit],[Disable optional AUDIT support]),
193                 [case "${enableval}" in
194                         yes) have_audit=yes ;;
195                         no) have_audit=no ;;
196                         *) AC_MSG_ERROR(bad value ${enableval} for --disable-audit) ;;
197                 esac],
198                 [have_audit=auto])
199
200 if test "x${have_audit}" != xno ; then
201         AC_CHECK_HEADERS(
202                 [libaudit.h],
203                 [have_audit=yes],
204                 [if test "x$have_audit" = xyes ; then
205                         AC_MSG_ERROR([*** AUDIT headers not found.])
206                 fi])
207
208         AC_CHECK_LIB(
209                 [audit],
210                 [audit_open],
211                 [have_audit=yes],
212                 [if test "x$have_audit" = xyes ; then
213                         AC_MSG_ERROR([*** libaudit not found.])
214                 fi])
215
216         if test "x$have_audit" = xyes ; then
217                 AUDIT_LIBS="-laudit"
218                 AC_DEFINE(HAVE_AUDIT, 1, [AUDIT available])
219         else
220                 have_audit=no
221         fi
222 else
223         AUDIT_LIBS=
224 fi
225 AC_SUBST(AUDIT_LIBS)
226
227 have_gtk=no
228 AC_ARG_ENABLE(gtk, AS_HELP_STRING([--disable-gtk], [disable GTK tools]))
229 if test "x$enable_gtk" != "xno"; then
230         PKG_CHECK_MODULES(GTK, [ gtk+-2.0 gio-unix-2.0 libnotify ],
231                 [AC_DEFINE(HAVE_GTK, 1, [Define if GTK is available]) have_gtk=yes], have_gtk=no)
232         AC_SUBST(GTK_CFLAGS)
233         AC_SUBST(GTK_LIBS)
234         if test "x$have_gtk" = xno -a "x$enable_gtk" = xyes; then
235              AC_MSG_ERROR([*** gtk support requested but libraries not found])
236         fi
237 fi
238 AM_CONDITIONAL(HAVE_GTK, [test "$have_gtk" = "yes"])
239
240 AM_PROG_VALAC([0.9])
241 AC_SUBST(VAPIDIR)
242 AM_CONDITIONAL(HAVE_VALAC, test x"$VALAC" != x)
243
244 AC_PATH_PROG([XSLTPROC], [xsltproc])
245 AM_CONDITIONAL(HAVE_XSLTPROC, test x"$XSLTPROC" != x)
246
247 AC_PATH_PROG([M4], [m4])
248
249 AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO],[Specify the distribution to target: One of fedora, suse, debian, arch, gentoo, slackware or other]))
250 if test "z$with_distro" = "z"; then
251         if test "$cross_compiling" = yes; then
252                 AC_MSG_WARN([Target distribution cannot be reliably detected when cross-compiling. You should specify it with --with-distro (see $0 --help for recognized distros)])
253         else
254                 AC_CHECK_FILE(/etc/redhat-release,with_distro="fedora")
255                 AC_CHECK_FILE(/etc/SuSE-release,with_distro="suse")
256                 AC_CHECK_FILE(/etc/debian_version,with_distro="debian")
257                 AC_CHECK_FILE(/etc/arch-release,with_distro="arch")
258                 AC_CHECK_FILE(/etc/gentoo-release,with_distro="gentoo")
259                 AC_CHECK_FILE(/etc/slackware-version,with_distro="slackware")
260         fi
261         if test "z$with_distro" = "z"; then
262                 with_distro=`uname -s`
263         fi
264 fi
265 with_distro=`echo ${with_distro} | tr '[[:upper:]]' '[[:lower:]]' `
266 AC_DEFINE_UNQUOTED(DISTRIBUTION, ["${with_distro}"], [Target Distribution])
267
268 # Default generic names
269 SPECIAL_SYSLOG_SERVICE=syslog.service
270
271 # Location of the init scripts as mandated by LSB
272 SYSTEM_SYSVINIT_PATH=/etc/init.d
273
274 M4_DISTRO_FLAG=
275
276 case $with_distro in
277         fedora)
278                 SYSTEM_SYSVINIT_PATH=/etc/rc.d/init.d
279                 SYSTEM_SYSVRCND_PATH=/etc/rc.d
280
281                 # A little background why we define this special unit
282                 # names here in configure.ac: SysV services currently
283                 # cannot have aliases. As long as syslog is started
284                 # via a SysV init script we hence define this name to
285                 # the actual SysV name here. Later on when SysV init
286                 # scripts are not used anymore it is advisable to use
287                 # the generic name instead and use symlinks in the
288                 # unit directories to point to the right native unit
289                 # file.
290
291                 SPECIAL_SYSLOG_SERVICE=rsyslog.service
292                 AC_DEFINE(TARGET_FEDORA, [], [Target is Fedora/RHEL])
293                 M4_DISTRO_FLAG=-DTARGET_FEDORA=1
294                 ;;
295         suse)
296                 SYSTEM_SYSVRCND_PATH=/etc/init.d
297                 AC_DEFINE(TARGET_SUSE, [], [Target is openSUSE/SLE])
298                 M4_DISTRO_FLAG=-DTARGET_SUSE=1
299                 ;;
300         debian)
301                 SYSTEM_SYSVRCND_PATH=/etc
302                 SPECIAL_SYSLOG_SERVICE=rsyslog.service
303                 AC_DEFINE(TARGET_DEBIAN, [], [Target is Debian/Ubuntu])
304                 M4_DISTRO_FLAG=-DTARGET_DEBIAN=1
305                 ;;
306         arch)
307                 SYSTEM_SYSVINIT_PATH=/etc/rc.d
308                 SYSTEM_SYSVRCND_PATH=/etc
309                 SPECIAL_SYSLOG_SERVICE=syslog-ng.service
310                 AC_DEFINE(TARGET_ARCH, [], [Target is ArchLinux])
311                 M4_DISTRO_FLAG=-DTARGET_ARCH=1
312                 ;;
313         gentoo)
314                 SYSTEM_SYSVINIT_PATH=
315                 SYSTEM_SYSVRCND_PATH=
316                 SPECIAL_SYSLOG_SERVICE=syslog-ng.service
317                 AC_DEFINE(TARGET_GENTOO, [], [Target is Gentoo])
318                 M4_DISTRO_FLAG=-DTARGET_GENTOO=1
319                 ;;
320         slackware)
321                 SYSTEM_SYSVINIT_PATH=/etc/rc.d/init.d
322                 SYSTEM_SYSVRCND_PATH=/etc/rc.d
323                 AC_DEFINE(TARGET_SLACKWARE, [], [Target is Slackware])
324                 M4_DISTRO_FLAG=-DTARGET_SLACKWARE=1
325                 ;;
326         other)
327                 AS_IF([test "x$with_syslog_service" = "x"],
328                         [AC_MSG_ERROR([With --distro=other, you must pass --with-syslog-service= to configure])])
329                 ;;
330         *)
331                 AC_MSG_ERROR([Your distribution (${with_distro}) is not yet supported, SysV init scripts could not be found! (patches welcome); you can specify --with-distro=other to skip this check])
332                 ;;
333 esac
334
335 AC_ARG_WITH([sysvinit-path],
336         [AS_HELP_STRING([--with-sysvinit-path=PATH],
337                 [Specify the path to where the SysV init scripts are located @<:@default=based on distro@:>@])],
338         [SYSTEM_SYSVINIT_PATH="$withval"],
339         [])
340
341 AC_ARG_WITH([sysvrcd-path],
342         [AS_HELP_STRING([--with-sysvrcd-path=PATH],
343                 [Specify the path to the base directory for the SysV rcN.d directories @<:@default=based on distro@:>@])],
344         [SYSTEM_SYSVRCND_PATH="$withval"],
345         [])
346
347 AC_ARG_WITH([syslog-service],
348         [AS_HELP_STRING([--with-syslog-service=UNIT],
349                 [Specify the name of the special syslog service @<:@default=based on distro@:>@])],
350         [SPECIAL_SYSLOG_SERVICE="$withval"],
351         [])
352
353 AC_SUBST(SYSTEM_SYSVINIT_PATH)
354 AC_SUBST(SYSTEM_SYSVRCND_PATH)
355 AC_SUBST(SPECIAL_SYSLOG_SERVICE)
356 AC_SUBST(M4_DISTRO_FLAG)
357
358 if test "x${SYSTEM_SYSVINIT_PATH}" != "x" -a "x${SYSTEM_SYSVRCND_PATH}" != "x"; then
359         AC_DEFINE(HAVE_SYSV_COMPAT, [], [SysV init scripts and rcN.d links are supported.])
360         SYSTEM_SYSV_COMPAT="yes"
361 elif test "x${SYSTEM_SYSVINIT_PATH}" != "x" -o "x${SYSTEM_SYSVRCND_PATH}" != "x"; then
362         AC_MSG_ERROR([*** You need both --with-sysvinit-path=PATH and --with-sysvrcd-path=PATH to enable SysV compatibility support, or both empty to disable it.])
363 else
364         SYSTEM_SYSV_COMPAT="no"
365 fi
366
367 AM_CONDITIONAL(TARGET_FEDORA, test x"$with_distro" = xfedora)
368 AM_CONDITIONAL(TARGET_SUSE, test x"$with_distro" = xsuse)
369 AM_CONDITIONAL(TARGET_DEBIAN, test x"$with_distro" = xdebian)
370 AM_CONDITIONAL(TARGET_ARCH, test x"$with_distro" = xarch)
371 AM_CONDITIONAL(TARGET_GENTOO, test x"$with_distro" = xgentoo)
372 AM_CONDITIONAL(TARGET_SLACKWARE, test x"$with_distro" = xslackware)
373
374 AC_DEFINE_UNQUOTED(SPECIAL_SYSLOG_SERVICE, ["$SPECIAL_SYSLOG_SERVICE"], [Syslog service name])
375
376 AC_ARG_WITH([dbuspolicydir],
377         AS_HELP_STRING([--with-dbuspolicydir=DIR], [D-Bus policy directory]),
378         [],
379         [with_dbuspolicydir=`pkg-config --variable=sysconfdir dbus-1`/dbus-1/system.d])
380
381 AC_ARG_WITH([dbussessionservicedir],
382         AS_HELP_STRING([--with-dbussessionservicedir=DIR], [D-Bus session service directory]),
383         [],
384         [with_dbussessionservicedir=`pkg-config --variable=session_bus_services_dir dbus-1`])
385
386 AC_ARG_WITH([dbussystemservicedir],
387         AS_HELP_STRING([--with-dbussystemservicedir=DIR], [D-Bus system service directory]),
388         [],
389         [with_dbussystemservicedir=`pkg-config --variable=session_bus_services_dir dbus-1`/../system-services])
390
391 AC_ARG_WITH([dbusinterfacedir],
392         AS_HELP_STRING([--with-dbusinterfacedir=DIR], [D-Bus interface directory]),
393         [],
394         [with_dbusinterfacedir=`pkg-config --variable=session_bus_services_dir dbus-1`/../interfaces])
395
396 AC_ARG_WITH([udevrulesdir],
397         AS_HELP_STRING([--with-udevrulesdir=DIR], [Diectory for udev rules]),
398         [],
399         [with_udevrulesdir=`pkg-config --variable=udevdir udev`/rules.d])
400
401 AC_ARG_WITH([pamlibdir],
402         AS_HELP_STRING([--with-pamlibdir=DIR], [Diectory for PAM modules]),
403         [],
404         [with_pamlibdir=/lib/`$CC -print-multi-os-directory`/security])
405
406 AC_ARG_WITH([rootdir],
407         AS_HELP_STRING([--with-rootdir=DIR], [Root directory for files necessary for boot]),
408         [],
409         [with_rootdir=${ac_default_prefix}])
410
411 AC_SUBST([dbuspolicydir], [$with_dbuspolicydir])
412 AC_SUBST([dbussessionservicedir], [$with_dbussessionservicedir])
413 AC_SUBST([dbussystemservicedir], [$with_dbussystemservicedir])
414 AC_SUBST([dbusinterfacedir], [$with_dbusinterfacedir])
415 AC_SUBST([udevrulesdir], [$with_udevrulesdir])
416 AC_SUBST([pamlibdir], [$with_pamlibdir])
417 AC_SUBST([rootdir], [$with_rootdir])
418
419 AC_CONFIG_FILES([Makefile])
420 AC_OUTPUT
421
422 echo "
423         $PACKAGE_NAME $VERSION
424
425         Distribution:            ${with_distro}
426         SysV compatibility:      ${SYSTEM_SYSV_COMPAT}
427         SysV init scripts:       ${SYSTEM_SYSVINIT_PATH}
428         SysV rc?.d directories:  ${SYSTEM_SYSVRCND_PATH}
429         Syslog service:          ${SPECIAL_SYSLOG_SERVICE}
430         Gtk:                     ${have_gtk}
431         tcpwrap:                 ${have_tcpwrap}
432         PAM:                     ${have_pam}
433         AUDIT:                   ${have_audit}
434         SELinux:                 ${have_selinux}
435         prefix:                  ${prefix}
436         root dir:                ${with_rootdir}
437         udev rules dir:          ${with_udevrulesdir}
438         pam modules dir:         ${with_pamlibdir}
439         dbus policy dir:         ${with_dbuspolicydir}
440         dbus session dir:        ${with_dbussessionservicedir}
441         dbus system dir:         ${with_dbussystemservicedir}
442         dbus interfaces dir:     ${with_dbusinterfacedir}
443 "