configure.ac revision 3d05230f
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.3.1],
27        [https://gitlab.freedesktop.org/xorg/lib/libxshmfence/-/issues],
28        [libxshmfence])
29AC_CONFIG_SRCDIR([Makefile.am])
30AC_CONFIG_HEADERS([config.h])
31
32AC_USE_SYSTEM_EXTENSIONS
33
34# Initialize Automake
35AM_INIT_AUTOMAKE([foreign dist-xz])
36
37# Initialize libtool
38AC_PROG_LIBTOOL
39
40# Require xorg-macros: XORG_DEFAULT_OPTIONS, XORG_WITH_LINT
41m4_ifndef([XORG_MACROS_VERSION],
42          [m4_fatal([must install xorg-macros 1.3 or later before running autoconf/autogen])])
43XORG_MACROS_VERSION(1.3)
44XORG_DEFAULT_OPTIONS
45
46dnl Allow checking code with lint, sparse, etc.
47XORG_WITH_LINT
48LINT_FLAGS="${LINT_FLAGS} ${FONTENC_CFLAGS}"
49
50		  
51dnl
52dnl Locate a suitable tmp file system for creating shared memory files
53dnl
54
55AC_ARG_ENABLE(futex,	AS_HELP_STRING([--enable-futex], [Enable futexes (default: auto)]),
56		[FUTEX=$enableval], [FUTEX=auto])
57
58if test "x$FUTEX" = "xauto"; then
59	AC_CHECK_HEADER([linux/futex.h], [FUTEX=yes])
60fi
61
62if test "x$FUTEX" = "xauto"; then
63	AC_CHECK_HEADER([sys/umtx.h], [FUTEX=yes], [FUTEX=no],
64	    [#include <errno.h>
65	     #include <sys/types.h>])
66	if test "x$FUTEX" = "xyes"; then
67		AC_DEFINE(HAVE_UMTX, 1, [Use umtx])
68	fi
69fi
70
71if test "x$FUTEX" = "xyes"; then
72	PTHREAD=no
73	AC_DEFINE(HAVE_FUTEX,1,[Use futexes])
74else
75	PTHREAD=yes
76	AC_DEFINE(HAVE_PTHREAD,1,[Use pthread primitives])
77fi
78
79PTHREAD_LIBS=
80if test "x$PTHREAD" = "xyes"; then
81	AC_CHECK_LIB(pthread,pthread_create,[PTHREAD_LIBS=-lpthread],[PTHREAD_LIBS=])
82fi
83
84AC_SUBST([PTHREAD_LIBS])
85
86AM_CONDITIONAL([FUTEX], [test x"$FUTEX" = xyes])
87AM_CONDITIONAL([PTHREAD], [test x"$PTHREAD" = xyes])
88
89PKG_CHECK_MODULES(XPROTO, xproto)
90
91AC_SUBST([XPROTO_CFLAGS])
92
93CFLAGS="$CFLAGS $XPROTO_CFLAGS"
94
95AC_CHECK_FUNCS(memfd_create mkostemp)
96
97AC_CHECK_DECLS([__NR_memfd_create], [], [], [[#include <asm/unistd.h>]])
98
99AC_CHECK_HEADERS([sys/memfd.h], [AC_DEFINE([HAVE_MEMFD_H], 1, [Has sys/memfd.h header])])
100
101AC_ARG_ENABLE(visibility,     AC_HELP_STRING([--enable-visibility], [Enable symbol visibility (default: auto)]),
102				[SYMBOL_VISIBILITY=$enableval],
103				[SYMBOL_VISIBILITY=auto])
104
105dnl ==================================================================
106dnl symbol visibility
107symbol_visibility=
108have_visibility=disabled
109if test x$SYMBOL_VISIBILITY != xno; then
110    AC_MSG_CHECKING(for symbol visibility support)
111    if test x$GCC = xyes; then
112	VISIBILITY_CFLAGS="-fvisibility=hidden"
113    else
114	if test x$SUNCC = xyes; then
115	    VISIBILITY_CFLAGS="-xldscope=hidden"
116	else
117	    have_visibility=no
118	fi
119    fi
120    if test x$have_visibility != xno; then
121	AC_TRY_COMPILE(
122	    [#include <X11/Xfuncproto.h>
123	     extern _X_HIDDEN int hidden_int;
124	     extern _X_EXPORT int public_int;
125	     extern _X_HIDDEN int hidden_int_func(void);
126	     extern _X_EXPORT int public_int_func(void);],
127	    [],
128	    have_visibility=yes,
129	    have_visibility=no)
130    fi
131    AC_MSG_RESULT([$have_visibility])
132    if test x$have_visibility != xno; then
133	symbol_visibility=$VISIBILITY_CFLAGS
134	CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
135    fi
136fi
137
138AC_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)]),
139[],
140[with_shared_memory_dir=yes])
141
142shmdirs="/run/shm /dev/shm /var/tmp /tmp"
143
144case x"$with_shared_memory_dir" in
145xyes)
146	for dir in $shmdirs; do
147		case x"$with_shared_memory_dir" in
148		xyes)
149			echo Checking temp dir "$dir"
150			if test -d "$dir"; then
151				with_shared_memory_dir="$dir"
152			fi
153			;;
154		esac
155	done
156	;;
157x/*)
158	;;
159xno)
160	;;
161*)
162	AC_MSG_ERROR([Invalid directory specified for --with-shared-memory-dir: $with_shared_memory_dir])
163	;;
164esac
165
166case x"$with_shared_memory_dir" in
167xyes)
168	AC_MSG_ERROR([No directory found for shared memory temp files.])
169	;;
170xno)
171	;;
172*)
173	AC_DEFINE_UNQUOTED(SHMDIR, ["$with_shared_memory_dir"], [Directory for shared memory temp files])
174	;;
175esac
176
177AC_CONFIG_FILES([Makefile
178                 src/Makefile
179		 test/Makefile
180                 xshmfence.pc])
181AC_OUTPUT
182