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.
 
 
 
 
 
 

344 lines
11 KiB

  1. # $Id$
  2. AC_INIT(caca/caca.c)
  3. AC_PREREQ(2.50)
  4. AC_CONFIG_AUX_DIR(autotools)
  5. AC_CANONICAL_SYSTEM
  6. AM_INIT_AUTOMAKE(libcaca, 0.99.beta10)
  7. LT_VERSION="99:0:99"
  8. AC_SUBST(LT_VERSION)
  9. AM_CONFIG_HEADER(config.h)
  10. AM_PROG_CC_C_O
  11. AC_PROG_CPP
  12. AC_PROG_CXX
  13. AC_PROG_CXXCPP
  14. AM_PROG_AS
  15. AC_LIBTOOL_WIN32_DLL
  16. AM_PROG_LIBTOOL
  17. AC_LIBTOOL_CXX
  18. AC_C_CONST
  19. AC_C_INLINE
  20. AC_TYPE_SIGNAL
  21. dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
  22. dnl now otherwise it might be set in an obscure if statement. Same thing for
  23. dnl PKG_PROG_PKG_CONFIG which needs to be called first.
  24. AC_EGREP_CPP(yes, foo)
  25. PKG_PROG_PKG_CONFIG()
  26. m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
  27. if test "${build}" != "${host}" -a "${PKG_CONFIG_LIBDIR}" = ""; then
  28. export PKG_CONFIG_LIBDIR=/dev/null
  29. fi
  30. dnl output driver features
  31. AC_ARG_ENABLE(slang,
  32. [ --enable-slang slang graphics support (autodetected)])
  33. AC_ARG_ENABLE(ncurses,
  34. [ --enable-ncurses ncurses graphics support (autodetected)])
  35. AC_ARG_ENABLE(win32,
  36. [ --enable-win32 Windows console support (autodetected)])
  37. AC_ARG_ENABLE(conio,
  38. [ --enable-conio DOS conio.h graphics support (autodetected)])
  39. AC_ARG_ENABLE(x11,
  40. [ --enable-x11 X11 support (autodetected)])
  41. AC_ARG_ENABLE(gl,
  42. [ --enable-gl OpenGL support (autodetected)])
  43. AC_ARG_ENABLE(network,
  44. [ --enable-network Network support (autodetected)])
  45. AC_ARG_ENABLE(vga,
  46. [ --enable-vga VGA support (default disabled)])
  47. dnl language bindings
  48. AC_ARG_ENABLE(cxx,
  49. [ --enable-cxx C++ bindings (default disabled)])
  50. dnl example programs features
  51. AC_ARG_ENABLE(imlib2,
  52. [ --enable-imlib2 Imlib2 graphics support (default enabled)])
  53. dnl conditional builds
  54. AC_ARG_ENABLE(debug,
  55. [ --enable-debug build debug versions of the library])
  56. AC_ARG_ENABLE(plugins,
  57. [ --enable-plugins build X11 and GL drivers as plugins])
  58. AC_ARG_ENABLE(doc,
  59. [ --enable-doc build documentation (needs doxygen and LaTeX)])
  60. AC_CHECK_HEADERS(stdio.h stdarg.h signal.h sys/ioctl.h sys/time.h inttypes.h endian.h unistd.h arpa/inet.h netinet/in.h winsock2.h errno.h locale.h getopt.h dlfcn.h)
  61. AC_CHECK_FUNCS(signal ioctl vsnprintf getenv putenv strcasecmp htons)
  62. AC_CHECK_FUNCS(usleep gettimeofday)
  63. AC_CHECK_FUNCS(getopt_long,
  64. [AC_DEFINE(HAVE_GETOPT_LONG, 1, Define to 1 if you have the `getopt_long' function.)],
  65. [AC_CHECK_LIB(gnugetopt, getopt_long,
  66. [AC_DEFINE(HAVE_GETOPT_LONG, 1, Define to 1 if you have the `getopt_long' function.)
  67. GETOPT_LIBS="${GETOPT_LIBS} -lgnugetopt"])])
  68. AC_SUBST(GETOPT_LIBS)
  69. AC_MSG_CHECKING(for Sleep)
  70. AC_TRY_COMPILE([#include <windows.h>],[Sleep(42);],
  71. [AC_MSG_RESULT(yes)
  72. AC_DEFINE(HAVE_SLEEP, 1, [Define to 1 if you have the `Sleep' function.])],
  73. [AC_MSG_RESULT(no)])
  74. AC_MSG_CHECKING(for fsin/fcos)
  75. AC_TRY_COMPILE([],[asm("fsin\n\tfcos");],
  76. [AC_MSG_RESULT(yes)
  77. AC_DEFINE(HAVE_FSIN_FCOS, 1, [Define to 1 if you have the `fsin' and `fcos' operands.])],
  78. [AC_MSG_RESULT(no)])
  79. AC_MSG_CHECKING(for fldln2/fxch/fyl2x)
  80. AC_TRY_COMPILE([],[asm("fldln2; fldln2; fxch; fyl2x");],
  81. [AC_MSG_RESULT(yes)
  82. AC_DEFINE(HAVE_FLDLN2, 1, [Define to 1 if you have the `fldln2' and other floating points operands.])],
  83. [AC_MSG_RESULT(no)])
  84. AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
  85. CACA_DRIVERS=""
  86. if test "${enable_conio}" != "no"; then
  87. ac_cv_my_have_conio="no"
  88. AC_CHECK_HEADERS(conio.h,
  89. [AC_MSG_CHECKING(for ScreenUpdate in pc.h)
  90. AC_EGREP_HEADER(ScreenUpdate, pc.h,
  91. [ac_cv_my_have_conio="yes"
  92. AC_MSG_RESULT(yes)
  93. AC_DEFINE(SCREENUPDATE_IN_PC_H, 1,
  94. Define to 1 if <pc.h> defines ScreenUpdate.)
  95. AC_DEFINE(USE_CONIO, 1, Define to 1 to activate the conio.h backend driver)
  96. CACA_DRIVERS="${CACA_DRIVERS} conio"],
  97. [AC_MSG_RESULT(no)])])
  98. if test "${ac_cv_my_have_conio}" = "no" -a "${enable_conio}" = "yes"; then
  99. AC_MSG_ERROR([cannot find conio.h])
  100. fi
  101. fi
  102. if test "${enable_win32}" != "no"; then
  103. ac_cv_my_have_win32="no"
  104. AC_CHECK_HEADERS(windows.h,
  105. [AC_MSG_CHECKING(for AllocConsole in windows.h)
  106. AC_EGREP_HEADER(AllocConsole, windows.h,
  107. [ac_cv_my_have_win32="yes"
  108. AC_MSG_RESULT(yes)
  109. AC_DEFINE(ALLOCCONSOLE_IN_WINDOWS_H, 1,
  110. Define to 1 if <windows.h> defines AllocConsole.)
  111. AC_DEFINE(USE_WIN32, 1, Define to 1 to activate the win32 backend driver)
  112. CACA_DRIVERS="${CACA_DRIVERS} win32"],
  113. [AC_MSG_RESULT(no)])])
  114. if test "${ac_cv_my_have_win32}" = "no" -a "${enable_win32}" = "yes"; then
  115. AC_MSG_ERROR([cannot find win32 console development files])
  116. fi
  117. fi
  118. if test "${enable_slang}" != "no"; then
  119. ac_cv_my_have_slang="no"
  120. AC_CHECK_HEADERS(slang.h slang/slang.h,
  121. [ac_cv_my_have_slang="yes"
  122. AC_DEFINE(USE_SLANG, 1, Define to 1 to activate the slang backend driver)
  123. AC_CHECK_LIB(slang, SLsmg_utf8_enable,
  124. [AC_DEFINE(HAVE_SLSMG_UTF8_ENABLE, 1, Define to 1 if you have the `SLsmg_utf8_enable' function.)])
  125. CPPFLAGS="${CPPFLAGS} -DOPTIMISE_SLANG_PALETTE=1"
  126. CACA_LIBS="${CACA_LIBS} -lslang"
  127. CACA_DRIVERS="${CACA_DRIVERS} slang"
  128. break])
  129. if test "${ac_cv_my_have_slang}" = "no" -a "${enable_slang}" = "yes"; then
  130. AC_MSG_ERROR([cannot find slang development files])
  131. fi
  132. fi
  133. if test "${enable_x11}" != "no"; then
  134. AC_PATH_X
  135. AC_CHECK_LIB(X11, XOpenDisplay,
  136. [ac_cv_my_have_x11="yes"
  137. if test -n "${x_includes}"; then X_CFLAGS="-I${x_includes}"; fi
  138. if test -n "${x_libraries}"; then X_LIBS="-L${x_libraries}"; fi
  139. AC_DEFINE(USE_X11, 1, Define to 1 to activate the X11 backend driver)
  140. CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
  141. X11_LIBS="${X11_LIBS} -lX11 ${X_LIBS}"
  142. CACA_DRIVERS="${CACA_DRIVERS} x11"],
  143. [ac_cv_my_have_x11="no"],
  144. [[`if test -n "${x_libraries}"; then echo -L${x_libraries}; fi`]])
  145. AC_CHECK_HEADERS(X11/XKBlib.h)
  146. if test "${ac_cv_my_have_x11}" != "yes" -a "${enable_x11}" = "yes"; then
  147. AC_MSG_ERROR([cannot find X11 development files])
  148. fi
  149. fi
  150. if test "${enable_gl}" != "no"; then
  151. ac_cv_my_have_gl="no"
  152. AC_CHECK_HEADERS(GL/gl.h OpenGL/gl.h,
  153. [AC_CHECK_HEADERS(GL/glut.h,
  154. [AC_CHECK_LIB(glut, glutCloseFunc,
  155. [AC_DEFINE(HAVE_GLUTCLOSEFUNC, 1, Define to 1 if you have the `glutCloseFunc' function.)])
  156. AC_CHECK_LIB(glut, glutMainLoopEvent,
  157. [ac_cv_my_have_gl="yes"])
  158. AC_CHECK_LIB(glut, glutCheckLoop,
  159. [ac_cv_my_have_gl="yes"
  160. AC_DEFINE(HAVE_GLUTCHECKLOOP, 1, Define to 1 if you have the `glutCheckLoop' function.)])])
  161. break])
  162. if test "${ac_cv_my_have_gl}" = "yes"; then
  163. AC_DEFINE(USE_GL, 1, Define to 1 to activate the OpenGL backend driver)
  164. GL_LIBS="${GL_LIBS} -lGL -lglut"
  165. CACA_DRIVERS="${CACA_DRIVERS} gl"
  166. elif test "${enable_gl}" = "yes"; then
  167. AC_MSG_ERROR([cannot find OpenGL+FreeGLUT development files])
  168. fi
  169. fi
  170. if test "${enable_ncurses}" != "no"; then
  171. ac_cv_my_have_ncurses="no"
  172. AC_CHECK_HEADERS(ncursesw/ncurses.h ncurses/ncurses.h ncurses.h curses.h,
  173. [ncurses="no"
  174. AC_CHECK_LIB(ncursesw, initscr,
  175. [ncurses="-lncursesw"],
  176. [AC_CHECK_LIB(ncurses, initscr,
  177. [ncurses="-lncurses"])])
  178. if test "${ncurses}" = "no"; then
  179. continue
  180. fi
  181. ac_cv_my_have_ncurses="yes"
  182. AC_DEFINE(USE_NCURSES, 1, Define to 1 to activate the ncurses backend driver)
  183. CACA_LIBS="${CACA_LIBS} ${ncurses}"
  184. CACA_DRIVERS="${CACA_DRIVERS} ncurses"
  185. dnl Check for resizeterm or resize_term
  186. SAVED_LIBS="${LIBS}"
  187. LIBS="${LIBS} ${ncurses}"
  188. AC_CHECK_FUNCS(resizeterm resize_term)
  189. LIBS="${SAVED_LIBS}"
  190. break])
  191. if test "${ac_cv_my_have_ncurses}" = "no" -a "${enable_ncurses}" = "yes"; then
  192. AC_MSG_ERROR([cannot find ncurses development files])
  193. fi
  194. fi
  195. if test "${enable_vga}" = "yes"; then
  196. ac_cv_my_have_vga="yes"
  197. CPPFLAGS="${CPPFLAGS} -I. -D__KERNEL__ -nostdinc -include kernel/kernel.h"
  198. CFLAGS="${CFLAGS} -fno-builtin -O2 -Wall"
  199. CCASFLAGS="${CCASFLAGS} -I."
  200. LDFLAGS="${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000"
  201. AC_DEFINE(USE_VGA, 1, Define to 1 to activate the VGA backend driver)
  202. CACA_DRIVERS="${CACA_DRIVERS} vga"
  203. fi
  204. AM_CONDITIONAL(USE_KERNEL, test "${ac_cv_my_have_vga}" = "yes")
  205. if test "${enable_debug}" = "yes"; then
  206. AC_DEFINE(DEBUG, 1, Define to 1 to activate debug)
  207. fi
  208. if test "${enable_plugins}" = "yes"; then
  209. ac_cv_my_have_plugins="yes"
  210. AC_DEFINE(USE_PLUGINS, 1, Define to 1 to activate plugins)
  211. CACA_LIBS="${CACA_LIBS} -ldl"
  212. else
  213. CACA_LIBS="${CACA_LIBS} ${X11_LIBS} ${GL_LIBS}"
  214. fi
  215. AM_CONDITIONAL(USE_PLUGINS, test "${ac_cv_my_have_plugins}" = "yes")
  216. AC_MSG_CHECKING(valid output drivers)
  217. if test -z "${CACA_DRIVERS}"; then
  218. AC_MSG_RESULT(no)
  219. AC_MSG_ERROR([no output drivers were selected!])
  220. else
  221. CACA_DRIVERS="${CACA_DRIVERS# *}"
  222. AC_MSG_RESULT([${CACA_DRIVERS}])
  223. fi
  224. AC_SUBST(MATH_LIBS)
  225. AC_SUBST(GETOPT_LIBS)
  226. AC_SUBST(CACA_LIBS)
  227. AC_SUBST(X11_LIBS)
  228. AC_SUBST(GL_LIBS)
  229. # Optimizations
  230. CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer"
  231. # Code qui fait des warnings == code de porc == deux baffes dans ta gueule
  232. # [Jylam] Removed -Wshadow in order to avoid ncurses/gl conflict
  233. # (Comme quoi on est pas les seuls porcs)
  234. CFLAGS="${CFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare"
  235. # Build the C++ bindings?
  236. ac_cv_my_have_cxx="no"
  237. if test "${enable_cxx}" = "yes"; then
  238. ac_cv_my_have_cxx="yes"
  239. fi
  240. AM_CONDITIONAL(USE_CXX, test "${ac_cv_my_have_cxx}" = "yes")
  241. # Build cacaserver?
  242. ac_cv_my_have_network="no"
  243. AC_CHECK_HEADERS(sys/socket.h,
  244. [ac_cv_my_have_network="yes"])
  245. AM_CONDITIONAL(USE_NETWORK, test "${ac_cv_my_have_network}" = "yes")
  246. # Use Imlib2?
  247. if test "${enable_imlib2}" != "no"; then
  248. IMLIB2="no"
  249. PKG_CHECK_MODULES(IMLIB2, imlib2, [IMLIB2="yes"], [AC_MSG_RESULT(no)])
  250. if test "${IMLIB2}" = no; then
  251. 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'.]])
  252. fi
  253. AC_DEFINE(USE_IMLIB2, 1, Define to 1 to use Imlib2)
  254. fi
  255. # Build development tools?
  256. PANGOFT2="no"
  257. PKG_CHECK_MODULES(PANGOFT2, pangoft2, [PANGOFT2="yes"], [AC_MSG_RESULT(no)])
  258. AM_CONDITIONAL(USE_PANGO, test "${PANGOFT2}" != "no")
  259. # Build documentation?
  260. DOXYGEN="no"
  261. LATEX="no"
  262. if test "${enable_doc}" != "no"; then
  263. AC_PATH_PROG(DOXYGEN, doxygen, no)
  264. if test "${DOXYGEN}" = "no"; then
  265. 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'.]])
  266. fi
  267. # Build LaTeX documentation?
  268. AC_PATH_PROG(LATEX, pdflatex, no)
  269. AC_PATH_PROG(DVIPS, dvips, no)
  270. if test "${DVIPS}" = "no"; then
  271. LATEX="no"
  272. fi
  273. AC_MSG_CHECKING(for a4wide.sty)
  274. if test -f /usr/share/texmf/tex/latex/misc/a4wide.sty; then
  275. AC_MSG_RESULT(yes)
  276. elif test -f /usr/share/texmf-tetex/tex/latex/a4wide/a4wide.sty; then
  277. AC_MSG_RESULT(yes)
  278. else
  279. LATEX="no"
  280. AC_MSG_RESULT(no)
  281. fi
  282. fi
  283. AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
  284. AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no")
  285. AC_CONFIG_FILES([
  286. Makefile
  287. kernel/Makefile
  288. cucul/Makefile
  289. caca/Makefile
  290. src/Makefile
  291. test/Makefile
  292. tools/Makefile
  293. cxx/Makefile
  294. doc/Makefile
  295. autotools/Makefile
  296. msvc/Makefile
  297. ])
  298. AC_CONFIG_FILES([
  299. cucul/cucul.pc
  300. caca/caca.pc
  301. doc/doxygen.cfg
  302. ])
  303. AC_CONFIG_FILES([caca-config], [chmod 0755 caca-config])
  304. AC_OUTPUT