source: libcaca/trunk/configure.ac @ 704

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