source: libcaca/trunk/configure.ac @ 1829

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