summaryrefslogtreecommitdiff
path: root/configure.ac
blob: ed02cdcf047ee4ceed78f53e032f45fa435186ec (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
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.60)
m4_define(sdl_freetype_version_major, 0)
m4_define(sdl_freetype_version_minor, 0)
m4_define(sdl_freetype_version_micro, 5)
AC_INIT(sdl-freetype, 0.0.5, sunmoon1997@gmail.com)
AC_CONFIG_SRCDIR([src/sdl-freetype.h])
AC_CONFIG_HEADER([config.h])

AM_INIT_AUTOMAKE([1.7])

lt_current=0
lt_revision=0
lt_age=0

VERSION_INFO="$lt_current:$lt_revision:$lt_age"
AC_SUBST(VERSION_INFO)

LT_CURRENT_MINUS_AGE=`expr $lt_current - $lt_age`
AC_SUBST(LT_CURRENT_MINUS_AGE)

SDL_FREETYPE_VERSION_MAJOR=sdl_freetype_version_major()
SDL_FREETYPE_VERSION_MINOR=sdl_freetype_version_minor()
SDL_FREETYPE_VERSION_MICRO=sdl_freetype_version_micro()
AC_SUBST(SDL_FREETYPE_VERSION_MAJOR)
AC_SUBST(SDL_FREETYPE_VERSION_MINOR)
AC_SUBST(SDL_FREETYPE_VERSION_MICRO)
AC_DEFINE_UNQUOTED(SDL_FREETYPE_VERSION_MAJOR,$SDL_FREETYPE_VERSION_MAJOR,
                   [sdl-freetype major version number])
AC_DEFINE_UNQUOTED(SDL_FREETYPE_VERSION_MINOR,$SDL_FREETYPE_VERSION_MINOR,
                   [sdl-freetype minor version number])
AC_DEFINE_UNQUOTED(SDL_FREETYPE_VERSION_MICRO,$SDL_FREETYPE_VERSION_MICRO,
                   [sdl-freetype micro version number])

# AM_MAINTAINER_MODE
# Checks for programs.
AC_STDC_HEADERS
AC_PROG_CXX
AC_PROG_CC
AC_PROG_LIBTOOL
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_BIGENDIAN
AX_C_FLOAT_WORDS_BIGENDIAN
AC_CHECK_HEADERS([stdint.h inttypes.h sys/int_types.h])
AC_TYPE_OFF_T
AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_CHECK_TYPES([uint64_t])
AC_CHECK_FUNCS([floor, memset, strdup])

AC_CHECK_LIBM
AC_SUBST(LIBM)

LIBS="$LIBS $LIBM"

# check if os is win32.
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])

SDL_FREETYPE_REQUIRES=""
SDL_FT_REQUIRES="sdl-freetype"
# Checks for freetype
PKGCONFIG_REQUIRED=0.19
PKG_PROG_PKG_CONFIG($PKGCONFIG_REQUIRED)
if test "x$PKG_CONFIG" = x; then
	AC_MSG_ERROR([pkg-config >= $PKGCONFIG_REQUIRED required but not found (http://pkgconfig.freedesktop.org/)])
fi
case `$PKG_CONFIG --version` in
[0.?|0.?.?|0.1[0-7]|0.1[0-7].?]) PKGCONFIG_REQUIRES="Requires"; ;;
*) PKGCONFIG_REQUIRES="Requires.private"; ;;
esac

AC_SUBST(PKGCONFIG_REQUIRES)

# release number - for information only
FREETYPE_MIN_RELEASE=2.1.0
# libtool-specific version - this is what is checked
FREETYPE_MIN_VERSION=8.0.2

PKG_CHECK_MODULES(FREETYPE, freetype2 >= $FREETYPE_MIN_VERSION,
                  [freetype_pkgconfig=yes], [freetype_pkgconfig=no])
  
if test "x$freetype_pkgconfig" = "xyes"; then
    SDL_FREETYPE_REQUIRES="freetype2 >= $FREETYPE_MIN_VERSION $SDL_FREETYPE_REQUIRES"
else
    if test -z "$FREETYPE_CONFIG"; then
        AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, no)
    fi
    if test "x$FREETYPE_CONFIG" = "xno" ; then
        AC_MSG_ERROR(no (freetype-config not found in path or $FREETYPE_CONFIG))
    else
        AC_MSG_CHECKING(freetype2 libtool version)

        FREETYPE_VERSION=`$FREETYPE_CONFIG --version`
        VERSION_DEC=`echo $FREETYPE_VERSION | awk -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'`
        MIN_VERSION_DEC=`echo $FREETYPE_MIN_VERSION | awk -F. '{printf("%d\n", 10000*$1 + 100*$2 + $3)};'`
        if test $VERSION_DEC -lt $MIN_VERSION_DEC; then
            AC_MSG_ERROR($FREETYPE_VERSION - Too old)
        else
            AC_MSG_RESULT($FREETYPE_VERSION - OK)

	    FREETYPE_CFLAGS=`$FREETYPE_CONFIG --cflags`
	    FREETPE_LIBS=`$FREETYPE_CONFIG --libs`
        fi
    fi
