configure.in 12.6 KB
Newer Older
David Zeuthen's avatar
David Zeuthen committed
1 2
dnl Process this file with autoconf to produce a configure script.

3
AC_PREREQ(2.59c)
4 5
AC_INIT(PolicyKit, 0.3, david@fubar.dk)
AM_INIT_AUTOMAKE(PolicyKit, 0.3)
David Zeuthen's avatar
David Zeuthen committed
6 7 8 9 10 11 12
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE

# libtool versioning - this applies to libpolkit
#
# See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
#
13
LT_CURRENT=1
David Zeuthen's avatar
David Zeuthen committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
LT_REVISION=0
LT_AGE=0
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)

AC_ISC_POSIX
AC_PROG_CC
AM_PROG_CC_STDC
AC_HEADER_STDC
AM_PROG_LIBTOOL
AC_PROG_MAKE_SET
AC_PROG_LN_S
AC_SYS_LARGEFILE

# Taken from dbus
AC_ARG_ENABLE(ansi,             [  --enable-ansi           enable -ansi -pedantic gcc flags],enable_ansi=$enableval,enable_ansi=no)
AC_ARG_ENABLE(verbose-mode,     [  --enable-verbose-mode   support verbose debug mode],enable_verbose_mode=$enableval,enable_verbose_mode=$USE_MAINTAINER_MODE)
32 33 34
AC_ARG_ENABLE(docbook-docs,     [  --enable-docbook-docs   build documentation (requires xmlto)],enable_docbook_docs=$enableval,enable_docbook_docs=no)
AC_ARG_ENABLE(man-pages,        [  --enable-man-pages      build manual pages],enable_man_pages=$enableval,enable_man_pages=yes)
AM_CONDITIONAL(MAN_PAGES_ENABLED, test x$enable_man_pages = xyes)
David Zeuthen's avatar
David Zeuthen committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123

GTK_DOC_CHECK([1.3])

#### gcc warning flags

if test "x$GCC" = "xyes"; then
  changequote(,)dnl
  case " $CFLAGS " in
  *[\ \	]-Wall[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wall" ;;
  esac

  case " $CFLAGS " in
  *[\ \	]-Wchar-subscripts[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wchar-subscripts" ;;
  esac

  case " $CFLAGS " in
  *[\ \	]-Wmissing-declarations[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wmissing-declarations" ;;
  esac

  case " $CFLAGS " in
  *[\ \	]-Wnested-externs[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wnested-externs" ;;
  esac

  case " $CFLAGS " in
  *[\ \	]-Wpointer-arith[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wpointer-arith" ;;
  esac

  case " $CFLAGS " in
  *[\ \	]-Wcast-align[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wcast-align" ;;
  esac

  case " $CFLAGS " in
  *[\ \	]-Wsign-compare[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wsign-compare" ;;
  esac

  if test "x$enable_ansi" = "xyes"; then
    case " $CFLAGS " in
    *[\ \	]-ansi[\ \	]*) ;;
    *) CFLAGS="$CFLAGS -ansi" ;;
    esac

    case " $CFLAGS " in
    *[\ \	]-D_POSIX_C_SOURCE*) ;;
    *) CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=199309L" ;;
    esac

    case " $CFLAGS " in
    *[\ \	]-D_BSD_SOURCE[\ \	]*) ;;
    *) CFLAGS="$CFLAGS -D_BSD_SOURCE" ;;
    esac

    case " $CFLAGS " in
    *[\ \	]-pedantic[\ \	]*) ;;
    *) CFLAGS="$CFLAGS -pedantic" ;;
    esac
  fi
  if test x$enable_gcov = xyes; then
    case " $CFLAGS " in
    *[\ \	]-fprofile-arcs[\ \	]*) ;;
    *) CFLAGS="$CFLAGS -fprofile-arcs" ;;
    esac
    case " $CFLAGS " in
    *[\ \	]-ftest-coverage[\ \	]*) ;;
    *) CFLAGS="$CFLAGS -ftest-coverage" ;;
    esac

    ## remove optimization
    CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'`
  fi
  changequote([,])dnl
else
  if test x$enable_gcov = xyes; then
    AC_MSG_ERROR([--enable-gcov can only be used with gcc])
  fi
fi

AM_CONDITIONAL(GCOV, test x$enable_gcov = xyes)

PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.6.0])
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)

124 125 126 127
PKG_CHECK_MODULES(DBUS, [dbus-1 >= 1.0])
AC_SUBST(DBUS_CFLAGS)
AC_SUBST(DBUS_LIBS)

David Zeuthen's avatar
David Zeuthen committed
128 129
AC_CHECK_FUNCS(getgrouplist)

