source: libcaca/trunk/configure.ac @ 1421

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