source: libcaca/trunk/configure.ac @ 781

Last change on this file since 781 was 781, checked in by Jean-Yves Lamoureux, 14 years ago
  • Added preliminary C++ bindings
  • Property svn:keywords set to Id
File size: 10.5 KB
Line 
1# $Id: configure.ac 781 2006-04-17 10:41:30Z jylam $
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, glutMainLoopEvent,
175       [ac_cv_my_have_gl="yes"])]
176     [AC_CHECK_LIB(glut, glutCheckLoop,
177       [ac_cv_my_have_gl="yes"
178        AC_DEFINE(HAVE_GLUTCHECKLOOP, 1, Define to 1 if you have the `glutCheckLoop' function.)])])
179      break])
180  if test "${ac_cv_my_have_gl}" = "yes"; then
181    AC_DEFINE(USE_GL, 1, Define to 1 to activate the OpenGL backend driver)
182    CACA_LIBS="${CACA_LIBS} -lGL -lglut"
183    CACA_DRIVERS="${CACA_DRIVERS} gl"
184  elif test "${enable_gl}" = "yes"; then
185    AC_MSG_ERROR([cannot find OpenGL+FreeGLUT development files])
186  fi
187fi
188
189if test "${enable_network}" != "no"; then
190  ac_cv_my_have_network="no"
191  AC_CHECK_HEADERS(sys/socket.h,
192     [ac_cv_my_have_network="yes"
193      AC_DEFINE(USE_NETWORK, 1, Define to 1 to activate the network backend driver)
194      CACA_DRIVERS="${CACA_DRIVERS} network"])
195  if test "${ac_cv_my_have_network}" = "no" -a "${enable_network}" = "yes"; then
196    AC_MSG_ERROR([cannot find standard networking socket files])
197  fi
198fi
199
200if test "${enable_ncurses}" != "no"; then
201  ac_cv_my_have_ncurses="no"
202  AC_CHECK_HEADERS(ncursesw/ncurses.h ncurses/ncurses.h ncurses.h curses.h,
203   [ncurses="no"
204    AC_CHECK_LIB(ncursesw, initscr,
205     [ncurses="-lncursesw"],
206     [AC_CHECK_LIB(ncurses, initscr,
207       [ncurses="-lncurses"])])
208    if test "${ncurses}" = "no"; then
209      continue
210    fi
211    ac_cv_my_have_ncurses="yes"
212    AC_DEFINE(USE_NCURSES, 1, Define to 1 to activate the ncurses backend driver)
213    CACA_LIBS="${CACA_LIBS} ${ncurses}"
214    CACA_DRIVERS="${CACA_DRIVERS} ncurses"
215    dnl  Check for resizeterm or resize_term
216    SAVED_LIBS="${LIBS}"
217    LIBS="${LIBS} ${ncurses}"
218    AC_CHECK_FUNCS(resizeterm resize_term)
219    LIBS="${SAVED_LIBS}"
220    break])
221  if test "${ac_cv_my_have_ncurses}" = "no" -a "${enable_ncurses}" = "yes"; then
222    AC_MSG_ERROR([cannot find ncurses development files])
223  fi
224fi
225
226if test "${enable_vga}" = "yes"; then
227  ac_cv_my_have_vga="yes"
228  CPPFLAGS="${CPPFLAGS} -I. -D__KERNEL__ -nostdinc -include kernel/kernel.h"
229  CFLAGS="${CFLAGS} -fno-builtin -O2 -Wall"
230  CCASFLAGS="${CCASFLAGS} -I."
231  LDFLAGS="${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000"
232  AC_DEFINE(USE_VGA, 1, Define to 1 to activate the VGA backend driver)
233  CACA_DRIVERS="${CACA_DRIVERS} vga"
234fi
235AM_CONDITIONAL(USE_KERNEL, test "${ac_cv_my_have_vga}" = "yes")
236
237AC_MSG_CHECKING(valid output drivers)
238if test -z "${CACA_DRIVERS}"; then
239  AC_MSG_RESULT(no)
240  AC_MSG_ERROR([no output drivers were selected!])
241else
242  AC_MSG_RESULT([${CACA_DRIVERS}])
243fi
244
245
246
247
248
249AC_SUBST(MATH_LIBS)
250AC_SUBST(CACA_LIBS)
251AC_SUBST(CUCUL_LIBS)
252AC_SUBST(CUCUL++_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 PIC library?
262case "${target_os}" in
263  *mingw32* | *cygwin* | *djgpp*)
264    NEED_PIC=false
265    ;;
266  *)
267    NEED_PIC=:
268    ;;
269esac
270AM_CONDITIONAL(NEED_PIC, ${NEED_PIC})
271
272# Use Imlib2?
273ac_cv_my_have_imlib2="no"
274save_CPPFLAGS="${CPPFLAGS}"
275if test "${enable_imlib2}" != "no"; then
276  AC_PATH_PROG(IMLIB2_CONFIG, imlib2-config, no)
277  if test "${IMLIB2_CONFIG}" != "no"; then
278    CPPFLAGS="${CPPFLAGS} `imlib2-config --cflags` -DX_DISPLAY_MISSING=1"
279  fi
280  AC_CHECK_HEADERS(Imlib2.h,
281    ac_cv_my_have_imlib2="yes",
282   [ac_cv_my_have_imlib2="no"
283    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'.]])])
284  CPPFLAGS="${save_CPPFLAGS}"
285fi
286AM_CONDITIONAL(USE_IMLIB2, test "${ac_cv_my_have_imlib2}" = "yes")
287
288# Build development tools?
289PANGOFT2="no"
290  PKG_CHECK_MODULES(pangoft2, pangoft2,
291   [PANGOFT2="yes"])
292AM_CONDITIONAL(USE_PANGO, test "${PANGO}" != "no")
293
294# Build documentation?
295DOXYGEN="no"
296LATEX="no"
297if test "${enable_doc}" != "no"; then
298  AC_PATH_PROG(DOXYGEN, doxygen, no)
299  if test "${DOXYGEN}" = "no"; then
300    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'.]])
301  fi
302
303  # Build LaTeX documentation?
304  AC_PATH_PROG(LATEX, pdflatex, no)
305  AC_PATH_PROG(DVIPS, dvips, no)
306  if test "${DVIPS}" = "no"; then
307    LATEX="no"
308  fi
309  AC_MSG_CHECKING(for a4wide.sty)
310  if test -f /usr/share/texmf/tex/latex/misc/a4wide.sty; then
311    AC_MSG_RESULT(yes)
312  elif test -f /usr/share/texmf-tetex/tex/latex/a4wide/a4wide.sty; then
313    AC_MSG_RESULT(yes)
314  else
315    LATEX="no"
316    AC_MSG_RESULT(no)
317  fi
318fi
319AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
320AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no")
321
322AC_CONFIG_FILES([
323  Makefile
324  kernel/Makefile
325  cucul/Makefile
326  caca/Makefile
327  src/Makefile
328  test/Makefile
329  tools/Makefile
330  cpp/Makefile
331  doc/Makefile
332  autotools/Makefile
333  debian/Makefile
334  msvc/Makefile
335])
336AC_CONFIG_FILES([
337  cucul/cucul.pc
338  caca/caca.pc
339  doc/doxygen.cfg
340])
341AC_CONFIG_FILES([caca-config], [chmod 0755 caca-config])
342AC_OUTPUT
343
Note: See TracBrowser for help on using the repository browser.