source: libcaca/trunk/configure.ac @ 554

Last change on this file since 554 was 554, checked in by Jean-Yves Lamoureux, 14 years ago
  • Added very preliminary network driver
  • Property svn:keywords set to Id
File size: 8.2 KB
Line 
1# $Id: configure.ac 554 2006-03-08 20:03:24Z 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
14
15AC_LIBTOOL_WIN32_DLL
16AM_PROG_LIBTOOL
17
18AC_C_CONST
19AC_C_INLINE
20AC_TYPE_SIGNAL
21
22dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
23dnl now otherwise it might be set in an obscure if statement.
24AC_EGREP_CPP(foo, foo)
25
26dnl output driver features
27AC_ARG_ENABLE(slang,
28  [  --enable-slang          slang graphics support (autodetected)])
29AC_ARG_ENABLE(ncurses,
30  [  --enable-ncurses        ncurses graphics support (autodetected)])
31AC_ARG_ENABLE(win32,
32  [  --enable-win32          Windows console support (autodetected)])
33AC_ARG_ENABLE(conio,
34  [  --enable-conio          DOS conio.h graphics support (autodetected)])
35AC_ARG_ENABLE(x11,
36  [  --enable-x11            X11 support (autodetected)])
37AC_ARG_ENABLE(gl,
38  [  --enable-gl             OpenGL support (autodetected)])
39AC_ARG_ENABLE(network,
40  [  --enable-network        Network support (autodetected)])
41
42dnl example programs features
43AC_ARG_ENABLE(imlib2,
44  [  --enable-imlib2         Imlib2 graphics support (default enabled)])
45
46dnl conditional builds
47AC_ARG_ENABLE(doc,
48  [  --enable-doc            build documentation (needs doxygen and LaTeX)])
49
50AC_CHECK_HEADERS(signal.h sys/ioctl.h sys/time.h inttypes.h endian.h unistd.h)
51AC_CHECK_FUNCS(signal ioctl vsnprintf getenv putenv strcasecmp)
52AC_CHECK_FUNCS(usleep gettimeofday)
53
54AC_MSG_CHECKING(for Sleep)
55AC_TRY_COMPILE([#include <windows.h>],[Sleep(42);],
56 [AC_MSG_RESULT(yes)
57  AC_DEFINE(HAVE_SLEEP, 1, [Define if you have Windows' Sleep])],
58 [AC_MSG_RESULT(no)])
59AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
60
61CACA_DRIVERS=""
62
63if test "${enable_conio}" != "no"; then
64  ac_cv_my_have_conio="no"
65  AC_CHECK_HEADERS(conio.h,
66   [AC_MSG_CHECKING(for ScreenUpdate in pc.h)
67    AC_EGREP_HEADER(ScreenUpdate, pc.h,
68     [ac_cv_my_have_conio="yes"
69      AC_MSG_RESULT(yes)
70      AC_DEFINE(SCREENUPDATE_IN_PC_H, 1,
71                Define if <pc.h> defines ScreenUpdate.)
72      AC_DEFINE(USE_CONIO, 1, Define to activate the conio.h backend driver)
73      CACA_DRIVERS="${CACA_DRIVERS} conio"],
74     [AC_MSG_RESULT(no)])])
75  if test "${ac_cv_my_have_conio}" = "no" -a "${enable_conio}" = "yes"; then
76    AC_MSG_ERROR([cannot find conio.h])
77  fi
78fi
79
80if test "${enable_win32}" != "no"; then
81  ac_cv_my_have_win32="no"
82  AC_CHECK_HEADERS(windows.h,
83   [AC_MSG_CHECKING(for AllocConsole in windows.h)
84    AC_EGREP_HEADER(AllocConsole, windows.h,
85     [ac_cv_my_have_win32="yes"
86      AC_MSG_RESULT(yes)
87      AC_DEFINE(ALLOCCONSOLE_IN_WINDOWS_H, 1,
88                Define if <windows.h> defines AllocConsole.)
89      AC_DEFINE(USE_WIN32, 1, Define to activate the win32 backend driver)
90      CACA_DRIVERS="${CACA_DRIVERS} win32"],
91     [AC_MSG_RESULT(no)])])
92  if test "${ac_cv_my_have_win32}" = "no" -a "${enable_win32}" = "yes"; then
93    AC_MSG_ERROR([cannot find win32 console development files])
94  fi
95fi
96
97if test "${enable_slang}" != "no"; then
98  ac_cv_my_have_slang="no"
99  AC_CHECK_HEADERS(slang.h slang/slang.h,
100   [AC_CHECK_LIB(slang, SLkp_init,
101     [ac_cv_my_have_slang="yes"
102      AC_DEFINE(USE_SLANG, 1, Define to activate the slang backend driver)
103      CPPFLAGS="${CPPFLAGS} -DOPTIMISE_SLANG_PALETTE=1"
104      CACA_LIBS="${CACA_LIBS} -lslang"
105      CACA_DRIVERS="${CACA_DRIVERS} slang"])])
106  if test "${ac_cv_my_have_slang}" = "no" -a "${enable_slang}" = "yes"; then
107    AC_MSG_ERROR([cannot find slang development files])
108  fi
109fi
110
111if test "${enable_x11}" != "no"; then
112  AC_PATH_X
113  AC_CHECK_LIB(X11, XOpenDisplay,
114   [ac_cv_my_have_x11="yes"
115    if test -n "${x_includes}"; then X_CFLAGS="-I${x_includes}"; fi
116    if test -n "${x_libraries}"; then X_LIBS="-lX11 -L${x_libraries}"; fi
117    AC_DEFINE(USE_X11, 1, Define to activate the X11 backend driver)
118    CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
119    CACA_LIBS="${CACA_LIBS} ${X_LIBS}"
120    CACA_DRIVERS="${CACA_DRIVERS} x11"],
121   [ac_cv_my_have_x11="no"],
122   [[-lXt -L${x_libraries}]])
123  AC_CHECK_HEADERS(X11/XKBlib.h)
124  if test "${ac_cv_my_have_x11}" != "yes" -a "${enable_x11}" = "yes"; then
125    AC_MSG_ERROR([cannot find X11 development files])
126  fi
127fi
128
129if test "${enable_gl}" != "no"; then
130  ac_cv_my_have_gl="no"
131  AC_CHECK_HEADERS(GL/gl.h GL/glut.h,
132   [AC_CHECK_LIB(glut, glutMainLoopEvent,
133     [ac_cv_my_have_gl="yes"
134      AC_DEFINE(USE_GL, 1, Define to activate the OpenGL backend driver)
135      CACA_LIBS="${CACA_LIBS} -lGL -lglut"
136      CACA_DRIVERS="${CACA_DRIVERS} gl"])])
137  if test "${ac_cv_my_have_gl}" = "no" -a "${enable_gl}" = "yes"; then
138    AC_MSG_ERROR([cannot find OpenGL+FreeGLUT development files])
139  fi
140fi
141
142if test "${enable_network}" != "no"; then
143  ac_cv_my_have_network="no"
144  AC_CHECK_HEADERS(sys/socket.h,
145     [ac_cv_my_have_network="yes"
146      AC_DEFINE(USE_NETWORK, 1, Define to activate the network backend driver)
147      CACA_DRIVERS="${CACA_DRIVERS} network"])
148  if test "${ac_cv_my_have_network}" = "no" -a "${enable_network}" = "yes"; then
149    AC_MSG_ERROR([cannot find standard networking socket files])
150  fi
151fi
152
153if test "${enable_ncurses}" != "no"; then
154  ac_cv_my_have_ncurses="no"
155  AC_CHECK_HEADERS(curses.h ncurses.h,
156   [AC_CHECK_LIB(ncurses, initscr,
157     [ac_cv_my_have_ncurses="yes"
158      AC_DEFINE(USE_NCURSES, 1, Define to activate the ncurses backend driver)
159      CACA_LIBS="${CACA_LIBS} -lncurses"
160      CACA_DRIVERS="${CACA_DRIVERS} ncurses"
161      dnl  Check for resizeterm or resize_term
162      SAVED_LIBS="${LIBS}"
163      LIBS="${LIBS} -lncurses"
164      AC_CHECK_FUNCS(resizeterm resize_term)
165      LIBS="${SAVED_LIBS}"])])
166  if test "${ac_cv_my_have_ncurses}" = "no" -a "${enable_ncurses}" = "yes"; then
167    AC_MSG_ERROR([cannot find ncurses development files])
168  fi
169fi
170
171AC_MSG_CHECKING(valid output drivers)
172if test -z "${CACA_DRIVERS}"; then
173  AC_MSG_RESULT(no)
174  AC_MSG_ERROR([no output drivers were selected!])
175else
176  AC_MSG_RESULT([${CACA_DRIVERS}])
177fi
178
179AC_SUBST(MATH_LIBS)
180AC_SUBST(CACA_LIBS)
181AC_SUBST(CUCUL_LIBS)
182
183# Optimizations
184CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer"
185# Code qui fait des warnings == code de porc == deux baffes dans ta gueule
186# [Jylam] Removed -Wshadow in order to avoid ncurses/gl conflict
187# (Comme quoi on est pas les seuls porcs)
188CFLAGS="${CFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare"
189
190# Build the PIC library?
191case "${target_os}" in
192  *mingw32* | *cygwin* | *djgpp*)
193    NEED_PIC=false
194    ;;
195  *)
196    NEED_PIC=:
197    ;;
198esac
199AM_CONDITIONAL(NEED_PIC, ${NEED_PIC})
200
201# Use Imlib2?
202ac_cv_my_have_imlib2="no"
203save_CPPFLAGS="${CPPFLAGS}"
204if test "${enable_imlib2}" != "no"; then
205  AC_PATH_PROG(IMLIB2_CONFIG, imlib2-config, no)
206  if test "${IMLIB2_CONFIG}" != "no"; then
207    CPPFLAGS="${CPPFLAGS} `imlib2-config --cflags` -DX_DISPLAY_MISSING=1"
208  fi
209  AC_CHECK_HEADERS(Imlib2.h,
210    ac_cv_my_have_imlib2="yes",
211   [ac_cv_my_have_imlib2="no"
212    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'.]])])
213  CPPFLAGS="${save_CPPFLAGS}"
214fi
215AM_CONDITIONAL(USE_IMLIB2, test "${ac_cv_my_have_imlib2}" = "yes")
216
217# Build documentation?
218DOXYGEN="no"
219LATEX="no"
220if test "${enable_doc}" != "no"; then
221  AC_PATH_PROG(DOXYGEN, doxygen, no)
222  if test "${DOXYGEN}" = "no"; then
223    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'.]])
224  fi
225
226  # Build LaTeX documentation?
227  AC_PATH_PROG(LATEX, latex, no)
228  AC_PATH_PROG(DVIPS, dvips, no)
229  if test "${DVIPS}" = "no"; then
230    LATEX="no"
231  fi
232  AC_MSG_CHECKING(for a4wide.sty)
233  if test -f /usr/share/texmf/tex/latex/misc/a4wide.sty; then
234    AC_MSG_RESULT(yes)
235  elif test -f /usr/share/texmf-tetex/tex/latex/a4wide/a4wide.sty; then
236    AC_MSG_RESULT(yes)
237  else
238    LATEX="no"
239    AC_MSG_RESULT(no)
240  fi
241fi
242AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
243AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no")
244
245AC_CONFIG_FILES([
246  Makefile
247  cucul/Makefile
248  caca/Makefile
249  src/Makefile
250  test/Makefile
251  doc/Makefile
252  doc/doxygen.cfg
253  autotools/Makefile
254  debian/Makefile
255  msvc/Makefile
256])
257AC_CONFIG_FILES([caca-config], [chmod 0755 caca-config])
258AC_OUTPUT
259
Note: See TracBrowser for help on using the repository browser.