fi
CFLAGS="$FREETYPE_CFLAGS"
LIBS="$FREETYPE_LIBS"

AC_CHECK_MEMBER(FT_Bitmap_Size.y_ppem,
                HAVE_FT_BITMAP_SIZE_Y_PPEM=1,
                HAVE_FT_BITMAP_SIZE_Y_PPEM=0,
                [#include <ft2build.h>
                 #include FT_FREETYPE_H])
AC_DEFINE_UNQUOTED(HAVE_FT_BITMAP_SIZE_Y_PPEM,$HAVE_FT_BITMAP_SIZE_Y_PPEM,
                   [FT_Bitmap_Size structure includes y_ppem field])

AC_CHECK_FUNCS(FT_GlyphSlot_Embolden FT_Library_SetLcdFilter)

dnl Check for SDL
SDL_VERSION=1.2.4
#enable_sdl=auto
AC_ARG_ENABLE(sdl,
  AS_HELP_STRING([--enable-sdl],
		 [build sdl renderer (sdl must be installed)]),
                 [], [])

if test "x$enable_sdl" != "xno"; then
  AM_PATH_SDL($SDL_VERSION,
              [have_sdl=yes
	       AC_DEFINE_UNQUOTED(HAVE_SDL, 1, [defined if you have sdl])],
	       [AC_MSG_WARN([*** SDL version $SDL_VERSION not found!])
	        have_sdl=no ])
fi
AM_CONDITIONAL(HAVE_SDL, test "x$have_sdl" = "xyes")
CFLAGS="$CFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"

#enable_fontconfig=auto
AC_ARG_ENABLE(fontconfig,
  AS_HELP_STRING([--enable-fontconfig],
		 [build sdl-ft (fontconfig must be installed)]))

if test "x$enable_fontconfig" != "xno"; then
  PKG_CHECK_MODULES(FONTCONFIG, fontconfig,
		    [have_fontconfig=yes],
		    [have_fontconfig=no])
fi

if test "x$have_fontconfig" == x"yes"; then
   AC_DEFINE_UNQUOTED(HAVE_FONTCONFIG, 1, [defined if you have fontconfig headers and library])
fi
AM_CONDITIONAL(HAVE_FONTCONFIG, test "x$have_fontconfig" = "xyes")
SDL_FT_REQUIRES="fontconfig $SDL_FT_REQUIRES"

SDL_FREETYPE_OPENGL_REQUIRES="sdl-freetype"
#enable_opengl=auto
AC_ARG_ENABLE(opengl,
  AS_HELP_STRING([--enable-opengl],
		 [build sdl-freetype-opengl (openl must be available)]),
                 [], [])

if test "x$enable_opengl" != "xno"; then
  AX_CHECK_GL
else
  no_gl=yes
  no_x=yes
fi
AM_CONDITIONAL(HAVE_OPENGL, [test "x$no_gl" != x"yes" ])
AM_CONDITIONAL(HAVE_X, [test "x$no_x" != x"yes" ])
if test "x$no_x" != x"yes"; then
   AC_DEFINE_UNQUOTED(HAVE_X, 1, [defined if you have X headers and libraries])
fi

SDL_FREETYPE_OPENGLES_REQUIRES="sdl-freetype"
#enable_opengles=auto
have_opengles=no
AC_ARG_ENABLE(opengles,
  AS_HELP_STRING([--enable-opengles],
		 [build sdl-freetype-opengles (opengles must be available)]),
                 [], [])

if test "x$enable_opengles" != "xno"; then
  AC_CHECK_HEADERS([EGL/egl.h GLES/gl.h])

  save_LIBS="$LIBS"
  LIBS="$other_egl_LIBS $LIBS"
  for egl_lib in EGL egl13 egl12 egl11 egl; do
      AC_CHECK_LIB($egl_lib, eglGetError, EGL_LIBS="-l$egl_lib $other_egl_LIBS")
  done

  LIBS="$other_gles_LIBS $EGL_LIBS $LIBS"
  for gles1_lib in GLES_CM GLESv1_CM GLESv1; do
      AC_CHECK_LIB($gles1_lib, glGenTextures,
      	 [GLES_LIBS="-l$gles1_lib $other_gles_LIBS"
	  have_opengles=yes])
  done

  LIBS="$save_LIBS"
fi
AM_CONDITIONAL(HAVE_OPENGLES, [test "x$have_opengles" == x"yes" ])
AC_SUBST(EGL_LIBS)
AC_SUBST(GLES_LIBS)

AC_SUBST(SDL_FREETYPE_REQUIRES)
AC_SUBST(SDL_FREETYPE_OPENGL_REQUIRES)
AC_SUBST(SDL_FREETYPE_OPENGLES_REQUIRES)
AC_SUBST(SDL_FT_REQUIRES)


AC_DEFUN([SDL_FREETYPE_CC_TRY_FLAG], [
  AC_MSG_CHECKING([whether $CC supports $1])

  sdl_freetype_save_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS $1"

  AC_COMPILE_IFELSE([ ], [sdl_freetype_cc_flag=yes], [sdl_freetype_cc_flag=no])
  CFLAGS="$sdl_freetype_save_CFLAGS"

  if test "x$sdl_freetype_cc_flag" = "xyes"; then
    ifelse([$2], , :, [$2])
  else
    ifelse([$3], , :, [$3])
  fi
  AC_MSG_RESULT([$sdl_freetype_cc_flag])
])

dnl Use lots of warning flags with with gcc and compatible compilers
dnl Note: if you change the following variable, the cache is automatically
dnl skipped and all flags rechecked.  So there's no need to do anything
dnl else.  If for any reason you need to force a recheck, just change
dnl MAYBE_WARN in an ignorable way (like adding whitespace)

MAYBE_WARN="-Wall -Wextra \
-Wsign-compare -Werror-implicit-function-declaration \
-Wpointer-arith -Wwrite-strings -Wstrict-prototypes \
-Wmissing-prototypes -Wmissing-declarations -Wnested-externs \
-Wpacked -Wswitch-enum -Wmissing-format-attribute \
-Wstrict-aliasing=2 -Winit-self -Wunsafe-loop-optimizations \
-Wdeclaration-after-statement -Wold-style-definition \
-Wno-missing-field-initializers -Wno-unused-parameter"


# invalidate cached value if MAYBE_WARN has changed
if test "x$sdl_freetype_cv_warn_maybe" != "x$MAYBE_WARN"; then
	unset sdl_freetype_cv_warn_cflags
fi
AC_CACHE_CHECK([for supported warning flags], sdl_freetype_cv_warn_cflags, [
	echo
	WARN_CFLAGS=""

	# Some warning options are not supported by all versions of
	# gcc, so test all desired options against the current
	# compiler.
	#
	# Note that there are some order dependencies
	# here. Specifically, an option that disables a warning will
	# have no net effect if a later option then enables that
	# warnings, (perhaps implicitly). So we put some grouped
	# options (-Wall and -Wextra) up front and the -Wno options
	# last.

	for W in $MAYBE_WARN; do
		SDL_FREETYPE_CC_TRY_FLAG([$W], [WARN_CFLAGS="$WARN_CFLAGS $W"])
	done

	sdl_freetype_cv_warn_cflags=$WARN_CFLAGS
	sdl_freetype_cv_warn_maybe=$MAYBE_WARN

	AC_MSG_CHECKING([which warning flags were supported])])
WARN_CFLAGS=$sdl_freetype_cv_warn_cflags
AC_SUBST(WARN_CFLAGS)

AC_OUTPUT([Makefile
           src/Makefile
           src/sdl-freetype.pc
           src/sdl-freetype-opengl.pc
           src/sdl-freetype-opengles.pc
           src/sdl-ft.pc])