2 dnl Copyright © 2013 Keith Packard
4 dnl Permission to use, copy, modify, distribute, and sell this software and its
5 dnl documentation for any purpose is hereby granted without fee, provided that
6 dnl the above copyright notice appear in all copies and that both that copyright
7 dnl notice and this permission notice appear in supporting documentation, and
8 dnl that the name of the copyright holders not be used in advertising or
9 dnl publicity pertaining to distribution of the software without specific,
10 dnl written prior permission. The copyright holders make no representations
11 dnl about the suitability of this software for any purpose. It is provided "as
12 dnl is" without express or implied warranty.
14 dnl THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 dnl INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 dnl EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 dnl CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 dnl DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 dnl TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
23 dnl Process this file with autoconf to create configure.
26 AC_INIT([libxshmfence], [1.1],
27 [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libxshmfence])
28 AC_CONFIG_SRCDIR([Makefile.am])
29 AC_CONFIG_HEADERS([config.h])
32 AM_INIT_AUTOMAKE([foreign dist-bzip2])
38 # Require xorg-macros: XORG_DEFAULT_OPTIONS, XORG_WITH_LINT
39 m4_ifndef([XORG_MACROS_VERSION],
40 [m4_fatal([must install xorg-macros 1.3 or later before running autoconf/autogen])])
41 XORG_MACROS_VERSION(1.3)
44 dnl Allow checking code with lint, sparse, etc.
46 LINT_FLAGS="${LINT_FLAGS} ${FONTENC_CFLAGS}"
50 dnl Locate a suitable tmp file system for creating shared memeory files
53 AC_ARG_ENABLE(futex, AS_HELP_STRING([--enable-futex], [Enable futexes (default: auto)]),
54 [FUTEX=$enableval], [FUTEX=auto])
56 if test "x$FUTEX" = "xauto"; then
57 AC_CHECK_HEADER([linux/futex.h], [FUTEX=yes], [FUTEX=no])
60 if test "x$FUTEX" = "xyes"; then
62 AC_DEFINE(HAVE_FUTEX,1,[Use futexes])
65 AC_DEFINE(HAVE_PTHREAD,1,[Use pthread primitives])
69 if test "x$PTHREAD" = "xyes"; then
70 AC_CHECK_LIB(pthread,pthread_create,[PTHREAD_LIBS=-lpthread],[PTHREAD_LIBS=])
73 AC_SUBST([PTHREAD_LIBS])
75 AM_CONDITIONAL([FUTEX], [test x"$FUTEX" = xyes])
76 AM_CONDITIONAL([PTHREAD], [test x"$PTHREAD" = xyes])
78 PKG_CHECK_MODULES(XPROTO, xproto)
80 AC_SUBST([XPROTO_CFLAGS])
82 CFLAGS="$CFLAGS $XPROTO_CFLAGS"
84 AC_ARG_ENABLE(visibility, AC_HELP_STRING([--enable-visibility], [Enable symbol visibility (default: auto)]),
85 [SYMBOL_VISIBILITY=$enableval],
86 [SYMBOL_VISIBILITY=auto])
88 dnl ==================================================================
91 have_visibility=disabled
92 if test x$SYMBOL_VISIBILITY != xno; then
93 AC_MSG_CHECKING(for symbol visibility support)
94 if test x$GCC = xyes; then
95 VISIBILITY_CFLAGS="-fvisibility=hidden"
97 if test x$SUNCC = xyes; then
98 VISIBILITY_CFLAGS="-xldscope=hidden"
103 if test x$have_visibility != xno; then
105 [#include <X11/Xfuncproto.h>
106 extern _X_HIDDEN int hidden_int;
107 extern _X_EXPORT int public_int;
108 extern _X_HIDDEN int hidden_int_func(void);
109 extern _X_EXPORT int public_int_func(void);],
114 AC_MSG_RESULT([$have_visibility])
115 if test x$have_visibility != xno; then
116 symbol_visibility=$VISIBILITY_CFLAGS
117 CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
121 AC_ARG_WITH(shared-memory-dir, AS_HELP_STRING([--with-shared-memory-dir=PATH], [Path to directory in a world-writable temporary directory for anonymous shared memory (default: auto)]),
123 [with_shared_memory_dir=yes])
125 shmdirs="/run/shm /var/tmp /tmp"
127 case x"$with_shared_memory_dir" in
129 for dir in $shmdirs; do
130 case x"$with_shared_memory_dir" in
132 echo Checking temp dir "$dir"
133 if test -d "$dir"; then
134 with_shared_memory_dir="$dir"
145 AC_MSG_ERROR([Invalid directory specified for --with-shared-memory-dir: $with_shared_memory_dir])
149 case x"$with_shared_memory_dir" in
151 AC_MSG_ERROR([No directory found for shared memory temp files.])
156 AC_DEFINE_UNQUOTED(SHMDIR, ["$with_shared_memory_dir"], [Directory for shared memory temp files])
160 AC_CONFIG_FILES([Makefile