configure.ac 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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_DIRS($srcdir/../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. have_glvnd=no
  80. AC_CHECK_LIB(OpenGL, glBegin,
  81. [
  82. dnl have_glvnd=yes
  83. SYS_GL_LIBS="-lOpenGL"
  84. ],[
  85. SYS_GL_LIBS="-lGL"
  86. ])
  87. ;;
  88. esac
  89. AC_SUBST(EXE)
  90. AC_SUBST(MATHLIB)
  91. AC_SUBST(ISMACOSX)
  92. AC_SUBST(ISWINDOWS)
  93. AC_SUBST(ISUNIX)
  94. dnl Check for SDL
  95. SDL_VERSION=2.0.0
  96. AM_PATH_SDL2($SDL_VERSION,
  97. :,
  98. AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
  99. )
  100. CFLAGS="$CFLAGS $SDL_CFLAGS"
  101. LIBS="$LIBS -lSDL2_test $SDL_LIBS"
  102. dnl Check for X11 path, needed for OpenGL on some systems
  103. AC_PATH_X
  104. if test x$have_x = xyes; then
  105. if test x$ac_x_includes = xno || test "x$ac_x_includes" = xNone || test "x$ac_x_includes" = x; then
  106. :
  107. else
  108. CFLAGS="$CFLAGS -I$ac_x_includes"
  109. fi
  110. if test x$ac_x_libraries = xno || test "x$ac_x_libraries" = xNone; then
  111. :
  112. else
  113. if test "x$ac_x_libraries" = x; then
  114. XPATH=""
  115. XLIB="-lX11"
  116. else
  117. XPATH="-L$ac_x_libraries"
  118. XLIB="-L$ac_x_libraries -lX11"
  119. fi
  120. fi
  121. fi
  122. dnl Check for OpenGL
  123. AC_MSG_CHECKING(for OpenGL support)
  124. have_opengl=no
  125. AC_TRY_COMPILE([
  126. #include "SDL_opengl.h"
  127. #ifndef SDL_VIDEO_OPENGL
  128. #error SDL_VIDEO_OPENGL
  129. #endif
  130. ],[
  131. ],[
  132. have_opengl=yes
  133. ])
  134. AC_MSG_RESULT($have_opengl)
  135. dnl Check for OpenGL ES
  136. AC_MSG_CHECKING(for OpenGL ES support)
  137. have_opengles=no
  138. AC_TRY_COMPILE([
  139. #include "SDL_opengles.h"
  140. #ifndef SDL_VIDEO_OPENGL_ES
  141. #error SDL_VIDEO_OPENGL_ES
  142. #endif
  143. ],[
  144. ],[
  145. have_opengles=yes
  146. ])
  147. AC_MSG_RESULT($have_opengles)
  148. dnl Check for OpenGL ES2
  149. AC_MSG_CHECKING(for OpenGL ES2 support)
  150. have_opengles2=no
  151. AC_TRY_COMPILE([
  152. #include "SDL_opengles2.h"
  153. #ifndef SDL_VIDEO_OPENGL_ES2
  154. #error SDL_VIDEO_OPENGL_ES2
  155. #endif
  156. ],[
  157. ],[
  158. have_opengles2=yes
  159. ])
  160. AC_MSG_RESULT($have_opengles2)
  161. GLLIB=""
  162. GLESLIB=""
  163. GLES2LIB=""
  164. OPENGLES1_TARGETS="UNUSED"
  165. OPENGLES2_TARGETS="UNUSED"
  166. OPENGL_TARGETS="UNUSED"
  167. if test x$have_opengles = xyes; then
  168. CFLAGS="$CFLAGS -DHAVE_OPENGLES"
  169. GLESLIB="$XPATH -lGLESv1_CM"
  170. OPENGLES1_TARGETS="TARGETS"
  171. fi
  172. if test x$have_opengles2 = xyes; then
  173. CFLAGS="$CFLAGS -DHAVE_OPENGLES2"
  174. #GLES2LIB="$XPATH -lGLESv2"
  175. OPENGLES2_TARGETS="TARGETS"
  176. fi
  177. if test x$have_opengl = xyes; then
  178. CFLAGS="$CFLAGS -DHAVE_OPENGL"
  179. GLLIB="$XPATH $SYS_GL_LIBS"
  180. OPENGL_TARGETS="TARGETS"
  181. fi
  182. AC_SUBST(OPENGLES1_TARGETS)
  183. AC_SUBST(OPENGLES2_TARGETS)
  184. AC_SUBST(OPENGL_TARGETS)
  185. AC_SUBST(GLLIB)
  186. AC_SUBST(GLESLIB)
  187. AC_SUBST(GLES2LIB)
  188. AC_SUBST(XLIB)
  189. dnl Check for SDL_ttf
  190. AC_CHECK_LIB(SDL2_ttf, TTF_Init, have_SDL_ttf=yes)
  191. if test x$have_SDL_ttf = xyes; then
  192. CFLAGS="$CFLAGS -DHAVE_SDL_TTF"
  193. SDL_TTF_LIB="-lSDL2_ttf"
  194. fi
  195. AC_SUBST(SDL_TTF_LIB)
  196. dnl Finally create all the generated files
  197. AC_CONFIG_FILES([Makefile])
  198. AC_OUTPUT