David Zeuthen's avatar
David Zeuthen committed
130 131 132 133
# DocBook Documentation

AC_MSG_CHECKING([whether to build DocBook documentation])

134 135 136 137 138
AC_PATH_PROG(XMLTO, xmlto, no)
AC_PATH_PROG(XMLLINT, xmllint, no)

if test x$XMLLINT = xno ; then
    have_xmllint=no
David Zeuthen's avatar
David Zeuthen committed
139
else
140
    have_xmllint=yes
David Zeuthen's avatar
David Zeuthen committed
141 142 143
fi

if test x$enable_docbook_docs = xauto ; then
144
    if test x$have_xmlto = xno || test x$have_xmllint = xno ; then
David Zeuthen's avatar
David Zeuthen committed
145 146 147 148 149 150 151
        enable_docbook_docs=no
    else
        enable_docbook_docs=yes
    fi
fi

if test x$enable_docbook_docs = xyes; then
152 153
    if test x$have_xmlto = xno; then
	AC_MSG_ERROR([Building DocBook docs explicitly required, but xmlto not found])
David Zeuthen's avatar
David Zeuthen committed
154 155 156 157 158 159
    fi
fi

AM_CONDITIONAL(DOCBOOK_DOCS_ENABLED, test x$enable_docbook_docs = xyes)
AC_MSG_RESULT(yes)

160 161
if test "x$GCC" = "xyes"; then
  LDFLAGS="-Wl,--as-needed $LDFLAGS"
162 163
fi

164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
dnl ---------------------------------------------------------------------------
dnl - User and group
dnl ---------------------------------------------------------------------------

AC_ARG_WITH(polkit_user,[  --with-polkit-user=<user>  user for PolicyKit])
if test -z "$with_polkit_user" ; then
    POLKIT_USER=polkit
else
    POLKIT_USER=$with_polkit_user
fi
AC_SUBST(POLKIT_USER)
AC_DEFINE_UNQUOTED(POLKIT_USER, "$POLKIT_USER", [User for PolicyKit])

AC_ARG_WITH(polkit_group,[  --with-polkit-group=<grp>  group for PolicyKit])
if test -z "$with_polkit_group" ; then
    POLKIT_GROUP=polkit
else
    POLKIT_GROUP=$with_polkit_group
fi
AC_SUBST(POLKIT_GROUP)
AC_DEFINE_UNQUOTED(POLKIT_GROUP,"$POLKIT_GROUP", [Group for PolicyKit])

dnl ---------------------------------------------------------------------------
dnl - Check for PAM
dnl ---------------------------------------------------------------------------

withval=""
AC_ARG_WITH(pam-prefix,
[  --with-pam-prefix=<prefix> specify where pam files go],[
if test x$withval != x; then
   AC_MSG_RESULT("PAM files will be installed in prefix ${withval}.")
fi])
if test x$withval != x; then
	PAM_PREFIX_UNEXPANDED="$withval"
else
	PAM_PREFIX_UNEXPANDED="$sysconfdir"
fi
PAM_PREFIX=`eval echo $PAM_PREFIX_UNEXPANDED`
AC_SUBST(PAM_PREFIX)

have_pam=no
AC_CHECK_LIB(pam, pam_start, have_pam=yes)
if test x$have_pam = xno; then
    AC_ERROR([Could not find pam/pam-devel, please install the needed packages.])
