1dnl Process this file with autoconf to produce a configure script. 2AC_PREREQ(2.52) 3AC_INIT(libgamin) 4AM_CONFIG_HEADER(config.h) 5AC_CANONICAL_SYSTEM 6 7# get any external flags setting before we start playing with the CFLAGS variable 8ENV_CFLAGS="$CFLAGS" 9 10GAMIN_MAJOR_VERSION=0 11GAMIN_MINOR_VERSION=1 12GAMIN_MICRO_VERSION=10 13GAMIN_VERSION=$GAMIN_MAJOR_VERSION.$GAMIN_MINOR_VERSION.$GAMIN_MICRO_VERSION$GAMIN_MICRO_VERSION_SUFFIX 14GAMIN_VERSION_INFO=`expr $GAMIN_MAJOR_VERSION + $GAMIN_MINOR_VERSION`:$GAMIN_MICRO_VERSION:$GAMIN_MINOR_VERSION 15 16AC_SUBST(GAMIN_MAJOR_VERSION) 17AC_SUBST(GAMIN_MINOR_VERSION) 18AC_SUBST(GAMIN_MICRO_VERSION) 19AC_SUBST(GAMIN_VERSION) 20AC_SUBST(GAMIN_VERSION_INFO) 21 22FAM_VERSION_INFO="0:0:0" 23 24AC_SUBST(FAM_VERSION_INFO) 25 26VERSION=${GAMIN_VERSION} 27 28AM_INIT_AUTOMAKE(gamin, $VERSION) 29 30AM_PROG_LIBTOOL 31 32AC_USE_SYSTEM_EXTENSIONS 33AC_PROG_CC 34AM_PROG_CC_STDC 35AC_HEADER_STDC 36AC_PROG_INSTALL 37AC_PROG_MAKE_SET 38 39dnl If the user set no CFLAGS, then don't assume the autotools defaults of 40dnl "-g -O2". We set default CFLAGS later based on the --disable-debug flag. 41if test -z "$ENV_CFLAGS"; then 42 CFLAGS="" 43fi 44 45dnl for the spec file 46RELDATE=`date +'%a %b %e %Y'` 47AC_SUBST(RELDATE) 48 49AC_ARG_ENABLE(docs, 50 AC_HELP_STRING([--enable-docs], [Build documentation (requires Doxygen)]), 51 [build_docs="${enableval}"], [build_docs=no]) 52 53AM_CONDITIONAL(BUILD_DOCS, test x$build_docs = xyes) 54 55################################################## 56# Check for gtk-doc. 57################################################## 58 59AC_ARG_WITH(html-dir, [ --with-html-dir=PATH path to installed docs ]) 60 61if test "x$with_html_dir" = "x" ; then 62 HTML_DIR='${datadir}/gtk-doc/html' 63else 64 HTML_DIR=$with_html_dir 65fi 66 67AC_SUBST(HTML_DIR) 68 69gtk_doc_min_version=1.0 70AC_MSG_CHECKING([gtk-doc version >= $gtk_doc_min_version]) 71if pkg-config --atleast-version=$gtk_doc_min_version gtk-doc; then 72 AC_MSG_RESULT(yes) 73 GTKDOC=true 74else 75 AC_MSG_RESULT(no) 76 GTKDOC=false 77fi 78 79dnl Let people disable the gtk-doc stuff. 80AC_ARG_ENABLE(gtk-doc, 81 AC_HELP_STRING([--enable-gtk-doc], [Use gtk-doc to build documentation (default=auto)]), 82 [enable_gtk_doc="$enableval"], [enable_gtk_doc=auto]) 83 84if test x$enable_gtk_doc = xauto -o x$enable_gtk_doc = xyes ; then 85 if test x$GTKDOC = xtrue ; then 86 enable_gtk_doc=yes 87 else 88 enable_gtk_doc=no 89 fi 90fi 91 92AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes) 93 94AC_CHECK_FUNCS(usleep setsid setenv putenv getlogin_r) 95AC_STRUCT_ST_MTIM_NSEC 96 97 98dnl 99dnl libgamin/libfam configuration 100dnl 101AC_ARG_ENABLE(libgamin, 102 AC_HELP_STRING([--enable-libgamin], [Build libgamin/libfam (default=yes)]), 103 [enable_libgamin="$enableval"], [enable_libgamin=yes]) 104AM_CONDITIONAL(BUILD_LIBGAMIN, test x$enable_libgamin = xyes) 105 106 107dnl 108dnl Server configuration 109dnl 110AC_ARG_ENABLE(server, 111 AC_HELP_STRING([--enable-server], [Build gam_server (default=yes)]), 112 [enable_server="$enableval"], [enable_server=yes]) 113 114if test x$enable_server = xyes ; then 115 PKG_CHECK_MODULES(DAEMON, glib-2.0) 116 AC_SUBST(DAEMON_CFLAGS) 117 AC_SUBST(DAEMON_LIBS) 118fi 119AM_CONDITIONAL(BUILD_SERVER, test x$enable_server = xyes) 120 121 122dnl 123dnl Tests 124dnl 125enable_tests="no" 126if test x$enable_server = xyes && test x$enable_libgamin = xyes ; then 127 PKG_CHECK_MODULES(TEST, glib-2.0) 128 AC_SUBST(TEST_LIBS) 129 AC_SUBST(TEST_CFLAGS) 130 enable_tests="yes" 131 132fi 133AM_CONDITIONAL(BUILD_TESTS, test x$enable_tests = xyes) 134 135 136AC_ARG_ENABLE(more-warnings, 137 AC_HELP_STRING([--disable-more-warnings], [Minimum compiler warnings]), 138 [set_more_warnings="${enableval}"], [ 139# if test -d $srcdir/CVS; then 140 warnings_default=yes 141# else 142# warnings_default=no 143# fi 144 ]) 145 146AC_ARG_ENABLE(debug, 147# AC_HELP_STRING([--enable-debug], [Enable debugging support]), 148# [debug=$enableval], [ 149# if test -d $srcdir/CVS; then 150# debug=yes 151# else 152# debug=no 153# fi 154# ]) 155 AC_HELP_STRING([--disable-debug], [Disable debugging support]), 156 [debug=$enableval], [debug=yes]) 157 158if test x$debug = xyes ; then 159 AC_DEFINE([GAMIN_DEBUG], [], [Enable debugging support]) 160fi 161 162AM_CONDITIONAL(GAMIN_DEBUG, test x$debug = xyes) 163 164AC_ARG_ENABLE(debug_api, 165AC_HELP_STRING([--enable-debug-api], [Enable debugging API]), 166[debug_api="${enableval}"]) 167 168if test "$debug_api" = "" -a -d $srcdir/CVS; then 169 echo "Building from CVS, enabling debug api" 170 debug_api=yes 171fi 172 173if test x$debug_api = xyes ; then 174 AC_DEFINE([GAMIN_DEBUG_API], [], [Enable debugging API]) 175fi 176 177dnl check what OS we're on 178#AM_CONDITIONAL(HAVE_LINUX, test x$target_os = xlinux-gnu) 179if test x$target_os = xlinux-gnu; then 180 AC_DEFINE([HAVE_LINUX],[],[Whether we are using linux or not]) 181fi 182 183AC_ARG_ENABLE(kernel, 184 AC_HELP_STRING([--disable-kernel], [Use polling regardless of what kernel-level systems are available]), 185 [os=${enableval}],[os=${target_os}]) 186 187if test x$os = xyes; then 188 os=${target_os} 189elif test x$os = xno; then 190 os="BogusOS" 191elif test x$os != x${target_os}; then 192 AC_MSG_ERROR(bad value ${enableval} for --disable-kernel) 193fi 194 195dnl We use polling no matter what. 196AC_DEFINE(ENABLE_POLLING,1,[Use polling as backend]) 197backends="polling" 198 199AC_ARG_ENABLE(inotify, 200 AC_HELP_STRING([--disable-inotify], [Disable the INotify backend]), 201 [inotify="${enableval}"], [inotify=auto]) 202 203if test x$inotify = xyes; then 204 inotify=true 205elif test x$inotify = xno; then 206 inotify=false 207fi 208 209if test x$inotify = xtrue -o x$inotify = xauto; then 210 AC_CHECK_HEADERS(sys/inotify.h) 211 if test x"$ac_cv_header_sys_inotify_h" = x"no" -a x"$inotify" = xtrue; then 212 AC_MSG_ERROR([sys/inotify.h requested but not available]) 213 fi 214 if test x"$ac_cv_header_sys_inotify_h" = xyes; then 215 AC_DEFINE(ENABLE_INOTIFY,1,[Use inotify as backend]) 216 backends="${backends}, inotify" 217 inotify=true 218 else 219 inotify=false 220 fi 221fi 222 223dnl check if inotify backend is enabled 224AM_CONDITIONAL(ENABLE_INOTIFY, test x$inotify = xtrue) 225 226if test x$os = xlinux-gnu; then 227 AC_ARG_ENABLE(dnotify, 228 AC_HELP_STRING([--disable-dnotify], [Disable the DNotify backend]), 229 [dnotify="${enableval}"], [dnotify=true]) 230 231 if test x$dnotify = xyes; then 232 dnotify=true 233 elif test x$dnotify = xno; then 234 dnotify=false 235 elif test x$dnotify != xtrue; then 236 AC_MSG_ERROR(bad value ${enableval} for --disable-dnotify) 237 fi 238fi 239 240if test x$dnotify = xfalse; then 241 if test x$inotify = xtrue; then 242 echo "When using inotify, gamin sometimes needs dnotify as a fallback" 243 echo "so dnotify support will be enabled" 244 dnotify=true 245 fi 246fi 247 248dnl check if dnotify backend is enabled 249AM_CONDITIONAL(ENABLE_DNOTIFY, test x$dnotify = xtrue) 250 251if test x$dnotify = xtrue; then 252 AC_DEFINE(ENABLE_DNOTIFY,1,[Use dnotify as backend]) 253 backends="${backends}, dnotify" 254fi 255 256if test x$os != xBogusOS; then 257 AC_CHECK_FUNC(kevent,[have_kevent=1],) 258 if test x$have_kevent = x1 ; then 259 AC_ARG_ENABLE(kqueue, 260 AC_HELP_STRING([--disable-kqueue], [Disable the KQueue backend]), 261 [kqueue="${enableval}"], [kqueue=true]) 262 263 if test x$kqueue = xyes; then 264 kqueue=true 265 elif test x$kqueue = xno; then 266 kqueue=false 267 elif test x$kqueue != xtrue; then 268 AC_MSG_ERROR(bad value ${enableval} for --disable-kqueue) 269 fi 270 fi 271fi 272 273dnl check if kqueue backend is enabled 274AM_CONDITIONAL(ENABLE_KQUEUE, test x$kqueue = xtrue) 275 276if test x$kqueue = xtrue; then 277 AC_CHECK_HEADERS(sys/event.h) 278 AC_DEFINE(ENABLE_KQUEUE,1,[Use kqueue as backend]) 279 backends="${backends}, kqueue" 280fi 281 282dnl pthread support for reentrance of the client library. 283AC_ARG_WITH(threads, 284[ --with-threads add multithread support(on)]) 285 286if test "$with_threads" = "no" ; then 287 echo Disabling multithreaded support 288else 289 echo Enabling multithreaded support 290 291 AC_CHECK_HEADER(pthread.h, 292 AC_CHECK_LIB(pthread, pthread_mutexattr_settype,[ 293 THREAD_LIBS="-lpthread" 294 AC_DEFINE([HAVE_LIBPTHREAD], [], [Define if pthread library is there (-lpthread)]) 295 AC_DEFINE([HAVE_PTHREAD_H], [], [Define if <pthread.h> is there]) 296 WITH_THREADS="1"])) 297fi 298 299dnl Use weak symbols on linux/gcc to avoid imposing libpthreads to apps 300if test x$os = xlinux-gnu -a x$WITH_THREADS = x1 ; then 301 if test "${CC}" = "gcc" ; then 302 echo Use weak symbols ! 303 THREAD_LIBS= 304 fi 305fi 306AC_SUBST(THREAD_LIBS) 307AC_SUBST(WITH_THREADS) 308 309# It may just be gnu but it could also be gnu0.3, etc. 310# if echo x$os | grep -E -e '^xgnu[0-9]*\.?[0-9]*$' >/dev/null; 311# won't work as m4 eats the []s. 312if case x$os in xgnu*) true;; *) false;; esac; then 313 AC_ARG_ENABLE(kqueue, 314 AC_HELP_STRING([--disable-hurd_mach_notify], [Disable the Hurd Mach Notify backend]), 315 [hurd_mach_notify="${enableval}"], [hurd_mach_notify=true]) 316 317 if test x$hurd_mach_notify = xyes; then 318 hurd_mach_notify=true 319 elif test x$hurd_mach_notify = xno; then 320 hurd_mach_notify=false 321 elif test x$hurd_mach_notify != xtrue; then 322 AC_MSG_ERROR(bad value ${enableval} for --disable-hurd_mach_notify) 323 fi 324fi 325 326dnl check if hurd_mach_notify backend is enabled 327AM_CONDITIONAL(ENABLE_HURD_MACH_NOTIFY, test x$hurd_mach_notify = xtrue) 328 329if test x$hurd_mach_notify = xtrue; then 330 # <hurd/ports.h> requires _GNU_SOURCE. 331 old_CPPFLAGS="$CPPFLAGS" 332 CPPFLAGS="$old_CPPFLAGS -D_GNU_SOURCE" 333 AC_CHECK_HEADERS([hurd/ports.h], , 334 [AC_MSG_ERROR([<hurd/ports.h> not found but required to build hurd_mach_notify backend.])]) 335 CPPFLAGS="$old_CPPFLAGS" 336 337 AC_CHECK_LIB([ports], [ports_create_port], [:], 338 [AC_MSG_ERROR([libports not found but required to build hurd_mach_notify backend.])], [-lthreads]) 339 340 AC_CHECK_TOOL(MIG, [mig], [AC_MSG_ERROR([mig not found but required to build hurd_mach_notify backend.])]) 341 AC_SUBST(MIG) 342 343 AC_DEFINE(ENABLE_HURD_MACH_NOTIFY,1,[Use hurd_mach_notify as backend]) 344 backends="${backends}, hurd_mach_notify" 345fi 346 347dnl check for flavours of varargs macros (test from GLib) 348AC_MSG_CHECKING(for ISO C99 varargs macros in C) 349AC_TRY_COMPILE([],[ 350int a(int p1, int p2, int p3); 351#define call_a(...) a(1,__VA_ARGS__) 352call_a(2,3); 353],dbus_have_iso_c_varargs=yes,dbus_have_iso_c_varargs=no) 354AC_MSG_RESULT($dbus_have_iso_c_varargs) 355 356AC_MSG_CHECKING(for GNUC varargs macros) 357AC_TRY_COMPILE([],[ 358int a(int p1, int p2, int p3); 359#define call_a(params...) a(1,params) 360call_a(2,3); 361],dbus_have_gnuc_varargs=yes,dbus_have_gnuc_varargs=no) 362AC_MSG_RESULT($dbus_have_gnuc_varargs) 363 364dnl Output varargs tests 365if test x$dbus_have_iso_c_varargs = xyes; then 366 AC_DEFINE(HAVE_ISO_VARARGS,1,[Have ISO C99 varargs macros]) 367fi 368if test x$dbus_have_gnuc_varargs = xyes; then 369 AC_DEFINE(HAVE_GNUC_VARARGS,1,[Have GNU-style varargs macros]) 370fi 371 372dnl Check for various credentials. 373AC_MSG_CHECKING(for struct cmsgcred) 374AC_TRY_COMPILE([ 375#include <sys/types.h> 376#include <sys/socket.h> 377],[ 378struct cmsgcred cred; 379 380cred.cmcred_pid = 0; 381],dbus_have_struct_cmsgcred=yes,dbus_have_struct_cmsgcred=no) 382AC_MSG_RESULT($dbus_have_struct_cmsgcred) 383 384if test x$dbus_have_struct_cmsgcred = xyes; then 385 AC_DEFINE(HAVE_CMSGCRED,1,[Have cmsgcred structure]) 386fi 387 388#### Abstract sockets 389 390AC_MSG_CHECKING(abstract socket namespace) 391AC_LANG_PUSH(C) 392AC_RUN_IFELSE([AC_LANG_PROGRAM( 393[[ 394#include <sys/types.h> 395#include <stdlib.h> 396#include <string.h> 397#include <stdio.h> 398#include <sys/socket.h> 399#include <sys/un.h> 400#include <errno.h> 401]], 402[[ 403 int listen_fd; 404 struct sockaddr_un addr; 405 406 listen_fd = socket (PF_UNIX, SOCK_STREAM, 0); 407 408 if (listen_fd < 0) 409 { 410 fprintf (stderr, "socket() failed: %s\n", strerror (errno)); 411 exit (1); 412 } 413 414 memset (&addr, '\0', sizeof (addr)); 415 addr.sun_family = AF_UNIX; 416 strcpy (addr.sun_path, "X/tmp/dbus-fake-socket-path-used-in-configure-test"); 417 addr.sun_path[0] = '\0'; /* this is what makes it abstract */ 418 419 if (bind (listen_fd, (struct sockaddr*) &addr, SUN_LEN (&addr)) < 0) 420 { 421 fprintf (stderr, "Abstract socket namespace bind() failed: %s\n", 422 strerror (errno)); 423 exit (1); 424 } 425 else 426 exit (0); 427]])], 428 [have_abstract_sockets=yes], 429 [have_abstract_sockets=no]) 430AC_LANG_POP(C) 431AC_MSG_RESULT($have_abstract_sockets) 432 433if test x$enable_abstract_sockets = xyes; then 434 if test x$have_abstract_sockets = xno; then 435 AC_MSG_ERROR([Abstract sockets explicitly required, and support not detected.]) 436 fi 437fi 438 439if test x$enable_abstract_sockets = xno; then 440 have_abstract_sockets=no; 441fi 442 443if test x$have_abstract_sockets = xyes ; then 444 AC_DEFINE_UNQUOTED(HAVE_ABSTRACT_SOCKETS, $abstract_sockets, [Have abstract socket namespace]) 445fi 446 447dnl 448dnl check for python 449dnl 450 451AC_ARG_WITH(python, 452[ --with-python[[=DIR]] build Python bindings if found]) 453 454PYTHON_VERSION= 455PYTHON_INCLUDES= 456PYTHON_SITE_PACKAGES= 457PYTHON_TESTS= 458pythondir= 459if test "$with_python" != "no" ; then 460 if test -x "$with_python/bin/python" 461 then 462 echo Found python in $with_python/bin/python 463 PYTHON="$with_python/bin/python" 464 else 465 if test -x "$with_python" 466 then 467 echo Found python in $with_python 468 PYTHON="$with_python" 469 else 470 if test -x "$PYTHON" 471 then 472 echo Found python in environment PYTHON=$PYTHON 473 with_python=`$PYTHON -c "import sys; print sys.exec_prefix"` 474 else 475 AC_PATH_PROG(PYTHON, python python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5) 476 fi 477 fi 478 fi 479 if test "$PYTHON" != "" 480 then 481 PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[[0:3]]"` 482 echo Found Python version $PYTHON_VERSION 483 fi 484 if test "$PYTHON_VERSION" != "" 485 then 486 if test -r $with_python/include/python$PYTHON_VERSION/Python.h -a \ 487 -d $with_python/lib/python$PYTHON_VERSION/site-packages 488 then 489 PYTHON_INCLUDES=$with_python/include/python$PYTHON_VERSION 490 PYTHON_SITE_PACKAGES=$libdir/python$PYTHON_VERSION/site-packages 491 else 492 if test -r $prefix/include/python$PYTHON_VERSION/Python.h 493 then 494 PYTHON_INCLUDES=$prefix/include/python$PYTHON_VERSION 495 PYTHON_SITE_PACKAGES=$libdir/python$PYTHON_VERSION/site-packages 496 else 497 if test -r /usr/include/python$PYTHON_VERSION/Python.h 498 then 499 PYTHON_INCLUDES=/usr/include/python$PYTHON_VERSION 500 PYTHON_SITE_PACKAGES=$libdir/python$PYTHON_VERSION/site-packages 501 else 502 echo could not find python$PYTHON_VERSION/Python.h 503 fi 504 fi 505 if test ! -d "$PYTHON_SITE_PACKAGES" 506 then 507 PYTHON_SITE_PACKAGES=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib()"` 508 fi 509 fi 510 fi 511 if test "$with_python" != "" 512 then 513 pythondir='$(PYTHON_SITE_PACKAGES)' 514 else 515 pythondir='$(libdir)/python$(PYTHON_VERSION)/site-packages' 516 fi 517else 518 PYTHON= 519fi 520if test "$PYTHON_INCLUDES" != "" 521then 522 enable_python="$enable_libgamin" 523else 524 enable_python="no" 525fi 526AM_CONDITIONAL(WITH_PYTHON, test "$enable_python" = "yes") 527AC_SUBST(pythondir) 528AC_SUBST(PYTHON_VERSION) 529AC_SUBST(PYTHON_INCLUDES) 530AC_SUBST(PYTHON_SITE_PACKAGES) 531 532dnl After all config-related tweaking of CFLAGS, set it to its "build" value 533 534AC_MSG_CHECKING(for more compiler warnings) 535if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then 536 AC_MSG_RESULT(yes) 537 warning_cflags="\ 538 -Wall\ 539 -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes\ 540 -Wnested-externs\ 541 -Wsign-compare" 542 543 SAVE_CFLAGS="$CFLAGS" 544 for option in -Wno-sign-compare; do 545 CFLAGS="$option" 546 AC_MSG_CHECKING([whether gcc understands $option]) 547 AC_TRY_COMPILE([], [], 548 has_option=yes, 549 has_option=no,) 550 if test "$has_option" != "no"; then 551 warning_cflags="$warning_cflags $option" 552 fi 553 AC_MSG_RESULT($has_option) 554 unset has_option 555 done 556 CFLAGS="$SAVE_CFLAGS" 557 unset option 558else 559 AC_MSG_RESULT(no) 560fi 561 562if test "$GCC" = "yes"; then 563 if test "$debug" = "yes"; then 564 debug_cflags="-g" 565 else 566 # autotools defaults to "-O2 -g" for cflags, but we don't 567 # want -g in non-debug builds 568 if test -z "$ENV_CFLAGS"; then 569 CFLAGS="-O2" 570 fi 571 fi 572fi 573 574AM_CFLAGS="$warning_cflags $debug_cflags" 575AC_SUBST(AM_CFLAGS) 576 577dnl ========================================================================== 578 579AC_OUTPUT([ 580Makefile 581lib/Makefile 582libgamin/Makefile 583server/Makefile 584tests/Makefile 585python/Makefile 586python/tests/Makefile 587doc/Makefile 588gamin.pc 589gamin.spec 590]) 591 592#docs/Makefile 593#docs/guide/Makefile 594 595echo " 596gamin-$VERSION: 597 598 prefix: ${prefix} 599 source code location: ${srcdir} 600 compiler: ${CC} 601 compiler flags: ${AM_CFLAGS} ${CFLAGS} 602 603 build gam_server: ${enable_server} 604 build libgamin/libfam: ${enable_libgamin} 605 build python bindings: ${enable_python} 606 build tests: ${enable_tests} 607 608 backends: ${backends} 609 build documentation: ${build_docs} 610 debug support: ${debug} 611" 612