chiark / gitweb /
units: add distribution-specific units
[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])
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 ])
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 have_gtk=no
108 AC_ARG_ENABLE(gtk, AS_HELP_STRING([--disable-gtk], [disable GTK tools]))
109 if test "x$enable_gtk" != "xno"; then
110         PKG_CHECK_MODULES(GTK, [ gtk+-2.0 ],
111                 [AC_DEFINE(HAVE_GTK, 1, [Define if GTK is available]) have_gtk=yes], have_gtk=no)
112         AC_SUBST(GTK_CFLAGS)
113         AC_SUBST(GTK_LIBS)
114         if test "x$have_gtk" = xno -a "x$enable_gtk" = xyes; then
115              AC_MSG_ERROR([*** gtk support requested but libraries not found])
116         fi
117 fi
118 AM_CONDITIONAL(HAVE_GTK, [test "$have_gtk" = "yes"])
119
120 PKG_CHECK_MODULES( CGROUP, [ libcgroup >= 0.35 ], [], [
121         AC_CHECK_HEADER( [libcgroup.h], [], [AC_MSG_ERROR([*** libcgroup.h not found])], )
122         save_CPPFLAGS="$CPPFLAGS"
123         save_LIBS="$LIBS"
124         CGROUP_LIBS=${CGROUP_LIBS:--lcgroup}
125         LIBS="$LIBS $CGROUP_LIBS"
126         CPPFLAGS="$CPPFLAGS $CGROUP_CFLAGS"
127         AC_MSG_CHECKING([for libcgroup >= 0.35])
128         AC_LINK_IFELSE(
129                 [AC_LANG_PROGRAM([[#include <libcgroup.h>]], [[ CGFLAG_DELETE_RECURSIVE; cgroup_init(); ]])],
130                 [AC_MSG_RESULT([yes])],
131                 [AC_MSG_RESULT([no]); AC_MSG_ERROR([*** systemd needs libcgroup 0.35 or newer])],
132                 [${CGROUP_LIBS}])
133         CPPFLAGS="$save_CPPFLAGS"
134         LIBS="$save_LIBS"
135 ])
136 AC_SUBST(CGROUP_CFLAGS)
137 AC_SUBST(CGROUP_LIBS)
138
139 AM_PROG_VALAC([0.8])
140 AC_SUBST(VAPIDIR)
141
142 AC_PATH_PROG([XSLTPROC], [xsltproc])
143 AM_CONDITIONAL(HAVE_XSLTPROC, test x"$XSLTPROC" != x)
144
145 AC_PATH_PROG([M4], [m4])
146
147 AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO],[Specify the distribution to target: One of fedora, suse, debian, arch, gentoo or other]))
148 if test "z$with_distro" = "z"; then
149         if test "$cross_compiling" = yes; then
150                 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)])
151         else
152                 AC_CHECK_FILE(/etc/redhat-release,with_distro="fedora")
153                 AC_CHECK_FILE(/etc/SuSE-release,with_distro="suse")
154                 AC_CHECK_FILE(/etc/debian_version,with_distro="debian")
155                 AC_CHECK_FILE(/etc/arch-release,with_distro="arch")
156                 AC_CHECK_FILE(/etc/gentoo-release,with_distro="gentoo")
157                 AC_CHECK_FILE(/etc/slackware-version,with_distro="slackware")
158         fi
159         if test "z$with_distro" = "z"; then
160                 with_distro=`uname -s`
161         fi
162 fi
163 with_distro=`echo ${with_distro} | tr '[[:upper:]]' '[[:lower:]]' `
164
165 # Default generic names
166 SPECIAL_DBUS_SERVICE=dbus.service
167 SPECIAL_SYSLOG_SERVICE=syslog.service
168
169 # Location of the init scripts as mandated by LSB
170 SYSTEM_SYSVINIT_PATH=/etc/init.d
171
172 case $with_distro in
173         fedora)
174                 SYSTEM_SYSVINIT_PATH=/etc/rc.d/init.d
175                 SYSTEM_SYSVRCND_PATH=/etc/rc.d
176
177                 # A little background why we define these special unit
178                 # names here in configure.ac: SysV services currently
179                 # cannot have aliases. As long as syslog is started
180                 # via a SysV init script we hence define these names
181                 # to the actual SysV name here. Later on when SysV
182                 # init scripts are not used anymore it is advisable to
183                 # use the generic names instead and use symlinks in
184                 # the unit directories to point to the right native
185                 # unit file.
186
187                 SPECIAL_DBUS_SERVICE=messagebus.service
188                 SPECIAL_SYSLOG_SERVICE=rsyslog.service
189                 AC_DEFINE(TARGET_FEDORA, [], [Target is Fedora/RHEL])
190                 ;;
191         suse)
192                 SYSTEM_SYSVRCND_PATH=/etc/init.d
193                 AC_DEFINE(TARGET_SUSE, [], [Target is OpenSUSE/SLES])
194                 ;;
195         debian)
196                 SYSTEM_SYSVRCND_PATH=/etc
197                 SPECIAL_SYSLOG_SERVICE=rsyslog.service
198                 AC_DEFINE(TARGET_DEBIAN, [], [Target is Debian/Ubuntu])
199                 ;;
200         arch)
201                 SYSTEM_SYSVINIT_PATH=/etc/rc.d
202                 SYSTEM_SYSVRCND_PATH=/etc
203                 SPECIAL_SYSLOG_SERVICE=syslog-ng.service
204                 AC_DEFINE(TARGET_ARCH, [], [Target is ArchLinux])
205                 ;;
206         gentoo)
207                 SYSTEM_SYSVRCND_PATH=/etc
208                 SPECIAL_SYSLOG_SERVICE=syslog-ng.service
209                 AC_DEFINE(TARGET_GENTOO, [], [Target is Gentoo])
210                 ;;
211         slackware)
212                 SYSTEM_SYSVINIT_PATH=/etc/rc.d/init.d
213                 SYSTEM_SYSVRCND_PATH=/etc/rc.d
214                 SPECIAL_DBUS_SERVICE=messagebus.service
215                 AC_DEFINE(TARGET_SLACKWARE, [], [Target is Slackware])
216                 ;;
217         other)
218                 AS_IF([test "x$with_sysvinit_path" = "x"],
219                         [AC_MSG_ERROR([With --distro=none, you must pass --with-sysvinit-path= to configure])])
220                 AS_IF([test "x$with_sysvrcd_path" = "x"],
221                         [AC_MSG_ERROR([With --distro=none, you must pass --with-sysvrcd-path= to configure])])
222                 AS_IF([test "x$with_dbus_service" = "x"],
223                         [AC_MSG_ERROR([With --distro=none, you must pass --with-dbus-service= to configure])])
224                 AS_IF([test "x$with_syslog_service" = "x"],
225                         [AC_MSG_ERROR([With --distro=none, you must pass --with-syslog-service= to configure])])
226                 ;;
227         *)
228                 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])
229                 ;;
230 esac
231
232 AC_ARG_WITH([sysvinit-path],
233         [AS_HELP_STRING([--with-sysvinit-path=PATH],
234                 [Specify the path to where the SysV init scripts are located @<:@default=based on distro@:>@])],
235         [SYSTEM_SYSVINIT_PATH="$withval"],
236         [])
237
238 AC_ARG_WITH([sysvrcd-path],
239         [AS_HELP_STRING([--with-sysvrcd-path=PATH],
240                 [Specify the path to the base directory for the SysV rcN.d directories @<:@default=based on distro@:>@])],
241         [SYSTEM_SYSVRCND_PATH="$withval"],
242         [])
243
244 AC_ARG_WITH([dbus-service],
245         [AS_HELP_STRING([--with-dbus-service=PATH],
246                 [Specify the name of the special DBus service @<:@default=based on distro@:>@])],
247         [SPECIAL_DBUS_SERVICE="$withval"],
248         [])
249
250 AC_ARG_WITH([syslog-service],
251         [AS_HELP_STRING([--with-syslog-service=PATH],
252                 [Specify the name of the special syslog service @<:@default=based on distro@:>@])],
253         [SPECIAL_SYSLOG_SERVICE="$withval"],
254         [])
255
256 AC_SUBST(SYSTEM_SYSVINIT_PATH)
257 AC_SUBST(SYSTEM_SYSVRCND_PATH)
258 AC_SUBST(SPECIAL_DBUS_SERVICE)
259 AC_SUBST(SPECIAL_SYSLOG_SERVICE)
260
261 AM_CONDITIONAL(TARGET_FEDORA, test x"$with_distro" = xfedora)
262 AM_CONDITIONAL(TARGET_SUSE, test x"$with_distro" = xsuse)
263 AM_CONDITIONAL(TARGET_DEBIAN, test x"$with_distro" = xdebian)
264 AM_CONDITIONAL(TARGET_ARCH, test x"$with_distro" = xarch)
265 AM_CONDITIONAL(TARGET_GENTOO, test x"$with_distro" = xgentoo)
266 AM_CONDITIONAL(TARGET_SLACKWARE, test x"$with_distro" = xslackware)
267
268 AC_DEFINE_UNQUOTED(SPECIAL_DBUS_SERVICE, ["$SPECIAL_DBUS_SERVICE"], [D-Bus service name])
269 AC_DEFINE_UNQUOTED(SPECIAL_SYSLOG_SERVICE, ["$SPECIAL_SYSLOG_SERVICE"], [Syslog service name])
270
271 AC_ARG_WITH([udevrulesdir],
272         AS_HELP_STRING([--with-udevrulesdir=DIR], [Diectory for udev rules]),
273         [],
274         [with_udevrulesdir=/lib/udev/rules.d])
275 AC_SUBST([udevrulesdir], [$with_udevrulesdir])
276
277 AC_OUTPUT([Makefile])
278
279 echo "
280         $PACKAGE_NAME $VERSION
281
282         Distribution:            ${with_distro}
283         SysV init scripts:       ${SYSTEM_SYSVINIT_PATH}
284         SysV rc?.d directories:  ${SYSTEM_SYSVRCND_PATH}
285         Syslog service:          ${SPECIAL_SYSLOG_SERVICE}
286         D-Bus service:           ${SPECIAL_DBUS_SERVICE}
287         Gtk:                     ${have_gtk}
288         udev rules dir:          ${with_udevrulesdir}
289 "