summaryrefslogtreecommitdiff
path: root/configure.in
blob: a5ac18402874042fa3d52c4f6e073b43fd5e35ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# Process this file with autoconf to produce a configure script.

AC_INIT(src/glitz.h)

dnl ===========================================================================

# Package version number, (as distinct from shared library version)
# This must be manually synchronized with the version in src/glitz.h
GLITZ_VERSION=0.5.2
# libtool shared library version

# Increment if the interface has additions, changes, removals.
LT_CURRENT=1

# Increment any time the source changes; set to
# 0 if you increment CURRENT
LT_REVISION=0

# Increment if any interfaces have been added; set to 0
# if any interfaces have been removed. removal has
# precedence over adding, so set to 0 if both happened.
LT_AGE=0

VERSION_INFO="$LT_CURRENT:$LT_REVISION:$LT_AGE"
AC_SUBST(VERSION_INFO)

dnl ===========================================================================

AC_CONFIG_AUX_DIR(config)

AM_INIT_AUTOMAKE(glitz, $GLITZ_VERSION)
AM_CONFIG_HEADER(config.h)

AM_MAINTAINER_MODE

AC_ISC_POSIX
AC_PROG_CC
AC_PROG_CPP
AC_PROG_AWK
AM_PROG_LIBTOOL
AC_STDC_HEADERS

if test "x$GCC" = "xyes"; then
  case " $CFLAGS " in
  *[[\ \	]]-Wall[[\ \	]]*) ;;
  *) CFLAGS="$CFLAGS -Wall" ;;
  esac

  case " $CFLAGS " in
  *[[\ \	]]-Wpointer-arith[[\ \	]]*) ;;
  *) CFLAGS="$CFLAGS -Wpointer-arith" ;;
  esac

  case " $CFLAGS " in
  *[[\ \	]]-Wstrict-prototypes[[\ \	]]*) ;;
  *) CFLAGS="$CFLAGS -Wstrict-prototypes" ;;
  esac

  case " $CFLAGS " in
  *[[\ \	]]-Wmissing-prototypes[[\ \	]]*) ;;
  *) CFLAGS="$CFLAGS -Wmissing-prototypes" ;;
  esac

  case " $CFLAGS " in
  *[[\ \	]]-Wmissing-declarations[[\ \	]]*) ;;
  *) CFLAGS="$CFLAGS -Wmissing-declarations" ;;
  esac

  case " $CFLAGS " in
  *[[\ \	]]-Wnested-externs[[\ \	]]*) ;;
  *) CFLAGS="$CFLAGS -Wnested-externs" ;;
  esac

  case " $CFLAGS " in
  *[[\ \	]]-fno-strict-aliasing[[\ \	]]*) ;;
  *) CFLAGS="$CFLAGS -fno-strict-aliasing" ;;
  esac

  if test "x$enable_ansi" = "xyes"; then
    case " $CFLAGS " in
    *[[\ \	]]-ansi[[\ \	]]*) ;;
    *) CFLAGS="$CFLAGS -ansi" ;;
    esac

    case " $CFLAGS " in
    *[[\ \	]]-pedantic[[\ \	]]*) ;;
    *) CFLAGS="$CFLAGS -pedantic" ;;
    esac
  fi
fi

AC_C_BIGENDIAN

dnl ===========================================================================

GLITZ_LIB='-L$(top_builddir)/src -lglitz'
GLITZ_INC='-I$(top_builddir)/src -I$(top_srcdir)/src'

AC_SUBST(GLITZ_LIB)
AC_SUBST(GLITZ_INC)

dnl ===========================================================================

AC_MSG_CHECKING([for Win32])
case "$host" in
  *-*-mingw*)
    native_win32=yes
    ;;
  *)
    native_win32=no
    LIBM="-lm"
    ;;
esac
AC_MSG_RESULT([$native_win32])

AM_CONDITIONAL(OS_WIN32, [test $native_win32 = yes])

AC_SUBST(LIBM)

dnl ===========================================================================

