configure.ac revision ed6f5d66
1dnl
2dnl Copyright © 2013 Keith Packard
3dnl
4dnl Permission to use, copy, modify, distribute, and sell this software and its
5dnl documentation for any purpose is hereby granted without fee, provided that
6dnl the above copyright notice appear in all copies and that both that copyright
7dnl notice and this permission notice appear in supporting documentation, and
8dnl that the name of the copyright holders not be used in advertising or
9dnl publicity pertaining to distribution of the software without specific,
10dnl written prior permission.  The copyright holders make no representations
11dnl about the suitability of this software for any purpose.  It is provided "as
12dnl is" without express or implied warranty.
13dnl
14dnl THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15dnl INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16dnl EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17dnl CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18dnl DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19dnl TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20dnl OF THIS SOFTWARE.
21dnl
22dnl
23dnl Process this file with autoconf to create configure.
24
25AC_PREREQ([2.60])
26AC_INIT([libxshmfence], [1.2],
27        [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libxshmfence])
28AC_CONFIG_SRCDIR([Makefile.am])
29AC_CONFIG_HEADERS([config.h])
30
31# Initialize Automake
32AM_INIT_AUTOMAKE([foreign dist-bzip2])
33
34# Initialize libtool
35AC_PROG_LIBTOOL
36
37# Require xorg-macros: XORG_DEFAULT_OPTIONS, XORG_WITH_LINT
38m4_ifndef([XORG_MACROS_VERSION],
39          [m4_fatal([must install xorg-macros 1.3 or later before running autoconf/autogen])])
40XORG_MACROS_VERSION(1.3)
41XORG_DEFAULT_OPTIONS
42
43dnl Allow checking code with lint, sparse, etc.
44XORG_WITH_LINT
45LINT_FLAGS="${LINT_FLAGS} ${FONTENC_CFLAGS}"
46
47		  
48dnl
49dnl Locate a suitable tmp file system for creating shared memeory files
50dnl
51
52AC_ARG_ENABLE(futex,	AS_HELP_STRING([--enable-futex], [Enable futexes (default: auto)]),
53		[FUTEX=$enableval], [FUTEX=auto])
54
55if test "x$FUTEX" = "xauto"; then
56	AC_CHECK_HEADER([linux/futex.h], [FUTEX=yes])
57fi
58
59if test "x$FUTEX" = "xauto"; then
60	AC_CHECK_HEADER([sys/umtx.h], [FUTEX=yes], [FUTEX=no],
61	    [#include <errno.h>
62	     #include <sys/types.h>])
63	if test "x$FUTEX" = "xyes"; then
64		AC_DEFINE(HAVE_UMTX, 1, [Use umtx])
65	fi
66fi
67
68if test "x$FUTEX" = "xyes"; then
69	PTHREAD=no
70	AC_DEFINE(HAVE_FUTEX,1,[Use futexes])
71else
72	PTHREAD=yes
73	AC_DEFINE(HAVE_PTHREAD,1,[Use pthread primitives])
74fi
75
76PTHREAD_LIBS=
77if test "x$PTHREAD" = "xyes"; then
78	AC_CHECK_LIB(pthread,pthread_create,[PTHREAD_LIBS=-lpthread],[PTHREAD_LIBS=])
79fi
80
81AC_SUBST([PTHREAD_LIBS])
82
83AM_CONDITIONAL([FUTEX], [test x"$FUTEX" = xyes])
84AM_CONDITIONAL([PTHREAD], [test x"$PTHREAD" = xyes])
85
86PKG_CHECK_MODULES(XPROTO, xproto)
87
88AC_SUBST([XPROTO_CFLAGS])
89
90CFLAGS="$CFLAGS $XPROTO_CFLAGS"
91
92AC_CHECK_FUNCS(memfd_create)
93
94AC_CHECK_DECLS([__NR_memfd_create], [], [], [[#include <asm/unistd.h>]])
95
96AC_CHECK_HEADERS([sys/memfd.h], [AC_DEFINE([HAVE_MEMFD_H], 1, [Has sys/memfd.h header])])
97
98AC_ARG_ENABLE(visibility,     AC_HELP_STRING([--enable-visibility], [Enable symbol visibility (default: auto)]),
99				[SYMBOL_VISIBILITY=$enableval],
100				[SYMBOL_VISIBILITY=auto])
101
102dnl ==================================================================
103dnl symbol visibility
104symbol_visibility=
105have_visibility=disabled
106if test x$SYMBOL_VISIBILITY != xno; then
107    AC_MSG_CHECKING(for symbol visibility support)
108    if test x$GCC = xyes; then
109	VISIBILITY_CFLAGS="-fvisibility=hidden"
110    else
111	if test x$SUNCC = xyes; then
112	    VISIBILITY_CFLAGS="-xldscope=hidden"
113	else
114	    have_visibility=no
115	fi
116    fi
117    if test x$have_visibility != xno; then
118	AC_TRY_COMPILE(
119	    [#include <X11/Xfuncproto.h>
120	     extern _X_HIDDEN int hidden_int;
121	     extern _X_EXPORT int public_int;
122	     extern _X_HIDDEN int hidden_int_func(void);
123	     extern _X_EXPORT int public_int_func(void);],
124	    [],
125	    have_visibility=yes,
126	    have_visibility=no)
127    fi
128    AC_MSG_RESULT([$have_visibility])
129    if test x$have_visibility != xno; then
130	symbol_visibility=$VISIBILITY_CFLAGS
131	CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
132    fi
133fi
134
135AC_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)]),
136[],
137[with_shared_memory_dir=yes])
138
139shmdirs="/run/shm /dev/shm /var/tmp /tmp"
140
141case x"$with_shared_memory_dir" in
142xyes)
143	for dir in $shmdirs; do
144		case x"$with_shared_memory_dir" in
145		xyes)
146			echo Checking temp dir "$dir"
147			if test -d "$dir"; then
148				with_shared_memory_dir="$dir"
149			fi
150			;;
151		esac
152	done
153	;;
154x/*)
155	;;
156xno)
157	;;
158*)
159	AC_MSG_ERROR([Invalid directory specified for --with-shared-memory-dir: $with_shared_memory_dir])
160	;;
161esac
162
163case x"$with_shared_memory_dir" in
164xyes)
165	AC_MSG_ERROR([No directory found for shared memory temp files.])
166	;;
167xno)
168	;;
169*)
170	AC_DEFINE_UNQUOTED(SHMDIR, ["$with_shared_memory_dir"], [Directory for shared memory temp files])
171	;;
172esac
173
174AC_CONFIG_FILES([Makefile
175                 src/Makefile
176		 test/Makefile
177                 xshmfence.pc])
178AC_OUTPUT
179