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 rivejä
4.4 KiB

  1. # LOL_CHECK_SDL()
  2. # ---------------
  3. AC_DEFUN([LOL_CHECK_SDL],
  4. [
  5. dnl Find which version of SDL to use (always required on Linux or Win32)
  6. dnl
  7. dnl Defined C/C++ macros:
  8. dnl USE_SDL -- whether SDL or SDL2 were found at all
  9. dnl USE_SDL_IMAGE -- whether SDL_image was found
  10. dnl USE_SDL_MIXER -- whether SDL_mixer was found
  11. dnl HAVE_SDL_SDL_H -- whether to include <SDL/SDL.h>
  12. dnl HAVE_SDL_H -- whether to include <SDL.h>
  13. dnl Generated automake conditionals:
  14. dnl USE_SDL -- whether SDL or SDL2 were found at all
  15. dnl USE_SDL_IMAGE -- whether SDL_image was found
  16. dnl USE_SDL_MIXER -- whether SDL_mixer was found
  17. dnl Generated shell variables:
  18. dnl SDL_CFLAGS -- flags for SDL compilation
  19. dnl SDL_LIBS -- flags for SDL linking
  20. ac_cv_my_have_sdl="no"
  21. ac_cv_my_have_sdl_image="no"
  22. ac_cv_my_have_sdl_mixer="no"
  23. dnl First, try the proper pkg-config check for SDL2
  24. dnl if test "x${ac_cv_my_have_sdl}" = xno; then
  25. dnl PKG_CHECK_MODULES(SDL2, sdl2,
  26. dnl [ac_cv_my_have_sdl="yes"
  27. dnl PKG_CHECK_MODULES(SDL2MIXER, SDL2_mixer,
  28. dnl [ac_cv_my_have_sdl_mixer="yes"
  29. dnl AC_DEFINE(HAVE_SDL_MIXER_H, 1, Define to 1 to use SDL_mixer.h)],
  30. dnl [:])
  31. dnl PKG_CHECK_MODULES(SDL2IMAGE, SDL2_image,
  32. dnl [ac_cv_my_have_sdl_image="yes"
  33. dnl AC_DEFINE(HAVE_SDL_IMAGE_H, 1, Define to 1 to use SDL_image.h)],
  34. dnl [:])
  35. dnl SDL_CFLAGS="${SDL2_CFLAGS} ${SDL2MIXER_CFLAGS} ${SDL2IMAGE_CFLAGS}"
  36. dnl SDL_LIBS="${SDL2_LIBS} ${SDL2MIXER_LIBS} ${SDL2IMAGE_LIBS}"
  37. dnl AC_DEFINE(HAVE_SDL_H, 1, Define to 1 to use SDL.h)],
  38. dnl [:])
  39. dnl fi
  40. dnl Then, try the proper pkg-config check for SDL 1.x
  41. if test "x${ac_cv_my_have_sdl}" = xno; then
  42. PKG_CHECK_MODULES(SDL, sdl,
  43. [ac_cv_my_have_sdl="yes"
  44. PKG_CHECK_MODULES(SDLMIXER, SDL_mixer,
  45. [ac_cv_my_have_sdl_mixer="yes"
  46. AC_DEFINE(HAVE_SDL_MIXER_H, 1, Define to 1 to use SDL_mixer.h)],
  47. [:])
  48. PKG_CHECK_MODULES(SDLIMAGE, SDL_image,
  49. [ac_cv_my_have_sdl_image="yes"
  50. AC_DEFINE(HAVE_SDL_IMAGE_H, 1, Define to 1 to use SDL_image.h)],
  51. [:])
  52. SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
  53. SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
  54. AC_DEFINE(HAVE_SDL_H, 1, Define to 1 to use SDL.h)],
  55. [:])
  56. fi
  57. dnl Then the old sdl-config method
  58. if test "x${cross_compiling}" != xyes -a "x${ac_cv_my_have_sdl}" = xno; then
  59. AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
  60. if test "${SDL_CONFIG}" != "no"; then
  61. ac_cv_my_have_sdl="yes"
  62. SDL_CFLAGS="${SDL_CFLAGS} `${SDL_CONFIG} --cflags`"
  63. SDL_LIBS="${SDL_LIBS} `${SDL_CONFIG} --libs`"
  64. AC_DEFINE(HAVE_SDL_H, 1, Define to 1 to use SDL.h),
  65. fi
  66. fi
  67. dnl Maybe all this has failed, try direct inclusion instead
  68. if test "x${ac_cv_my_have_sdl}" = xno; then
  69. save_CPPFLAGS="${CPPFLAGS}"
  70. save_LIBS="${LIBS}"
  71. CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS}"
  72. LIBS="${LIBS} ${SDL_LIBS}"
  73. AC_CHECK_HEADERS(SDL.h SDL/SDL.h, [ac_cv_my_have_sdl="yes"])
  74. if test "x${ac_cv_my_have_sdl}" != xno; then
  75. AC_CHECK_HEADERS(SDL_mixer.h SDL/SDL_mixer.h, [ac_cv_my_have_sdl_mixer="yes"])
  76. AC_CHECK_HEADERS(SDL_image.h SDL/SDL_image.h, [ac_cv_my_have_sdl_image="yes"])
  77. AC_CHECK_LIB(SDL, main,
  78. [SDL_LIBS="${SDL_LIBS} -lSDL"],
  79. [ac_cv_my_have_sdl="no"])
  80. AC_CHECK_LIB(SDLmain, main,
  81. [SDL_LIBS="${SDL_LIBS} -lSDLmain -lSDL"])
  82. AC_CHECK_LIB(SDL_mixer, main,
  83. [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"],
  84. [ac_cv_my_have_sdl_mixer="no"])
  85. AC_CHECK_LIB(SDL_image, main,
  86. [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"],
  87. [ac_cv_my_have_sdl_image="no"])
  88. fi
  89. SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
  90. SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
  91. CPPFLAGS="${save_CPPFLAGS}"
  92. LIBS="${save_LIBS}"
  93. fi
  94. if test "x${ac_cv_my_have_sdl}" = xno; then
  95. AC_MSG_WARN([SDL not found])
  96. else
  97. AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL)
  98. fi
  99. AM_CONDITIONAL(USE_SDL, test "x${ac_cv_my_have_sdl}" = xyes)
  100. if test "x${ac_cv_my_have_sdl_mixer}" = xno; then
  101. AC_MSG_WARN([SDL_mixer not found])
  102. else
  103. AC_DEFINE(USE_SDL_MIXER, 1, Define to 1 to use SDL_mixer)
  104. fi
  105. AM_CONDITIONAL(USE_SDL_MIXER, test "x${ac_cv_my_have_sdl_mixer}" = xyes)
  106. if test "x${ac_cv_my_have_sdl_image}" = xno; then
  107. AC_MSG_WARN([SDL_image not found])
  108. else
  109. AC_DEFINE(USE_SDL_IMAGE, 1, Define to 1 to use SDL_image)
  110. fi
  111. AM_CONDITIONAL(USE_SDL_IMAGE, test "x${ac_cv_my_have_sdl_image}" = xyes)
  112. ])# LOL_CHECK_SDL