configure.ac 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. dnl Process this file with autoconf to produce a configure script.
  2. AC_INIT
  3. AC_CONFIG_SRCDIR([loopwave.c])
  4. dnl Detect the canonical build and host environments
  5. AC_CONFIG_AUX_DIR([../build-scripts])
  6. AC_CANONICAL_HOST
  7. dnl Check for tools
  8. AC_PROG_CC
  9. dnl Check for compiler environment
  10. AC_C_CONST
  11. dnl We only care about this for building testnative at the moment, so these
  12. dnl values shouldn't be considered absolute truth.
  13. dnl (Haiku, for example, sets none of these.)
  14. ISUNIX="false"
  15. ISWINDOWS="false"
  16. ISMACOSX="false"
  17. dnl Figure out which math library to use
  18. case "$host" in
  19. *-*-cygwin* | *-*-mingw*)
  20. ISWINDOWS="true"
  21. EXE=".exe"
  22. MATHLIB=""
  23. SYS_GL_LIBS="-lopengl32"
  24. ;;
  25. *-*-haiku*)
  26. EXE=""
  27. MATHLIB=""
  28. SYS_GL_LIBS="-lGL"
  29. ;;
  30. *-*-darwin*)
  31. ISMACOSX="true"
  32. EXE=""
  33. MATHLIB=""
  34. SYS_GL_LIBS="-Wl,-framework,OpenGL"
  35. ;;
  36. *-*-aix*)
  37. ISUNIX="true"
  38. EXE=""
  39. if test x$ac_cv_c_compiler_gnu = xyes; then
  40. CFLAGS="-mthreads"
  41. fi
  42. SYS_GL_LIBS=""
  43. ;;
  44. *-*-mint*)
  45. EXE=""
  46. MATHLIB=""
  47. AC_PATH_PROG(OSMESA_CONFIG, osmesa-config, no)
  48. if test "x$OSMESA_CONFIG" = "xyes"; then
  49. OSMESA_CFLAGS=`$OSMESA_CONFIG --cflags`
  50. OSMESA_LIBS=`$OSMESA_CONFIG --libs`
  51. CFLAGS="$CFLAGS $OSMESA_CFLAGS"
  52. SYS_GL_LIBS="$OSMESA_LIBS"
  53. else
  54. SYS_GL_LIBS="-lOSMesa"
  55. fi
  56. ;;
  57. *-*-emscripten*)
  58. dnl This should really be .js, but we need to specify extra flags when compiling to js
  59. EXE=".bc"
  60. MATHLIB=""
  61. SYS_GL_LIBS=""
  62. ;;
  63. *-*-riscos*)
  64. EXE=",e1f"
  65. MATHLIB=""
  66. SYS_GL_LIBS=""
  67. ;;
  68. *)
  69. dnl Oh well, call it Unix...
  70. ISUNIX="true"
  71. EXE=""
  72. MATHLIB="-lm"
  73. dnl Use the new libOpenGL if present.
  74. AC_CHECK_LIB(OpenGL, glBegin,
  75. [SYS_GL_LIBS="-lOpenGL"],[SYS_GL_LIBS="-lGL"])
  76. ;;
  77. esac
  78. AC_SUBST(EXE)
  79. AC_SUBST(MATHLIB)
  80. AC_SUBST(ISMACOSX)
  81. AC_SUBST(ISWINDOWS)
  82. AC_SUBST(ISUNIX)
  83. dnl Check for SDL
  84. SDL_VERSION=3.0.0
  85. AM_PATH_SDL3($SDL_VERSION,
  86. :,
  87. AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
  88. )
  89. CFLAGS="$CFLAGS $SDL_CFLAGS"
  90. LIBS="$LIBS -lSDL3_test $SDL_LIBS"
  91. dnl Check for X11 path, needed for OpenGL on some systems
  92. AC_PATH_X
  93. if test x$have_x = xyes; then
  94. if test x$ac_x_includes = xno || test "x$ac_x_includes" = xNone || test "x$ac_x_includes" = x; then
  95. :
  96. else
  97. CFLAGS="$CFLAGS -I$ac_x_includes"
  98. fi
  99. if test x$ac_x_libraries = xno || test "x$ac_x_libraries" = xNone; then
  100. :
  101. else
  102. if test "x$ac_x_libraries" = x; then
  103. XPATH=""
  104. XLIB="-lX11"
  105. else
  106. XPATH="-L$ac_x_libraries"
  107. XLIB="-L$ac_x_libraries -lX11"
  108. fi
  109. fi
  110. fi
  111. dnl Check for OpenGL
  112. AC_MSG_CHECKING(for OpenGL support)
  113. have_opengl=no
  114. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  115. #include "SDL_opengl.h"
  116. #ifndef SDL_VIDEO_OPENGL
  117. #error SDL_VIDEO_OPENGL
  118. #endif
  119. ]],[])], [have_opengl=yes],[])
  120. AC_MSG_RESULT($have_opengl)
  121. dnl Check for OpenGL ES
  122. AC_MSG_CHECKING(for OpenGL ES support)
  123. have_opengles=no
  124. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  125. #include "SDL_opengles.h"
  126. #ifndef SDL_VIDEO_OPENGL_ES
  127. #error SDL_VIDEO_OPENGL_ES
  128. #endif
  129. ]],[])] ,[have_opengles=yes],[])
  130. AC_MSG_RESULT($have_opengles)
  131. dnl Check for OpenGL ES2
  132. AC_MSG_CHECKING(for OpenGL ES2 support)
  133. have_opengles2=no
  134. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  135. #include "SDL_opengles2.h"
  136. #ifndef SDL_VIDEO_OPENGL_ES2
  137. #error SDL_VIDEO_OPENGL_ES2
  138. #endif
  139. ]],[])], [have_opengles2=yes],[])
  140. AC_MSG_RESULT($have_opengles2)
  141. GLLIB=""
  142. GLESLIB=""
  143. GLES2LIB=""
  144. OPENGLES1_TARGETS="UNUSED"
  145. OPENGLES2_TARGETS="UNUSED"
  146. OPENGL_TARGETS="UNUSED"
  147. if test x$have_opengles = xyes; then
  148. CFLAGS="$CFLAGS -DHAVE_OPENGLES"
  149. GLESLIB="$XPATH -lGLESv1_CM"
  150. OPENGLES1_TARGETS="TARGETS"
  151. fi
  152. if test x$have_opengles2 = xyes; then
  153. CFLAGS="$CFLAGS -DHAVE_OPENGLES2"
  154. #GLES2LIB="$XPATH -lGLESv2"
  155. OPENGLES2_TARGETS="TARGETS"
  156. fi
  157. if test x$have_opengl = xyes; then
  158. CFLAGS="$CFLAGS -DHAVE_OPENGL"
  159. GLLIB="$XPATH $SYS_GL_LIBS"
  160. OPENGL_TARGETS="TARGETS"
  161. fi
  162. AC_MSG_CHECKING(for GCC -Wformat)
  163. have_wformat=no
  164. save_CFLAGS="$CFLAGS"
  165. CFLAGS="$save_CFLAGS -Wformat"
  166. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x = 0;]],[])],
  167. [have_wformat=yes], [])
  168. AC_MSG_RESULT($have_wformat)
  169. CFLAGS="$save_CFLAGS"
  170. if test x$have_wformat = xyes; then
  171. CFLAGS="$CFLAGS -DHAVE_WFORMAT"
  172. fi
  173. AC_MSG_CHECKING(for GCC -Wformat-overflow)
  174. have_wformat_overflow=no
  175. save_CFLAGS="$CFLAGS"
  176. CFLAGS="$save_CFLAGS -Wformat-overflow"
  177. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x = 0;]],[])],
  178. [have_wformat_overflow=yes], [])
  179. AC_MSG_RESULT($have_wformat_overflow)
  180. CFLAGS="$save_CFLAGS"
  181. if test x$have_wformat_overflow = xyes; then
  182. CFLAGS="$CFLAGS -DHAVE_WFORMAT_OVERFLOW"
  183. fi
  184. AC_MSG_CHECKING(for GCC -Wformat-extra-args)
  185. have_wformat_extra_args=no
  186. save_CFLAGS="$CFLAGS"
  187. CFLAGS="$save_CFLAGS -Wformat-extra-args"
  188. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x = 0;]],[])],
  189. [have_wformat_extra_args=yes], [])
  190. AC_MSG_RESULT($have_wformat_extra_args)
  191. CFLAGS="$save_CFLAGS"
  192. if test x$have_wformat_extra_args = xyes; then
  193. CFLAGS="$CFLAGS -DHAVE_WFORMAT_EXTRA_ARGS"
  194. fi
  195. AC_ARG_ENABLE(werror,
  196. [AS_HELP_STRING([--enable-werror], [treat warnings as errors [default=no]])],
  197. enable_werror=$enableval, enable_werror=no)
  198. if test x$enable_werror = xyes; then
  199. AC_MSG_CHECKING(for GCC -Werror option)
  200. have_gcc_werror=no
  201. save_CFLAGS="$CFLAGS"
  202. CFLAGS="$save_CFLAGS -Werror"
  203. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x = 0;]],[])],
  204. [have_gcc_werror=yes], [])
  205. AC_MSG_RESULT($have_gcc_werror)
  206. CFLAGS="$save_CFLAGS"
  207. if test x$have_gcc_werror = xyes; then
  208. CFLAGS="$CFLAGS -Werror"
  209. fi
  210. fi
  211. case "$host" in
  212. *-ios-*|*-*-darwin* )
  213. AC_MSG_CHECKING(for GCC -Wno-error=deprecated-declarations option)
  214. have_gcc_wno_error_deprecated_declarations=no
  215. save_CFLAGS="$CFLAGS"
  216. CFLAGS="$save_CFLAGS -Wno-error=deprecated-declarations"
  217. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  218. int x = 0;
  219. ]],[])], [have_gcc_wno_error_deprecated_declarations=yes],[])
  220. AC_MSG_RESULT($have_gcc_werror)
  221. CFLAGS="$save_CFLAGS"
  222. if test x$have_gcc_wno_error_deprecated_declarations = xyes; then
  223. EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-error=deprecated-declarations"
  224. fi
  225. ;;
  226. esac
  227. AC_SUBST(OPENGLES1_TARGETS)
  228. AC_SUBST(OPENGLES2_TARGETS)
  229. AC_SUBST(OPENGL_TARGETS)
  230. AC_SUBST(GLLIB)
  231. AC_SUBST(GLESLIB)
  232. AC_SUBST(GLES2LIB)
  233. AC_SUBST(XLIB)
  234. dnl Check for SDL_ttf
  235. AC_CHECK_LIB(SDL3_ttf, TTF_Init, have_SDL_ttf=yes)
  236. if test x$have_SDL_ttf = xyes; then
  237. CFLAGS="$CFLAGS -DHAVE_SDL_TTF"
  238. SDL_TTF_LIB="-lSDL3_ttf"
  239. fi
  240. AC_SUBST(SDL_TTF_LIB)
  241. dnl Really, SDL3_test should be linking against libunwind (if it found
  242. dnl libunwind.h when configured), but SDL3_test is a static library, so
  243. dnl there's no way for it to link against it. We could make SDL3 depend on
  244. dnl it, but we don't want all SDL3 build to suddenly gain an extra dependency,
  245. dnl so just assume that if it's here now, SDL3_test was probably built with it.
  246. PKG_CHECK_MODULES(LIBUNWIND, libunwind, have_libunwind=yes, have_libunwind=no)
  247. if test x$have_libunwind = xyes ; then
  248. LIBS="$LIBS $LIBUNWIND_LIBS"
  249. fi
  250. dnl Finally create all the generated files
  251. AC_CONFIG_FILES([Makefile])
  252. AC_OUTPUT