blob: b0bb452e8ecfd952a22bea57961892bfdafcfdd2 [file] [log] [blame]
Eric Anholta909eb42013-09-19 09:50:49 -07001# 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],
Emmanuele Bassi545b9112018-10-05 00:46:33 +010025 [1.5.4],
Christopher Mengb7e921d2015-03-04 10:37:02 +080026 [https://github.com/anholt/libepoxy],
Eric Anholta909eb42013-09-19 09:50:49 -070027 [libepoxy])
28AC_CONFIG_SRCDIR([Makefile.am])
29AC_CONFIG_HEADERS([config.h])
Emmanuele Bassi48ee13e2017-02-09 17:10:34 +000030AC_CONFIG_MACRO_DIR([m4])
Eric Anholta909eb42013-09-19 09:50:49 -070031
32# Initialize Automake
Emmanuele Bassi43a66ca2017-02-06 15:00:37 +000033AM_INIT_AUTOMAKE([foreign -Wno-portability dist-xz no-dist-gzip tar-ustar subdir-objects])
Eric Anholta909eb42013-09-19 09:50:49 -070034
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
Emmanuele Bassi877fe812017-02-13 09:33:19 +000044AC_CHECK_PROGS([PYTHON], [python3 python2 python])
Eric Anholta909eb42013-09-19 09:50:49 -070045
46# Initialize libtool
47AC_DISABLE_STATIC
Eric Anholt25913682013-12-06 13:40:30 -080048AC_LIBTOOL_WIN32_DLL
Eric Anholta909eb42013-09-19 09:50:49 -070049AC_PROG_LIBTOOL
50AC_SYS_LARGEFILE
51
Eric Anholte4f5da92014-02-06 10:51:33 -080052AC_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 Anholt0cfb0a02013-12-12 11:18:28 -080058# 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
Emmanuele Bassice8cbdb2018-02-23 15:44:50 +000062AC_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 Bassi2b6f01b2017-01-18 16:07:02 +000067AC_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 Anholtc92fcc82013-12-16 08:25:12 -080071
Emmanuele Bassi2b6f01b2017-01-18 16:07:02 +000072# 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 ],
Eric Anholtbfd687d2013-12-06 16:33:46 -080084
Emmanuele Bassi2b6f01b2017-01-18 16:07:02 +000085 [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 Petazzoni0511fc52017-05-08 23:12:49 +020096AC_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],
Thomas Petazzoni0511fc52017-05-08 23:12:49 +0200106 [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 Bassi2b6f01b2017-01-18 16:07:02 +0000122AS_CASE([$host_os],
123 [mingw*], [
Emmanuele Bassi2b6f01b2017-01-18 16:07:02 +0000124 build_wgl=yes
125 has_znow=yes
126 # On windows, the DLL has to have all of its functions
luz.pazd60b9232018-03-05 06:08:53 -0500127 # resolved at link time, so we have to link directly against
Emmanuele Bassi2b6f01b2017-01-18 16:07:02 +0000128 # 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 Bassi2b6f01b2017-01-18 16:07:02 +0000139 build_wgl=no
Emmanuele Bassi2b6f01b2017-01-18 16:07:02 +0000140 has_znow=no
141 EPOXY_LINK_LIBS=""
142 ],
143
144 [
Emmanuele Bassi2b6f01b2017-01-18 16:07:02 +0000145 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 Anholt0d7d2652013-12-06 12:09:57 -0800152
Eric Anholt25913682013-12-06 13:40:30 -0800153AC_SUBST(EPOXY_LINK_LIBS)
154
Emmanuele Bassice8cbdb2018-02-23 15:44:50 +0000155if 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 Bassia5c019e2018-10-04 21:59:34 +0100160else
161 AC_DEFINE([ENABLE_X11], [1], [Whether X11 support is enabled])
Emmanuele Bassice8cbdb2018-02-23 15:44:50 +0000162fi
163
Eric Anholt0d7d2652013-12-06 12:09:57 -0800164AM_CONDITIONAL(BUILD_EGL, test x$build_egl = xyes)
165if test x$build_egl = xyes; then
Eric Anholtd56f21c2014-06-13 14:59:37 -0700166 PKG_CHECK_MODULES(EGL, [egl])
Eric Anholt0d7d2652013-12-06 12:09:57 -0800167 AC_DEFINE([BUILD_EGL], [1], [build EGL tests])
Thomas Petazzoni0511fc52017-05-08 23:12:49 +0200168 AC_DEFINE(ENABLE_EGL, [1], [Whether EGL support is enabled])
Eric Anholt0d7d2652013-12-06 12:09:57 -0800169fi
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
Eric Anholt1d746bf2013-12-09 14:52:19 -0800176AM_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
Eric Anholtc92fcc82013-12-16 08:25:12 -0800181AM_CONDITIONAL(HAS_ZNOW, test x$has_znow = xyes)
Eric Anholta909eb42013-09-19 09:50:49 -0700182
Emmanuele Bassi6b68dde2017-01-18 14:24:09 +0000183AC_CHECK_LIB([GLESv1_CM], [glFlush], [has_gles1=yes], [has_gles1=no])
184AM_CONDITIONAL(HAS_GLES1, test x$has_gles1 = xyes)
185
Eric Anholtf6e91a72014-01-30 12:08:57 -0800186AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])
187AC_SUBST([DLOPEN_LIBS])
188
Ross Burtonf9098b02018-03-07 13:33:14 +0000189savelibs=$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
Emmanuele Bassi7a068032017-01-24 17:43:59 +0000195VISIBILITY_CFLAGS=""
196AS_CASE(["$host"],
Eric Anholt25913682013-12-06 13:40:30 -0800197
Emmanuele Bassi7a068032017-01-24 17:43:59 +0000198 [*-*-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 Anholta909eb42013-09-19 09:50:49 -0700228
229AC_SUBST([VISIBILITY_CFLAGS])
230
Emmanuele Bassice8cbdb2018-02-23 15:44:50 +0000231if 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 Bassi2b6f01b2017-01-18 16:07:02 +0000236else
Emmanuele Bassice8cbdb2018-02-23 15:44:50 +0000237 x11=no
238fi
239
240if test x$build_glx = xyes; then
241 AC_DEFINE(ENABLE_GLX, [1], [Whether GLX support is enabled])
Eric Anholt847ba1a2013-12-11 16:25:48 -0800242fi
243
Eric Anholta909eb42013-09-19 09:50:49 -0700244AM_CONDITIONAL(HAVE_X11, test x$x11 = xyes)
245
Eric Anholt9ffa5d22013-12-05 13:50:10 -0800246PKG_CHECK_MODULES(GL, [gl], [gl=yes], [gl=no])
Emmanuele Bassibaa75c42018-02-23 10:52:58 +0000247PKG_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)
Eric Anholta909eb42013-09-19 09:50:49 -0700253
Emmanuele Bassi7b52d332017-02-06 14:49:21 +0000254# 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
Eric Anholta909eb42013-09-19 09:50:49 -0700263AC_CONFIG_FILES([
264 epoxy.pc
265 Makefile
Eric Anholt43acf7b2013-12-06 11:50:00 -0800266 include/epoxy/Makefile
Eric Anholta909eb42013-09-19 09:50:49 -0700267 src/Makefile
Eric Anholt04cf9402013-11-11 09:59:25 -0800268 test/Makefile
Eric Anholta909eb42013-09-19 09:50:49 -0700269])
270AC_OUTPUT
271
Eric Anholt906d5b62013-12-06 12:21:54 -0800272echo " EGL: $build_egl"
273echo " GLX: $build_glx"
Eric Anholt1d746bf2013-12-09 14:52:19 -0800274echo " WGL: $build_wgl"
Eric Anholta909eb42013-09-19 09:50:49 -0700275echo " PYTHON: $PYTHON"