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.
 
 
 
 
 
 

428 lines
14 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.beta12)
  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_DEPENDENCIES([OBJC])
  15. OBJC="${CC}"
  16. AC_SUBST(OBJC)
  17. AC_SUBST(OBJCFLAGS)
  18. AM_PROG_AS
  19. AC_LIBTOOL_WIN32_DLL
  20. AM_PROG_LIBTOOL
  21. AC_LIBTOOL_CXX
  22. AC_C_CONST
  23. AC_C_INLINE
  24. AC_TYPE_SIGNAL
  25. dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
  26. dnl now otherwise it might be set in an obscure if statement. Same thing for
  27. dnl PKG_PROG_PKG_CONFIG which needs to be called first.
  28. AC_EGREP_CPP(yes, foo)
  29. PKG_PROG_PKG_CONFIG()
  30. m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
  31. if test "${build}" != "${host}" -a "${PKG_CONFIG_LIBDIR}" = ""; then
  32. export PKG_CONFIG_LIBDIR=/dev/null
  33. fi
  34. dnl output driver features
  35. AC_ARG_ENABLE(slang,
  36. [ --enable-slang slang graphics support (autodetected)])
  37. AC_ARG_ENABLE(ncurses,
  38. [ --enable-ncurses ncurses graphics support (autodetected)])
  39. AC_ARG_ENABLE(win32,
  40. [ --enable-win32 Windows console support (autodetected)])
  41. AC_ARG_ENABLE(conio,
  42. [ --enable-conio DOS conio.h graphics support (autodetected)])
  43. AC_ARG_ENABLE(x11,
  44. [ --enable-x11 X11 support (autodetected)])
  45. AC_ARG_ENABLE(gl,
  46. [ --enable-gl OpenGL support (autodetected)])
  47. AC_ARG_ENABLE(cocoa,
  48. [ --enable-cocoa Cocoa support (autodetected)])
  49. AC_ARG_ENABLE(network,
  50. [ --enable-network Network support (autodetected)])
  51. AC_ARG_ENABLE(vga,
  52. [ --enable-vga VGA support (default disabled)])
  53. dnl language bindings
  54. AC_ARG_ENABLE(csharp,
  55. [ --enable-csharp C# bindings (autodetected)])
  56. AC_ARG_ENABLE(cxx,
  57. [ --enable-cxx C++ bindings (default enabled)])
  58. AC_ARG_ENABLE(ruby,
  59. [ --enable-ruby Ruby bindings (autodetected)])
  60. dnl example programs features
  61. AC_ARG_ENABLE(imlib2,
  62. [ --enable-imlib2 Imlib2 graphics support (autodetected)])
  63. dnl conditional builds
  64. AC_ARG_ENABLE(debug,
  65. [ --enable-debug build debug versions of the library])
  66. AC_ARG_ENABLE(plugins,
  67. [ --enable-plugins build X11 and GL drivers as plugins])
  68. AC_ARG_ENABLE(doc,
  69. [ --enable-doc build documentation (needs doxygen and LaTeX)])
  70. 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 termios.h)
  71. AC_CHECK_FUNCS(signal ioctl vsnprintf getenv putenv strcasecmp htons)
  72. AC_CHECK_FUNCS(usleep gettimeofday)
  73. AC_CHECK_FUNCS(getopt_long,
  74. [AC_DEFINE(HAVE_GETOPT_LONG, 1, Define to 1 if you have the `getopt_long' function.)],
  75. [AC_CHECK_LIB(gnugetopt, getopt_long,
  76. [AC_DEFINE(HAVE_GETOPT_LONG, 1, Define to 1 if you have the `getopt_long' function.)
  77. GETOPT_LIBS="${GETOPT_LIBS} -lgnugetopt"])])
  78. AC_SUBST(GETOPT_LIBS)
  79. AC_MSG_CHECKING(for Sleep)
  80. AC_TRY_COMPILE([#include <windows.h>],[Sleep(42);],
  81. [AC_MSG_RESULT(yes)
  82. AC_DEFINE(HAVE_SLEEP, 1, [Define to 1 if you have the `Sleep' function.])],
  83. [AC_MSG_RESULT(no)])
  84. AC_MSG_CHECKING(for fsin/fcos)
  85. AC_TRY_COMPILE([],[asm("fsin\n\tfcos");],
  86. [AC_MSG_RESULT(yes)
  87. AC_DEFINE(HAVE_FSIN_FCOS, 1, [Define to 1 if you have the `fsin' and `fcos' operands.])],
  88. [AC_MSG_RESULT(no)])
  89. AC_MSG_CHECKING(for fldln2/fxch/fyl2x)
  90. AC_TRY_COMPILE([],[asm("fldln2; fldln2; fxch; fyl2x");],
  91. [AC_MSG_RESULT(yes)
  92. AC_DEFINE(HAVE_FLDLN2, 1, [Define to 1 if you have the `fldln2' and other floating points operands.])],
  93. [AC_MSG_RESULT(no)])
  94. AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
  95. CACA_DRIVERS=""
  96. if test "${enable_conio}" != "no"; then
  97. ac_cv_my_have_conio="no"
  98. AC_CHECK_HEADERS(conio.h,
  99. [AC_MSG_CHECKING(for ScreenUpdate in pc.h)
  100. AC_EGREP_HEADER(ScreenUpdate, pc.h,
  101. [ac_cv_my_have_conio="yes"
  102. AC_MSG_RESULT(yes)
  103. AC_DEFINE(SCREENUPDATE_IN_PC_H, 1,
  104. Define to 1 if <pc.h> defines ScreenUpdate.)
  105. AC_DEFINE(USE_CONIO, 1, Define to 1 to activate the conio.h backend driver)
  106. CACA_DRIVERS="${CACA_DRIVERS} conio"],
  107. [AC_MSG_RESULT(no)])])
  108. if test "${ac_cv_my_have_conio}" = "no" -a "${enable_conio}" = "yes"; then
  109. AC_MSG_ERROR([cannot find conio.h])
  110. fi
  111. fi
  112. if test "${enable_win32}" != "no"; then
  113. ac_cv_my_have_win32="no"
  114. AC_CHECK_HEADERS(windows.h,
  115. [AC_MSG_CHECKING(for AllocConsole in windows.h)
  116. AC_EGREP_HEADER(AllocConsole, windows.h,
  117. [ac_cv_my_have_win32="yes"
  118. AC_MSG_RESULT(yes)
  119. AC_DEFINE(ALLOCCONSOLE_IN_WINDOWS_H, 1,
  120. Define to 1 if <windows.h> defines AllocConsole.)
  121. AC_DEFINE(USE_WIN32, 1, Define to 1 to activate the win32 backend driver)
  122. CACA_DRIVERS="${CACA_DRIVERS} win32"],
  123. [AC_MSG_RESULT(no)])])
  124. if test "${ac_cv_my_have_win32}" = "no" -a "${enable_win32}" = "yes"; then
  125. AC_MSG_ERROR([cannot find win32 console development files])
  126. fi
  127. fi
  128. if test "${enable_slang}" != "no"; then
  129. ac_cv_my_have_slang="no"
  130. AC_CHECK_HEADERS(slang.h slang/slang.h,
  131. [ac_cv_my_have_slang="yes"
  132. AC_DEFINE(USE_SLANG, 1, Define to 1 to activate the slang backend driver)
  133. AC_CHECK_LIB(slang, SLsmg_utf8_enable,
  134. [AC_DEFINE(HAVE_SLSMG_UTF8_ENABLE, 1, Define to 1 if you have the `SLsmg_utf8_enable' function.)])
  135. CPPFLAGS="${CPPFLAGS} -DOPTIMISE_SLANG_PALETTE=1"
  136. CACA_LIBS="${CACA_LIBS} -lslang"
  137. CACA_DRIVERS="${CACA_DRIVERS} slang"
  138. break])
  139. if test "${ac_cv_my_have_slang}" = "no" -a "${enable_slang}" = "yes"; then
  140. AC_MSG_ERROR([cannot find slang development files])
  141. fi
  142. fi
  143. if test "${enable_x11}" != "no"; then
  144. AC_PATH_X
  145. AC_CHECK_LIB(X11, XOpenDisplay,
  146. [ac_cv_my_have_x11="yes"
  147. if test -n "${x_includes}"; then X_CFLAGS="-I${x_includes}"; fi
  148. if test -n "${x_libraries}"; then X_LIBS="-L${x_libraries}"; fi
  149. AC_DEFINE(USE_X11, 1, Define to 1 to activate the X11 backend driver)
  150. CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
  151. X11_LIBS="${X11_LIBS} -lX11 ${X_LIBS}"
  152. CACA_DRIVERS="${CACA_DRIVERS} x11"],
  153. [ac_cv_my_have_x11="no"],
  154. [[`if test -n "${x_libraries}"; then echo -L${x_libraries}; fi`]])
  155. AC_CHECK_HEADERS(X11/XKBlib.h)
  156. if test "${ac_cv_my_have_x11}" != "yes" -a "${enable_x11}" = "yes"; then
  157. AC_MSG_ERROR([cannot find X11 development files])
  158. fi
  159. fi
  160. if test "${enable_gl}" != "no"; then
  161. ac_cv_my_have_gl="no"
  162. AC_CHECK_HEADERS(GL/gl.h OpenGL/gl.h,
  163. [AC_CHECK_HEADERS(GL/glut.h,
  164. [AC_CHECK_LIB(glut, glutCloseFunc,
  165. [AC_DEFINE(HAVE_GLUTCLOSEFUNC, 1, Define to 1 if you have the `glutCloseFunc' function.)])
  166. AC_CHECK_LIB(glut, glutMainLoopEvent,
  167. [ac_cv_my_have_gl="yes"])
  168. AC_CHECK_LIB(glut, glutCheckLoop,
  169. [ac_cv_my_have_gl="yes"
  170. AC_DEFINE(HAVE_GLUTCHECKLOOP, 1, Define to 1 if you have the `glutCheckLoop' function.)])])
  171. break])
  172. if test "${ac_cv_my_have_gl}" = "yes"; then
  173. AC_DEFINE(USE_GL, 1, Define to 1 to activate the OpenGL backend driver)
  174. GL_LIBS="${GL_LIBS} -lGL -lglut"
  175. CACA_DRIVERS="${CACA_DRIVERS} gl"
  176. elif test "${enable_gl}" = "yes"; then
  177. AC_MSG_ERROR([cannot find OpenGL+FreeGLUT development files])
  178. fi
  179. fi
  180. if test "${enable_cocoa}" != "no"; then
  181. ac_cv_my_have_cocoa="no"
  182. AC_CHECK_HEADERS(Cocoa/Cocoa.h,
  183. [ac_cv_my_have_cocoa="yes"])
  184. if test "${ac_cv_my_have_cocoa}" = "yes"; then
  185. case x${target} in
  186. xpowerpc*darwin*)
  187. # 10.3 needed to link with X11
  188. MACOSX_SDK=/Developer/SDKs/MacOSX10.3.9.sdk
  189. GCC_VERSION=3.3
  190. ARCH="-arch ppc"
  191. MACOSX_SDK_CFLAGS="-nostdinc -isystem ${MACOSX_SDK}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOSX_SDK}/usr/include"
  192. MACOSX_SDK_CXXFLAGS="-nostdinc++ -I${MACOSX_SDK}/usr/include/gcc/darwin/${GCC_VERSION}/c++ -I${MACOSX_SDK}/usr/include/gcc/darwin/${GCC_VERSION}/c++/ppc-darwin -I${MACOSX_SDK}/usr/include/gcc/darwin/${GCC_VERSION}/c++/backward"
  193. MACOSX_SDK_LDFLAGS="-L${MACOSX_SDK}/usr/lib/gcc/darwin -L${MACOSX_SDK}/usr/lib/gcc/darwin/${GCC_VERSION} -L${MACOSX_SDK}/usr/lib"
  194. ;;
  195. x*86*darwin*)
  196. MACOSX_SDK=/Developer/SDKs/MacOSX10.4u.sdk
  197. GCC_VERSION=4.0
  198. ARCH="-arch i386"
  199. MACOSX_SDK_CFLAGS="-isysroot ${MACOSX_SDK}"
  200. MACOSX_SDK_CXXFLAGS="${MACOSX_SDK_CFLAGS}"
  201. ;;
  202. esac
  203. CC=gcc-${GCC_VERSION}
  204. CXX=g++-${GCC_VERSION}
  205. MACOSX_SDK_FRAMEWORKS="-F${MACOSX_SDK}/System/Library/Frameworks"
  206. CPPFLAGS="${CPPFLAGS} ${ARCH} ${MACOSX_SDK_FRAMEWORKS}"
  207. CFLAGS="${CFLAGS} ${MACOSX_SDK_CFLAGS}"
  208. CXXFLAGS="${CXXFLAGS} ${MACOSX_SDK_CXXFLAGS}"
  209. OBJCFLAGS="${OBJCFLAGS} ${MACOSX_SDK_CFLAGS}"
  210. LDFLAGS="${ARCH} ${MACOSX_SDK_LDFLAGS} ${LDFLAGS}"
  211. AC_DEFINE(USE_COCOA, 1, Define to 1 to activate the Cocoa backend driver)
  212. CACA_LIBS="${CACA_LIBS} -Wl,-syslibroot,${MACOSX_SDK},-framework,Cocoa"
  213. CACA_DRIVERS="${CACA_DRIVERS} cocoa"
  214. elif test "${enable_cocoa}" = "yes"; then
  215. AC_MSG_ERROR([cannot find Cocoa development files])
  216. fi
  217. fi
  218. AM_CONDITIONAL(USE_COCOA, test "${ac_cv_my_have_cocoa}" = "yes")
  219. if test "${enable_ncurses}" != "no"; then
  220. ac_cv_my_have_ncurses="no"
  221. AC_CHECK_HEADERS(ncursesw/ncurses.h ncurses/ncurses.h ncurses.h curses.h,
  222. [ncurses="no"
  223. AC_CHECK_LIB(ncursesw, initscr,
  224. [ncurses="-lncursesw"],
  225. [AC_CHECK_LIB(ncurses, initscr,
  226. [ncurses="-lncurses"])])
  227. if test "${ncurses}" = "no"; then
  228. continue
  229. fi
  230. ac_cv_my_have_ncurses="yes"
  231. AC_DEFINE(USE_NCURSES, 1, Define to 1 to activate the ncurses backend driver)
  232. CACA_LIBS="${CACA_LIBS} ${ncurses}"
  233. CACA_DRIVERS="${CACA_DRIVERS} ncurses"
  234. dnl Check for resizeterm or resize_term
  235. SAVED_LIBS="${LIBS}"
  236. LIBS="${LIBS} ${ncurses}"
  237. AC_CHECK_FUNCS(resizeterm resize_term)
  238. LIBS="${SAVED_LIBS}"
  239. break])
  240. if test "${ac_cv_my_have_ncurses}" = "no" -a "${enable_ncurses}" = "yes"; then
  241. AC_MSG_ERROR([cannot find ncurses development files])
  242. fi
  243. fi
  244. if test "${enable_vga}" = "yes"; then
  245. ac_cv_my_have_vga="yes"
  246. CPPFLAGS="${CPPFLAGS} -I. -D__KERNEL__ -nostdinc -include kernel/kernel.h"
  247. CFLAGS="${CFLAGS} -fno-builtin -O2 -Wall"
  248. CCASFLAGS="${CCASFLAGS} -I."
  249. LDFLAGS="${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000"
  250. AC_DEFINE(USE_VGA, 1, Define to 1 to activate the VGA backend driver)
  251. CACA_DRIVERS="${CACA_DRIVERS} vga"
  252. fi
  253. AM_CONDITIONAL(USE_KERNEL, test "${ac_cv_my_have_vga}" = "yes")
  254. if test "${enable_debug}" = "yes"; then
  255. AC_DEFINE(DEBUG, 1, Define to 1 to activate debug)
  256. fi
  257. if test "${enable_plugins}" = "yes"; then
  258. ac_cv_my_have_plugins="yes"
  259. AC_DEFINE(USE_PLUGINS, 1, Define to 1 to activate plugins)
  260. CACA_LIBS="${CACA_LIBS} -ldl"
  261. else
  262. CACA_LIBS="${CACA_LIBS} ${X11_LIBS} ${GL_LIBS}"
  263. fi
  264. AM_CONDITIONAL(USE_PLUGINS, test "${ac_cv_my_have_plugins}" = "yes")
  265. AC_MSG_CHECKING(valid output drivers)
  266. if test -z "${CACA_DRIVERS}"; then
  267. AC_MSG_RESULT(no)
  268. AC_MSG_ERROR([no output drivers were selected!])
  269. else
  270. CACA_DRIVERS="${CACA_DRIVERS# *}"
  271. AC_MSG_RESULT([${CACA_DRIVERS}])
  272. fi
  273. AC_SUBST(MATH_LIBS)
  274. AC_SUBST(GETOPT_LIBS)
  275. AC_SUBST(CACA_LIBS)
  276. AC_SUBST(X11_LIBS)
  277. AC_SUBST(GL_LIBS)
  278. # Optimizations
  279. CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer"
  280. # Code qui fait des warnings == code de porc == deux baffes dans ta gueule
  281. # [Jylam] Removed -Wshadow in order to avoid ncurses/gl conflict
  282. # (Comme quoi on n'est pas les seuls porcs)
  283. CFLAGS="${CFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare"
  284. # Build the C++ bindings?
  285. ac_cv_my_have_cxx="no"
  286. if test "${enable_cxx}" != "no"; then
  287. ac_cv_my_have_cxx="yes"
  288. fi
  289. AM_CONDITIONAL(USE_CXX, test "${ac_cv_my_have_cxx}" = "yes")
  290. # Build the .NET bindings?
  291. ac_cv_my_have_csharp="no"
  292. if test "${enable_csharp}" != "no"; then
  293. AC_PATH_PROG(GMCS, gmcs, no)
  294. if test "${GMCS}" != "no"; then
  295. ac_cv_my_have_csharp="yes"
  296. fi
  297. fi
  298. AM_CONDITIONAL(USE_CSHARP, test "${ac_cv_my_have_csharp}" = "yes")
  299. # Build the Ruby bindings?
  300. ac_cv_my_have_ruby="no"
  301. if test "${enable_ruby}" != "no"; then
  302. AC_PATH_PROG(RUBY, ruby, no)
  303. if test "${RUBY}" != "no"; then
  304. RUBY_ARCHDIR=`ruby -r rbconfig -e 'print Config::CONFIG@<:@"archdir"@:>@'`
  305. RUBY_SITEARCHDIR=`ruby -r rbconfig -e 'print Config::CONFIG@<:@"sitearchdir"@:>@'`
  306. RUBY_SITELIBDIR=`ruby -r rbconfig -e 'print Config::CONFIG@<:@"sitelibdir"@:>@'`
  307. RUBY_LIBDIR=`ruby -r rbconfig -e 'print Config::CONFIG@<:@"libdir"@:>@'`
  308. RUBY_SO_NAME=`ruby -r rbconfig -e 'print Config::CONFIG@<:@"RUBY_SO_NAME"@:>@'`
  309. AC_SUBST(RUBY_ARCHDIR)
  310. AC_SUBST(RUBY_SITEARCHDIR)
  311. AC_SUBST(RUBY_SITELIBDIR)
  312. AC_SUBST(RUBY_LIBDIR)
  313. AC_SUBST(RUBY_SO_NAME)
  314. AC_CHECK_HEADERS($RUBY_ARCHDIR/ruby.h, [ac_cv_my_have_ruby="yes"])
  315. fi
  316. fi
  317. AM_CONDITIONAL(USE_RUBY, test "${ac_cv_my_have_ruby}" = "yes")
  318. # Build cacaserver?
  319. ac_cv_my_have_network="no"
  320. AC_CHECK_HEADERS(sys/socket.h,
  321. [ac_cv_my_have_network="yes"])
  322. AM_CONDITIONAL(USE_NETWORK, test "${ac_cv_my_have_network}" = "yes")
  323. # Use Imlib2?
  324. if test "${enable_imlib2}" != "no"; then
  325. IMLIB2="no"
  326. PKG_CHECK_MODULES(IMLIB2, imlib2, [IMLIB2="yes"], [AC_MSG_RESULT(no)])
  327. if test "${IMLIB2}" != "no"; then
  328. AC_DEFINE(USE_IMLIB2, 1, Define to 1 to use Imlib2)
  329. fi
  330. fi
  331. # Build development tools?
  332. PANGOFT2="no"
  333. PKG_CHECK_MODULES(PANGOFT2, pangoft2, [PANGOFT2="yes"], [AC_MSG_RESULT(no)])
  334. AM_CONDITIONAL(USE_PANGO, test "${PANGOFT2}" != "no")
  335. # Build documentation?
  336. DOXYGEN="no"
  337. LATEX="no"
  338. if test "${enable_doc}" != "no"; then
  339. AC_PATH_PROG(DOXYGEN, doxygen, no)
  340. if test "${DOXYGEN}" != "no"; then
  341. # Build LaTeX documentation?
  342. AC_PATH_PROG(LATEX, pdflatex, no)
  343. AC_PATH_PROG(KPSEWHICH, kpsewhich, no)
  344. AC_PATH_PROG(DVIPS, dvips, no)
  345. if test "${DVIPS}" = "no" -o "${KPSEWHICH}" = "no"; then
  346. LATEX="no"
  347. fi
  348. if test "${LATEX}" != "no"; then
  349. AC_MSG_CHECKING(for a4.sty and a4wide.sty)
  350. if "${KPSEWHICH}" a4.sty >/dev/null 2>&1; then
  351. if "${KPSEWHICH}" a4wide.sty >/dev/null 2>&1; then
  352. AC_MSG_RESULT(yes)
  353. else
  354. LATEX="no"
  355. AC_MSG_RESULT(no)
  356. fi
  357. else
  358. LATEX="no"
  359. AC_MSG_RESULT(no)
  360. fi
  361. fi
  362. fi
  363. fi
  364. AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
  365. AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no")
  366. AC_CONFIG_FILES([
  367. Makefile
  368. kernel/Makefile
  369. cucul/Makefile
  370. caca/Makefile
  371. src/Makefile
  372. test/Makefile
  373. tools/Makefile
  374. csharp/Makefile
  375. cxx/Makefile
  376. ruby/Makefile
  377. doc/Makefile
  378. msvc/Makefile
  379. ])
  380. AC_CONFIG_FILES([
  381. cucul/cucul.pc
  382. caca/caca.pc
  383. doc/doxygen.cfg
  384. ])
  385. AC_CONFIG_FILES([caca-config], [chmod 0755 caca-config])
  386. AC_OUTPUT