1# Copyright © 2013 Intel Corporation 2# 3# Permission is hereby granted, free of charge, to any person obtaining a 4# copy of this software and associated documentation files (the "Software"), 5# to deal in the Software without restriction, including without limitation 6# the rights to use, copy, modify, merge, publish, distribute, sublicense, 7# and/or sell copies of the Software, and to permit persons to whom the 8# Software is furnished to do so, subject to the following conditions: 9# 10# The above copyright notice and this permission notice (including the next 11# paragraph) shall be included in all copies or substantial portions of the 12# Software. 13# 14# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20# IN THE SOFTWARE. 21 22# Initialize Autoconf 23AC_PREREQ([2.60]) 24AC_INIT([libepoxy], 25 [1.5.4], 26 [https://github.com/anholt/libepoxy], 27 [libepoxy]) 28AC_CONFIG_SRCDIR([Makefile.am]) 29AC_CONFIG_HEADERS([config.h]) 30AC_CONFIG_MACRO_DIR([m4]) 31 32# Initialize Automake 33AM_INIT_AUTOMAKE([foreign -Wno-portability dist-xz no-dist-gzip tar-ustar subdir-objects]) 34 35# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS 36m4_ifndef([XORG_MACROS_VERSION], 37 [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen. 38 Hint: either install from source, git://anongit.freedesktop.org/xorg/util/macros or, 39 depending on you distribution, try package 'xutils-dev' or 'xorg-x11-util-macros'])]) 40 41XORG_MACROS_VERSION(1.8) 42XORG_DEFAULT_OPTIONS 43 44AC_CHECK_PROGS([PYTHON], [python3 python2 python]) 45 46# Initialize libtool 47AC_DISABLE_STATIC 48AC_LIBTOOL_WIN32_DLL 49AC_PROG_LIBTOOL 50AC_SYS_LARGEFILE 51 52AC_CHECK_HEADER([KHR/khrplatform.h], 53 [AC_DEFINE([HAVE_KHRPLATFORM_H], [1], 54 [Define to 1 if you have <KHR/khrplatform.h> (used for tests)] 55 )] 56 ) 57 58# OS X defaults to having -Wint-conversion ("warn when passing 59# uintptr_t to a void *") by default. Kill that. 60XORG_TESTSET_CFLAG(CWARNFLAGS, [-Wno-int-conversion]) 61 62AC_ARG_ENABLE([x11], 63 [AC_HELP_STRING([--enable-x11=@<:@yes,no@:>@], [Enable X11 support @<:@default=yes@:>@])], 64 [enable_x11=$enableval], 65 [enable_x11=yes]) 66 67AC_ARG_ENABLE([glx], 68 [AC_HELP_STRING([--enable-glx=@<:@auto,yes,no@:>@], [Enable GLX support @<:@default=auto@:>@])], 69 [enable_glx=$enableval], 70 [enable_glx=auto]) 71 72# GLX can be used on different platforms, so we expose a 73# configure time switch to enable or disable it; in case 74# the "auto" default value is set, we only enable GLX 75# support on Linux and Unix 76AS_CASE([$enable_glx], 77 [auto], [ 78 AS_CASE([$host_os], 79 [mingw*], [build_glx=no], 80 [darwin*], [build_glx=no], 81 [android*], [build_glx=no], 82 [build_glx=yes]) 83 ], 84 85 [yes], [ 86 build_glx=yes 87 ], 88 89 [no], [ 90 build_glx=no 91 ], 92 93 [AC_MSG_ERROR([Invalid value "$enable_glx" for option "--enable-glx"])] 94]) 95 96AC_ARG_ENABLE([egl], 97 [AC_HELP_STRING([--enable-egl=@<:@auto,yes,no@:>@], [Enable EGL support @<:@default=auto@:>@])], 98 [enable_egl=$enableval], 99 [enable_egl=auto]) 100 101AS_CASE([$enable_egl], 102 [auto], [ 103 AS_CASE([$host_os], 104 [mingw*], [build_egl=no], 105 [darwin*], [build_egl=no], 106 [build_egl=yes]) 107 ], 108 109 [yes], [ 110 build_egl=yes 111 ], 112 113 [no], [ 114 build_egl=no 115 ], 116 117 [AC_MSG_ERROR([Invalid value "$enable_egl" for option "--enable-egl"])] 118]) 119 120# The remaining platform specific API are enabled depending on the 121# platform we're building for 122AS_CASE([$host_os], 123 [mingw*], [ 124 build_wgl=yes 125 has_znow=yes 126 # On windows, the DLL has to have all of its functions 127 # resolved at link time, so we have to link directly against 128 # opengl32.dll. But that's the only GL provider, anyway. 129 EPOXY_LINK_LIBS="-lopengl32" 130 131 # Testing our built windows binaries requires that they be run 132 # under wine. Yeah, we should be nice and autodetect, but 133 # there's lots of missing autodetection for the testsuite 134 # (like checking for EGL and GLX libs in non-windows.). 135 AC_SUBST([LOG_COMPILER], [wine]) 136 ], 137 138 [darwin*], [ 139 build_wgl=no 140 has_znow=no 141 EPOXY_LINK_LIBS="" 142 ], 143 144 [ 145 build_wgl=no 146 has_znow=yes 147 # On platforms with dlopen, we load everything dynamically and 148 # don't link against a specific window system or GL implementation. 149 EPOXY_LINK_LIBS="" 150 ] 151) 152 153AC_SUBST(EPOXY_LINK_LIBS) 154 155if test x$enable_x11 = xno; then 156 if test x$enable_glx = xyes; then 157 AC_MSG_ERROR([GLX support is explicitly enabled, but X11 was disabled]) 158 fi 159 build_glx=no 160else 161 AC_DEFINE([ENABLE_X11], [1], [Whether X11 support is enabled]) 162fi 163 164AM_CONDITIONAL(BUILD_EGL, test x$build_egl = xyes) 165if test x$build_egl = xyes; then 166 PKG_CHECK_MODULES(EGL, [egl]) 167 AC_DEFINE([BUILD_EGL], [1], [build EGL tests]) 168 AC_DEFINE(ENABLE_EGL, [1], [Whether EGL support is enabled]) 169fi 170 171AM_CONDITIONAL(BUILD_GLX, test x$build_glx = xyes) 172if test x$build_glx = xyes; then 173 AC_DEFINE([BUILD_GLX], [1], [build GLX tests]) 174fi 175 176AM_CONDITIONAL(BUILD_WGL, test x$build_wgl = xyes) 177if test x$build_wgl = xyes; then 178 AC_DEFINE([BUILD_WGL], [1], [build WGL tests]) 179fi 180 181AM_CONDITIONAL(HAS_ZNOW, test x$has_znow = xyes) 182 183AC_CHECK_LIB([GLESv1_CM], [glFlush], [has_gles1=yes], [has_gles1=no]) 184AM_CONDITIONAL(HAS_GLES1, test x$has_gles1 = xyes) 185 186AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"]) 187AC_SUBST([DLOPEN_LIBS]) 188 189savelibs=$LIBS 190LIBS=$DLOPEN_LIBS 191AC_CHECK_FUNCS([dlvsym], [have_dlvsym=1], [have_dlvsym=0]) 192AM_CONDITIONAL(HAVE_DLVSYM, test $have_dlvsym = 1) 193LIBS=$savelibs 194 195VISIBILITY_CFLAGS="" 196AS_CASE(["$host"], 197 198 [*-*-mingw*], [ 199 dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport) 200 AC_DEFINE([EPOXY_PUBLIC], 201 [__attribute__((visibility("default"))) __declspec(dllexport) extern], 202 [defines how to decorate public symbols while building]) 203 VISIBILITY_CFLAGS="-fvisibility=hidden" 204 ], 205 206 [ 207 dnl on other compilers, check if we can do -fvisibility=hidden 208 SAVED_CFLAGS="${CFLAGS}" 209 CFLAGS="-fvisibility=hidden" 210 AC_MSG_CHECKING([for -fvisibility=hidden compiler flag]) 211 AC_TRY_COMPILE([], [int main (void) { return 0; }], [ 212 AC_MSG_RESULT(yes) 213 enable_fvisibility_hidden=yes 214 ], [ 215 AC_MSG_RESULT(no) 216 enable_fvisibility_hidden=no 217 ]) 218 CFLAGS="${SAVED_CFLAGS}" 219 220 AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [ 221 AC_DEFINE([EPOXY_PUBLIC], 222 [__attribute__((visibility("default"))) extern], 223 [defines how to decorate public symbols while building]) 224 VISIBILITY_CFLAGS="-fvisibility=hidden" 225 ]) 226 ] 227) 228 229AC_SUBST([VISIBILITY_CFLAGS]) 230 231if test x$enable_x11 = xyes; then 232 PKG_CHECK_MODULES(X11, [x11], [x11=yes], [x11=no]) 233 if test x$x11 = xno -a x$build_glx = xyes; then 234 AC_MSG_ERROR([libX11 headers (libx11-dev) are required to build with GLX support]) 235 fi 236else 237 x11=no 238fi 239 240if test x$build_glx = xyes; then 241 AC_DEFINE(ENABLE_GLX, [1], [Whether GLX support is enabled]) 242fi 243 244AM_CONDITIONAL(HAVE_X11, test x$x11 = xyes) 245 246PKG_CHECK_MODULES(GL, [gl], [gl=yes], [gl=no]) 247PKG_CHECK_MODULES(EGL, [egl], [egl=yes], [egl=no]) 248 249GL_REQS="" 250AS_IF([test x$gl = xyes], [GL_REQS="$GL_REQS gl"]) 251AS_IF([test x$build_egl = xyes && test x$egl = xyes], [GL_REQS="$GL_REQS egl"]) 252AC_SUBST(GL_REQS) 253 254# Variables for the pkg-config file; AC_SUBST does not do `test` substitutions, 255# so we need to specify the boolean values here 256AS_IF([test x$build_glx = xyes], [epoxy_has_glx=1], [epoxy_has_glx=0]) 257AS_IF([test x$build_egl = xyes], [epoxy_has_egl=1], [epoxy_has_egl=0]) 258AS_IF([test x$build_wgl = xyes], [epoxy_has_wgl=1], [epoxy_has_wgl=0]) 259AC_SUBST(epoxy_has_glx) 260AC_SUBST(epoxy_has_egl) 261AC_SUBST(epoxy_has_wgl) 262 263AC_CONFIG_FILES([ 264 epoxy.pc 265 Makefile 266 include/epoxy/Makefile 267 src/Makefile 268 test/Makefile 269]) 270AC_OUTPUT 271 272echo " EGL: $build_egl" 273echo " GLX: $build_glx" 274echo " WGL: $build_wgl" 275echo " PYTHON: $PYTHON" 276