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.
 
 
 

126 lines
4.1 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_SDL_SDL_H -- whether to include <SDL/SDL.h>
  38. dnl HAVE_SDL2_SDL_H -- whether to include <SDL2/SDL.h>
  39. dnl Generated automake conditionals:
  40. dnl LOL_USE_SDL -- whether SDL v2 was found
  41. dnl LOL_USE_SDL_IMAGE -- whether SDL_image was found
  42. dnl LOL_USE_SDL_MIXER -- whether SDL_mixer was found
  43. dnl Generated shell variables:
  44. dnl SDL_CFLAGS -- flags for SDL compilation
  45. dnl SDL_LIBS -- flags for SDL linking
  46. dnl First, try the proper pkg-config check for SDL2
  47. if test "x${ac_cv_my_have_sdl}" = xno; then
  48. PKG_CHECK_MODULES(SDL2, sdl2,
  49. [ac_cv_my_have_sdl="yes"
  50. PKG_CHECK_MODULES(SDL2MIXER, SDL2_mixer,
  51. [ac_cv_my_have_sdl_mixer="yes"
  52. AC_DEFINE(HAVE_SDL_MIXER_H, 1, Define to 1 to use SDL_mixer.h)],
  53. [:])
  54. PKG_CHECK_MODULES(SDL2IMAGE, SDL2_image,
  55. [ac_cv_my_have_sdl_image="yes"
  56. AC_DEFINE(HAVE_SDL_IMAGE_H, 1, Define to 1 to use SDL_image.h)],
  57. [:])
  58. SDL_CFLAGS="${SDL2_CFLAGS} ${SDL2MIXER_CFLAGS} ${SDL2IMAGE_CFLAGS}"
  59. SDL_LIBS="${SDL2_LIBS} ${SDL2MIXER_LIBS} ${SDL2IMAGE_LIBS}"
  60. AC_DEFINE(HAVE_SDL_H, 1, Define to 1 to use SDL.h)],
  61. [:])
  62. fi
  63. dnl Maybe all this has failed, try direct inclusion instead
  64. if test "x${ac_cv_my_have_sdl}" = xno; then
  65. save_CPPFLAGS="${CPPFLAGS}"
  66. save_LIBS="${LIBS}"
  67. CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS}"
  68. LIBS="${LIBS} ${SDL_LIBS}"
  69. AC_CHECK_HEADERS(SDL.h SDL/SDL.h SDL2/SDL.h,
  70. [ac_cv_my_have_sdl="yes"])
  71. if test "x${ac_cv_my_have_sdl}" != xno; then
  72. AC_CHECK_HEADERS(SDL_mixer.h SDL/SDL_mixer.h SDL2/SDL_mixer.h,
  73. [ac_cv_my_have_sdl_mixer="yes"])
  74. AC_CHECK_HEADERS(SDL_image.h SDL/SDL_image.h SDL2/SDL_image.h,
  75. [ac_cv_my_have_sdl_image="yes"])
  76. AC_CHECK_LIB(SDL2, main,
  77. [SDL_LIBS="${SDL_LIBS} -lSDL2"],
  78. [ac_cv_my_have_sdl="no"])
  79. AC_CHECK_LIB(SDL2main, main,
  80. [SDL_LIBS="${SDL_LIBS} -lSDL2main -lSDL2"])
  81. AC_CHECK_LIB(SDL2_mixer, main,
  82. [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL2_mixer"],
  83. [ac_cv_my_have_sdl_mixer="no"])
  84. AC_CHECK_LIB(SDL2_image, main,
  85. [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL2_image"],
  86. [ac_cv_my_have_sdl_image="no"])
  87. SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
  88. SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
  89. fi
  90. CPPFLAGS="${save_CPPFLAGS}"
  91. LIBS="${save_LIBS}"
  92. fi
  93. dnl Convert all this into conditionals
  94. if test "x${ac_cv_my_have_sdl}" = xno; then
  95. AC_MSG_WARN([SDL v2 not found])
  96. else
  97. AC_DEFINE(LOL_USE_SDL, 1, Define to 1 to use SDL)
  98. fi
  99. if test "x${ac_cv_my_have_sdl_mixer}" = xno; then
  100. AC_MSG_WARN([SDL_mixer not found])
  101. else
  102. AC_DEFINE(LOL_USE_SDL_MIXER, 1, Define to 1 to use SDL_mixer)
  103. fi
  104. if test "x${ac_cv_my_have_sdl_image}" = xno; then
  105. AC_MSG_WARN([SDL_image not found])
  106. else
  107. AC_DEFINE(LOL_USE_SDL_IMAGE, 1, Define to 1 to use SDL_image)
  108. fi
  109. ]) # LOL_AC_CHECK_SDL_INNER