source: libcaca/trunk/configure.ac @ 799

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