source: libcaca/trunk/configure.ac @ 1255

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