summaryrefslogtreecommitdiff
path: root/configure.in
blob: 35c2bb9efc9d506b71245387e3c29f4f355b663e (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
# 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.4.0
# 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_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_OUTPUT([
Makefile
src/Makefile
src/glx/Makefile
src/agl/Makefile
src/glitz.pc
src/glx/glitz-glx.pc
src/agl/glitz-agl.pc
])

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

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