configure.ac 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. *-*-qnx*)
  58. EXE=""
  59. MATHLIB=""
  60. SYS_GL_LIBS="-lGLES_CM"
  61. ;;
  62. *-*-emscripten* )
  63. dnl This should really be .js, but we need to specify extra flags when compiling to js
  64. EXE=".bc"
  65. MATHLIB=""
  66. SYS_GL_LIBS=""
  67. ;;
  68. *-*-riscos* )
  69. EXE=",e1f"
  70. MATHLIB=""
  71. SYS_GL_LIBS=""
  72. ;;
  73. *)
  74. dnl Oh well, call it Unix...
  75. ISUNIX="true"
  76. EXE=""
  77. MATHLIB="-lm"
  78. dnl Use the new libOpenGL if present.
  79. AC_CHECK_LIB(OpenGL, glBegin,
  80. [SYS_GL_LIBS="-lOpenGL"],[SYS_GL_LIBS="-lGL"])
  81. ;;
  82. esac
  83. AC_SUBST(EXE)
  84. AC_SUBST(MATHLIB)
  85. AC_SUBST(ISMACOSX)
  86. AC_SUBST(ISWINDOWS)
  87. AC_SUBST(ISUNIX)
  88. dnl Check for SDL
  89. SDL_VERSION=2.0.18
  90. AM_PATH_SDL2($SDL_VERSION,
  91. :,
  92. AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
  93. )
  94. CFLAGS="$CFLAGS $SDL_CFLAGS"
  95. LIBS="$LIBS -lSDL2_test $SDL_LIBS"
  96. dnl Check for X11 path, needed for OpenGL on some systems
  97. AC_PATH_X
  98. if test x$have_x = xyes; then
  99. if test x$ac_x_includes = xno || test "x$ac_x_includes" = xNone || test "x$ac_x_includes" = x; then
  100. :
  101. else
  102. CFLAGS="$CFLAGS -I$ac_x_includes"
  103. fi
  104. if test x$ac_x_libraries = xno || test "x$ac_x_libraries" = xNone; then
  105. :
  106. else
  107. if test "x$ac_x_libraries" = x; then
  108. XPATH=""
  109. XLIB="-lX11"
  110. else
  111. XPATH="-L$ac_x_libraries"
  112. XLIB="-L$ac_x_libraries -lX11"
  113. fi
  114. fi
  115. fi
  116. dnl Check for OpenGL
  117. AC_MSG_CHECKING(for OpenGL support)
  118. have_opengl=no
  119. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  120. #include "SDL_opengl.h"
  121. #ifndef SDL_VIDEO_OPENGL
  122. #error SDL_VIDEO_OPENGL
  123. #endif
  124. ]],[])], [have_opengl=yes],[])
  125. AC_MSG_RESULT($have_opengl)
  126. dnl Check for OpenGL ES
  127. AC_MSG_CHECKING(for OpenGL ES support)
  128. have_opengles=no
  129. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  130. #include "SDL_opengles.h"
  131. #ifndef SDL_VIDEO_OPENGL_ES
  132. #error SDL_VIDEO_OPENGL_ES
  133. #endif
  134. ]],[])] ,[have_opengles=yes],[])
  135. AC_MSG_RESULT($have_opengles)
  136. dnl Check for OpenGL ES2
  137. AC_MSG_CHECKING(for OpenGL ES2 support)
  138. have_opengles2=no
  139. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  140. #include "SDL_opengles2.h"
  141. #ifndef SDL_VIDEO_OPENGL_ES2
  142. #error SDL_VIDEO_OPENGL_ES2
  143. #endif
  144. ]],[])], [have_opengles2=yes],[])
  145. AC_MSG_RESULT($have_opengles2)
  146. GLLIB=""
  147. GLESLIB=""
  148. GLES2LIB=""
  149. OPENGLES1_TARGETS="UNUSED"
  150. OPENGLES2_TARGETS="UNUSED"
  151. OPENGL_TARGETS="UNUSED"
  152. if test x$have_opengles = xyes; then
  153. CFLAGS="$CFLAGS -DHAVE_OPENGLES"
  154. GLESLIB="$XPATH -lGLESv1_CM"
  155. OPENGLES1_TARGETS="TARGETS"
  156. fi
  157. if test x$have_opengles2 = xyes; then
  158. CFLAGS="$CFLAGS -DHAVE_OPENGLES2"
  159. #GLES2LIB="$XPATH -lGLESv2"
  160. OPENGLES2_TARGETS="TARGETS"
  161. fi
  162. if test x$have_opengl = xyes; then
  163. CFLAGS="$CFLAGS -DHAVE_OPENGL"
  164. GLLIB="$XPATH $SYS_GL_LIBS"
  165. OPENGL_TARGETS="TARGETS"
  166. fi
  167. AC_SUBST(OPENGLES1_TARGETS)
  168. AC_SUBST(OPENGLES2_TARGETS)
  169. AC_SUBST(OPENGL_TARGETS)
  170. AC_SUBST(GLLIB)
  171. AC_SUBST(GLESLIB)
  172. AC_SUBST(GLES2LIB)
  173. AC_SUBST(XLIB)
  174. dnl Check for SDL_ttf
  175. AC_CHECK_LIB(SDL2_ttf, TTF_Init, have_SDL_ttf=yes)
  176. if test x$have_SDL_ttf = xyes; then
  177. CFLAGS="$CFLAGS -DHAVE_SDL_TTF"
  178. SDL_TTF_LIB="-lSDL2_ttf"
  179. fi
  180. AC_SUBST(SDL_TTF_LIB)
  181. dnl Really, SDL2_test should be linking against libunwind (if it found
  182. dnl libunwind.h when configured), but SDL2_test is a static library, so
  183. dnl there's no way for it to link against it. We could make SDL2 depend on
  184. dnl it, but we don't want all SDL2 build to suddenly gain an extra dependency,
  185. dnl so just assume that if it's here now, SDL2_test was probably built with it.
  186. PKG_CHECK_MODULES(LIBUNWIND, libunwind, have_libunwind=yes, have_libunwind=no)
  187. if test x$have_libunwind = xyes ; then
  188. LIBS="$LIBS $LIBUNWIND_LIBS"
  189. fi
  190. dnl Finally create all the generated files
  191. AC_CONFIG_FILES([Makefile])
  192. AC_OUTPUT