Eric Anholt | a909eb4 | 2013-09-19 09:50:49 -0700 | [diff] [blame] | 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 |
| 23 | AC_PREREQ([2.60]) |
| 24 | AC_INIT([libepoxy], |
Emmanuele Bassi | 545b911 | 2018-10-05 00:46:33 +0100 | [diff] [blame^] | 25 | [1.5.4], |
Christopher Meng | b7e921d | 2015-03-04 10:37:02 +0800 | [diff] [blame] | 26 | [https://github.com/anholt/libepoxy], |
Eric Anholt | a909eb4 | 2013-09-19 09:50:49 -0700 | [diff] [blame] | 27 | [libepoxy]) |
| 28 | AC_CONFIG_SRCDIR([Makefile.am]) |
| 29 | AC_CONFIG_HEADERS([config.h]) |
Emmanuele Bassi | 48ee13e | 2017-02-09 17:10:34 +0000 | [diff] [blame] | 30 | AC_CONFIG_MACRO_DIR([m4]) |
Eric Anholt | a909eb4 | 2013-09-19 09:50:49 -0700 | [diff] [blame] | 31 | |
| 32 | # Initialize Automake |
Emmanuele Bassi | 43a66ca | 2017-02-06 15:00:37 +0000 | [diff] [blame] | 33 | AM_INIT_AUTOMAKE([foreign -Wno-portability dist-xz no-dist-gzip tar-ustar subdir-objects]) |
Eric Anholt | a909eb4 | 2013-09-19 09:50:49 -0700 | [diff] [blame] | 34 | |
| 35 | # Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS |
| 36 | m4_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 | |
| 41 | XORG_MACROS_VERSION(1.8) |
| 42 | XORG_DEFAULT_OPTIONS |
| 43 | |
Emmanuele Bassi | 877fe81 | 2017-02-13 09:33:19 +0000 | [diff] [blame] | 44 | AC_CHECK_PROGS([PYTHON], [python3 python2 python]) |
Eric Anholt | a909eb4 | 2013-09-19 09:50:49 -0700 | [diff] [blame] | 45 | |
| 46 | # Initialize libtool |
| 47 | AC_DISABLE_STATIC |
Eric Anholt | 2591368 | 2013-12-06 13:40:30 -0800 | [diff] [blame] | 48 | AC_LIBTOOL_WIN32_DLL |
Eric Anholt | a909eb4 | 2013-09-19 09:50:49 -0700 | [diff] [blame] | 49 | AC_PROG_LIBTOOL |
| 50 | AC_SYS_LARGEFILE |
| 51 | |
Eric Anholt | e4f5da9 | 2014-02-06 10:51:33 -0800 | [diff] [blame] | 52 | AC_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 | |
Eric Anholt | 0cfb0a0 | 2013-12-12 11:18:28 -0800 | [diff] [blame] | 58 | # OS X defaults to having -Wint-conversion ("warn when passing |
| 59 | # uintptr_t to a void *") by default. Kill that. |
| 60 | XORG_TESTSET_CFLAG(CWARNFLAGS, [-Wno-int-conversion]) |
| 61 | |
Emmanuele Bassi | ce8cbdb | 2018-02-23 15:44:50 +0000 | [diff] [blame] | 62 | AC_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 | |
Emmanuele Bassi | 2b6f01b | 2017-01-18 16:07:02 +0000 | [diff] [blame] | 67 | AC_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]) |
Eric Anholt | c92fcc8 | 2013-12-16 08:25:12 -0800 | [diff] [blame] | 71 | |
Emmanuele Bassi | 2b6f01b | 2017-01-18 16:07:02 +0000 | [diff] [blame] | 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 |
| 76 | AS_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 | ], |
Eric Anholt | bfd687d | 2013-12-06 16:33:46 -0800 | [diff] [blame] | 84 | |
Emmanuele Bassi | 2b6f01b | 2017-01-18 16:07:02 +0000 | [diff] [blame] | 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 | |
Thomas Petazzoni | 0511fc5 | 2017-05-08 23:12:49 +0200 | [diff] [blame] | 96 | AC_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 | |
| 101 | AS_CASE([$enable_egl], |
| 102 | [auto], [ |
| 103 | AS_CASE([$host_os], |
| 104 | [mingw*], [build_egl=no], |
| 105 | [darwin*], [build_egl=no], |
Thomas Petazzoni | 0511fc5 | 2017-05-08 23:12:49 +0200 | [diff] [blame] | 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 |
Emmanuele Bassi | 2b6f01b | 2017-01-18 16:07:02 +0000 | [diff] [blame] | 122 | AS_CASE([$host_os], |
| 123 | [mingw*], [ |
Emmanuele Bassi | 2b6f01b | 2017-01-18 16:07:02 +0000 | [diff] [blame] | 124 | build_wgl=yes |
| 125 | has_znow=yes |
| 126 | # On windows, the DLL has to have all of its functions |
luz.paz | d60b923 | 2018-03-05 06:08:53 -0500 | [diff] [blame] | 127 | # resolved at link time, so we have to link directly against |
Emmanuele Bassi | 2b6f01b | 2017-01-18 16:07:02 +0000 | [diff] [blame] | 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*], [ |
Emmanuele Bassi | 2b6f01b | 2017-01-18 16:07:02 +0000 | [diff] [blame] | 139 | build_wgl=no |
Emmanuele Bassi | 2b6f01b | 2017-01-18 16:07:02 +0000 | [diff] [blame] | 140 | has_znow=no |
| 141 | EPOXY_LINK_LIBS="" |
| 142 | ], |
| 143 | |
| 144 | [ |
Emmanuele Bassi | 2b6f01b | 2017-01-18 16:07:02 +0000 | [diff] [blame] | 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 | ) |
Eric Anholt | 0d7d265 | 2013-12-06 12:09:57 -0800 | [diff] [blame] | 152 | |
Eric Anholt | 2591368 | 2013-12-06 13:40:30 -0800 | [diff] [blame] | 153 | AC_SUBST(EPOXY_LINK_LIBS) |
| 154 | |
Emmanuele Bassi | ce8cbdb | 2018-02-23 15:44:50 +0000 | [diff] [blame] | 155 | if 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 |
Emmanuele Bassi | a5c019e | 2018-10-04 21:59:34 +0100 | [diff] [blame] | 160 | else |
| 161 | AC_DEFINE([ENABLE_X11], [1], [Whether X11 support is enabled]) |
Emmanuele Bassi | ce8cbdb | 2018-02-23 15:44:50 +0000 | [diff] [blame] | 162 | fi |
| 163 | |
Eric Anholt | 0d7d265 | 2013-12-06 12:09:57 -0800 | [diff] [blame] | 164 | AM_CONDITIONAL(BUILD_EGL, test x$build_egl = xyes) |
| 165 | if test x$build_egl = xyes; then |
Eric Anholt | d56f21c | 2014-06-13 14:59:37 -0700 | [diff] [blame] | 166 | PKG_CHECK_MODULES(EGL, [egl]) |
Eric Anholt | 0d7d265 | 2013-12-06 12:09:57 -0800 | [diff] [blame] | 167 | AC_DEFINE([BUILD_EGL], [1], [build EGL tests]) |
Thomas Petazzoni | 0511fc5 | 2017-05-08 23:12:49 +0200 | [diff] [blame] | 168 | AC_DEFINE(ENABLE_EGL, [1], [Whether EGL support is enabled]) |
Eric Anholt | 0d7d265 | 2013-12-06 12:09:57 -0800 | [diff] [blame] | 169 | fi |
| 170 | |
| 171 | AM_CONDITIONAL(BUILD_GLX, test x$build_glx = xyes) |
| 172 | if test x$build_glx = xyes; then |
| 173 | AC_DEFINE([BUILD_GLX], [1], [build GLX tests]) |
| 174 | fi |
| 175 | |
Eric Anholt | 1d746bf | 2013-12-09 14:52:19 -0800 | [diff] [blame] | 176 | AM_CONDITIONAL(BUILD_WGL, test x$build_wgl = xyes) |
| 177 | if test x$build_wgl = xyes; then |
| 178 | AC_DEFINE([BUILD_WGL], [1], [build WGL tests]) |
| 179 | fi |
| 180 | |
Eric Anholt | c92fcc8 | 2013-12-16 08:25:12 -0800 | [diff] [blame] | 181 | AM_CONDITIONAL(HAS_ZNOW, test x$has_znow = xyes) |
Eric Anholt | a909eb4 | 2013-09-19 09:50:49 -0700 | [diff] [blame] | 182 | |
Emmanuele Bassi | 6b68dde | 2017-01-18 14:24:09 +0000 | [diff] [blame] | 183 | AC_CHECK_LIB([GLESv1_CM], [glFlush], [has_gles1=yes], [has_gles1=no]) |
| 184 | AM_CONDITIONAL(HAS_GLES1, test x$has_gles1 = xyes) |
| 185 | |
Eric Anholt | f6e91a7 | 2014-01-30 12:08:57 -0800 | [diff] [blame] | 186 | AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"]) |
| 187 | AC_SUBST([DLOPEN_LIBS]) |
| 188 | |
Ross Burton | f9098b0 | 2018-03-07 13:33:14 +0000 | [diff] [blame] | 189 | savelibs=$LIBS |
| 190 | LIBS=$DLOPEN_LIBS |
| 191 | AC_CHECK_FUNCS([dlvsym], [have_dlvsym=1], [have_dlvsym=0]) |
| 192 | AM_CONDITIONAL(HAVE_DLVSYM, test $have_dlvsym = 1) |
| 193 | LIBS=$savelibs |
| 194 | |
Emmanuele Bassi | 7a06803 | 2017-01-24 17:43:59 +0000 | [diff] [blame] | 195 | VISIBILITY_CFLAGS="" |
| 196 | AS_CASE(["$host"], |
Eric Anholt | 2591368 | 2013-12-06 13:40:30 -0800 | [diff] [blame] | 197 | |
Emmanuele Bassi | 7a06803 | 2017-01-24 17:43:59 +0000 | [diff] [blame] | 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 | ) |
Eric Anholt | a909eb4 | 2013-09-19 09:50:49 -0700 | [diff] [blame] | 228 | |
| 229 | AC_SUBST([VISIBILITY_CFLAGS]) |
| 230 | |
Emmanuele Bassi | ce8cbdb | 2018-02-23 15:44:50 +0000 | [diff] [blame] | 231 | if 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 |
Emmanuele Bassi | 2b6f01b | 2017-01-18 16:07:02 +0000 | [diff] [blame] | 236 | else |
Emmanuele Bassi | ce8cbdb | 2018-02-23 15:44:50 +0000 | [diff] [blame] | 237 | x11=no |
| 238 | fi |
| 239 | |
| 240 | if test x$build_glx = xyes; then |
| 241 | AC_DEFINE(ENABLE_GLX, [1], [Whether GLX support is enabled]) |
Eric Anholt | 847ba1a | 2013-12-11 16:25:48 -0800 | [diff] [blame] | 242 | fi |
| 243 | |
Eric Anholt | a909eb4 | 2013-09-19 09:50:49 -0700 | [diff] [blame] | 244 | AM_CONDITIONAL(HAVE_X11, test x$x11 = xyes) |
| 245 | |
Eric Anholt | 9ffa5d2 | 2013-12-05 13:50:10 -0800 | [diff] [blame] | 246 | PKG_CHECK_MODULES(GL, [gl], [gl=yes], [gl=no]) |
Emmanuele Bassi | baa75c4 | 2018-02-23 10:52:58 +0000 | [diff] [blame] | 247 | PKG_CHECK_MODULES(EGL, [egl], [egl=yes], [egl=no]) |
| 248 | |
| 249 | GL_REQS="" |
| 250 | AS_IF([test x$gl = xyes], [GL_REQS="$GL_REQS gl"]) |
| 251 | AS_IF([test x$build_egl = xyes && test x$egl = xyes], [GL_REQS="$GL_REQS egl"]) |
| 252 | AC_SUBST(GL_REQS) |
Eric Anholt | a909eb4 | 2013-09-19 09:50:49 -0700 | [diff] [blame] | 253 | |
Emmanuele Bassi | 7b52d33 | 2017-02-06 14:49:21 +0000 | [diff] [blame] | 254 | # Variables for the pkg-config file; AC_SUBST does not do `test` substitutions, |
| 255 | # so we need to specify the boolean values here |
| 256 | AS_IF([test x$build_glx = xyes], [epoxy_has_glx=1], [epoxy_has_glx=0]) |
| 257 | AS_IF([test x$build_egl = xyes], [epoxy_has_egl=1], [epoxy_has_egl=0]) |
| 258 | AS_IF([test x$build_wgl = xyes], [epoxy_has_wgl=1], [epoxy_has_wgl=0]) |
| 259 | AC_SUBST(epoxy_has_glx) |
| 260 | AC_SUBST(epoxy_has_egl) |
| 261 | AC_SUBST(epoxy_has_wgl) |
| 262 | |
Eric Anholt | a909eb4 | 2013-09-19 09:50:49 -0700 | [diff] [blame] | 263 | AC_CONFIG_FILES([ |
| 264 | epoxy.pc |
| 265 | Makefile |
Eric Anholt | 43acf7b | 2013-12-06 11:50:00 -0800 | [diff] [blame] | 266 | include/epoxy/Makefile |
Eric Anholt | a909eb4 | 2013-09-19 09:50:49 -0700 | [diff] [blame] | 267 | src/Makefile |
Eric Anholt | 04cf940 | 2013-11-11 09:59:25 -0800 | [diff] [blame] | 268 | test/Makefile |
Eric Anholt | a909eb4 | 2013-09-19 09:50:49 -0700 | [diff] [blame] | 269 | ]) |
| 270 | AC_OUTPUT |
| 271 | |
Eric Anholt | 906d5b6 | 2013-12-06 12:21:54 -0800 | [diff] [blame] | 272 | echo " EGL: $build_egl" |
| 273 | echo " GLX: $build_glx" |
Eric Anholt | 1d746bf | 2013-12-09 14:52:19 -0800 | [diff] [blame] | 274 | echo " WGL: $build_wgl" |
Eric Anholt | a909eb4 | 2013-09-19 09:50:49 -0700 | [diff] [blame] | 275 | echo " PYTHON: $PYTHON" |