Allow using things that were deprecated in gtk+-3.22.
[freeciv.git] / m4 / sdl2-client.m4
blob3497c3582668f769b806c64f5b87237b278bc164
1 # Try to configure the SDL2 client (gui-sdl2)
3 dnl FC_SDL2_CLIENT
4 dnl Test for SDL and needed libraries for gui-sdl2
6 AC_DEFUN([FC_SDL2_CLIENT],
8   if test "x$gui_sdl2" = "xyes" || test "x$client" = "xall" ||
9      test "x$client" = "xauto" ; then
10     if test "x$SDL_mixer" = "xsdl" ; then
11       if test "x$gui_sdl2" = "xyes"; then
12         AC_MSG_ERROR([specified client 'sdl2' not configurable (cannot use SDL_mixer with it))])
13       fi
14       sdl2_found=no
15     else
16       AM_PATH_SDL2([2.0.0], [sdl2_found="yes"], [sdl2_found="no"])
17     fi
18     if test "$sdl2_found" = yes; then
19       gui_sdl2_cflags="$SDL2_CFLAGS"
20       gui_sdl2_libs="$SDL2_LIBS"
21       FC_SDL2_PROJECT([SDL2_image], [IMG_Load], [SDL_image.h])
22       if test "x$sdl2_h_found" = "xyes" ; then
23         FC_SDL2_PROJECT([SDL2_ttf], [TTF_OpenFont], [SDL_ttf.h])
24       else
25         missing_2_project="SDL2_image"
26       fi
27       if test "x$sdl2_h_found" = "xyes" ; then
28         FC_SDL2_PROJECT([SDL2_gfx], [rotozoomSurface], [SDL2_rotozoom.h])
29       elif test "x$missing_2_project" = "x" ; then
30         missing_2_project="SDL2_ttf"
31       fi
32       if test "x$sdl2_h_found" = "xyes" ; then
33         PKG_CHECK_MODULES([FT2], [freetype2 >= 2.1.3], [freetype_found="yes"], [freetype_found="no"])
34         if test "$freetype_found" = yes; then
35           gui_sdl2_cflags="$gui_sdl2_cflags $FT2_CFLAGS"
36           gui_sdl2_libs="$gui_sdl2_libs $FT2_LIBS"
37           found_sdl2_client=yes
38         elif test "x$gui_sdl2" = "xyes"; then
39           AC_MSG_ERROR([specified client 'sdl2' not configurable (FreeType2 >= 2.1.3 is needed (www.freetype.org))])
40         fi
41       elif test "x$gui_sdl2" = "xyes"; then
42         if test "x$missing_2_project" = "x" ; then
43           missing_2_project="SDL2_gfx"
44         fi
45         if test "x$sdl2_lib_found" = "xyes" ; then
46           missing_type="-devel"
47         else
48           missing_type=""
49         fi
50         AC_MSG_ERROR([specified client 'sdl2' not configurable (${missing_2_project}${missing_type} is needed (www.libsdl.org))])
51       fi
52     fi
54     if test "$found_sdl2_client" = yes; then
55       gui_sdl2=yes
56       if test "x$client" = "xauto" ; then
57         client=yes
58       fi
60       dnl Check for libiconv (which is usually included in glibc, but may
61       dnl be distributed separately).
62       AM_ICONV
63       FC_LIBCHARSET
64       AM_LANGINFO_CODESET
65       gui_sdl2_libs="$LIBICONV $gui_sdl2_libs"
67       dnl Check for some other libraries - needed under BeOS for instance.
68       dnl These should perhaps be checked for in all cases?
69       AC_CHECK_LIB(socket, connect, gui_sdl2_libs="-lsocket $gui_sdl2_libs")
70       AC_CHECK_LIB(bind, gethostbyaddr, gui_sdl2_libs="-lbind $gui_sdl2_libs")
72     elif test "x$gui_sdl2" = "xyes"; then
73       AC_MSG_ERROR([specified client 'sdl2' not configurable (SDL2 >= 2.0.0 is needed (www.libsdl.org))])
74     fi
75   fi
78 AC_DEFUN([FC_SDL2_PROJECT],
80   ac_save_CPPFLAGS="$CPPFLAGS"
81   ac_save_CFLAGS="$CFLAGS"
82   ac_save_LIBS="$LIBS"
83   CPPFLAGS="$CPPFLAGS $SDL2_CFLAGS"
84   CFLAGS="$CFLAGS $SDL2_CFLAGS"
85   LIBS="$LIBS $SDL2_LIBS"
86   AC_CHECK_LIB([$1], [$2],
87                [sdl2_lib_found="yes"], [sdl2_lib_found="no"
88 sdl2_h_found="no"])
89   if test "x$sdl2_lib_found" = "xyes" ; then
90     sdl2_h_found="no"
91     if test x$sdl_headers_without_path != xyes ; then
92       AC_CHECK_HEADER([SDL2/$3],
93                       [sdl2_h_found="yes"
94 gui_sdl2_libs="${gui_sdl2_libs} -l$1"], [])
95     fi
96     if test x$sdl2_h_found = xno ; then
97       AC_CHECK_HEADER([$3], [sdl2_h_found="yes"
98 gui_sdl2_libs="${gui_sdl2_libs} -l$1"
99 if test x$sdl_headers_without_path != xyes ; then
100   AC_DEFINE([SDL2_PLAIN_INCLUDE], [1], [sdl2 headers must be included without path])
101   sdl_headers_without_path=yes
102 fi], [])
103     fi
104   fi
105   CPPFLAGS="$ac_save_CPPFLAGS"
106   CFLAGS="$ac_save_CFLAGS"
107   LIBS="$ac_save_LIBS"