1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ(2.57)
5
6# Init autoconf.
7# --------------
8
9AC_INIT([QuesoGLC], [0.7.2],
10        [quesoglc-general@lists.sourceforge.net],
11        [quesoglc])
12
13AC_CONFIG_HEADER([include/qglc_config.h:include/qglc_config.hin])
14
15AC_CONFIG_SRCDIR([src/global.c])
16AC_CONFIG_AUX_DIR([build])
17
18# Optional parameters definition.
19# -------------------------------
20
21AC_ARG_WITH([fribidi],
22  AC_HELP_STRING([--with-fribidi],
23   [use the FriBiDi system library @<:@default=yes@:>@]),
24   [], [with_fribidi=yes]
25)
26AC_ARG_WITH([glew],
27  AC_HELP_STRING([--with-glew],
28   [use the GLEW system library @<:@default=yes@:>@]),
29   [], [with_glew=yes]
30)
31AC_ARG_ENABLE([executables],
32  AC_HELP_STRING([--enable-executables],
33   [build example and test executables @<:@default=yes@:>@]),
34   [], [enable_executables=yes]
35)
36AC_ARG_ENABLE([debug],
37  AC_HELP_STRING([--enable-debug],
38   [compile debug version @<:@default=no@:>@]),
39   [], [enable_debug=no]
40)
41
42# Init automake.
43# --------------
44
45AM_INIT_AUTOMAKE([dist-bzip2])
46
47
48# Checks for programs.
49# --------------------
50
51AC_PROG_CC
52AM_PROG_CC_C_O
53AC_PROG_INSTALL
54AC_PROG_LN_S
55AC_PROG_LIBTOOL
56
57
58# Checks for multithreading support.
59# ----------------------------------
60
61ACX_PTHREAD
62
63CC="$PTHREAD_CC"
64
65
66# Checks for TLS support.
67# -----------------------
68
69AX_CHECK_TLS
70
71
72# Checks for typedefs, structures, and compiler characteristics.
73# --------------------------------------------------------------
74
75AC_C_CONST
76AC_C_INLINE
77
78AC_TYPE_SIZE_T
79
80AC_CHECK_SIZEOF(short, 2)
81AC_CHECK_SIZEOF(int, 4)
82AC_CHECK_SIZEOF(long, 4)
83
84
85# Checks for header files.
86# ------------------------
87
88AC_HEADER_STDC
89AC_CHECK_HEADERS([stdlib.h string.h unistd.h], [],
90                 [AC_MSG_ERROR([Unable to locate a required header])])
91
92
93# Checks for C library features.
94# ------------------------------
95
96case $target_alias in
97*mingw32*) ;;
98*)
99  AC_FUNC_MALLOC
100  AC_FUNC_MEMCMP
101  AC_FUNC_REALLOC
102  ;;
103esac
104AC_FUNC_STAT
105AC_CHECK_FUNCS([atexit memmove memset strdup])
106
107AC_CHECK_LIB([m], [sqrt])
108
109
110# Checks for font libraries.
111# --------------------------
112
113AX_CHECK_FREETYPE2
114
115if (test "x$no_ft2" = "xyes"); then
116  AC_MSG_ERROR([Unable to locate the required FreeType library])
117fi
118
119AC_CHECK_LIB(freetype, FTC_Manager_New,
120             AC_DEFINE([HAVE_FT_CACHE], [1], [Define if FreeType supports the caching routines]))
121
122AX_CHECK_FONTCONFIG
123
124if (test "x$no_fc" = "xyes"); then
125  AC_MSG_ERROR([Unable to locate the required Fontconfig library])
126fi
127
128
129# Checks for Unicode libraries.
130# -----------------------------
131
132if (test "x$with_fribidi" = "xyes"); then
133  AX_CHECK_FRIBIDI
134  if (test "x$no_fribidi" = "xyes"); then
135    AC_MSG_NOTICE([FriBiDi will be built and embedded])
136  fi
137else
138  no_fribidi="yes"
139fi
140
141if (test "x$no_fribidi" = "xyes"); then
142  FRIBIDI_OBJ="libGLC_la-fribidi.lo libGLC_la-fribidi_char_type.lo \
143               libGLC_la-fribidi_mirroring.lo libGLC_la-fribidi_types.lo"
144else
145  PKGCONFIG_REQUIREMENTS="fribidi"
146fi
147
148# Checks for OpenGL and related libraries.
149# ----------------------------------------
150
151AX_CHECK_GL
152
153if (test "x$no_gl" = "xyes"); then
154  AC_MSG_ERROR([OpenGL not found])
155fi
156
157AX_CHECK_GLU
158
159if (test "x$no_glu" = "xyes"); then
160  AC_MSG_ERROR([GLU library not found])
161fi
162
163PKGCONFIG_LIBS_PRIVATE="$PHREAD_LIBS $GLU_LIBS"
164PKGCONFIG_INCLUDE="$GLU_CFLAGS"
165
166# Checks for GLEW library.
167# ------------------------
168
169if (test "x$with_glew" = "xyes"); then
170  AX_CHECK_GLEW
171  if (test "x$no_glew" = "xyes"); then
172    AC_MSG_NOTICE([GLEW will be built and embedded])
173  fi
174else
175  no_glew="yes"
176fi
177
178if (test "x$no_glew" = "xyes"); then
179  GLEW_CFLAGS="-DGLEW_MX"
180  GLEW_OBJ="libGLC_la-glew.lo"
181else
182  PKGCONFIG_LIBS_PRIVATE="-lGLEW $PKGCONFIG_LIBS_PRIVATE"
183fi
184
185# Special flags for MinGW32 build.
186# --------------------------------
187
188case $target_alias in
189*mingw32*)
190  if (test "x$enable_static" = "xyes"); then
191    GLEW_CFLAGS+=" -DGLEW_STATIC"
192  else
193    GLEW_CFLAGS+=" -DGLEW_BUILD"
194  fi
195  ;;
196esac
197
198# Determine whether to build (or not) test and examples executables.
199# ------------------------------------------------------------------
200
201if (test "x$enable_executables" = "xyes"); then
202
203  AX_CHECK_GLUT
204
205  if (test "x$no_glut" = "xyes"); then
206    AC_MSG_WARN([The GLUT library could not be found : example programs and \
207                 some tests will not be built])
208    EXECUTABLES="tests"
209  else
210    EXECUTABLES="tests examples"
211    case $target_alias in
212    *mingw32*)
213      TESTS_WITH_GLUT="test1 test5 test6 test7 test8 test9.1 test9.2 test9.3 \
214                       test9.4 test9.5 test9.6 test9.7 test9.8 test10 test11.1 \
215                       test11.2 test11.3 test11.4 test11.5 test11.6 test11.7 \
216                       test12 test13 test14 test15 test16 testcontex testfont \
217		       testmaster testrender"
218      ;;
219    *)
220      TESTS_WITH_GLUT="test1 test2 test3 test5 test6 test7 test8 test9.1 \
221                       test9.2 test9.3 test9.4 test9.5 test9.6 test9.7 test9.8 \
222                       test10 test11.1 test11.2 test11.3 test11.4 test11.5 \
223                       test11.6 test11.7 test12 test13 test14 test15 test16 \
224		       testcontex testfont testmaster testrender"
225      ;;
226    esac
227
228  fi
229fi
230
231# Compile debug version
232# ---------------------
233
234if (test "x$enable_debug" = "xyes"); then
235  CFLAGS+=" -g -DDEBUGMODE"
236  DEBUG_TESTS="test17"
237fi
238
239# Output.
240# -------
241
242AC_CONFIG_FILES([Makefile
243                 build/Makefile
244                 include/Makefile
245                 tests/Makefile
246                 examples/Makefile
247                 quesoglc.pc])
248
249AC_SUBST(EXECUTABLES)
250AC_SUBST(DEBUG_TESTS)
251AC_SUBST(TESTS_WITH_GLUT)
252AC_SUBST(FRIBIDI_OBJ)
253AC_SUBST(GLEW_OBJ)
254AC_SUBST(GLEW_CFLAGS)
255AC_SUBST(PKGCONFIG_REQUIREMENTS)
256AC_SUBST(PKGCONFIG_LIBS_PRIVATE)
257AC_SUBST(PKGCONFIG_INCLUDE)
258AC_OUTPUT
259