You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

244 lines
7.6 KiB

  1. # $Id$
  2. AC_INIT(src/caca.c)
  3. AC_PREREQ(2.50)
  4. AC_CONFIG_AUX_DIR(autotools)
  5. AC_CANONICAL_SYSTEM
  6. AM_INIT_AUTOMAKE(libcaca, 0.9)
  7. AM_CONFIG_HEADER(config.h)
  8. AM_PROG_CC_C_O
  9. AC_PROG_CPP
  10. AC_LIBTOOL_WIN32_DLL
  11. AC_DISABLE_SHARED
  12. AM_PROG_LIBTOOL
  13. AC_C_CONST
  14. AC_C_INLINE
  15. AC_TYPE_SIGNAL
  16. dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
  17. dnl now otherwise it might be set in an obscure if statement.
  18. AC_EGREP_CPP(foo, foo)
  19. dnl output driver features
  20. AC_ARG_ENABLE(slang,
  21. [ --enable-slang slang graphics support (autodetected)])
  22. AC_ARG_ENABLE(ncurses,
  23. [ --enable-ncurses ncurses graphics support (autodetected)])
  24. AC_ARG_ENABLE(win32,
  25. [ --enable-win32 Windows console support (autodetected)])
  26. AC_ARG_ENABLE(conio,
  27. [ --enable-conio DOS conio.h graphics support (autodetected)])
  28. AC_ARG_ENABLE(x11,
  29. [ --enable-x11 X11 support (autodetected)])
  30. AC_ARG_ENABLE(gl,
  31. [ --enable-gl OpenGL support (autodetected)])
  32. dnl example programs features
  33. AC_ARG_ENABLE(imlib2,
  34. [ --enable-imlib2 Imlib2 graphics support (default enabled)])
  35. dnl conditional builds
  36. AC_ARG_ENABLE(doc,
  37. [ --enable-doc build documentation (needs doxygen and LaTeX)])
  38. AC_CHECK_HEADERS(signal.h sys/ioctl.h sys/time.h inttypes.h endian.h unistd.h)
  39. AC_CHECK_FUNCS(signal ioctl vsnprintf getenv putenv strcasecmp)
  40. AC_CHECK_FUNCS(usleep gettimeofday)
  41. AC_MSG_CHECKING(for Sleep)
  42. AC_TRY_COMPILE([#include <windows.h>],[Sleep(42);],
  43. [AC_MSG_RESULT(yes)
  44. AC_DEFINE(HAVE_SLEEP, 1, [Define if you have Windows' Sleep])],
  45. [AC_MSG_RESULT(no)])
  46. AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
  47. CACA_DRIVERS=""
  48. if test "${enable_conio}" != "no"; then
  49. ac_cv_my_have_conio="no"
  50. AC_CHECK_HEADERS(conio.h,
  51. [AC_MSG_CHECKING(for ScreenUpdate in pc.h)
  52. AC_EGREP_HEADER(ScreenUpdate, pc.h,
  53. [ac_cv_my_have_conio="yes"
  54. AC_MSG_RESULT(yes)
  55. AC_DEFINE(SCREENUPDATE_IN_PC_H, 1,
  56. Define if <pc.h> defines ScreenUpdate.)
  57. AC_DEFINE(USE_CONIO, 1, Define to activate the conio.h backend driver)
  58. CACA_DRIVERS="${CACA_DRIVERS} conio"],
  59. [AC_MSG_RESULT(no)])])
  60. if test "${ac_cv_my_have_conio}" = "no" -a "${enable_conio}" = "yes"; then
  61. AC_MSG_ERROR([cannot find conio.h])
  62. fi
  63. fi
  64. if test "${enable_win32}" != "no"; then
  65. ac_cv_my_have_win32="no"
  66. AC_CHECK_HEADERS(windows.h,
  67. [AC_MSG_CHECKING(for AllocConsole in windows.h)
  68. AC_EGREP_HEADER(AllocConsole, windows.h,
  69. [ac_cv_my_have_win32="yes"
  70. AC_MSG_RESULT(yes)
  71. AC_DEFINE(ALLOCCONSOLE_IN_WINDOWS_H, 1,
  72. Define if <windows.h> defines AllocConsole.)
  73. AC_DEFINE(USE_WIN32, 1, Define to activate the win32 backend driver)
  74. CACA_DRIVERS="${CACA_DRIVERS} win32"],
  75. [AC_MSG_RESULT(no)])])
  76. if test "${ac_cv_my_have_win32}" = "no" -a "${enable_win32}" = "yes"; then
  77. AC_MSG_ERROR([cannot find win32 console development files])
  78. fi
  79. fi
  80. if test "${enable_slang}" != "no"; then
  81. ac_cv_my_have_slang="no"
  82. AC_CHECK_HEADERS(slang.h slang/slang.h,
  83. [AC_CHECK_LIB(slang, SLkp_init,
  84. [ac_cv_my_have_slang="yes"
  85. AC_DEFINE(USE_SLANG, 1, Define to activate the slang backend driver)
  86. CPPFLAGS="${CPPFLAGS} -DOPTIMISE_SLANG_PALETTE=1"
  87. CACA_LIBS="${CACA_LIBS} -lslang"
  88. CACA_DRIVERS="${CACA_DRIVERS} slang"])])
  89. if test "${ac_cv_my_have_slang}" = "no" -a "${enable_slang}" = "yes"; then
  90. AC_MSG_ERROR([cannot find slang development files])
  91. fi
  92. fi
  93. if test "${enable_x11}" != "no"; then
  94. AC_PATH_X
  95. AC_CHECK_LIB(X11, XOpenDisplay,
  96. [ac_cv_my_have_x11="yes"
  97. if test -n "${x_includes}"; then X_CFLAGS="-I${x_includes}"; fi
  98. if test -n "${x_libraries}"; then X_LIBS="-lX11 -L${x_libraries}"; fi
  99. AC_DEFINE(USE_X11, 1, Define to activate the X11 backend driver)
  100. CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
  101. CACA_LIBS="${CACA_LIBS} ${X_LIBS}"
  102. CACA_DRIVERS="${CACA_DRIVERS} x11"],
  103. [ac_cv_my_have_x11="no"],
  104. [[-lXt -L${x_libraries}]])
  105. AC_CHECK_HEADERS(X11/XKBlib.h)
  106. if test "${ac_cv_my_have_x11}" != "yes" -a "${enable_x11}" = "yes"; then
  107. AC_MSG_ERROR([cannot find X11 development files])
  108. fi
  109. fi
  110. if test "${enable_gl}" != "no"; then
  111. ac_cv_my_have_gl="no"
  112. AC_CHECK_HEADERS(GL/gl.h GL/glut.h,
  113. [AC_CHECK_LIB(glut, glutMainLoopEvent,
  114. [ac_cv_my_have_gl="yes"
  115. AC_DEFINE(USE_GL, 1, Define to activate the OpenGL backend driver)
  116. CACA_LIBS="${CACA_LIBS} -lGL -lglut"
  117. CACA_DRIVERS="${CACA_DRIVERS} gl"])])
  118. if test "${ac_cv_my_have_gl}" = "no" -a "${enable_gl}" = "yes"; then
  119. AC_MSG_ERROR([cannot find OpenGL+FreeGLUT development files])
  120. fi
  121. fi
  122. if test "${enable_ncurses}" != "no"; then
  123. ac_cv_my_have_ncurses="no"
  124. AC_CHECK_HEADERS(curses.h ncurses.h,
  125. [AC_CHECK_LIB(ncurses, initscr,
  126. [ac_cv_my_have_ncurses="yes"
  127. AC_DEFINE(USE_NCURSES, 1, Define to activate the ncurses backend driver)
  128. CACA_LIBS="${CACA_LIBS} -lncurses"
  129. CACA_DRIVERS="${CACA_DRIVERS} ncurses"
  130. dnl Check for resizeterm or resize_term
  131. SAVED_LIBS="${LIBS}"
  132. LIBS="${LIBS} -lncurses"
  133. AC_CHECK_FUNCS(resizeterm resize_term)
  134. LIBS="${SAVED_LIBS}"])])
  135. if test "${ac_cv_my_have_ncurses}" = "no" -a "${enable_ncurses}" = "yes"; then
  136. AC_MSG_ERROR([cannot find ncurses development files])
  137. fi
  138. fi
  139. AC_MSG_CHECKING(valid output drivers)
  140. if test -z "${CACA_DRIVERS}"; then
  141. AC_MSG_RESULT(no)
  142. AC_MSG_ERROR([no output drivers were selected!])
  143. else
  144. AC_MSG_RESULT([${CACA_DRIVERS}])
  145. fi
  146. AC_SUBST(MATH_LIBS)
  147. AC_SUBST(CACA_LIBS)
  148. # Optimizations
  149. CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer"
  150. # Code qui fait des warnings == code de porc == deux baffes dans ta gueule
  151. # [Jylam] Removed -Wshadow in order to avoid ncurses/gl conflict
  152. # (Comme quoi on est pas les seuls porcs)
  153. CFLAGS="${CFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare"
  154. # Build the PIC library?
  155. case "${target_os}" in
  156. *mingw32* | *cygwin* | *djgpp*)
  157. NEED_PIC=false
  158. ;;
  159. *)
  160. NEED_PIC=:
  161. ;;
  162. esac
  163. AM_CONDITIONAL(NEED_PIC, ${NEED_PIC})
  164. # Use Imlib2?
  165. ac_cv_my_have_imlib2="no"
  166. save_CPPFLAGS="${CPPFLAGS}"
  167. if test "${enable_imlib2}" != "no"; then
  168. AC_PATH_PROG(IMLIB2_CONFIG, imlib2-config, no)
  169. if test "${IMLIB2_CONFIG}" != "no"; then
  170. CPPFLAGS="${CPPFLAGS} `imlib2-config --cflags` -DX_DISPLAY_MISSING=1"
  171. fi
  172. AC_CHECK_HEADERS(Imlib2.h,
  173. ac_cv_my_have_imlib2="yes",
  174. [ac_cv_my_have_imlib2="no"
  175. AC_MSG_ERROR([[cannot find Imlib2 development files. Without Imlib2, cacaview will only open BMP files; if this is really what you want, re-run configure with '--disable-imlib2'.]])])
  176. CPPFLAGS="${save_CPPFLAGS}"
  177. fi
  178. AM_CONDITIONAL(USE_IMLIB2, test "${ac_cv_my_have_imlib2}" = "yes")
  179. # Build documentation?
  180. DOXYGEN="no"
  181. LATEX="no"
  182. if test "${enable_doc}" != "no"; then
  183. AC_PATH_PROG(DOXYGEN, doxygen, no)
  184. if test "${DOXYGEN}" = "no"; then
  185. AC_MSG_ERROR([[cannot find doxygen, which is needed to build the libcaca documentation; if this is really what you want, re-run configure with '--disable-doc'.]])
  186. fi
  187. # Build LaTeX documentation?
  188. AC_PATH_PROG(LATEX, latex, no)
  189. AC_PATH_PROG(DVIPS, dvips, no)
  190. if test "${DVIPS}" = "no"; then
  191. LATEX="no"
  192. fi
  193. AC_MSG_CHECKING(for a4wide.sty)
  194. if test -f /usr/share/texmf/tex/latex/misc/a4wide.sty; then
  195. AC_MSG_RESULT(yes)
  196. else
  197. LATEX="no"
  198. AC_MSG_RESULT(no)
  199. fi
  200. fi
  201. AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
  202. AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no")
  203. AC_CONFIG_FILES([
  204. Makefile
  205. src/Makefile
  206. examples/Makefile
  207. test/Makefile
  208. doc/Makefile
  209. doc/doxygen.cfg
  210. autotools/Makefile
  211. debian/Makefile
  212. msvc/Makefile
  213. ])
  214. AC_CONFIG_FILES([caca-config], [chmod 0755 caca-config])
  215. AC_OUTPUT