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