Merging upstream version 0.5.3 (Closes: #805659 CVE-2015-8308).
[debian/lxdm.git] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ([2.63])
5 AC_INIT([lxdm], [0.5.3], [http://lxde.org/])
6 AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects no-dist-gzip dist-xz])
7
8 AC_CONFIG_SRCDIR([src/lxdm.c])
9 AC_CONFIG_HEADERS([config.h])
10
11 # Checks for programs.
12 AC_PROG_CC
13 AC_PROG_INSTALL
14 AM_PROG_CC_C_O
15
16 # Checks for libraries.
17 AC_CHECK_LIB([crypt], [crypt])
18
19 # Check for PAM support
20 AC_ARG_WITH(pam, AC_HELP_STRING([--with-pam],[Use PAM for authentication]),
21         [USE_PAM=$withval], [USE_PAM=$use_pam_default])
22 if test "x$USE_PAM" != "xno" ; then
23         AC_SEARCH_LIBS(pam_open_session,[pam])
24         AC_CHECK_FUNC(pam_open_session, 
25                 [USE_PAM=1
26                         AC_DEFINE(USE_PAM,1,[Use PAM for authentication])],
27                 [if test "x$USE_PAM" != "xtry" ; then
28                         AC_MSG_ERROR(["PAM support requested, but pam_open_session not found."])
29                  fi])
30 fi
31 AM_CONDITIONAL(HAVE_PAM, [test -n "$USE_PAM" -a "x$USE_PAM" != xno ])
32
33 # Checks for header files.
34 AC_PATH_X
35 AC_CHECK_HEADERS([shadow.h stdlib.h string.h unistd.h utmpx.h])
36
37 # Checks for typedefs, structures, and compiler characteristics.
38 AC_TYPE_PID_T
39
40 # Checks for library functions.
41 AC_FUNC_FORK
42 AC_CHECK_FUNCS([atexit endpwent getspnam getusershell memset putenv strstr])
43
44 PKG_CONFIG=pkg-config # FIXME: is this OK?
45 # Check for ISO Codes, this is taken from gdm
46 AC_MSG_CHECKING([whether iso-codes has iso-639 domain])
47 if $PKG_CONFIG --variable=domains iso-codes | grep 639 >/dev/null ; then
48         AC_MSG_RESULT([yes])
49 else
50         AC_MSG_RESULT([no])
51 fi
52 AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX],["`$PKG_CONFIG --variable=prefix iso-codes`"],[ISO codes prefix])
53 ISO_CODES=iso-codes
54
55 IT_PROG_INTLTOOL([0.40.0])
56
57 PKG_CHECK_MODULES(XLIB,x11)
58 AC_SUBST(XLIB_CFLAGS)
59 AC_SUBST(XLIB_LIBS)
60
61 PKG_CHECK_MODULES(GLIB,glib-2.0)
62 AC_SUBST(GLIB_CFLAGS)
63 AC_SUBST(GLIB_LIBS)
64
65 AC_ARG_ENABLE(gtk3,
66 AC_HELP_STRING([--enable-gtk3],[enable to use gtk-3.0 instead of gtk-2.0]),
67 [case "${enableval}" in
68   yes)  enable_gtk3=yes ;;
69   no)   enable_gtk3=no ;;
70   *) AC_MSG_ERROR([bad value "${enableval}" for --enable-gtk3, use "yes" (default) or "no".]) ;;
71 esac],[])
72
73 if test "x$enable_gtk3" = "xyes" ; then
74   pkg_modules="gdk-3.0"
75 else
76   pkg_modules="gdk-2.0"
77 fi
78 PKG_CHECK_MODULES(GDK,[$pkg_modules])
79 AC_SUBST(GDK_CFLAGS)
80 AC_SUBST(GDK_LIBS)
81
82 if test "x$enable_gtk3" = "xyes" ; then
83   CFLAGS="$CFLAGS -DENABLE_GTK3"
84   pkg_modules="gtk+-3.0 >= 3.0.0"
85 else
86   pkg_modules="gtk+-2.0 >= 2.12.0"
87 fi
88 PKG_CHECK_MODULES(GTK, [$pkg_modules])
89 AC_SUBST(GTK_CFLAGS)
90 AC_SUBST(GTK_LIBS)
91
92
93 AC_ARG_ENABLE(consolekit,
94         AC_HELP_STRING([--disable-consolekit],[disable ConsoleKit support]),
95         [enable_consolekit=$enableval],
96         [enable_consolekit=yes]
97 )
98
99 if test "x$enable_consolekit" = "xyes" ; then
100   PKG_CHECK_MODULES(CONSOLEKIT, "ck-connector",[
101         AC_SUBST(CONSOLEKIT_CFLAGS)
102         AC_SUBST(CONSOLEKIT_LIBS)],[
103         echo "ConsoleKit devel package not found"
104         ])
105   AC_CHECK_LIB([ck-connector],[ck_connector_open_session])
106 fi
107
108
109 AC_ARG_ENABLE(password,
110 AC_HELP_STRING([--enable-password],[enable to load autologin password store at config file]),
111 [case "${enableval}" in
112   yes)  enable_password=yes ;;
113   no)   enable_password=no ;;
114   *) AC_MSG_ERROR([bad value "${enableval}" for --enable-password, use "yes" (default) or "no".]) ;;
115 esac],[])
116
117 if test "x$enable_password" = "xyes" ; then
118   CFLAGS="$CFLAGS -DENABLE_PASSWORD"
119 fi
120
121 AC_ARG_ENABLE(xauth,
122         AC_HELP_STRING([--disable-xauth],[disable the xauth support ]),
123         [enable_xauth=$enablevar],
124         [enable_xauth=yes]
125 )
126
127 if test "x$enable_xauth" = "x$no" ; then
128   CFLAGS="$CFLAGS -DDISABLE_XAUTH"
129 fi
130
131 AC_ARG_ENABLE(debug,
132     AC_HELP_STRING([--enable-debug],[enable detailed debug]),
133     [enable_debug=$enablevar],
134     [enable_debug=yes]
135 )
136 if test "x$enable_debug" = "x$yes" ; then
137         CFLAGS="$CFLAGS -DLXDM_DEBUG"
138 fi
139
140 AC_ARG_WITH(xconn,
141         [AC_HELP_STRING([--with-xconn=@<:@xlib/xcb@:>@],[use xlib or xcb to use])],
142         [if test "x$with_xconn" = "xxlib"; then
143                 PKG_CHECK_MODULES(XCONN,"x11")
144                 AC_SUBST(XCONN_CFLAGS)
145                 AC_SUBST(XCONN_LIBS)
146                 CFLAGS="$CFLAGS -DLXDM_XCONN_XLIB"
147
148          else
149                 PKG_CHECK_MODULES(XCONN,"xcb")
150                 AC_SUBST(XCONN_CFLAGS)
151                 AC_SUBST(XCONN_LIBS)
152                 CFLAGS="$CFLAGS -DLXDM_XCONN_XCB"
153          fi],
154         [PKG_CHECK_MODULES(XCONN,"xcb")
155          AC_SUBST(XCONN_CFLAGS)
156          AC_SUBST(XCONN_LIBS)
157          CFLAGS="$CFLAGS -DLXDM_XCONN_XCB"
158         ]
159 )
160
161 AC_ARG_WITH([systemdsystemunitdir],
162         AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
163         [], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
164 if test "x$with_systemdsystemunitdir" != xno; then
165         AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
166 fi
167 AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
168
169 GETTEXT_PACKAGE=lxdm
170 AC_SUBST(GETTEXT_PACKAGE)
171 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
172
173 AC_DEFUN([AS_AC_EXPAND],[
174         EXP_VAR=[$1]
175         FROM_VAR=[$2]
176         dnl first expand prefix and exec_prefix if necessary
177         prefix_save=$prefix
178         exec_prefix_save=$exec_prefix
179         dnl if no prefix given, then use /usr/local, the default prefix
180         if test "x$prefix" = "xNONE"; then
181         prefix="$ac_default_prefix"
182         fi
183         dnl if no exec_prefix given, then use prefix
184         if test "x$exec_prefix" = "xNONE"; then
185         exec_prefix=$prefix
186         fi
187         full_var="$FROM_VAR"
188         dnl loop until it doesn not change anymore
189         while true; do
190         new_full_var="`eval echo $full_var`"
191         if test "x$new_full_var" = "x$full_var"; then break; fi
192         full_var=$new_full_var
193         done
194         dnl clean up
195         full_var=$new_full_var
196         AC_SUBST([$1], "$full_var")
197         dnl restore prefix and exec_prefix
198         prefix=$prefix_save
199         exec_prefix=$exec_prefix_save
200 ])
201 AS_AC_EXPAND(FULL_LIBEXECDIR, $libexecdir)
202
203 AC_CONFIG_FILES([
204         Makefile
205         lxdm.spec
206         src/Makefile
207         po/Makefile.in
208         pam/Makefile
209         systemd/Makefile
210         data/Makefile
211         data/PostLogin
212         data/PostLogout
213         data/PreLogin
214         data/PreReboot
215         data/PreShutdown
216         data/LoginReady
217         data/lxdm.conf
218 ])
219 AC_CONFIG_FILES([data/lxdm], [chmod +x data/lxdm])
220 AC_OUTPUT
221
222 dnl sanity checks
223 if test "$sysconfdir" != "/etc"; then
224    AC_MSG_WARN(sysconfdir is not /etc.)
225    AC_MSG_WARN(Please consider passing --sysconfdir=/etc to configure.)
226 fi