source: libcaca/trunk/configure.ac @ 994

Last change on this file since 994 was 994, checked in by Sam Hocevar, 14 years ago
  • Fix a build failure when X11R7 is available but OpenGL isn't.
  • Property svn:keywords set to Id
File size: 10.5 KB
Line 
1# $Id: configure.ac 994 2006-05-31 14:08:58Z 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.beta2)
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
18AM_PROG_AS
19
20AC_LIBTOOL_WIN32_DLL
21AM_PROG_LIBTOOL
22AC_LIBTOOL_CXX
23
24AC_C_CONST
25AC_C_INLINE
26AC_TYPE_SIGNAL
27
28dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
29dnl now otherwise it might be set in an obscure if statement. Same thing for
30dnl PKG_PROG_PKG_CONFIG which needs to be called first.
31AC_EGREP_CPP(yes, foo)
32PKG_PROG_PKG_CONFIG()
33m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
34if test "$build" != "$host" -a "${PKG_CONFIG_LIBDIR}" = ""; then
35  export PKG_CONFIG_LIBDIR=/dev/null
36fi
37
38dnl output driver features
39AC_ARG_ENABLE(slang,
40  [  --enable-slang          slang graphics support (autodetected)])
41AC_ARG_ENABLE(ncurses,
42  [  --enable-ncurses        ncurses graphics support (autodetected)])
43AC_ARG_ENABLE(win32,
44  [  --enable-win32          Windows console support (autodetected)])
45AC_ARG_ENABLE(conio,
46  [  --enable-conio          DOS conio.h graphics support (autodetected)])
47AC_ARG_ENABLE(x11,
48  [  --enable-x11            X11 support (autodetected)])
49AC_ARG_ENABLE(gl,
50  [  --enable-gl             OpenGL support (autodetected)])
51AC_ARG_ENABLE(network,
52  [  --enable-network        Network support (autodetected)])
53AC_ARG_ENABLE(vga,
54  [  --enable-vga            VGA support (default disabled)])
55
56dnl language bindings
57AC_ARG_ENABLE(cxx,
58  [  --enable-cxx            C++ bindings (default disabled)])
59
60dnl example programs features
61AC_ARG_ENABLE(imlib2,
62  [  --enable-imlib2         Imlib2 graphics support (default enabled)])
63
64dnl conditional builds
65AC_ARG_ENABLE(doc,
66  [  --enable-doc            build documentation (needs doxygen and LaTeX)])
67
68AC_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)
69AC_CHECK_FUNCS(signal ioctl vsnprintf getenv putenv strcasecmp htons)
70AC_CHECK_FUNCS(usleep gettimeofday)
71
72AC_MSG_CHECKING(for Sleep)
73AC_TRY_COMPILE([#include <windows.h>],[Sleep(42);],
74 [AC_MSG_RESULT(yes)
75  AC_DEFINE(HAVE_SLEEP, 1, [Define to 1 if you have the `Sleep' function.])],
76 [AC_MSG_RESULT(no)])
77
78AC_MSG_CHECKING(for fsin/fcos)
79AC_TRY_COMPILE([],[asm("fsin\n\tfcos");],
80 [AC_MSG_RESULT(yes)
81  AC_DEFINE(HAVE_FSIN_FCOS, 1, [Define to 1 if you have the `fsin' and `fcos' operands.])],
82 [AC_MSG_RESULT(no)])
83
84AC_MSG_CHECKING(for fldln2/fxch/fyl2x)
85AC_TRY_COMPILE([],[asm("fldln2; fldln2; fxch; fyl2x");],
86 [AC_MSG_RESULT(yes)
87  AC_DEFINE(HAVE_FLDLN2, 1, [Define to 1 if you have the `fldln2' and other floating points operands.])],
88 [AC_MSG_RESULT(no)])
89
90AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
91
92CACA_DRIVERS=""
93
94if test "${enable_conio}" != "no"; then
95  ac_cv_my_have_conio="no"
96  AC_CHECK_HEADERS(conio.h,
97   [AC_MSG_CHECKING(for ScreenUpdate in pc.h)
98    AC_EGREP_HEADER(ScreenUpdate, pc.h,
99     [ac_cv_my_have_conio="yes"
100      AC_MSG_RESULT(yes)
101      AC_DEFINE(SCREENUPDATE_IN_PC_H, 1,
102                Define to 1 if <pc.h> defines ScreenUpdate.)
103      AC_DEFINE(USE_CONIO, 1, Define to 1 to activate the conio.h backend driver)
104      CACA_DRIVERS="${CACA_DRIVERS} conio"],
105     [AC_MSG_RESULT(no)])])
106  if test "${ac_cv_my_have_conio}" = "no" -a "${enable_conio}" = "yes"; then
107    AC_MSG_ERROR([cannot find conio.h])
108  fi
109fi
110
111if test "${enable_win32}" != "no"; then
112  ac_cv_my_have_win32="no"
113  AC_CHECK_HEADERS(windows.h,
114   [AC_MSG_CHECKING(for AllocConsole in windows.h)
115    AC_EGREP_HEADER(AllocConsole, windows.h,
116     [ac_cv_my_have_win32="yes"
117      AC_MSG_RESULT(yes)
118      AC_DEFINE(ALLOCCONSOLE_IN_WINDOWS_H, 1,
119                Define to 1 if <windows.h> defines AllocConsole.)
120      AC_DEFINE(USE_WIN32, 1, Define to 1 to activate the win32 backend driver)
121      CACA_DRIVERS="${CACA_DRIVERS} win32"],
122     [AC_MSG_RESULT(no)])])
123  if test "${ac_cv_my_have_win32}" = "no" -a "${enable_win32}" = "yes"; then
124    AC_MSG_ERROR([cannot find win32 console development files])
125  fi
126fi
127
128if 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
142fi
143
144if test "${enable_x11}" != "no"; then
145  AC_PATH_X
146  AC_CHECK_LIB(X11, XOpenDisplay,
147   [ac_cv_my_have_x11="yes"
148    if test -n "${x_includes}"; then X_CFLAGS="-I${x_includes}"; fi
149    if test -n "${x_libraries}"; then X_LIBS="-L${x_libraries}"; fi
150    AC_DEFINE(USE_X11, 1, Define to 1 to activate the X11 backend driver)
151    CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
152    CACA_LIBS="${CACA_LIBS} -lX11 ${X_LIBS}"
153    CACA_DRIVERS="${CACA_DRIVERS} x11"],
154   [ac_cv_my_have_x11="no"],
155   [[`if test -n "${x_libraries}"; then echo -L${x_libraries}; fi`]])
156  AC_CHECK_HEADERS(X11/XKBlib.h)
157  if test "${ac_cv_my_have_x11}" != "yes" -a "${enable_x11}" = "yes"; then
158    AC_MSG_ERROR([cannot find X11 development files])
159  fi
160fi
161
162if test "${enable_gl}" != "no"; then
163  ac_cv_my_have_gl="no"
164  AC_CHECK_HEADERS(GL/gl.h OpenGL/gl.h,
165   [AC_CHECK_HEADERS(GL/glut.h,
166     [AC_CHECK_LIB(glut, glutCloseFunc,
167       [AC_DEFINE(HAVE_GLUTCLOSEFUNC, 1, Define to 1 if you have the `glutCloseFunc' function.)])
168      AC_CHECK_LIB(glut, glutMainLoopEvent,
169       [ac_cv_my_have_gl="yes"])
170      AC_CHECK_LIB(glut, glutCheckLoop,
171       [ac_cv_my_have_gl="yes"
172        AC_DEFINE(HAVE_GLUTCHECKLOOP, 1, Define to 1 if you have the `glutCheckLoop' function.)])])
173      break])
174  if test "${ac_cv_my_have_gl}" = "yes"; then
175    AC_DEFINE(USE_GL, 1, Define to 1 to activate the OpenGL backend driver)
176    CACA_LIBS="${CACA_LIBS} -lGL -lglut"
177    CACA_DRIVERS="${CACA_DRIVERS} gl"
178  elif test "${enable_gl}" = "yes"; then
179    AC_MSG_ERROR([cannot find OpenGL+FreeGLUT development files])
180  fi
181fi
182
183if test "${enable_ncurses}" != "no"; then
184  ac_cv_my_have_ncurses="no"
185  AC_CHECK_HEADERS(ncursesw/ncurses.h ncurses/ncurses.h ncurses.h curses.h,
186   [ncurses="no"
187    AC_CHECK_LIB(ncursesw, initscr,
188     [ncurses="-lncursesw"],
189     [AC_CHECK_LIB(ncurses, initscr,
190       [ncurses="-lncurses"])])
191    if test "${ncurses}" = "no"; then
192      continue
193    fi
194    ac_cv_my_have_ncurses="yes"
195    AC_DEFINE(USE_NCURSES, 1, Define to 1 to activate the ncurses backend driver)
196    CACA_LIBS="${CACA_LIBS} ${ncurses}"
197    CACA_DRIVERS="${CACA_DRIVERS} ncurses"
198    dnl  Check for resizeterm or resize_term
199    SAVED_LIBS="${LIBS}"
200    LIBS="${LIBS} ${ncurses}"
201    AC_CHECK_FUNCS(resizeterm resize_term)
202    LIBS="${SAVED_LIBS}"
203    break])
204  if test "${ac_cv_my_have_ncurses}" = "no" -a "${enable_ncurses}" = "yes"; then
205    AC_MSG_ERROR([cannot find ncurses development files])
206  fi
207fi
208
209if test "${enable_vga}" = "yes"; then
210  ac_cv_my_have_vga="yes"
211  CPPFLAGS="${CPPFLAGS} -I. -D__KERNEL__ -nostdinc -include kernel/kernel.h"
212  CFLAGS="${CFLAGS} -fno-builtin -O2 -Wall"
213  CCASFLAGS="${CCASFLAGS} -I."
214  LDFLAGS="${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000"
215  AC_DEFINE(USE_VGA, 1, Define to 1 to activate the VGA backend driver)
216  CACA_DRIVERS="${CACA_DRIVERS} vga"
217fi
218AM_CONDITIONAL(USE_KERNEL, test "${ac_cv_my_have_vga}" = "yes")
219
220AC_MSG_CHECKING(valid output drivers)
221if test -z "${CACA_DRIVERS}"; then
222  AC_MSG_RESULT(no)
223  AC_MSG_ERROR([no output drivers were selected!])
224else
225  AC_MSG_RESULT([${CACA_DRIVERS}])
226fi
227
228AC_SUBST(MATH_LIBS)
229AC_SUBST(CACA_LIBS)
230
231# Optimizations
232CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer"
233# Code qui fait des warnings == code de porc == deux baffes dans ta gueule
234# [Jylam] Removed -Wshadow in order to avoid ncurses/gl conflict
235# (Comme quoi on est pas les seuls porcs)
236CFLAGS="${CFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare"
237
238# Build the C++ bindings?
239ac_cv_my_have_cxx="no"
240if test "${enable_cxx}" = "yes"; then
241  ac_cv_my_have_cxx="yes"
242fi
243AM_CONDITIONAL(USE_CXX, test "${ac_cv_my_have_cxx}" = "yes")
244
245# Build cacaserver?
246ac_cv_my_have_network="no"
247AC_CHECK_HEADERS(sys/socket.h,
248 [ac_cv_my_have_network="yes"])
249AM_CONDITIONAL(USE_NETWORK, test "${ac_cv_my_have_network}" = "yes")
250
251# Use Imlib2?
252ac_cv_my_have_imlib2="no"
253save_CPPFLAGS="${CPPFLAGS}"
254if test "${enable_imlib2}" != "no"; then
255  AC_PATH_PROG(IMLIB2_CONFIG, imlib2-config, no)
256  if test "${IMLIB2_CONFIG}" != "no"; then
257    CPPFLAGS="${CPPFLAGS} `imlib2-config --cflags` -DX_DISPLAY_MISSING=1"
258  fi
259  AC_CHECK_HEADERS(Imlib2.h,
260    ac_cv_my_have_imlib2="yes",
261   [ac_cv_my_have_imlib2="no"
262    AC_MSG_ERROR([[cannot find Imlib2 development files. Without Imlib2, cacaview will only open BMP files; if this is really what you want, re-run configure with '--disable-imlib2'.]])])
263  CPPFLAGS="${save_CPPFLAGS}"
264fi
265AM_CONDITIONAL(USE_IMLIB2, test "${ac_cv_my_have_imlib2}" = "yes")
266
267# Build development tools?
268PANGOFT2="no"
269PKG_CHECK_MODULES(pangoft2, pangoft2, [PANGOFT2="yes"], [AC_MSG_RESULT(no)])
270AM_CONDITIONAL(USE_PANGO, test "${PANGOFT2}" != "no")
271
272# Build documentation?
273DOXYGEN="no"
274LATEX="no"
275if test "${enable_doc}" != "no"; then
276  AC_PATH_PROG(DOXYGEN, doxygen, no)
277  if test "${DOXYGEN}" = "no"; then
278    AC_MSG_ERROR([[cannot find doxygen, which is needed to build the libcaca documentation; if this is really what you want, re-run configure with '--disable-doc'.]])
279  fi
280
281  # Build LaTeX documentation?
282  AC_PATH_PROG(LATEX, pdflatex, no)
283  AC_PATH_PROG(DVIPS, dvips, no)
284  if test "${DVIPS}" = "no"; then
285    LATEX="no"
286  fi
287  AC_MSG_CHECKING(for a4wide.sty)
288  if test -f /usr/share/texmf/tex/latex/misc/a4wide.sty; then
289    AC_MSG_RESULT(yes)
290  elif test -f /usr/share/texmf-tetex/tex/latex/a4wide/a4wide.sty; then
291    AC_MSG_RESULT(yes)
292  else
293    LATEX="no"
294    AC_MSG_RESULT(no)
295  fi
296fi
297AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
298AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no")
299
300AC_CONFIG_FILES([
301  Makefile
302  kernel/Makefile
303  cucul/Makefile
304  caca/Makefile
305  src/Makefile
306  test/Makefile
307  tools/Makefile
308  cxx/Makefile
309  doc/Makefile
310  autotools/Makefile
311  debian/Makefile
312  msvc/Makefile
313])
314AC_CONFIG_FILES([
315  cucul/cucul.pc
316  caca/caca.pc
317  doc/doxygen.cfg
318])
319AC_CONFIG_FILES([caca-config], [chmod 0755 caca-config])
320AC_OUTPUT
321
Note: See TracBrowser for help on using the repository browser.