Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

184 Zeilen
6.0 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 v2 was found
  9. dnl USE_OLD_SDL -- whether SDL v1 was found
  10. dnl USE_SDL_IMAGE -- whether SDL_image (v1 or v2) was found
  11. dnl USE_SDL_MIXER -- whether SDL_mixer (v1 or v2) was found
  12. dnl HAVE_SDL_H -- whether to include <SDL.h>
  13. dnl HAVE_SDL_SDL_H -- whether to include <SDL/SDL.h>
  14. dnl HAVE_SDL2_SDL_H -- whether to include <SDL2/SDL.h>
  15. dnl Generated automake conditionals:
  16. dnl USE_SDL -- whether SDL v2 was found
  17. dnl USE_OLD_SDL -- whether SDL v1 was found
  18. dnl USE_SDL_IMAGE -- whether SDL_image was found
  19. dnl USE_SDL_MIXER -- whether SDL_mixer was found
  20. dnl Generated shell variables:
  21. dnl SDL_CFLAGS -- flags for SDL compilation
  22. dnl SDL_LIBS -- flags for SDL linking
  23. ac_cv_my_have_sdl="no"
  24. ac_cv_my_have_old_sdl="no"
  25. ac_cv_my_have_sdl_image="no"
  26. ac_cv_my_have_sdl_mixer="no"
  27. dnl First, try the proper pkg-config check for SDL2
  28. if test "x${ac_cv_my_have_sdl}" = xno; then
  29. PKG_CHECK_MODULES(SDL2, sdl2,
  30. [ac_cv_my_have_sdl="yes"
  31. PKG_CHECK_MODULES(SDL2MIXER, SDL2_mixer,
  32. [ac_cv_my_have_sdl_mixer="yes"
  33. AC_DEFINE(HAVE_SDL_MIXER_H, 1, Define to 1 to use SDL_mixer.h)],
  34. [:])
  35. PKG_CHECK_MODULES(SDL2IMAGE, SDL2_image,
  36. [ac_cv_my_have_sdl_image="yes"
  37. AC_DEFINE(HAVE_SDL_IMAGE_H, 1, Define to 1 to use SDL_image.h)],
  38. [:])
  39. SDL_CFLAGS="${SDL2_CFLAGS} ${SDL2MIXER_CFLAGS} ${SDL2IMAGE_CFLAGS}"
  40. SDL_LIBS="${SDL2_LIBS} ${SDL2MIXER_LIBS} ${SDL2IMAGE_LIBS}"
  41. AC_DEFINE(HAVE_SDL_H, 1, Define to 1 to use SDL.h)],
  42. [:])
  43. fi
  44. dnl Maybe all this has failed, try direct inclusion instead
  45. if test "x${ac_cv_my_have_sdl}" = xno; then
  46. save_CPPFLAGS="${CPPFLAGS}"
  47. save_LIBS="${LIBS}"
  48. CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS}"
  49. LIBS="${LIBS} ${SDL_LIBS}"
  50. AC_CHECK_HEADERS(SDL.h SDL/SDL.h SDL2/SDL.h,
  51. [ac_cv_my_have_sdl="yes"])
  52. if test "x${ac_cv_my_have_sdl}" != xno; then
  53. AC_CHECK_HEADERS(SDL_mixer.h SDL/SDL_mixer.h SDL2/SDL_mixer.h,
  54. [ac_cv_my_have_sdl_mixer="yes"])
  55. AC_CHECK_HEADERS(SDL_image.h SDL/SDL_image.h SDL2/SDL_image.h,
  56. [ac_cv_my_have_sdl_image="yes"])
  57. AC_CHECK_LIB(SDL2, main,
  58. [SDL_LIBS="${SDL_LIBS} -lSDL2"],
  59. [ac_cv_my_have_sdl="no"])
  60. AC_CHECK_LIB(SDL2main, main,
  61. [SDL_LIBS="${SDL_LIBS} -lSDL2main -lSDL2"])
  62. AC_CHECK_LIB(SDL2_mixer, main,
  63. [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL2_mixer"],
  64. [ac_cv_my_have_sdl_mixer="no"])
  65. AC_CHECK_LIB(SDL2_image, main,
  66. [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL2_image"],
  67. [ac_cv_my_have_sdl_image="no"])
  68. SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
  69. SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
  70. fi
  71. CPPFLAGS="${save_CPPFLAGS}"
  72. LIBS="${save_LIBS}"
  73. fi
  74. dnl Then, try the proper pkg-config check for SDL 1.x
  75. if test "x${ac_cv_my_have_sdl}" = xno \
  76. -a "x${ac_cv_my_have_old_sdl}" = xno; then
  77. PKG_CHECK_MODULES(SDL, sdl,
  78. [ac_cv_my_have_old_sdl="yes"
  79. PKG_CHECK_MODULES(SDLMIXER, SDL_mixer,
  80. [ac_cv_my_have_sdl_mixer="yes"
  81. AC_DEFINE(HAVE_SDL_MIXER_H, 1, Define to 1 to use SDL_mixer.h)],
  82. [:])
  83. PKG_CHECK_MODULES(SDLIMAGE, SDL_image,
  84. [ac_cv_my_have_sdl_image="yes"
  85. AC_DEFINE(HAVE_SDL_IMAGE_H, 1, Define to 1 to use SDL_image.h)],
  86. [:])
  87. SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
  88. SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
  89. AC_DEFINE(HAVE_SDL_H, 1, Define to 1 to use SDL.h)],
  90. [:])
  91. fi
  92. dnl Then the old sdl-config method
  93. if test "x${ac_cv_my_have_sdl}" = xno \
  94. -a "x${ac_cv_my_have_old_sdl}" = xno \
  95. -a "x${cross_compiling}" != xyes; then
  96. AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
  97. if test "${SDL_CONFIG}" != "no" && "${SDL_CONFIG}" --version >/dev/null; then
  98. ac_cv_my_have_old_sdl="yes"
  99. SDL_CFLAGS="${SDL_CFLAGS} `${SDL_CONFIG} --cflags`"
  100. SDL_LIBS="${SDL_LIBS} `${SDL_CONFIG} --libs`"
  101. AC_DEFINE(HAVE_SDL_H, 1, Define to 1 to use SDL.h)
  102. fi
  103. fi
  104. dnl Finally, try direct inclusion
  105. if test "x${ac_cv_my_have_sdl}" = xno \
  106. -a "x${ac_cv_my_have_old_sdl}" = xno; then
  107. save_CPPFLAGS="${CPPFLAGS}"
  108. save_LIBS="${LIBS}"
  109. CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS}"
  110. LIBS="${LIBS} ${SDL_LIBS}"
  111. AC_CHECK_HEADERS(SDL.h SDL/SDL.h, [ac_cv_my_have_old_sdl="yes"])
  112. if test "x${ac_cv_my_have_old_sdl}" != xno; then
  113. AC_CHECK_HEADERS(SDL_mixer.h SDL/SDL_mixer.h,
  114. [ac_cv_my_have_sdl_mixer="yes"])
  115. AC_CHECK_HEADERS(SDL_image.h SDL/SDL_image.h,
  116. [ac_cv_my_have_sdl_image="yes"])
  117. AC_CHECK_LIB(SDL, main,
  118. [SDL_LIBS="${SDL_LIBS} -lSDL"],
  119. [ac_cv_my_have_old_sdl="no"])
  120. AC_CHECK_LIB(SDLmain, main,
  121. [SDL_LIBS="${SDL_LIBS} -lSDLmain -lSDL"])
  122. AC_CHECK_LIB(SDL_mixer, main,
  123. [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"],
  124. [ac_cv_my_have_sdl_mixer="no"])
  125. AC_CHECK_LIB(SDL_image, main,
  126. [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"],
  127. [ac_cv_my_have_sdl_image="no"])
  128. fi
  129. SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
  130. SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
  131. CPPFLAGS="${save_CPPFLAGS}"
  132. LIBS="${save_LIBS}"
  133. fi
  134. dnl Convert all this into conditionals
  135. if test "x${ac_cv_my_have_sdl}" = xno; then
  136. AC_MSG_WARN([SDL v2 not found])
  137. else
  138. AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL)
  139. fi
  140. AM_CONDITIONAL(USE_SDL, test "x${ac_cv_my_have_sdl}" = xyes)
  141. if test "x${ac_cv_my_have_sdl_mixer}" = xno; then
  142. AC_MSG_WARN([SDL_mixer not found])
  143. else
  144. AC_DEFINE(USE_SDL_MIXER, 1, Define to 1 to use SDL_mixer)
  145. fi
  146. AM_CONDITIONAL(USE_SDL_MIXER, test "x${ac_cv_my_have_sdl_mixer}" = xyes)
  147. if test "x${ac_cv_my_have_sdl_image}" = xno; then
  148. AC_MSG_WARN([SDL_image not found])
  149. else
  150. AC_DEFINE(USE_SDL_IMAGE, 1, Define to 1 to use SDL_image)
  151. fi
  152. AM_CONDITIONAL(USE_SDL_IMAGE, test "x${ac_cv_my_have_sdl_image}" = xyes)
  153. if test "x${ac_cv_my_have_old_sdl}" != xno; then
  154. AC_DEFINE(USE_OLD_SDL, 1, Define to 1 to use SDL)
  155. fi
  156. AM_CONDITIONAL(USE_OLD_SDL, test "x${ac_cv_my_have_old_sdl}" = xyes)
  157. ])# LOL_CHECK_SDL