source: libcaca/trunk/configure.ac @ 1951

Last change on this file since 1951 was 1951, checked in by Sam Hocevar, 13 years ago
  • Autotoolified the Ruby bindings. Use --enable-ruby.
  • Property svn:keywords set to Id
File size: 13.5 KB
Line 
1# $Id: configure.ac 1951 2007-11-13 23:55:01Z 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(cxx,
64  [  --enable-cxx            C++ bindings (default disabled)])
65AC_ARG_ENABLE(ruby,
66  [  --enable-ruby           Ruby bindings (default disabled)])
67
68dnl example programs features
69AC_ARG_ENABLE(imlib2,
70  [  --enable-imlib2         Imlib2 graphics support (autodetected)])
71
72dnl conditional builds
73AC_ARG_ENABLE(debug,
74  [  --enable-debug          build debug versions of the library])
75AC_ARG_ENABLE(plugins,
76  [  --enable-plugins        build X11 and GL drivers as plugins])
77AC_ARG_ENABLE(doc,
78  [  --enable-doc            build documentation (needs doxygen and LaTeX)])
79
80AC_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)
81AC_CHECK_FUNCS(signal ioctl vsnprintf getenv putenv strcasecmp htons)
82AC_CHECK_FUNCS(usleep gettimeofday)
83
84AC_CHECK_FUNCS(getopt_long,
85 [AC_DEFINE(HAVE_GETOPT_LONG, 1, Define to 1 if you have the `getopt_long' function.)],
86 [AC_CHECK_LIB(gnugetopt, getopt_long,
87   [AC_DEFINE(HAVE_GETOPT_LONG, 1, Define to 1 if you have the `getopt_long' function.)
88    GETOPT_LIBS="${GETOPT_LIBS} -lgnugetopt"])])
89AC_SUBST(GETOPT_LIBS)
90
91AC_MSG_CHECKING(for Sleep)
92AC_TRY_COMPILE([#include <windows.h>],[Sleep(42);],
93 [AC_MSG_RESULT(yes)
94  AC_DEFINE(HAVE_SLEEP, 1, [Define to 1 if you have the `Sleep' function.])],
95 [AC_MSG_RESULT(no)])
96
97AC_MSG_CHECKING(for fsin/fcos)
98AC_TRY_COMPILE([],[asm("fsin\n\tfcos");],
99 [AC_MSG_RESULT(yes)
100  AC_DEFINE(HAVE_FSIN_FCOS, 1, [Define to 1 if you have the `fsin' and `fcos' operands.])],
101 [AC_MSG_RESULT(no)])
102
103AC_MSG_CHECKING(for fldln2/fxch/fyl2x)
104AC_TRY_COMPILE([],[asm("fldln2; fldln2; fxch; fyl2x");],
105 [AC_MSG_RESULT(yes)
106  AC_DEFINE(HAVE_FLDLN2, 1, [Define to 1 if you have the `fldln2' and other floating points operands.])],
107 [AC_MSG_RESULT(no)])
108
109AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
110
111CACA_DRIVERS=""
112
113if test "${enable_conio}" != "no"; then
114  ac_cv_my_have_conio="no"
115  AC_CHECK_HEADERS(conio.h,
116   [AC_MSG_CHECKING(for ScreenUpdate in pc.h)
117    AC_EGREP_HEADER(ScreenUpdate, pc.h,
118     [ac_cv_my_have_conio="yes"
119      AC_MSG_RESULT(yes)
120      AC_DEFINE(SCREENUPDATE_IN_PC_H, 1,
121                Define to 1 if <pc.h> defines ScreenUpdate.)
122      AC_DEFINE(USE_CONIO, 1, Define to 1 to activate the conio.h backend driver)
123      CACA_DRIVERS="${CACA_DRIVERS} conio"],
124     [AC_MSG_RESULT(no)])])
125  if test "${ac_cv_my_have_conio}" = "no" -a "${enable_conio}" = "yes"; then
126    AC_MSG_ERROR([cannot find conio.h])
127  fi
128fi
129
130if test "${enable_win32}" != "no"; then
131  ac_cv_my_have_win32="no"
132  AC_CHECK_HEADERS(windows.h,
133   [AC_MSG_CHECKING(for AllocConsole in windows.h)
134    AC_EGREP_HEADER(AllocConsole, windows.h,
135     [ac_cv_my_have_win32="yes"
136      AC_MSG_RESULT(yes)
137      AC_DEFINE(ALLOCCONSOLE_IN_WINDOWS_H, 1,
138                Define to 1 if <windows.h> defines AllocConsole.)
139      AC_DEFINE(USE_WIN32, 1, Define to 1 to activate the win32 backend driver)
140      CACA_DRIVERS="${CACA_DRIVERS} win32"],
141     [AC_MSG_RESULT(no)])])
142  if test "${ac_cv_my_have_win32}" = "no" -a "${enable_win32}" = "yes"; then
143    AC_MSG_ERROR([cannot find win32 console development files])
144  fi
145fi
146
147if test "${enable_slang}" != "no"; then
148  ac_cv_my_have_slang="no"
149  AC_CHECK_HEADERS(slang.h slang/slang.h,
150   [ac_cv_my_have_slang="yes"
151    AC_DEFINE(USE_SLANG, 1, Define to 1 to activate the slang backend driver)
152    AC_CHECK_LIB(slang, SLsmg_utf8_enable,
153     [AC_DEFINE(HAVE_SLSMG_UTF8_ENABLE, 1, Define to 1 if you have the `SLsmg_utf8_enable' function.)])
154    CPPFLAGS="${CPPFLAGS} -DOPTIMISE_SLANG_PALETTE=1"
155    CACA_LIBS="${CACA_LIBS} -lslang"
156    CACA_DRIVERS="${CACA_DRIVERS} slang"
157    break])
158  if test "${ac_cv_my_have_slang}" = "no" -a "${enable_slang}" = "yes"; then
159    AC_MSG_ERROR([cannot find slang development files])
160  fi
161fi
162
163if test "${enable_x11}" != "no"; then
164  AC_PATH_X
165  AC_CHECK_LIB(X11, XOpenDisplay,
166   [ac_cv_my_have_x11="yes"
167    if test -n "${x_includes}"; then X_CFLAGS="-I${x_includes}"; fi
168    if test -n "${x_libraries}"; then X_LIBS="-L${x_libraries}"; fi
169    AC_DEFINE(USE_X11, 1, Define to 1 to activate the X11 backend driver)
170    CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
171    X11_LIBS="${X11_LIBS} -lX11 ${X_LIBS}"
172    CACA_DRIVERS="${CACA_DRIVERS} x11"],
173   [ac_cv_my_have_x11="no"],
174   [[`if test -n "${x_libraries}"; then echo -L${x_libraries}; fi`]])
175  AC_CHECK_HEADERS(X11/XKBlib.h)
176  if test "${ac_cv_my_have_x11}" != "yes" -a "${enable_x11}" = "yes"; then
177    AC_MSG_ERROR([cannot find X11 development files])
178  fi
179fi
180
181if test "${enable_gl}" != "no"; then
182  ac_cv_my_have_gl="no"
183  AC_CHECK_HEADERS(GL/gl.h OpenGL/gl.h,
184   [AC_CHECK_HEADERS(GL/glut.h,
185     [AC_CHECK_LIB(glut, glutCloseFunc,
186       [AC_DEFINE(HAVE_GLUTCLOSEFUNC, 1, Define to 1 if you have the `glutCloseFunc' function.)])
187      AC_CHECK_LIB(glut, glutMainLoopEvent,
188       [ac_cv_my_have_gl="yes"])
189      AC_CHECK_LIB(glut, glutCheckLoop,
190       [ac_cv_my_have_gl="yes"
191        AC_DEFINE(HAVE_GLUTCHECKLOOP, 1, Define to 1 if you have the `glutCheckLoop' function.)])])
192      break])
193  if test "${ac_cv_my_have_gl}" = "yes"; then
194    AC_DEFINE(USE_GL, 1, Define to 1 to activate the OpenGL backend driver)
195    GL_LIBS="${GL_LIBS} -lGL -lglut"
196    CACA_DRIVERS="${CACA_DRIVERS} gl"
197  elif test "${enable_gl}" = "yes"; then
198    AC_MSG_ERROR([cannot find OpenGL+FreeGLUT development files])
199  fi
200fi
201
202if test "${enable_cocoa}" != "no"; then
203  ac_cv_my_have_cocoa="no"
204  AC_CHECK_HEADERS(Cocoa/Cocoa.h,
205   [ac_cv_my_have_cocoa="yes"])
206  if test "${ac_cv_my_have_cocoa}" = "yes"; then
207    case x${target} in
208    xpowerpc*darwin*)
209      # 10.3 needed to link with X11
210      MACOSX_SDK=/Developer/SDKs/MacOSX10.3.9.sdk
211      GCC_VERSION=3.3
212      ARCH="-arch ppc"
213      MACOSX_SDK_CFLAGS="-nostdinc -isystem ${MACOSX_SDK}/usr/include/gcc/darwin/${GCC_VERSION} -isystem ${MACOSX_SDK}/usr/include"
214      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"
215      MACOSX_SDK_LDFLAGS="-L${MACOSX_SDK}/usr/lib/gcc/darwin -L${MACOSX_SDK}/usr/lib/gcc/darwin/${GCC_VERSION} -L${MACOSX_SDK}/usr/lib"
216      ;;
217    x*86*darwin*)
218      MACOSX_SDK=/Developer/SDKs/MacOSX10.4u.sdk
219      GCC_VERSION=4.0
220      ARCH="-arch i386"
221      MACOSX_SDK_CFLAGS="-isysroot ${MACOSX_SDK}"
222      MACOSX_SDK_CXXFLAGS="${MACOSX_SDK_CFLAGS}"
223      ;;
224    esac
225    CC=gcc-${GCC_VERSION}
226    CXX=g++-${GCC_VERSION}
227    MACOSX_SDK_FRAMEWORKS="-F${MACOSX_SDK}/System/Library/Frameworks"
228    CPPFLAGS="${CPPFLAGS} ${ARCH} ${MACOSX_SDK_FRAMEWORKS}"
229    CFLAGS="${CFLAGS} ${MACOSX_SDK_CFLAGS}"
230    CXXFLAGS="${CXXFLAGS} ${MACOSX_SDK_CXXFLAGS}"
231    OBJCFLAGS="${OBJCFLAGS} ${MACOSX_SDK_CFLAGS}"
232    LDFLAGS="${ARCH} ${MACOSX_SDK_LDFLAGS} ${LDFLAGS}"
233    AC_DEFINE(USE_COCOA, 1, Define to 1 to activate the Cocoa backend driver)
234    CACA_LIBS="${CACA_LIBS} -Wl,-syslibroot,${MACOSX_SDK},-framework,Cocoa"
235    CACA_DRIVERS="${CACA_DRIVERS} cocoa"
236  elif test "${enable_cocoa}" = "yes"; then
237    AC_MSG_ERROR([cannot find Cocoa development files])
238  fi
239fi
240AM_CONDITIONAL(USE_COCOA, test "${ac_cv_my_have_cocoa}" = "yes")
241
242if test "${enable_ncurses}" != "no"; then
243  ac_cv_my_have_ncurses="no"
244  AC_CHECK_HEADERS(ncursesw/ncurses.h ncurses/ncurses.h ncurses.h curses.h,
245   [ncurses="no"
246    AC_CHECK_LIB(ncursesw, initscr,
247     [ncurses="-lncursesw"],
248     [AC_CHECK_LIB(ncurses, initscr,
249       [ncurses="-lncurses"])])
250    if test "${ncurses}" = "no"; then
251      continue
252    fi
253    ac_cv_my_have_ncurses="yes"
254    AC_DEFINE(USE_NCURSES, 1, Define to 1 to activate the ncurses backend driver)
255    CACA_LIBS="${CACA_LIBS} ${ncurses}"
256    CACA_DRIVERS="${CACA_DRIVERS} ncurses"
257    dnl  Check for resizeterm or resize_term
258    SAVED_LIBS="${LIBS}"
259    LIBS="${LIBS} ${ncurses}"
260    AC_CHECK_FUNCS(resizeterm resize_term)
261    LIBS="${SAVED_LIBS}"
262    break])
263  if test "${ac_cv_my_have_ncurses}" = "no" -a "${enable_ncurses}" = "yes"; then
264    AC_MSG_ERROR([cannot find ncurses development files])
265  fi
266fi
267
268if test "${enable_vga}" = "yes"; then
269  ac_cv_my_have_vga="yes"
270  CPPFLAGS="${CPPFLAGS} -I. -D__KERNEL__ -nostdinc -include kernel/kernel.h"
271  CFLAGS="${CFLAGS} -fno-builtin -O2 -Wall"
272  CCASFLAGS="${CCASFLAGS} -I."
273  LDFLAGS="${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000"
274  AC_DEFINE(USE_VGA, 1, Define to 1 to activate the VGA backend driver)
275  CACA_DRIVERS="${CACA_DRIVERS} vga"
276fi
277AM_CONDITIONAL(USE_KERNEL, test "${ac_cv_my_have_vga}" = "yes")
278
279if test "${enable_debug}" = "yes"; then
280  AC_DEFINE(DEBUG, 1, Define to 1 to activate debug)
281fi
282
283if test "${enable_plugins}" = "yes"; then
284  ac_cv_my_have_plugins="yes"
285  AC_DEFINE(USE_PLUGINS, 1, Define to 1 to activate plugins)
286  CACA_LIBS="${CACA_LIBS} -ldl"
287else
288  CACA_LIBS="${CACA_LIBS} ${X11_LIBS} ${GL_LIBS}"
289fi
290AM_CONDITIONAL(USE_PLUGINS, test "${ac_cv_my_have_plugins}" = "yes")
291
292AC_MSG_CHECKING(valid output drivers)
293if test -z "${CACA_DRIVERS}"; then
294  AC_MSG_RESULT(no)
295  AC_MSG_ERROR([no output drivers were selected!])
296else
297  CACA_DRIVERS="${CACA_DRIVERS# *}"
298  AC_MSG_RESULT([${CACA_DRIVERS}])
299fi
300
301
302AC_SUBST(MATH_LIBS)
303AC_SUBST(GETOPT_LIBS)
304AC_SUBST(CACA_LIBS)
305AC_SUBST(X11_LIBS)
306AC_SUBST(GL_LIBS)
307
308# Optimizations
309CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer"
310# Code qui fait des warnings == code de porc == deux baffes dans ta gueule
311# [Jylam] Removed -Wshadow in order to avoid ncurses/gl conflict
312# (Comme quoi on n'est pas les seuls porcs)
313CFLAGS="${CFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare"
314
315# Build the C++ bindings?
316ac_cv_my_have_cxx="no"
317if test "${enable_cxx}" = "yes"; then
318  ac_cv_my_have_cxx="yes"
319fi
320AM_CONDITIONAL(USE_CXX, test "${ac_cv_my_have_cxx}" = "yes")
321
322# Build the Ruby bindings?
323ac_cv_my_have_ruby="no"
324if test "${enable_ruby}" = "yes"; then
325  AC_PATH_PROG(RUBY, ruby, no)
326  if test "${RUBY}" != "no"; then
327    AC_MSG_CHECKING(for mkmf.rb)
328    if "${RUBY}" -e 'require "mkmf"' >/dev/null 2>&1; then
329      AC_MSG_RESULT(yes)
330      ac_cv_my_have_ruby="yes"
331    else
332      AC_MSG_RESULT(no)
333    fi
334  fi
335fi
336AM_CONDITIONAL(USE_RUBY, test "${ac_cv_my_have_ruby}" = "yes")
337
338# Build cacaserver?
339ac_cv_my_have_network="no"
340AC_CHECK_HEADERS(sys/socket.h,
341 [ac_cv_my_have_network="yes"])
342AM_CONDITIONAL(USE_NETWORK, test "${ac_cv_my_have_network}" = "yes")
343
344# Use Imlib2?
345if test "${enable_imlib2}" != "no"; then
346  IMLIB2="no"
347  PKG_CHECK_MODULES(IMLIB2, imlib2, [IMLIB2="yes"], [AC_MSG_RESULT(no)])
348  if test "${IMLIB2}" != "no"; then
349    AC_DEFINE(USE_IMLIB2, 1, Define to 1 to use Imlib2)
350  fi
351fi
352
353# Build development tools?
354PANGOFT2="no"
355PKG_CHECK_MODULES(PANGOFT2, pangoft2, [PANGOFT2="yes"], [AC_MSG_RESULT(no)])
356AM_CONDITIONAL(USE_PANGO, test "${PANGOFT2}" != "no")
357
358# Build documentation?
359DOXYGEN="no"
360LATEX="no"
361if test "${enable_doc}" != "no"; then
362  AC_PATH_PROG(DOXYGEN, doxygen, no)
363  if test "${DOXYGEN}" != "no"; then
364    # Build LaTeX documentation?
365    AC_PATH_PROG(LATEX, pdflatex, no)
366    AC_PATH_PROG(KPSEWHICH, kpsewhich, no)
367    AC_PATH_PROG(DVIPS, dvips, no)
368    if test "${DVIPS}" = "no" -o "${KPSEWHICH}" = "no"; then
369      LATEX="no"
370    fi
371    if test "${LATEX}" != "no"; then
372      AC_MSG_CHECKING(for a4.sty and a4wide.sty)
373      if "${KPSEWHICH}" a4.sty >/dev/null 2>&1; then
374        if "${KPSEWHICH}" a4wide.sty >/dev/null 2>&1; then
375          AC_MSG_RESULT(yes)
376        else
377          LATEX="no"
378          AC_MSG_RESULT(no)
379        fi
380      else
381        LATEX="no"
382        AC_MSG_RESULT(no)
383      fi
384    fi
385  fi
386fi
387AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
388AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no")
389
390AC_CONFIG_FILES([
391  Makefile
392  kernel/Makefile
393  cucul/Makefile
394  caca/Makefile
395  src/Makefile
396  test/Makefile
397  tools/Makefile
398  cxx/Makefile
399  ruby/Makefile
400  doc/Makefile
401  msvc/Makefile
402])
403AC_CONFIG_FILES([
404  cucul/cucul.pc
405  caca/caca.pc
406  doc/doxygen.cfg
407])
408AC_CONFIG_FILES([caca-config], [chmod 0755 caca-config])
409AC_OUTPUT
410
Note: See TracBrowser for help on using the repository browser.