source: libcaca/trunk/configure.ac @ 866

Last change on this file since 866 was 866, checked in by Sam Hocevar, 14 years ago
  • Brought the Win32 build back on its wheels.
  • Property svn:keywords set to Id
File size: 10.9 KB
Line 
1# $Id: configure.ac 866 2006-04-24 21:45:26Z 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.beta1)
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()
33
34dnl output driver features
35AC_ARG_ENABLE(slang,
36  [  --enable-slang          slang graphics support (autodetected)])
37AC_ARG_ENABLE(ncurses,
38  [  --enable-ncurses        ncurses graphics support (autodetected)])
39AC_ARG_ENABLE(win32,
40  [  --enable-win32          Windows console support (autodetected)])
41AC_ARG_ENABLE(conio,
42  [  --enable-conio          DOS conio.h graphics support (autodetected)])
43AC_ARG_ENABLE(x11,
44  [  --enable-x11            X11 support (autodetected)])
45AC_ARG_ENABLE(gl,
46  [  --enable-gl             OpenGL support (autodetected)])
47AC_ARG_ENABLE(network,
48  [  --enable-network        Network support (autodetected)])
49AC_ARG_ENABLE(vga,
50  [  --enable-vga            VGA support (default disabled)])
51
52dnl language bindings
53AC_ARG_ENABLE(cpp,
54  [  --enable-cpp            C++ bindings (default disabled)])
55
56dnl example programs features
57AC_ARG_ENABLE(imlib2,
58  [  --enable-imlib2         Imlib2 graphics support (default enabled)])
59
60dnl conditional builds
61AC_ARG_ENABLE(doc,
62  [  --enable-doc            build documentation (needs doxygen and LaTeX)])
63AC_ARG_ENABLE(pangoft2,
64  [  --enable-pangoft2       build font generator tool (autodetected)])
65
66AC_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)
67AC_CHECK_FUNCS(signal ioctl vsnprintf getenv putenv strcasecmp htons)
68AC_CHECK_FUNCS(usleep gettimeofday)
69
70AC_MSG_CHECKING(for Sleep)
71AC_TRY_COMPILE([#include <windows.h>],[Sleep(42);],
72 [AC_MSG_RESULT(yes)
73  AC_DEFINE(HAVE_SLEEP, 1, [Define to 1 if you have the `Sleep' function.])],
74 [AC_MSG_RESULT(no)])
75
76AC_MSG_CHECKING(for fsin/fcos)
77AC_TRY_COMPILE([],[asm("fsin\n\tfcos");],
78 [AC_MSG_RESULT(yes)
79  AC_DEFINE(HAVE_FSIN_FCOS, 1, [Define to 1 if you have the `fsin' and `fcos' operands.])],
80 [AC_MSG_RESULT(no)])
81
82AC_MSG_CHECKING(for fldln2/fxch/fyl2x)
83AC_TRY_COMPILE([],[asm("fldln2; fldln2; fxch; fyl2x");],
84 [AC_MSG_RESULT(yes)
85  AC_DEFINE(HAVE_FLDLN2, 1, [Define to 1 if you have the `fldln2' and other floating points operands.])],
86 [AC_MSG_RESULT(no)])
87
88AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
89
90CACA_DRIVERS=""
91
92if test "${enable_conio}" != "no"; then
93  ac_cv_my_have_conio="no"
94  AC_CHECK_HEADERS(conio.h,
95   [AC_MSG_CHECKING(for ScreenUpdate in pc.h)
96    AC_EGREP_HEADER(ScreenUpdate, pc.h,
97     [ac_cv_my_have_conio="yes"
98      AC_MSG_RESULT(yes)
99      AC_DEFINE(SCREENUPDATE_IN_PC_H, 1,
100                Define to 1 if <pc.h> defines ScreenUpdate.)
101      AC_DEFINE(USE_CONIO, 1, Define to 1 to activate the conio.h backend driver)
102      CACA_DRIVERS="${CACA_DRIVERS} conio"],
103     [AC_MSG_RESULT(no)])])
104  if test "${ac_cv_my_have_conio}" = "no" -a "${enable_conio}" = "yes"; then
105    AC_MSG_ERROR([cannot find conio.h])
106  fi
107fi
108
109if test "${enable_win32}" != "no"; then
110  ac_cv_my_have_win32="no"
111  AC_CHECK_HEADERS(windows.h,
112   [AC_MSG_CHECKING(for AllocConsole in windows.h)
113    AC_EGREP_HEADER(AllocConsole, windows.h,
114     [ac_cv_my_have_win32="yes"
115      AC_MSG_RESULT(yes)
116      AC_DEFINE(ALLOCCONSOLE_IN_WINDOWS_H, 1,
117                Define to 1 if <windows.h> defines AllocConsole.)
118      AC_DEFINE(USE_WIN32, 1, Define to 1 to activate the win32 backend driver)
119      CACA_DRIVERS="${CACA_DRIVERS} win32"],
120     [AC_MSG_RESULT(no)])])
121  if test "${ac_cv_my_have_win32}" = "no" -a "${enable_win32}" = "yes"; then
122    AC_MSG_ERROR([cannot find win32 console development files])
123  fi
124fi
125
126if test "${enable_slang}" != "no"; then
127  ac_cv_my_have_slang="no"
128  AC_CHECK_HEADERS(slang.h slang/slang.h,
129   [ac_cv_my_have_slang="yes"
130    AC_DEFINE(USE_SLANG, 1, Define to 1 to activate the slang backend driver)
131    AC_CHECK_LIB(slang, SLsmg_utf8_enable,
132     [AC_DEFINE(HAVE_SLSMG_UTF8_ENABLE, 1, Define to 1 if you have the `SLsmg_utf8_enable' function.)])
133    CPPFLAGS="${CPPFLAGS} -DOPTIMISE_SLANG_PALETTE=1"
134    CACA_LIBS="${CACA_LIBS} -lslang"
135    CACA_DRIVERS="${CACA_DRIVERS} slang"
136    break])
137  if test "${ac_cv_my_have_slang}" = "no" -a "${enable_slang}" = "yes"; then
138    AC_MSG_ERROR([cannot find slang development files])
139  fi
140fi
141
142if test "${enable_x11}" != "no"; then
143  AC_PATH_X
144  AC_CHECK_LIB(X11, XOpenDisplay,
145   [ac_cv_my_have_x11="yes"
146    if test -n "${x_includes}"; then X_CFLAGS="-I${x_includes}"; fi
147    if test -n "${x_libraries}"; then X_LIBS="-lX11 -L${x_libraries}"; fi
148    AC_DEFINE(USE_X11, 1, Define to 1 to activate the X11 backend driver)
149    CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
150    CACA_LIBS="${CACA_LIBS} ${X_LIBS}"
151    CACA_DRIVERS="${CACA_DRIVERS} x11"],
152   [ac_cv_my_have_x11="no"],
153   [[-lXt `if test -n "${x_libraries}"; then echo -L${x_libraries}; fi`]])
154  AC_CHECK_HEADERS(X11/XKBlib.h)
155  if test "${ac_cv_my_have_x11}" != "yes" -a "${enable_x11}" = "yes"; then
156    AC_MSG_ERROR([cannot find X11 development files])
157  fi
158fi
159
160if test "${enable_gl}" != "no"; then
161  ac_cv_my_have_gl="no"
162  AC_CHECK_HEADERS(GL/gl.h OpenGL/gl.h,
163   [AC_CHECK_HEADERS(GL/glut.h,
164     [AC_CHECK_LIB(glut, glutCloseFunc,
165       [AC_DEFINE(HAVE_GLUTCLOSEFUNC, 1, Define to 1 if you have the `glutCloseFunc' function.)])
166      AC_CHECK_LIB(glut, glutMainLoopEvent,
167       [ac_cv_my_have_gl="yes"])
168      AC_CHECK_LIB(glut, glutCheckLoop,
169       [ac_cv_my_have_gl="yes"
170        AC_DEFINE(HAVE_GLUTCHECKLOOP, 1, Define to 1 if you have the `glutCheckLoop' function.)])])
171      break])
172  if test "${ac_cv_my_have_gl}" = "yes"; then
173    AC_DEFINE(USE_GL, 1, Define to 1 to activate the OpenGL backend driver)
174    CACA_LIBS="${CACA_LIBS} -lGL -lglut"
175    CACA_DRIVERS="${CACA_DRIVERS} gl"
176  elif test "${enable_gl}" = "yes"; then
177    AC_MSG_ERROR([cannot find OpenGL+FreeGLUT development files])
178  fi
179fi
180
181if test "${enable_network}" != "no"; then
182  ac_cv_my_have_network="no"
183  AC_CHECK_HEADERS(sys/socket.h,
184     [ac_cv_my_have_network="yes"
185      AC_DEFINE(USE_NETWORK, 1, Define to 1 to activate the network backend driver)
186      CACA_DRIVERS="${CACA_DRIVERS} network"])
187  if test "${ac_cv_my_have_network}" = "no" -a "${enable_network}" = "yes"; then
188    AC_MSG_ERROR([cannot find standard networking socket 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
229AC_MSG_CHECKING(valid output drivers)
230if test -z "${CACA_DRIVERS}"; then
231  AC_MSG_RESULT(no)
232  AC_MSG_ERROR([no output drivers were selected!])
233else
234  AC_MSG_RESULT([${CACA_DRIVERS}])
235fi
236
237AC_SUBST(MATH_LIBS)
238AC_SUBST(CACA_LIBS)
239
240# Optimizations
241CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer"
242# Code qui fait des warnings == code de porc == deux baffes dans ta gueule
243# [Jylam] Removed -Wshadow in order to avoid ncurses/gl conflict
244# (Comme quoi on est pas les seuls porcs)
245CFLAGS="${CFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare"
246
247# Build the C++ bindings?
248ac_cv_my_have_cpp="no"
249if test "${enable_cpp}" = "yes"; then
250  ac_cv_my_have_cpp="yes"
251fi
252AM_CONDITIONAL(USE_CPP, test "${ac_cv_my_have_cpp}" = "yes")
253
254# Build cacaserver?
255ac_cv_my_have_fcntl="no"
256AC_CHECK_FUNC(fcntl,
257 [ac_cv_my_have_fcntl="yes"])
258AM_CONDITIONAL(USE_FCNTL, test "${ac_cv_my_have_fcntl}" = "yes")
259
260# Use Imlib2?
261ac_cv_my_have_imlib2="no"
262save_CPPFLAGS="${CPPFLAGS}"
263if test "${enable_imlib2}" != "no"; then
264  AC_PATH_PROG(IMLIB2_CONFIG, imlib2-config, no)
265  if test "${IMLIB2_CONFIG}" != "no"; then
266    CPPFLAGS="${CPPFLAGS} `imlib2-config --cflags` -DX_DISPLAY_MISSING=1"
267  fi
268  AC_CHECK_HEADERS(Imlib2.h,
269    ac_cv_my_have_imlib2="yes",
270   [ac_cv_my_have_imlib2="no"
271    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'.]])])
272  CPPFLAGS="${save_CPPFLAGS}"
273fi
274AM_CONDITIONAL(USE_IMLIB2, test "${ac_cv_my_have_imlib2}" = "yes")
275
276# Build development tools?
277PANGOFT2="no"
278if test "${enable_pangoft2}" != "no"; then
279  PKG_CHECK_MODULES(pangoft2, pangoft2, [PANGOFT2="yes"], [AC_MSG_RESULT(no)])
280fi
281AM_CONDITIONAL(USE_PANGO, test "${PANGOFT2}" != "no")
282
283# Build documentation?
284DOXYGEN="no"
285LATEX="no"
286if test "${enable_doc}" != "no"; then
287  AC_PATH_PROG(DOXYGEN, doxygen, no)
288  if test "${DOXYGEN}" = "no"; then
289    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'.]])
290  fi
291
292  # Build LaTeX documentation?
293  AC_PATH_PROG(LATEX, pdflatex, no)
294  AC_PATH_PROG(DVIPS, dvips, no)
295  if test "${DVIPS}" = "no"; then
296    LATEX="no"
297  fi
298  AC_MSG_CHECKING(for a4wide.sty)
299  if test -f /usr/share/texmf/tex/latex/misc/a4wide.sty; then
300    AC_MSG_RESULT(yes)
301  elif test -f /usr/share/texmf-tetex/tex/latex/a4wide/a4wide.sty; then
302    AC_MSG_RESULT(yes)
303  else
304    LATEX="no"
305    AC_MSG_RESULT(no)
306  fi
307fi
308AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
309AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no")
310
311AC_CONFIG_FILES([
312  Makefile
313  kernel/Makefile
314  cucul/Makefile
315  caca/Makefile
316  src/Makefile
317  test/Makefile
318  tools/Makefile
319  cpp/Makefile
320  doc/Makefile
321  autotools/Makefile
322  debian/Makefile
323  msvc/Makefile
324])
325AC_CONFIG_FILES([
326  cucul/cucul.pc
327  caca/caca.pc
328  doc/doxygen.cfg
329])
330AC_CONFIG_FILES([caca-config], [chmod 0755 caca-config])
331AC_OUTPUT
332
Note: See TracBrowser for help on using the repository browser.