選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

196 行
6.5 KiB

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