tizen 2.4 release
[framework/uifw/xorg/lib/libxshmfence.git] / configure.ac
1 dnl
2 dnl Copyright © 2013 Keith Packard
3 dnl
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.
13 dnl
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
20 dnl OF THIS SOFTWARE.
21 dnl
22 dnl
23 dnl Process this file with autoconf to create configure.
24
25 AC_PREREQ([2.60])
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])
30
31 # Initialize Automake
32 AM_INIT_AUTOMAKE([foreign dist-bzip2])
33 AM_MAINTAINER_MODE
34
35 # Initialize libtool
36 AC_PROG_LIBTOOL
37
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)
42 XORG_DEFAULT_OPTIONS
43
44 dnl Allow checking code with lint, sparse, etc.
45 XORG_WITH_LINT
46 LINT_FLAGS="${LINT_FLAGS} ${FONTENC_CFLAGS}"
47
48                   
49 dnl
50 dnl Locate a suitable tmp file system for creating shared memeory files
51 dnl
52
53 AC_ARG_ENABLE(futex,    AS_HELP_STRING([--enable-futex], [Enable futexes (default: auto)]),
54                 [FUTEX=$enableval], [FUTEX=auto])
55
56 if test "x$FUTEX" = "xauto"; then
57         AC_CHECK_HEADER([linux/futex.h], [FUTEX=yes], [FUTEX=no])
58 fi
59
60 if test "x$FUTEX" = "xyes"; then
61         PTHREAD=no
62         AC_DEFINE(HAVE_FUTEX,1,[Use futexes])
63 else
64         PTHREAD=yes
65         AC_DEFINE(HAVE_PTHREAD,1,[Use pthread primitives])
66 fi
67
68 PTHREAD_LIBS=
69 if test "x$PTHREAD" = "xyes"; then
70         AC_CHECK_LIB(pthread,pthread_create,[PTHREAD_LIBS=-lpthread],[PTHREAD_LIBS=])
71 fi
72
73 AC_SUBST([PTHREAD_LIBS])
74
75 AM_CONDITIONAL([FUTEX], [test x"$FUTEX" = xyes])
76 AM_CONDITIONAL([PTHREAD], [test x"$PTHREAD" = xyes])
77
78 PKG_CHECK_MODULES(XPROTO, xproto)
79
80 AC_SUBST([XPROTO_CFLAGS])
81
82 CFLAGS="$CFLAGS $XPROTO_CFLAGS"
83
84 AC_ARG_ENABLE(visibility,     AC_HELP_STRING([--enable-visibility], [Enable symbol visibility (default: auto)]),
85                                 [SYMBOL_VISIBILITY=$enableval],
86                                 [SYMBOL_VISIBILITY=auto])
87
88 dnl ==================================================================
89 dnl symbol visibility
90 symbol_visibility=
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"
96     else
97         if test x$SUNCC = xyes; then
98             VISIBILITY_CFLAGS="-xldscope=hidden"
99         else
100             have_visibility=no
101         fi
102     fi
103     if test x$have_visibility != xno; then
104         AC_TRY_COMPILE(
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);],
110             [],
111             have_visibility=yes,
112             have_visibility=no)
113     fi
114     AC_MSG_RESULT([$have_visibility])
115     if test x$have_visibility != xno; then
116         symbol_visibility=$VISIBILITY_CFLAGS
117         CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
118     fi
119 fi
120
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)]),
122 [],
123 [with_shared_memory_dir=yes])
124
125 shmdirs="/run/shm /var/tmp /tmp"
126
127 case x"$with_shared_memory_dir" in
128 xyes)
129         for dir in $shmdirs; do
130                 case x"$with_shared_memory_dir" in
131                 xyes)
132                         echo Checking temp dir "$dir"
133                         if test -d "$dir"; then
134                                 with_shared_memory_dir="$dir"
135                         fi
136                         ;;
137                 esac
138         done
139         ;;
140 x/*)
141         ;;
142 xno)
143         ;;
144 *)
145         AC_MSG_ERROR([Invalid directory specified for --with-shared-memory-dir: $with_shared_memory_dir])
146         ;;
147 esac
148
149 case x"$with_shared_memory_dir" in
150 xyes)
151         AC_MSG_ERROR([No directory found for shared memory temp files.])
152         ;;
153 xno)
154         ;;
155 *)
156         AC_DEFINE_UNQUOTED(SHMDIR, ["$with_shared_memory_dir"], [Directory for shared memory temp files])
157         ;;
158 esac
159
160 AC_CONFIG_FILES([Makefile
161                  src/Makefile
162                  test/Makefile
163                  xshmfence.pc])
164 AC_OUTPUT