chiark / gitweb /
f44b493dd71e5a5edd6ff8897a92e7eaa3f80c2d
[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],[0],[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
31 AM_SILENT_RULES([yes])
32
33 AC_CHECK_PROG([STOW], [stow], [yes], [no])
34
35 AS_IF([test "x$STOW" = "xyes" && test -d /usr/local/stow], [
36         AC_MSG_NOTICE([*** Found /usr/local/stow: default install prefix set to /usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION} ***])
37         ac_default_prefix="/usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION}"
38 ])
39
40 AC_PROG_MKDIR_P
41 AC_PROG_LN_S
42 AC_PROG_SED
43
44 AC_PROG_CC
45 AC_PROG_CC_C99
46 AM_PROG_CC_C_O
47 AC_PROG_GCC_TRADITIONAL
48 AC_USE_SYSTEM_EXTENSIONS
49
50 CC_CHECK_CFLAGS_APPEND([ \
51         -Wall \
52         -W \
53         -Wextra \
54         -pipe \
55         -Wno-long-long \
56         -Winline \
57         -Wvla \
58         -Wno-overlength-strings \
59         -Wundef \
60         -Wformat=2 \
61         -Wlogical-op \
62         -Wsign-compare \
63         -Wformat-security \
64         -Wmissing-include-dirs \
65         -Wformat-nonliteral \
66         -Wold-style-definition \
67         -Wpointer-arith \
68         -Winit-self \
69         -Wdeclaration-after-statement \
70         -Wfloat-equal \
71         -Wmissing-prototypes \
72         -Wstrict-prototypes \
73         -Wredundant-decls \
74         -Wmissing-declarations \
75         -Wmissing-noreturn \
76         -Wshadow \
77         -Wendif-labels \
78         -Wcast-align \
79         -Wstrict-aliasing=2 \
80         -Wwrite-strings \
81         -Wno-unused-parameter \
82         -ffast-math \
83         -Wp,-D_FORTIFY_SOURCE=2 \
84         -fno-common \
85         -fdiagnostics-show-option \
86         -Wno-missing-field-initializers])
87
88 AC_SEARCH_LIBS([clock_gettime], [rt], [], [AC_MSG_ERROR([*** POSIX RT library not found])])
89 AC_SEARCH_LIBS([cap_init], [cap], [], [AC_MSG_ERROR([*** POSIX caps library not found])])
90 AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([*** POSIX caps headers not found])])
91
92 # This makes sure pkg.m4 is available.
93 m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-config])
94
95 PKG_CHECK_MODULES(UDEV, [ libudev >= 154 ])
96 AC_SUBST(UDEV_CFLAGS)
97 AC_SUBST(UDEV_LIBS)
98
99 PKG_CHECK_MODULES(DBUS, [ dbus-1 ])
100 AC_SUBST(DBUS_CFLAGS)
101 AC_SUBST(DBUS_LIBS)
102
103 PKG_CHECK_MODULES(DBUSGLIB, [ dbus-glib-1 ])
104 AC_SUBST(DBUSGLIB_CFLAGS)
105 AC_SUBST(DBUSGLIB_LIBS)
106
107 PKG_CHECK_MODULES(CGROUP, [ libcgroup >= 0.36 ])
108 AC_SUBST(CGROUP_CFLAGS)
109 AC_SUBST(CGROUP_LIBS)
110
111 AC_ARG_ENABLE([tcpwrap],
112         AS_HELP_STRING([--disable-tcpwrap],[Disable optional TCP wrappers support]),
113                 [case "${enableval}" in
114                         yes) have_tcpwrap=yes ;;
115                         no) have_tcpwrap=no ;;
116                         *) AC_MSG_ERROR(bad value ${enableval} for --disable-tcpwrap) ;;
117                 esac],
118                 [have_tcpwrap=auto])
119
120 if test "x${have_tcpwrap}" != xno ; then
121         ACX_LIBWRAP
122         if test "x${LIBWRAP_LIBS}" = x ; then
123                 if test "x$have_tcpwrap" = xyes ; then
124                         AC_MSG_ERROR([*** TCP wrappers support not found.])
125                 fi
126                 have_tcpwrap=no
127         else
128                 have_tcpwrap=yes
129         fi
130 else
131         LIBWRAP_LIBS=
132 fi
133 AC_SUBST(LIBWRAP_LIBS)
134
135 AC_ARG_ENABLE([pam],
136         AS_HELP_STRING([--disable-pam],[Disable optional PAM support]),
137                 [case "${enableval}" in
138                         yes) have_pam=yes ;;
139                         no) have_pam=no ;;
140                         *) AC_MSG_ERROR(bad value ${enableval} for --disable-pam) ;;
141                 esac],
142                 [have_pam=auto])
143
144 if test "x${have_pam}" != xno ; then
145         AC_CHECK_HEADERS(
146                 [security/pam_modules.h security/pam_modutil.h security/pam_ext.h],
147                 [have_pam=yes],
148                 [if test "x$have_pam" = xyes ; then
149                         AC_MSG_ERROR([*** PAM headers not found.])
150                 fi])
151
152         AC_CHECK_LIB(
153                 [pam],
154                 [pam_syslog],
155                 [have_pam=yes],
156                 [if test "x$have_pam" = xyes ; then
157                         AC_MSG_ERROR([*** libpam not found.])
158                 fi])
159
160         if test "x$have_pam" = xyes ; then
161                 PAM_LIBS="-lpam -lpam_misc"
162                 AC_DEFINE(HAVE_PAM, 1, [PAM available])
163         else
164                 have_pam=no
165         fi
166 else
167         PAM_LIBS=
168 fi
169 AC_SUBST(PAM_LIBS)
170 AM_CONDITIONAL([HAVE_PAM], [test "x$have_pam" != xno])
171
172 have_gtk=no
173 AC_ARG_ENABLE(gtk, AS_HELP_STRING([--disable-gtk], [disable GTK tools]))
174 if test "x$enable_gtk" != "xno"; then
175         PKG_CHECK_MODULES(GTK, [ gtk+-2.0 ],
176                 [AC_DEFINE(HAVE_GTK, 1, [Define if GTK is available]) have_gtk=yes], have_gtk=no)
177         AC_SUBST(GTK_CFLAGS)
178         AC_SUBST(GTK_LIBS)
179         if test "x$have_gtk" = xno -a "x$enable_gtk" = xyes; then
180              AC_MSG_ERROR([*** gtk support requested but libraries not found])
181         fi
182 fi
183 AM_CONDITIONAL(HAVE_GTK, [test "$have_gtk" = "yes"])
184
185 AM_PROG_VALAC([0.8])
186 AC_SUBST(VAPIDIR)
187 AM_CONDITIONAL(HAVE_VALAC, test x"$VALAC" != x)
188
189 AC_PATH_PROG([XSLTPROC], [xsltproc])
190 AM_CONDITIONAL(HAVE_XSLTPROC, test x"$XSLTPROC" != x)
191
192 AC_PATH_PROG([M4], [m4])
193
194 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]))
195 if test "z$with_distro" = "z"; then
196         if test "$cross_compiling" = yes; then
197                 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)])
198         else
199                 AC_CHECK_FILE(/etc/redhat-release,with_distro="fedora")
200                 AC_CHECK_FILE(/etc/SuSE-release,with_distro="suse")
201                 AC_CHECK_FILE(/etc/debian_version,with_distro="debian")
202                 AC_CHECK_FILE(/etc/arch-release,with_distro="arch")
203                 AC_CHECK_FILE(/etc/gentoo-release,with_distro="gentoo")
204                 AC_CHECK_FILE(/etc/slackware-version,with_distro="slackware")
205         fi
206         if test "z$with_distro" = "z"; then
207                 with_distro=`uname -s`
208         fi
209 fi
210 with_distro=`echo ${with_distro} | tr '[[:upper:]]' '[[:lower:]]' `
211
212 # Default generic names
213 SPECIAL_DBUS_SERVICE=dbus.service
214 SPECIAL_SYSLOG_SERVICE=syslog.service
215
216 # Location of the init scripts as mandated by LSB
217 SYSTEM_SYSVINIT_PATH=/etc/init.d
218
219 M4_DISTRO_FLAG=
220
221 case $with_distro in
222         fedora)
223                 SYSTEM_SYSVINIT_PATH=/etc/rc.d/init.d
224                 SYSTEM_SYSVRCND_PATH=/etc/rc.d
225
226                 # A little background why we define these special unit
227                 # names here in configure.ac: SysV services currently
228                 # cannot have aliases. As long as syslog is started
229                 # via a SysV init script we hence define these names
230                 # to the actual SysV name here. Later on when SysV
231                 # init scripts are not used anymore it is advisable to
232                 # use the generic names instead and use symlinks in
233                 # the unit directories to point to the right native
234                 # unit file.
235
236                 SPECIAL_DBUS_SERVICE=messagebus.service
237                 SPECIAL_SYSLOG_SERVICE=rsyslog.service
238                 AC_DEFINE(TARGET_FEDORA, [], [Target is Fedora/RHEL])
239                 M4_DISTRO_FLAG=-DTARGET_FEDORA=1
240                 ;;
241         suse)
242                 SYSTEM_SYSVRCND_PATH=/etc/init.d
243                 AC_DEFINE(TARGET_SUSE, [], [Target is OpenSUSE/SLE])
244                 M4_DISTRO_FLAG=-DTARGET_SUSE=1
245                 ;;
246         debian)
247                 SYSTEM_SYSVRCND_PATH=/etc
248                 SPECIAL_SYSLOG_SERVICE=rsyslog.service
249                 AC_DEFINE(TARGET_DEBIAN, [], [Target is Debian/Ubuntu])
250                 M4_DISTRO_FLAG=-DTARGET_DEBIAN=1
251                 ;;
252         arch)
253                 SYSTEM_SYSVINIT_PATH=/etc/rc.d
254                 SYSTEM_SYSVRCND_PATH=/etc
255                 SPECIAL_SYSLOG_SERVICE=syslog-ng.service
256                 AC_DEFINE(TARGET_ARCH, [], [Target is ArchLinux])
257                 M4_DISTRO_FLAG=-DTARGET_ARCH=1
258                 ;;
259         gentoo)
260                 SYSTEM_SYSVRCND_PATH=/etc
261                 SPECIAL_SYSLOG_SERVICE=syslog-ng.service
262                 AC_DEFINE(TARGET_GENTOO, [], [Target is Gentoo])
263                 M4_DISTRO_FLAG=-DTARGET_GENTOO=1
264                 ;;
265         slackware)
266                 SYSTEM_SYSVINIT_PATH=/etc/rc.d/init.d
267                 SYSTEM_SYSVRCND_PATH=/etc/rc.d
268                 SPECIAL_DBUS_SERVICE=messagebus.service
269                 AC_DEFINE(TARGET_SLACKWARE, [], [Target is Slackware])
270                 M4_DISTRO_FLAG=-DTARGET_SLACKWARE=1
271                 ;;
272         other)
273                 AS_IF([test "x$with_sysvinit_path" = "x"],
274                         [AC_MSG_ERROR([With --distro=other, you must pass --with-sysvinit-path= to configure])])
275                 AS_IF([test "x$with_sysvrcd_path" = "x"],
276                         [AC_MSG_ERROR([With --distro=other, you must pass --with-sysvrcd-path= to configure])])
277                 AS_IF([test "x$with_dbus_service" = "x"],
278                         [AC_MSG_ERROR([With --distro=other, you must pass --with-dbus-service= to configure])])
279                 AS_IF([test "x$with_syslog_service" = "x"],
280                         [AC_MSG_ERROR([With --distro=other, you must pass --with-syslog-service= to configure])])
281                 ;;
282         *)
283                 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])
284                 ;;
285 esac
286
287 AC_ARG_WITH([sysvinit-path],
288         [AS_HELP_STRING([--with-sysvinit-path=PATH],
289                 [Specify the path to where the SysV init scripts are located @<:@default=based on distro@:>@])],
290         [SYSTEM_SYSVINIT_PATH="$withval"],
291         [])
292
293 AC_ARG_WITH([sysvrcd-path],
294         [AS_HELP_STRING([--with-sysvrcd-path=PATH],
295                 [Specify the path to the base directory for the SysV rcN.d directories @<:@default=based on distro@:>@])],
296         [SYSTEM_SYSVRCND_PATH="$withval"],
297         [])
298
299 AC_ARG_WITH([dbus-service],
300         [AS_HELP_STRING([--with-dbus-service=UNIT],
301                 [Specify the name of the special DBus service @<:@default=based on distro@:>@])],
302         [SPECIAL_DBUS_SERVICE="$withval"],
303         [])
304
305 AC_ARG_WITH([syslog-service],
306         [AS_HELP_STRING([--with-syslog-service=UNIT],
307                 [Specify the name of the special syslog service @<:@default=based on distro@:>@])],
308         [SPECIAL_SYSLOG_SERVICE="$withval"],
309         [])
310
311 AC_SUBST(SYSTEM_SYSVINIT_PATH)
312 AC_SUBST(SYSTEM_SYSVRCND_PATH)
313 AC_SUBST(SPECIAL_DBUS_SERVICE)
314 AC_SUBST(SPECIAL_SYSLOG_SERVICE)
315 AC_SUBST(M4_DISTRO_FLAG)
316
317 AM_CONDITIONAL(TARGET_FEDORA, test x"$with_distro" = xfedora)
318 AM_CONDITIONAL(TARGET_SUSE, test x"$with_distro" = xsuse)
319 AM_CONDITIONAL(TARGET_DEBIAN, test x"$with_distro" = xdebian)
320 AM_CONDITIONAL(TARGET_ARCH, test x"$with_distro" = xarch)
321 AM_CONDITIONAL(TARGET_GENTOO, test x"$with_distro" = xgentoo)
322 AM_CONDITIONAL(TARGET_SLACKWARE, test x"$with_distro" = xslackware)
323
324 AC_DEFINE_UNQUOTED(SPECIAL_DBUS_SERVICE, ["$SPECIAL_DBUS_SERVICE"], [D-Bus service name])
325 AC_DEFINE_UNQUOTED(SPECIAL_SYSLOG_SERVICE, ["$SPECIAL_SYSLOG_SERVICE"], [Syslog service name])
326
327 AC_ARG_WITH([dbuspolicydir],
328         AS_HELP_STRING([--with-dbuspolicydir=DIR], [D-Bus policy directory]),
329         [],
330         [with_dbuspolicydir=`pkg-config --variable=sysconfdir dbus-1`/dbus-1/system.d])
331
332 AC_ARG_WITH([dbussessionservicedir],
333         AS_HELP_STRING([--with-dbussessionservicedir=DIR], [D-Bus session service directory]),
334         [],
335         [with_dbussessionservicedir=`pkg-config --variable=session_bus_services_dir dbus-1`])
336
337 AC_ARG_WITH([dbussystemservicedir],
338         AS_HELP_STRING([--with-dbussystemservicedir=DIR], [D-Bus system service directory]),
339         [],
340         [with_dbussystemservicedir=`pkg-config --variable=session_bus_services_dir dbus-1`/../system-services])
341
342 AC_ARG_WITH([dbusinterfacedir],
343         AS_HELP_STRING([--with-dbusinterfacedir=DIR], [D-Bus interface directory]),
344         [],
345         [with_dbusinterfacedir=`pkg-config --variable=session_bus_services_dir dbus-1`/../interfaces])
346
347 AC_ARG_WITH([udevrulesdir],
348         AS_HELP_STRING([--with-udevrulesdir=DIR], [Diectory for udev rules]),
349         [],
350         [with_udevrulesdir=/lib/udev/rules.d])
351
352 AC_ARG_WITH([rootdir],
353         AS_HELP_STRING([--with-rootdir=DIR], [Root directory for files necessary for boot]),
354         [],
355         [with_rootdir=${ac_default_prefix}])
356
357 AC_SUBST([dbuspolicydir], [$with_dbuspolicydir])
358 AC_SUBST([dbussessionservicedir], [$with_dbussessionservicedir])
359 AC_SUBST([dbussystemservicedir], [$with_dbussystemservicedir])
360 AC_SUBST([dbusinterfacedir], [$with_dbusinterfacedir])
361 AC_SUBST([udevrulesdir], [$with_udevrulesdir])
362 AC_SUBST([rootdir], [$with_rootdir])
363
364 AC_CONFIG_FILES([Makefile])
365 AC_OUTPUT
366
367 echo "
368         $PACKAGE_NAME $VERSION
369
370         Distribution:            ${with_distro}
371         SysV init scripts:       ${SYSTEM_SYSVINIT_PATH}
372         SysV rc?.d directories:  ${SYSTEM_SYSVRCND_PATH}
373         Syslog service:          ${SPECIAL_SYSLOG_SERVICE}
374         D-Bus service:           ${SPECIAL_DBUS_SERVICE}
375         Gtk:                     ${have_gtk}
376         tcpwrap:                 ${have_tcpwrap}
377         PAM:                     ${have_pam}
378         prefix:                  ${prefix}
379         root dir:                ${with_rootdir}
380         udev rules dir:          ${with_udevrulesdir}
381         dbus policy dir:         ${with_dbuspolicydir}
382         dbus session dir:        ${with_dbussessionservicedir}
383         dbus system dir:         ${with_dbussystemservicedir}
384         dbus interfaces dir:     ${with_dbusinterfacedir}
385 "