source: libcaca/trunk/configure.ac @ 1427

Last change on this file since 1427 was 1427, checked in by Sam Hocevar, 14 years ago
  • Added a test app that swallows two console applications. Switch with C-a.
  • Property svn:keywords set to Id
File size: 11.8 KB
Line 
1# $Id: configure.ac 1427 2006-11-21 07:09:35Z 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.beta11)
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="${CXX}"
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 pty.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")
108AC_CHECK_LIB(util, forkpty, UTIL_LIBS="${UTIL_LIBS} -lutil")
109
110CACA_DRIVERS=""
111
112if test "${enable_conio}" != "no"; then
113  ac_cv_my_have_conio="no"
114  AC_CHECK_HEADERS(conio.h,
115   [AC_MSG_CHECKING(for ScreenUpdate in pc.h)
116    AC_EGREP_HEADER(ScreenUpdate, pc.h,
117     [ac_cv_my_have_conio="yes"
118      AC_MSG_RESULT(yes)
119      AC_DEFINE(SCREENUPDATE_IN_PC_H, 1,
120                Define to 1 if <pc.h> defines ScreenUpdate.)
121      AC_DEFINE(USE_CONIO, 1, Define to 1 to activate the conio.h backend driver)
122      CACA_DRIVERS="${CACA_DRIVERS} conio"],
123     [AC_MSG_RESULT(no)])])
124  if test "${ac_cv_my_have_conio}" = "no" -a "${enable_conio}" = "yes"; then
125    AC_MSG_ERROR([cannot find conio.h])
126  fi
127fi
128
129if test "${enable_win32}" != "no"; then
130  ac_cv_my_have_win32="no"
131  AC_CHECK_HEADERS(windows.h,
132   [AC_MSG_CHECKING(for AllocConsole in windows.h)
133    AC_EGREP_HEADER(AllocConsole, windows.h,
134     [ac_cv_my_have_win32="yes"
135      AC_MSG_RESULT(yes)
136      AC_DEFINE(ALLOCCONSOLE_IN_WINDOWS_H, 1,
137                Define to 1 if <windows.h> defines AllocConsole.)
138      AC_DEFINE(USE_WIN32, 1, Define to 1 to activate the win32 backend driver)
139      CACA_DRIVERS="${CACA_DRIVERS} win32"],
140     [AC_MSG_RESULT(no)])])
141  if test "${ac_cv_my_have_win32}" = "no" -a "${enable_win32}" = "yes"; then
142    AC_MSG_ERROR([cannot find win32 console development files])
143  fi
144fi
145
146if test "${enable_slang}" != "no"; then
147  ac_cv_my_have_slang="no"
148  AC_CHECK_HEADERS(slang.h slang/slang.h,
149   [ac_cv_my_have_slang="yes"
150    AC_DEFINE(USE_SLANG, 1, Define to 1 to activate the slang backend driver)
151    AC_CHECK_LIB(slang, SLsmg_utf8_enable,
152     [AC_DEFINE(HAVE_SLSMG_UTF8_ENABLE, 1, Define to 1 if you have the `SLsmg_utf8_enable' function.)])
153    CPPFLAGS="${CPPFLAGS} -DOPTIMISE_SLANG_PALETTE=1"
154    CACA_LIBS="${CACA_LIBS} -lslang"
155    CACA_DRIVERS="${CACA_DRIVERS} slang"
156    break])
157  if test "${ac_cv_my_have_slang}" = "no" -a "${enable_slang}" = "yes"; then
158    AC_MSG_ERROR([cannot find slang development files])
159  fi
160fi
161
162if test "${enable_x11}" != "no"; then
163  AC_PATH_X
164  AC_CHECK_LIB(X11, XOpenDisplay,
165   [ac_cv_my_have_x11="yes"
166    if test -n "${x_includes}"; then X_CFLAGS="-I${x_includes}"; fi
167    if test -n "${x_libraries}"; then X_LIBS="-L${x_libraries}"; fi
168    AC_DEFINE(USE_X11, 1, Define to 1 to activate the X11 backend driver)
169    CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
170    X11_LIBS="${X11_LIBS} -lX11 ${X_LIBS}"
171    CACA_DRIVERS="${CACA_DRIVERS} x11"],
172   [ac_cv_my_have_x11="no"],
173   [[`if test -n "${x_libraries}"; then echo -L${x_libraries}; fi`]])
174  AC_CHECK_HEADERS(X11/XKBlib.h)
175  if test "${ac_cv_my_have_x11}" != "yes" -a "${enable_x11}" = "yes"; then
176    AC_MSG_ERROR([cannot find X11 development files])
177  fi
178fi
179
180if test "${enable_gl}" != "no"; then
181  ac_cv_my_have_gl="no"
182  AC_CHECK_HEADERS(GL/gl.h OpenGL/gl.h,
183   [AC_CHECK_HEADERS(GL/glut.h,
184     [AC_CHECK_LIB(glut, glutCloseFunc,
185       [AC_DEFINE(HAVE_GLUTCLOSEFUNC, 1, Define to 1 if you have the `glutCloseFunc' function.)])
186      AC_CHECK_LIB(glut, glutMainLoopEvent,
187       [ac_cv_my_have_gl="yes"])
188      AC_CHECK_LIB(glut, glutCheckLoop,
189       [ac_cv_my_have_gl="yes"
190        AC_DEFINE(HAVE_GLUTCHECKLOOP, 1, Define to 1 if you have the `glutCheckLoop' function.)])])
191      break])
192  if test "${ac_cv_my_have_gl}" = "yes"; then
193    AC_DEFINE(USE_GL, 1, Define to 1 to activate the OpenGL backend driver)
194    GL_LIBS="${GL_LIBS} -lGL -lglut"
195    CACA_DRIVERS="${CACA_DRIVERS} gl"
196  elif test "${enable_gl}" = "yes"; then
197    AC_MSG_ERROR([cannot find OpenGL+FreeGLUT development files])
198  fi
199fi
200
201if test "${enable_cocoa}" != "no"; then
202  ac_cv_my_have_cocoa="no"
203  AC_LANG_PUSH(C++)
204  savedCPPFLAGS="${CPPFLAGS}"
205  CPPFLAGS="${CPPFLAGS} -ObjC"
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    AC_DEFINE(USE_COCOA, 1, Define to 1 to activate the Cocoa backend driver)
210    CACA_LIBS="${CACA_LIBS} -Wl,-framework,Carbon,-framework,Cocoa"
211    CACA_DRIVERS="${CACA_DRIVERS} cocoa"
212  elif test "${enable_cocoa}" = "yes"; then
213    AC_MSG_ERROR([cannot find Cocoa development files])
214  fi
215  CPPFLAGS="${savedCPPFLAGS}"
216  AC_LANG_POP(C++)
217fi
218AM_CONDITIONAL(USE_COCOA, test "${ac_cv_my_have_cocoa}" = "yes")
219
220if test "${enable_ncurses}" != "no"; then
221  ac_cv_my_have_ncurses="no"
222  AC_CHECK_HEADERS(ncursesw/ncurses.h ncurses/ncurses.h ncurses.h curses.h,
223   [ncurses="no"
224    AC_CHECK_LIB(ncursesw, initscr,
225     [ncurses="-lncursesw"],
226     [AC_CHECK_LIB(ncurses, initscr,
227       [ncurses="-lncurses"])])
228    if test "${ncurses}" = "no"; then
229      continue
230    fi
231    ac_cv_my_have_ncurses="yes"
232    AC_DEFINE(USE_NCURSES, 1, Define to 1 to activate the ncurses backend driver)
233    CACA_LIBS="${CACA_LIBS} ${ncurses}"
234    CACA_DRIVERS="${CACA_DRIVERS} ncurses"
235    dnl  Check for resizeterm or resize_term
236    SAVED_LIBS="${LIBS}"
237    LIBS="${LIBS} ${ncurses}"
238    AC_CHECK_FUNCS(resizeterm resize_term)
239    LIBS="${SAVED_LIBS}"
240    break])
241  if test "${ac_cv_my_have_ncurses}" = "no" -a "${enable_ncurses}" = "yes"; then
242    AC_MSG_ERROR([cannot find ncurses development files])
243  fi
244fi
245
246if test "${enable_vga}" = "yes"; then
247  ac_cv_my_have_vga="yes"
248  CPPFLAGS="${CPPFLAGS} -I. -D__KERNEL__ -nostdinc -include kernel/kernel.h"
249  CFLAGS="${CFLAGS} -fno-builtin -O2 -Wall"
250  CCASFLAGS="${CCASFLAGS} -I."
251  LDFLAGS="${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000"
252  AC_DEFINE(USE_VGA, 1, Define to 1 to activate the VGA backend driver)
253  CACA_DRIVERS="${CACA_DRIVERS} vga"
254fi
255AM_CONDITIONAL(USE_KERNEL, test "${ac_cv_my_have_vga}" = "yes")
256
257if test "${enable_debug}" = "yes"; then
258  AC_DEFINE(DEBUG, 1, Define to 1 to activate debug)
259fi
260
261if test "${enable_plugins}" = "yes"; then
262  ac_cv_my_have_plugins="yes"
263  AC_DEFINE(USE_PLUGINS, 1, Define to 1 to activate plugins)
264  CACA_LIBS="${CACA_LIBS} -ldl"
265else
266  CACA_LIBS="${CACA_LIBS} ${X11_LIBS} ${GL_LIBS}"
267fi
268AM_CONDITIONAL(USE_PLUGINS, test "${ac_cv_my_have_plugins}" = "yes")
269
270AC_MSG_CHECKING(valid output drivers)
271if test -z "${CACA_DRIVERS}"; then
272  AC_MSG_RESULT(no)
273  AC_MSG_ERROR([no output drivers were selected!])
274else
275  CACA_DRIVERS="${CACA_DRIVERS# *}"
276  AC_MSG_RESULT([${CACA_DRIVERS}])
277fi
278
279
280AC_SUBST(MATH_LIBS)
281AC_SUBST(UTIL_LIBS)
282AC_SUBST(GETOPT_LIBS)
283AC_SUBST(CACA_LIBS)
284AC_SUBST(X11_LIBS)
285AC_SUBST(GL_LIBS)
286
287# Optimizations
288CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer"
289# Code qui fait des warnings == code de porc == deux baffes dans ta gueule
290# [Jylam] Removed -Wshadow in order to avoid ncurses/gl conflict
291# (Comme quoi on est pas les seuls porcs)
292CFLAGS="${CFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare"
293
294# Build the C++ bindings?
295ac_cv_my_have_cxx="no"
296if test "${enable_cxx}" = "yes"; then
297  ac_cv_my_have_cxx="yes"
298fi
299AM_CONDITIONAL(USE_CXX, test "${ac_cv_my_have_cxx}" = "yes")
300
301# Build cacaserver?
302ac_cv_my_have_network="no"
303AC_CHECK_HEADERS(sys/socket.h,
304 [ac_cv_my_have_network="yes"])
305AM_CONDITIONAL(USE_NETWORK, test "${ac_cv_my_have_network}" = "yes")
306
307# Use Imlib2?
308if test "${enable_imlib2}" != "no"; then
309  IMLIB2="no"
310  PKG_CHECK_MODULES(IMLIB2, imlib2, [IMLIB2="yes"], [AC_MSG_RESULT(no)])
311  if test "${IMLIB2}" != "no"; then
312    AC_DEFINE(USE_IMLIB2, 1, Define to 1 to use Imlib2)
313  fi
314fi
315
316# Build development tools?
317PANGOFT2="no"
318PKG_CHECK_MODULES(PANGOFT2, pangoft2, [PANGOFT2="yes"], [AC_MSG_RESULT(no)])
319AM_CONDITIONAL(USE_PANGO, test "${PANGOFT2}" != "no")
320
321# Build documentation?
322DOXYGEN="no"
323LATEX="no"
324if test "${enable_doc}" != "no"; then
325  AC_PATH_PROG(DOXYGEN, doxygen, no)
326  if test "${DOXYGEN}" != "no"; then
327    # Build LaTeX documentation?
328    AC_PATH_PROG(LATEX, pdflatex, no)
329    AC_PATH_PROG(DVIPS, dvips, no)
330    if test "${DVIPS}" = "no"; then
331      LATEX="no"
332    fi
333    AC_MSG_CHECKING(for a4wide.sty)
334    if test -f /usr/share/texmf/tex/latex/misc/a4wide.sty; then
335      AC_MSG_RESULT(yes)
336    elif test -f /usr/share/texmf-tetex/tex/latex/a4wide/a4wide.sty; then
337      AC_MSG_RESULT(yes)
338    else
339      LATEX="no"
340      AC_MSG_RESULT(no)
341    fi
342  fi
343fi
344AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
345AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no")
346
347AC_CONFIG_FILES([
348  Makefile
349  kernel/Makefile
350  cucul/Makefile
351  caca/Makefile
352  src/Makefile
353  test/Makefile
354  tools/Makefile
355  cxx/Makefile
356  doc/Makefile
357  autotools/Makefile
358  msvc/Makefile
359])
360AC_CONFIG_FILES([
361  cucul/cucul.pc
362  caca/caca.pc
363  doc/doxygen.cfg
364])
365AC_CONFIG_FILES([caca-config], [chmod 0755 caca-config])
366AC_OUTPUT
367
Note: See TracBrowser for help on using the repository browser.