else
    AUTH_LIBS="${AUTH_LIBS} -lpam"
    AC_DEFINE(HAVE_PAM, 1, [Define if PAM support is included])

    # On Linux, sigtimedwait() is in libc; on Solaris, it's in librt.
    have_timedwait=no
    AC_CHECK_LIB(c, sigtimedwait, [have_timedwait=yes])
    if test "$have_timedwait" = no ; then
      AC_CHECK_LIB(rt, sigtimedwait, [AUTH_LIBS="${AUTH_LIBS} -lrt"])
    fi

    AC_MSG_CHECKING(how to call pam_strerror)
    AC_CACHE_VAL(ac_cv_pam_strerror_args,
     [AC_TRY_COMPILE([#include <stdio.h>
                      #include <stdlib.h>
                      #include <security/pam_appl.h>],
                     [pam_handle_t *pamh = 0;
                      char *s = pam_strerror(pamh, PAM_SUCCESS);],
                     [ac_pam_strerror_args=2],
                     [AC_TRY_COMPILE([#include <stdio.h>
                                      #include <stdlib.h>
                                      #include <security/pam_appl.h>],
                                     [char *s =
                                       pam_strerror(PAM_SUCCESS);],
                                     [ac_pam_strerror_args=1],
                                     [ac_pam_strerror_args=0])])
      ac_cv_pam_strerror_args=$ac_pam_strerror_args])
    ac_pam_strerror_args=$ac_cv_pam_strerror_args
    if test "$ac_pam_strerror_args" = 1 ; then
      AC_MSG_RESULT(one argument)
    elif test "$ac_pam_strerror_args" = 2 ; then
      AC_DEFINE(PAM_STRERROR_TWO_ARGS, 1, [Define if pam_strerror takes two arguments])
      AC_MSG_RESULT(two arguments)
    else
      AC_MSG_RESULT(unknown)
    fi
 
fi

AM_CONDITIONAL(HAVE_PAM, test x$have_pam = xyes)
AC_SUBST(HAVE_PAM)
AC_SUBST(AUTH_LIBS)

AC_CHECK_HEADER(security/pam_modutil.h, [AC_DEFINE(HAVE_PAM_MODUTIL_H, [], "Have pam_modutil.h")])
AC_CHECK_HEADER(security/pam_ext.h, [AC_DEFINE(HAVE_PAM_EXT_H, [], "Have pam_ext.h")])
AC_CHECK_LIB(pam, pam_vsyslog, [AC_DEFINE(HAVE_PAM_VSYSLOG, [], "Have pam_vsyslog")])

AC_ARG_WITH(pam-module-dir, [  --with-pam-module-dir=[dirname]  directory to install PAM security module])
if ! test -z "$with_pam_module_dir"; then
    PAM_MODULE_DIR=$with_pam_module_dir
else
    PAM_MODULE_DIR="/lib/security"
fi

AC_SUBST(PAM_MODULE_DIR)

AC_ARG_WITH(os-type,     [  --with-os-type=<os>        distribution or OS (redhat)])

#### Check our operating system (distro-tweaks required)
if test "z$with_os_type" = "z"; then
	AC_CHECK_FILE(/etc/redhat-release,distro_type="redhat")
	AC_CHECK_FILE(/etc/SuSE-release,distro_type="suse")
	if test "z$distro_type" = "z"; then
		echo "Linux distribution autodetection failed, specify the distribution to target using --with-os-type="
	else
		operating_system=`echo ${distro_type} | tr '[[:upper:]]' '[[:lower:]]' `
	fi
fi

#### Sort out OS (distro-tweaks required)
if test x$with_os_type = x; then
    if test x$operating_system = xredhat ; then
        with_os_type=redhat
    elif test x$operating_system = xsuse ; then
        with_os_type=suse
    else
        with_os_type=unknown
    fi
fi

# (distro-tweaks required)
AM_CONDITIONAL(OS_TYPE_UNKNOWN, test x$with_os_type = xunknown, [Running on unknown OS])
AM_CONDITIONAL(OS_TYPE_RED_HAT, test x$with_os_type = xredhat, [Running on Red Hat OS'es])
AM_CONDITIONAL(OS_TYPE_SUSE, test x$with_os_type = xsuse, [Running on SUSE OS'es])

AC_ARG_WITH(pam-include, [  --with-pam-include=<file>  pam file to include])

#### Set up pam file to include (distro-tweaks required)
if ! test -z "$with_pam_include"; then
   PAM_FILE_INCLUDE_AUTH=$with_pam_include
   PAM_FILE_INCLUDE_ACCOUNT=$with_pam_include
   PAM_FILE_INCLUDE_PASSWORD=$with_pam_include
   PAM_FILE_INCLUDE_SESSION=$with_pam_include
elif test x$with_os_type = xredhat ; then
   PAM_FILE_INCLUDE_AUTH=system-auth
   PAM_FILE_INCLUDE_ACCOUNT=system-auth
   PAM_FILE_INCLUDE_PASSWORD=system-auth
   PAM_FILE_INCLUDE_SESSION=system-auth
elif test x$with_os_type = xsuse ; then
   PAM_FILE_INCLUDE_AUTH=common-auth
   PAM_FILE_INCLUDE_ACCOUNT=common-account
   PAM_FILE_INCLUDE_PASSWORD=common-password
   PAM_FILE_INCLUDE_SESSION=common-session
else
   PAM_FILE_INCLUDE_AUTH=system-auth
   PAM_FILE_INCLUDE_ACCOUNT=system-auth
   PAM_FILE_INCLUDE_PASSWORD=system-auth
   PAM_FILE_INCLUDE_SESSION=system-auth
fi

AC_SUBST(PAM_FILE_INCLUDE_AUTH)
AC_SUBST(PAM_FILE_INCLUDE_ACCOUNT)
AC_SUBST(PAM_FILE_INCLUDE_PASSWORD)
AC_SUBST(PAM_FILE_INCLUDE_SESSION)
AC_DEFINE_UNQUOTED(PAM_FILE_INCLUDE_AUTH, "$PAM_FILE_INCLUDE_AUTH", [pam file auth])
AC_DEFINE_UNQUOTED(PAM_FILE_INCLUDE_ACCOUNT, "$PAM_FILE_INCLUDE_ACCOUNT", [pam file account])
AC_DEFINE_UNQUOTED(PAM_FILE_INCLUDE_PASSWORD, "$PAM_FILE_INCLUDE_PASSWORD", [pam file password])
AC_DEFINE_UNQUOTED(PAM_FILE_INCLUDE_SESSION, "$PAM_FILE_INCLUDE_SESSION", [pam file session])

David Zeuthen's avatar
David Zeuthen committed
327
AC_OUTPUT([
328
libpolkit.pc
329 330
libpolkit-dbus.pc
libpolkit-grant.pc
David Zeuthen's avatar
David Zeuthen committed
331
Makefile
332
polkit
David Zeuthen's avatar
David Zeuthen committed
333
libpolkit/Makefile
334 335
libpolkit-dbus/Makefile
libpolkit-grant/Makefile
David Zeuthen's avatar
David Zeuthen committed
336 337 338
tools/Makefile
doc/Makefile
doc/api/Makefile
339 340
doc/api/libpolkit/Makefile
doc/api/libpolkit/version.xml
341 342 343 344
doc/api/libpolkit-dbus/Makefile
doc/api/libpolkit-dbus/version.xml
doc/api/libpolkit-grant/Makefile
doc/api/libpolkit-grant/version.xml
David Zeuthen's avatar
David Zeuthen committed
345
doc/spec/Makefile
346 347
doc/spec/polkit-spec.xml.in
doc/man/Makefile
David Zeuthen's avatar
David Zeuthen committed
348
policy/Makefile
349 350 351 352
modules/Makefile
modules/default/Makefile
modules/allow-all/Makefile
modules/deny-all/Makefile
353
modules/run-program/Makefile
354
modules/grant/Makefile
David Zeuthen's avatar
David Zeuthen committed
355 356 357 358
])

dnl ==========================================================================
echo "
Kay Sievers's avatar
Kay Sievers committed
359
                  PolicyKit $VERSION
360
                =================
David Zeuthen's avatar
David Zeuthen committed
361 362

        prefix:                     ${prefix}
363 364 365 366 367 368 369 370
        libdir:                     ${libdir}
        libexecdir:                 ${libexecdir}
        bindir:                     ${bindir}
        sbindir:                    ${sbindir}
        datadir:                    ${datadir}
        sysconfdir:                 ${sysconfdir}
        localstatedir:              ${localstatedir}
        docdir:                     ${docdir}
David Zeuthen's avatar
David Zeuthen committed
371 372 373 374

        compiler:                   ${CC}
        cflags:                     ${CFLAGS}
        cppflags:                   ${CPPFLAGS}
375 376
        xmlto:                      ${XMLTO}
        xmllint:                    ${XMLLINT}
David Zeuthen's avatar
David Zeuthen committed
377

378 379 380 381 382 383 384 385 386 387 388
        user for PolicyKit:         ${POLKIT_USER}
        group for PolicyKit:        ${POLKIT_GROUP}

        Distribution/OS:            ${with_os_type}

        PAM support:                ${have_pam}
        PAM file auth:              ${PAM_FILE_INCLUDE_AUTH}
        PAM file account:           ${PAM_FILE_INCLUDE_ACCOUNT}
        PAM file password:          ${PAM_FILE_INCLUDE_PASSWORD}
        PAM file session:           ${PAM_FILE_INCLUDE_SESSION}

David Zeuthen's avatar
David Zeuthen committed
389 390 391
        Maintainer mode:            ${USE_MAINTAINER_MODE}
        Building verbose mode:      ${enable_verbose_mode}
        Building api docs:          ${enable_gtk_doc}
David Zeuthen's avatar
David Zeuthen committed
392
        Building docs:              ${enable_docbook_docs}
393
        Building man pages:         ${enable_man_pages}
David Zeuthen's avatar
David Zeuthen committed
394
"
395 396 397 398 399 400 401 402 403 404 405 406

echo "NOTE: Remember to create user '${POLKIT_USER}' and group '${POLKIT_GROUP}' before 'make install'"
echo

echo "NOTE: ${libexecdir}/polkit-grant-helper will be owner by group"
echo "      '${POLKIT_USER}', and installed with mode 2755 (setgid binary)."
echo "      The directories ${localstatedir}/run/PolicyKit and ${localstatedir}/lib/PolicyKit will be"
echo "      owned by user '${POLKIT_USER}' and group '${POLKIT_GROUP}' and will be of mode 775."
echo

echo "NOTE: For packaging, remember to retain the modes and ownership."
echo