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