AC_ARG_ENABLE(glx,
  AC_HELP_STRING([--disable-glx], [Disable glitz's GLX backend]),
  [use_glx=$enableval], [use_glx=yes])

AH_TEMPLATE([XTHREADS], [Define if Xlib supports XTHREADS])

if test "x$use_glx" = "xyes"; then
  AC_PATH_XTRA

  if test "x$have_x" = "xyes"; then
    GLX_LIBS="$X_LIBS -lX11 -lGL"
    GLX_CFLAGS="$X_CFLAGS"

    save_LIBS="$LIBS"
    save_CFLAGS="$CFLAGS"
    CFLAGS="$CFLAGS $GLX_CFLAGS"
    LIBS="$LIBS $GLX_LIBS"

    AC_MSG_CHECKING([for XTHREADS in Xlib])
    AC_RUN_IFELSE(
      [AC_LANG_PROGRAM([[#include <X11/Xlib.h>]],
          [[return XInitThreads() == 0 ? 0 : 1;]])],
      [xthreads=no],
      [xthreads=yes],
      [xthreads=yes])

    AC_MSG_RESULT($xthreads)

    LIBS="$save_LIBS"
    CFLAGS="$save_CFLAGS"

    if test "x$xthreads" = "xyes"
    then
      GLX_LIBS="$GLX_LIBS -lpthread"
      AC_DEFINE(XTHREADS, 1)
    fi

    use_glx="yes"
  else
    use_glx="no"
  fi
fi

if test "x$use_glx" = "xyes"; then
  AM_CONDITIONAL(GLITZ_BUILD_GLX_BACKEND, true)
else
  AM_CONDITIONAL(GLITZ_BUILD_GLX_BACKEND, false)
fi

AC_SUBST(GLX_CFLAGS)
AC_SUBST(GLX_LIBS)

dnl ===========================================================================

AC_ARG_ENABLE(agl,
  AC_HELP_STRING([--disable-agl], [Disable glitz's AGL backend]),
  [use_agl=$enableval], [use_agl=yes])

AH_TEMPLATE([PTHREADS], [Define if PTHREADS are supported])

if test "x$use_agl" = "xyes"; then
  AC_MSG_CHECKING([for AGL.framework])
  save_libs="$LIBS"
  LIBS="-framework AGL"
  AC_TRY_LINK_FUNC(aglCreateContext, [use_agl=yes], [use_agl=no])
  LIBS="$save_libs"
  AC_MSG_RESULT([$use_agl])

  if test "x$use_agl" = "xyes"; then
    save_libs="$LIBS"
    LIBS="-lpthread"

    AC_MSG_CHECKING([for PTHREADS])
    AC_TRY_LINK_FUNC(pthread_key_create, [use_pthreads=yes], [use_pthreads=no])

    LIBS="$save_LIBS"

    if test "x$use_pthreads" = "xyes"
    then
      AGL_LIBS="$AGL_LIBS -lpthread"
      AC_DEFINE(PTHREADS, 1)
    fi
    AC_MSG_RESULT($use_pthreads)
  fi
fi

if test "x$use_agl" = "xyes"; then
  AM_CONDITIONAL(GLITZ_BUILD_AGL_BACKEND, true)
else
  AM_CONDITIONAL(GLITZ_BUILD_AGL_BACKEND, false)
fi

AC_SUBST(AGL_CFLAGS)
AC_SUBST(AGL_LIBS)


dnl ===========================================================================

AC_ARG_ENABLE(egl,
  AC_HELP_STRING([--enable-egl], [Enable glitz's EGL backend]),
  [use_egl=$enableval], [use_egl=no])

if test "x$use_egl" = "xyes"; then
  EGL_LIBS="-lGL -lEGL"
  EGL_CFLAGS="$EGL_CFLAGS"
  
  save_libs="$LIBS"
  LIBS="-lpthread"

  AC_MSG_CHECKING([for PTHREADS])
  AC_TRY_LINK_FUNC(pthread_key_create, [use_pthreads=yes], [use_pthreads=no])

  LIBS="$save_LIBS"

  if test "x$use_pthreads" = "xyes"
  then
    EGL_LIBS="$EGL_LIBS -lpthread"
    AC_DEFINE(PTHREADS, 1)
  fi
  AC_MSG_RESULT($use_pthreads)
fi

if test "x$use_egl" = "xyes"; then
  AM_CONDITIONAL(GLITZ_BUILD_EGL_BACKEND, true)
else
  AM_CONDITIONAL(GLITZ_BUILD_EGL_BACKEND, false)
fi

AC_SUBST(EGL_CFLAGS)
AC_SUBST(EGL_LIBS)


dnl ===========================================================================

AC_ARG_ENABLE(wgl,
  AC_HELP_STRING([--disable-wgl], [Disable glitz's WGL backend]),
  [use_wgl=$enableval], [use_wgl=yes])

if test "x$use_wgl" = "xyes"; then
  AC_MSG_CHECKING([for WGL])
  WGL_LIBS="-lopengl32 -lgdi32"
  WGL_CFLAGS=""

  save_libs="$LIBS"
  LIBS="$WGL_LIBS"
  AC_TRY_LINK([#include <windows.h>], [int main() { wglCreateContext(0); }],
	[use_wgl=yes], [use_wgl=no])
  LIBS="$save_libs"
  AC_MSG_RESULT([$use_wgl])
fi

if test "x$use_wgl" = "xyes"; then
  AM_CONDITIONAL(GLITZ_BUILD_WGL_BACKEND, true)
else
  AM_CONDITIONAL(GLITZ_BUILD_WGL_BACKEND, false)
  WGL_LIBS=""
  WGL_CFLAGS=""
fi

AC_SUBST(WGL_CFLAGS)
AC_SUBST(WGL_LIBS)

dnl ===========================================================================

AC_OUTPUT([
Makefile
src/Makefile
src/glx/Makefile
src/agl/Makefile
src/egl/Makefile
src/wgl/Makefile
src/glitz.pc
src/glx/glitz-glx.pc
src/agl/glitz-agl.pc
src/egl/glitz-egl.pc
src/wgl/glitz-wgl.pc
])

dnl ===========================================================================

echo ""
echo "glitz will be compiled with the following backends:"
echo "  GLX: $use_glx"
echo "  AGL: $use_agl"
echo "  EGL: $use_egl"
echo "  WGL: $use_wgl"
echo ""