source: libcaca/trunk/configure.ac @ 2056

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