configure.ac 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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 ES2
  122. AC_MSG_CHECKING(for OpenGL ES2 support)
  123. have_opengles2=no
  124. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  125. #include "SDL_opengles2.h"
  126. #ifndef SDL_VIDEO_OPENGL_ES2
  127. #error SDL_VIDEO_OPENGL_ES2
  128. #endif
  129. ]],[])], [have_opengles2=yes],[])
  130. AC_MSG_RESULT($have_opengles2)
  131. GLLIB=""
  132. GLESLIB=""
  133. GLES2LIB=""
  134. OPENGLES2_TARGETS="UNUSED"
  135. OPENGL_TARGETS="UNUSED"
  136. if test x$have_opengles2 = xyes; then
  137. CFLAGS="$CFLAGS -DHAVE_OPENGLES2"
  138. #GLES2LIB="$XPATH -lGLESv2"
  139. OPENGLES2_TARGETS="TARGETS"
  140. fi
  141. if test x$have_opengl = xyes; then
  142. CFLAGS="$CFLAGS -DHAVE_OPENGL"
  143. GLLIB="$XPATH $SYS_GL_LIBS"
  144. OPENGL_TARGETS="TARGETS"
  145. fi
  146. AC_MSG_CHECKING(for GCC -Wformat)
  147. have_wformat=no
  148. save_CFLAGS="$CFLAGS"
  149. CFLAGS="$save_CFLAGS -Wformat"
  150. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x = 0;]],[])],
  151. [have_wformat=yes], [])
  152. AC_MSG_RESULT($have_wformat)
  153. CFLAGS="$save_CFLAGS"
  154. if test x$have_wformat = xyes; then
  155. CFLAGS="$CFLAGS -DHAVE_WFORMAT"
  156. fi
  157. AC_MSG_CHECKING(for GCC -Wformat-overflow)
  158. have_wformat_overflow=no
  159. save_CFLAGS="$CFLAGS"
  160. CFLAGS="$save_CFLAGS -Wformat-overflow"
  161. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x = 0;]],[])],
  162. [have_wformat_overflow=yes], [])
  163. AC_MSG_RESULT($have_wformat_overflow)
  164. CFLAGS="$save_CFLAGS"
  165. if test x$have_wformat_overflow = xyes; then
  166. CFLAGS="$CFLAGS -DHAVE_WFORMAT_OVERFLOW"
  167. fi
  168. AC_MSG_CHECKING(for GCC -Wformat-extra-args)
  169. have_wformat_extra_args=no
  170. save_CFLAGS="$CFLAGS"
  171. CFLAGS="$save_CFLAGS -Wformat-extra-args"
  172. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x = 0;]],[])],
  173. [have_wformat_extra_args=yes], [])
  174. AC_MSG_RESULT($have_wformat_extra_args)
  175. CFLAGS="$save_CFLAGS"
  176. if test x$have_wformat_extra_args = xyes; then
  177. CFLAGS="$CFLAGS -DHAVE_WFORMAT_EXTRA_ARGS"
  178. fi
  179. AC_ARG_ENABLE(werror,
  180. [AS_HELP_STRING([--enable-werror], [treat warnings as errors [default=no]])],
  181. enable_werror=$enableval, enable_werror=no)
  182. if test x$enable_werror = xyes; then
  183. AC_MSG_CHECKING(for GCC -Werror option)
  184. have_gcc_werror=no
  185. save_CFLAGS="$CFLAGS"
  186. CFLAGS="$save_CFLAGS -Werror"
  187. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int x = 0;]],[])],
  188. [have_gcc_werror=yes], [])
  189. AC_MSG_RESULT($have_gcc_werror)
  190. CFLAGS="$save_CFLAGS"
  191. if test x$have_gcc_werror = xyes; then
  192. CFLAGS="$CFLAGS -Werror"
  193. fi
  194. fi
  195. case "$host" in
  196. *-ios-*|*-*-darwin* )
  197. AC_MSG_CHECKING(for GCC -Wno-error=deprecated-declarations option)
  198. have_gcc_wno_error_deprecated_declarations=no
  199. save_CFLAGS="$CFLAGS"
  200. CFLAGS="$save_CFLAGS -Wno-error=deprecated-declarations"
  201. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  202. int x = 0;
  203. ]],[])], [have_gcc_wno_error_deprecated_declarations=yes],[])
  204. AC_MSG_RESULT($have_gcc_werror)
  205. CFLAGS="$save_CFLAGS"
  206. if test x$have_gcc_wno_error_deprecated_declarations = xyes; then
  207. EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-error=deprecated-declarations"
  208. fi
  209. ;;
  210. esac
  211. AC_SUBST(OPENGLES2_TARGETS)
  212. AC_SUBST(OPENGL_TARGETS)
  213. AC_SUBST(GLLIB)
  214. AC_SUBST(GLESLIB)
  215. AC_SUBST(GLES2LIB)
  216. AC_SUBST(XLIB)
  217. dnl Check for SDL_ttf
  218. AC_CHECK_LIB(SDL3_ttf, TTF_Init, have_SDL_ttf=yes)
  219. if test x$have_SDL_ttf = xyes; then
  220. CFLAGS="$CFLAGS -DHAVE_SDL_TTF"
  221. SDL_TTF_LIB="-lSDL3_ttf"
  222. fi
  223. AC_SUBST(SDL_TTF_LIB)
  224. dnl Really, SDL3_test should be linking against libunwind (if it found
  225. dnl libunwind.h when configured), but SDL3_test is a static library, so
  226. dnl there's no way for it to link against it. We could make SDL3 depend on
  227. dnl it, but we don't want all SDL3 build to suddenly gain an extra dependency,
  228. dnl so just assume that if it's here now, SDL3_test was probably built with it.
  229. PKG_CHECK_MODULES(LIBUNWIND, libunwind, have_libunwind=yes, have_libunwind=no)
  230. if test x$have_libunwind = xyes ; then
  231. LIBS="$LIBS $LIBUNWIND_LIBS"
  232. fi
  233. dnl Finally create all the generated files
  234. AC_CONFIG_FILES([Makefile])
  235. AC_OUTPUT