chiark / gitweb /
cd7aaff0c0ebda9ab6c832d2c3cc3532c47e0afd
[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],[mzflfgrzq (at) 0pointer (dot) net])
21 AC_CONFIG_SRCDIR([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])
26
27 AC_SUBST(PACKAGE_URL, [http://git.0pointer.de/?p=systemd.git])
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_CC
41 AC_PROG_CC_C99
42 AM_PROG_CC_C_O
43 AC_PROG_GCC_TRADITIONAL
44 AC_USE_SYSTEM_EXTENSIONS
45
46 CC_CHECK_CFLAGS_APPEND([ \
47         -Wall \
48         -W \
49         -Wextra \
50         -pipe \
51         -Wno-long-long \
52         -Winline \
53         -Wvla \
54         -Wno-overlength-strings \
55         -Wundef \
56         -Wformat=2 \
57         -Wlogical-op \
58         -Wsign-compare \
59         -Wformat-security \
60         -Wmissing-include-dirs \
61         -Wformat-nonliteral \
62         -Wold-style-definition \
63         -Wpointer-arith \
64         -Winit-self \
65         -Wdeclaration-after-statement \
66         -Wfloat-equal \
67         -Wmissing-prototypes \
68         -Wstrict-prototypes \
69         -Wredundant-decls \
70         -Wmissing-declarations \
71         -Wmissing-noreturn \
72         -Wshadow \
73         -Wendif-labels \
74         -Wcast-align \
75         -Wstrict-aliasing=2 \
76         -Wwrite-strings \
77         -Wno-unused-parameter \
78         -ffast-math \
79         -Wp,-D_FORTIFY_SOURCE=2 \
80         -fno-common \
81         -fdiagnostics-show-option \
82         -Wno-missing-field-initializers])
83
84 AC_SEARCH_LIBS([clock_gettime], [rt], [], [AC_MSG_ERROR([*** POSIX RT library not found])])
85 AC_SEARCH_LIBS([cap_init], [cap], [], [AC_MSG_ERROR([*** POSIX caps library not found])])
86 AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([*** POSIX caps headers not found])])
87
88 # This makes sure pkg.m4 is available.
89 m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-config])
90
91 PKG_CHECK_MODULES(UDEV, [ libudev ])
92 AC_SUBST(UDEV_CFLAGS)
93 AC_SUBST(UDEV_LIBS)
94
95 PKG_CHECK_MODULES(DBUS, [ dbus-1 ])
96 AC_SUBST(DBUS_CFLAGS)
97 AC_SUBST(DBUS_LIBS)
98
99 PKG_CHECK_MODULES(DBUSGLIB, [ dbus-glib-1 ])
100 AC_SUBST(DBUSGLIB_CFLAGS)
101 AC_SUBST(DBUSGLIB_LIBS)
102
103 have_gtk=no
104 AC_ARG_ENABLE(gtk, AS_HELP_STRING([--disable-gtk], [disable GTK tools]))
105 if test "x$enable_gtk" != "xno"; then
106         PKG_CHECK_MODULES(GTK, [ gtk+-2.0 ],
107                 [AC_DEFINE(HAVE_GTK, 1, [Define if GTK is available]) have_gtk=yes], have_gtk=no)
108         AC_SUBST(GTK_CFLAGS)
109         AC_SUBST(GTK_LIBS)
110         if test "x$have_gtk" = xno -a "x$enable_gtk" = xyes; then
111              AC_MSG_ERROR([*** gtk support requested but libraries not found])
112         fi
113 fi
114 AM_CONDITIONAL(HAVE_GTK, [test "$have_gtk" = "yes"])
115
116 PKG_CHECK_MODULES( CGROUP, [ libcgroup >= 0.35 ], [], [
117         AC_CHECK_HEADER( [libcgroup.h], [], [AC_MSG_ERROR([*** libcgroup.h not found])], )
118         save_CPPFLAGS="$CPPFLAGS"
119         save_LIBS="$LIBS"
120         CGROUP_LIBS=${CGROUP_LIBS:--lcgroup}
121         LIBS="$LIBS $CGROUP_LIBS"
122         CPPFLAGS="$CPPFLAGS $CGROUP_CFLAGS"
123         AC_MSG_CHECKING([for libcgroup >= 0.35])
124         AC_LINK_IFELSE(
125                 [AC_LANG_PROGRAM([[#include <libcgroup.h>]], [[ CGFLAG_DELETE_RECURSIVE; cgroup_init(); ]])],
126                 [AC_MSG_RESULT([yes])],
127                 [AC_MSG_RESULT([no]); AC_MSG_ERROR([*** systemd needs libcgroup 0.35 or newer])],
128                 [${CGROUP_LIBS}])
129         CPPFLAGS="$save_CPPFLAGS"
130         LIBS="$save_LIBS"
131 ])
132 AC_SUBST(CGROUP_CFLAGS)
133 AC_SUBST(CGROUP_LIBS)
134
135 AM_PROG_VALAC([0.8])
136 AC_SUBST(VAPIDIR)
137
138 AC_PATH_PROG([XSLTPROC], [xsltproc])
139 AM_CONDITIONAL(HAVE_XSLTPROC, test x"$XSLTPROC" != x)
140
141 AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO],[Specify the distribution to target: One of fedora, suse, debian, arch, gentoo, or none]))
142 if test "z$with_distro" = "z"; then
143         if test "$cross_compiling" = yes; then
144                 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)])
145         else
146                 AC_CHECK_FILE(/etc/redhat-release,with_distro="fedora")
147                 AC_CHECK_FILE(/etc/SuSE-release,with_distro="suse")
148                 AC_CHECK_FILE(/etc/debian_version,with_distro="debian")
149                 AC_CHECK_FILE(/etc/arch-release,with_distro="arch")
150                 AC_CHECK_FILE(/etc/gentoo-release,with_distro="gentoo")
151         fi
152         if test "z$with_distro" = "z"; then
153                 with_distro=`uname -s`
154         fi
155 fi
156 with_distro=`echo ${with_distro} | tr '[[:upper:]]' '[[:lower:]]' `
157
158 case $with_distro in
159         fedora)
160                 SYSTEM_SYSVINIT_PATH=/etc/rc.d/init.d
161                 SYSTEM_SYSVRCND_PATH=/etc/rc.d
162                 special_dbus_service=messagebus.service
163                 special_syslog_service=rsyslog.service
164                 AC_DEFINE(TARGET_FEDORA, [], [Target is Fedora/RHEL])
165                 ;;
166         suse)
167                 SYSTEM_SYSVINIT_PATH=/etc/init.d
168                 SYSTEM_SYSVRCND_PATH=/etc/init.d
169                 special_dbus_service=dbus.service
170                 special_syslog_service=syslog.service
171                 AC_DEFINE(TARGET_SUSE, [], [Target is OpenSUSE/SLES])
172                 ;;
173         debian)
174                 SYSTEM_SYSVINIT_PATH=/etc/init.d
175                 SYSTEM_SYSVRCND_PATH=/etc
176                 special_dbus_service=dbus.service
177                 special_syslog_service=rsyslog.service
178                 AC_DEFINE(TARGET_DEBIAN, [], [Target is Debian/Ubuntu])
179                 ;;
180         arch)
181                 SYSTEM_SYSVINIT_PATH=/etc/rc.d
182                 SYSTEM_SYSVRCND_PATH=/etc
183                 special_dbus_service=dbus.service
184                 special_syslog_service=syslog-ng.service
185                 AC_DEFINE(TARGET_ARCH, [], [Target is ArchLinux])
186                 ;;
187         gentoo)
188                 SYSTEM_SYSVINIT_PATH=/etc/init.d
189                 SYSTEM_SYSVRCND_PATH=/etc
190                 special_dbus_service=dbus.service
191                 special_syslog_service=syslog-ng.service
192                 AC_DEFINE(TARGET_GENTOO, [], [Target is Gentoo])
193                 ;;
194         none)
195                 SYSTEM_SYSVINIT_PATH=/fix/the/configure/script
196                 SYSTEM_SYSVRCND_PATH=/fix/the/configure/script
197                 special_dbus_service=fix-the-configure-script.service
198                 special_syslog_service=fix-the-configure-script.service
199                 ;;
200         *)
201                 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=none to skip this check])
202                 ;;
203 esac
204
205 AC_SUBST(SYSTEM_SYSVINIT_PATH)
206 AC_SUBST(SYSTEM_SYSVRCND_PATH)
207
208 AM_CONDITIONAL(TARGET_FEDORA, test x"$with_distro" = xfedora)
209 AM_CONDITIONAL(TARGET_SUSE, test x"$with_distro" = xsuse)
210 AM_CONDITIONAL(TARGET_DEBIAN, test x"$with_distro" = xdebian)
211 AM_CONDITIONAL(TARGET_ARCH, test x"$with_distro" = xarch)
212 AM_CONDITIONAL(TARGET_GENTOO, test x"$with_distro" = xgentoo)
213
214 AC_DEFINE_UNQUOTED(SPECIAL_DBUS_SERVICE, ["$special_dbus_service"], [D-Bus service name])
215 AC_DEFINE_UNQUOTED(SPECIAL_SYSLOG_SERVICE, ["$special_syslog_service"], [syslog service name])
216
217 AC_ARG_WITH([udevrulesdir],
218         AS_HELP_STRING([--with-udevrulesdir=DIR], [Diectory for udev rules]),
219         [],
220         [with_udevrulesdir=/lib/udev/rules.d])
221 AC_SUBST([udevrulesdir], [$with_udevrulesdir])
222
223
224 AC_OUTPUT([Makefile])
225
226 echo "
227         $PACKAGE_NAME $VERSION
228
229         Distribution:            ${with_distro}
230         SysV init scripts:       ${SYSTEM_SYSVINIT_PATH}
231         SysV rc?.d directories:  ${SYSTEM_SYSVRCND_PATH}
232         Syslog service:          ${special_syslog_service}
233         D-Bus service:           ${special_dbus_service}
234         Gtk:                     ${have_gtk}
235         udev rules dir:          ${with_udevrulesdir}
236 "