You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

125 lines
4.0 KiB

  1. dnl
  2. dnl Lol Engine
  3. dnl
  4. dnl Copyright © 2010—2017 Sam Hocevar <sam@hocevar.net>
  5. dnl
  6. dnl Lol Engine is free software. It comes without any warranty, to
  7. dnl the extent permitted by applicable law. You can redistribute it
  8. dnl and/or modify it under the terms of the Do What the Fuck You Want
  9. dnl to Public License, Version 2, as published by the WTFPL Task Force.
  10. dnl See http://www.wtfpl.net/ for more details.
  11. dnl
  12. # LOL_AC_CHECK_SDL()
  13. # ------------------
  14. AC_DEFUN([LOL_AC_CHECK_SDL],
  15. [
  16. ac_cv_my_have_sdl="no"
  17. ac_cv_my_have_sdl_image="no"
  18. ac_cv_my_have_sdl_mixer="no"
  19. if test "${enable_sdl}" != "no"; then
  20. LOL_AC_CHECK_SDL_INNER()
  21. fi
  22. AM_CONDITIONAL(LOL_USE_SDL, test "${ac_cv_my_have_sdl}" != "no")
  23. AM_CONDITIONAL(LOL_USE_SDL_MIXER, test "${ac_cv_my_have_sdl_mixer}" != "no")
  24. AM_CONDITIONAL(LOL_USE_SDL_IMAGE, test "${ac_cv_my_have_sdl_image}" != "no")
  25. ])
  26. # LOL_AC_CHECK_SDL_INNER()
  27. # ------------------------
  28. AC_DEFUN([LOL_AC_CHECK_SDL_INNER],
  29. [
  30. dnl Find which version of SDL to use (always required on Linux or Win32)
  31. dnl
  32. dnl Defined C/C++ macros:
  33. dnl LOL_USE_SDL -- whether SDL v2 was found
  34. dnl LOL_USE_SDL_IMAGE -- whether SDL_image was found
  35. dnl LOL_USE_SDL_MIXER -- whether SDL_mixer was found
  36. dnl HAVE_SDL_H -- whether to include <SDL.h>
  37. dnl HAVE_SDL2_SDL_H -- whether to include <SDL2/SDL.h>
  38. dnl Generated automake conditionals:
  39. dnl LOL_USE_SDL -- whether SDL v2 was found
  40. dnl LOL_USE_SDL_IMAGE -- whether SDL_image was found
  41. dnl LOL_USE_SDL_MIXER -- whether SDL_mixer was found
  42. dnl Generated shell variables:
  43. dnl SDL_CFLAGS -- flags for SDL compilation
  44. dnl SDL_LIBS -- flags for SDL linking
  45. dnl First, try the proper pkg-config check for SDL2
  46. if test "x${ac_cv_my_have_sdl}" = xno; then
  47. PKG_CHECK_MODULES(SDL2, sdl2,
  48. [ac_cv_my_have_sdl="yes"
  49. PKG_CHECK_MODULES(SDL2MIXER, SDL2_mixer,
  50. [ac_cv_my_have_sdl_mixer="yes"
  51. AC_DEFINE(HAVE_SDL_MIXER_H, 1, Define to 1 to use SDL_mixer.h)],
  52. [:])
  53. PKG_CHECK_MODULES(SDL2IMAGE, SDL2_image,
  54. [ac_cv_my_have_sdl_image="yes"
  55. AC_DEFINE(HAVE_SDL_IMAGE_H, 1, Define to 1 to use SDL_image.h)],
  56. [:])
  57. SDL_CFLAGS="${SDL2_CFLAGS} ${SDL2MIXER_CFLAGS} ${SDL2IMAGE_CFLAGS}"
  58. SDL_LIBS="${SDL2_LIBS} ${SDL2MIXER_LIBS} ${SDL2IMAGE_LIBS}"
  59. AC_DEFINE(HAVE_SDL_H, 1, Define to 1 to use SDL.h)],
  60. [:])
  61. fi
  62. dnl Maybe all this has failed, try direct inclusion instead
  63. if test "x${ac_cv_my_have_sdl}" = xno; then
  64. save_CPPFLAGS="${CPPFLAGS}"
  65. save_LIBS="${LIBS}"
  66. CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS}"
  67. LIBS="${LIBS} ${SDL_LIBS}"
  68. AC_CHECK_HEADERS(SDL.h SDL2/SDL.h,
  69. [ac_cv_my_have_sdl="yes"])
  70. if test "x${ac_cv_my_have_sdl}" != xno; then
  71. AC_CHECK_HEADERS(SDL_mixer.h SDL2/SDL_mixer.h,
  72. [ac_cv_my_have_sdl_mixer="yes"])
  73. AC_CHECK_HEADERS(SDL_image.h SDL2/SDL_image.h,
  74. [ac_cv_my_have_sdl_image="yes"])
  75. AC_CHECK_LIB(SDL2, main,
  76. [SDL_LIBS="${SDL_LIBS} -lSDL2"],
  77. [ac_cv_my_have_sdl="no"])
  78. AC_CHECK_LIB(SDL2main, main,
  79. [SDL_LIBS="${SDL_LIBS} -lSDL2main -lSDL2"])
  80. AC_CHECK_LIB(SDL2_mixer, main,
  81. [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL2_mixer"],
  82. [ac_cv_my_have_sdl_mixer="no"])
  83. AC_CHECK_LIB(SDL2_image, main,
  84. [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL2_image"],
  85. [ac_cv_my_have_sdl_image="no"])
  86. SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
  87. SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
  88. fi
  89. CPPFLAGS="${save_CPPFLAGS}"
  90. LIBS="${save_LIBS}"
  91. fi
  92. dnl Convert all this into conditionals
  93. if test "x${ac_cv_my_have_sdl}" = xno; then
  94. AC_MSG_WARN([SDL v2 not found])
  95. else
  96. AC_DEFINE(LOL_USE_SDL, 1, Define to 1 to use SDL)
  97. fi
  98. if test "x${ac_cv_my_have_sdl_mixer}" = xno; then
  99. AC_MSG_WARN([SDL_mixer not found])
  100. else
  101. AC_DEFINE(LOL_USE_SDL_MIXER, 1, Define to 1 to use SDL_mixer)
  102. fi
  103. if test "x${ac_cv_my_have_sdl_image}" = xno; then
  104. AC_MSG_WARN([SDL_image not found])
  105. else
  106. AC_DEFINE(LOL_USE_SDL_IMAGE, 1, Define to 1 to use SDL_image)
  107. fi
  108. ]) # LOL_AC_CHECK_SDL_INNER