source: libcaca/trunk/configure.ac @ 652

Last change on this file since 652 was 652, checked in by Sam Hocevar, 14 years ago
  • Use the asm versions of sin and cos when available.
  • Property svn:keywords set to Id
File size: 9.4 KB
Line 
1# $Id: configure.ac 652 2006-03-21 09:48:02Z 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)])
62AC_MSG_CHECKING(for fsin/fcos)
63AC_TRY_COMPILE([],[asm("fsin\n\tfcos");],
64 [AC_MSG_RESULT(yes)
65  AC_DEFINE(HAVE_FSIN_FCOS, 1, [Define to 1 if you have the `fsin' and `fcos' operands.])],
66 [AC_MSG_RESULT(no)])
67AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
68
69CACA_DRIVERS=""
70
71if test "${enable_conio}" != "no"; then
72  ac_cv_my_have_conio="no"
73  AC_CHECK_HEADERS(conio.h,
74   [AC_MSG_CHECKING(for ScreenUpdate in pc.h)
75    AC_EGREP_HEADER(ScreenUpdate, pc.h,
76     [ac_cv_my_have_conio="yes"
77      AC_MSG_RESULT(yes)
78      AC_DEFINE(SCREENUPDATE_IN_PC_H, 1,
79                Define to 1 if <pc.h> defines ScreenUpdate.)
80      AC_DEFINE(USE_CONIO, 1, Define to 1 to activate the conio.h backend driver)
81      CACA_DRIVERS="${CACA_DRIVERS} conio"],
82     [AC_MSG_RESULT(no)])])
83  if test "${ac_cv_my_have_conio}" = "no" -a "${enable_conio}" = "yes"; then
84    AC_MSG_ERROR([cannot find conio.h])
85  fi
86fi
87
88if test "${enable_win32}" != "no"; then
89  ac_cv_my_have_win32="no"
90  AC_CHECK_HEADERS(windows.h,
91   [AC_MSG_CHECKING(for AllocConsole in windows.h)
92    AC_EGREP_HEADER(AllocConsole, windows.h,
93     [ac_cv_my_have_win32="yes"
94      AC_MSG_RESULT(yes)
95      AC_DEFINE(ALLOCCONSOLE_IN_WINDOWS_H, 1,
96                Define to 1 if <windows.h> defines AllocConsole.)
97      AC_DEFINE(USE_WIN32, 1, Define to 1 to activate the win32 backend driver)
98      CACA_DRIVERS="${CACA_DRIVERS} win32"],
99     [AC_MSG_RESULT(no)])])
100  if test "${ac_cv_my_have_win32}" = "no" -a "${enable_win32}" = "yes"; then
101    AC_MSG_ERROR([cannot find win32 console development files])
102  fi
103fi
104
105if test "${enable_slang}" != "no"; then
106  ac_cv_my_have_slang="no"
107  AC_CHECK_HEADERS(slang.h slang/slang.h,
108   [ac_cv_my_have_slang="yes"
109    AC_DEFINE(USE_SLANG, 1, Define to 1 to activate the slang backend driver)
110    AC_CHECK_LIB(slang, SLsmg_utf8_enable,
111     [AC_DEFINE(HAVE_SLSMG_UTF8_ENABLE, 1, Define to 1 if you have the `SLsmg_utf8_enable' function.)])
112    CPPFLAGS="${CPPFLAGS} -DOPTIMISE_SLANG_PALETTE=1"
113    CACA_LIBS="${CACA_LIBS} -lslang"
114    CACA_DRIVERS="${CACA_DRIVERS} slang"
115    break])
116  if test "${ac_cv_my_have_slang}" = "no" -a "${enable_slang}" = "yes"; then
117    AC_MSG_ERROR([cannot find slang development files])
118  fi
119fi
120
121if test "${enable_x11}" != "no"; then
122  AC_PATH_X
123  AC_CHECK_LIB(X11, XOpenDisplay,
124   [ac_cv_my_have_x11="yes"
125    if test -n "${x_includes}"; then X_CFLAGS="-I${x_includes}"; fi
126    if test -n "${x_libraries}"; then X_LIBS="-lX11 -L${x_libraries}"; fi
127    AC_DEFINE(USE_X11, 1, Define to 1 to activate the X11 backend driver)
128    CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
129    CACA_LIBS="${CACA_LIBS} ${X_LIBS}"
130    CACA_DRIVERS="${CACA_DRIVERS} x11"],
131   [ac_cv_my_have_x11="no"],
132   [[-lXt -L${x_libraries}]])
133  AC_CHECK_HEADERS(X11/XKBlib.h)
134  if test "${ac_cv_my_have_x11}" != "yes" -a "${enable_x11}" = "yes"; then
135    AC_MSG_ERROR([cannot find X11 development files])
136  fi
137fi
138
139if test "${enable_gl}" != "no"; then
140  ac_cv_my_have_gl="no"
141  AC_CHECK_HEADERS(GL/gl.h,
142   [AC_CHECK_HEADERS(GL/glut.h,
143     [AC_CHECK_LIB(glut, glutMainLoopEvent,
144       [ac_cv_my_have_gl="yes"
145        AC_DEFINE(USE_GL, 1, Define to 1 to activate the OpenGL backend driver)
146        CACA_LIBS="${CACA_LIBS} -lGL -lglut"
147        CACA_DRIVERS="${CACA_DRIVERS} gl"])])])
148  if test "${ac_cv_my_have_gl}" = "no" -a "${enable_gl}" = "yes"; then
149    AC_MSG_ERROR([cannot find OpenGL+FreeGLUT development files])
150  fi
151fi
152
153if test "${enable_network}" != "no"; then
154  ac_cv_my_have_network="no"
155  AC_CHECK_HEADERS(sys/socket.h,
156     [ac_cv_my_have_network="yes"
157      AC_DEFINE(USE_NETWORK, 1, Define to 1 to activate the network backend driver)
158      CACA_DRIVERS="${CACA_DRIVERS} network"])
159  if test "${ac_cv_my_have_network}" = "no" -a "${enable_network}" = "yes"; then
160    AC_MSG_ERROR([cannot find standard networking socket files])
161  fi
162fi
163
164if test "${enable_ncurses}" != "no"; then
165  ac_cv_my_have_ncurses="no"
166  AC_CHECK_HEADERS(ncursesw/ncurses.h ncurses/ncurses.h ncurses.h curses.h,
167   [ncurses="no"
168    AC_CHECK_LIB(ncursesw, initscr,
169     [ncurses="-lncursesw"],
170     [AC_CHECK_LIB(ncurses, initscr,
171       [ncurses="-lncurses"])])
172    if test "${ncurses}" = "no"; then
173      continue
174    fi
175    ac_cv_my_have_ncurses="yes"
176    AC_DEFINE(USE_NCURSES, 1, Define to 1 to activate the ncurses backend driver)
177    CACA_LIBS="${CACA_LIBS} ${ncurses}"
178    CACA_DRIVERS="${CACA_DRIVERS} ncurses"
179    dnl  Check for resizeterm or resize_term
180    SAVED_LIBS="${LIBS}"
181    LIBS="${LIBS} ${ncurses}"
182    AC_CHECK_FUNCS(resizeterm resize_term)
183    LIBS="${SAVED_LIBS}"
184    break])
185  if test "${ac_cv_my_have_ncurses}" = "no" -a "${enable_ncurses}" = "yes"; then
186    AC_MSG_ERROR([cannot find ncurses development files])
187  fi
188fi
189
190if test "${enable_vga}" = "yes"; then
191  ac_cv_my_have_vga="yes"
192  CPPFLAGS="${CPPFLAGS} -I. -D__KERNEL__ -nostdinc -include kernel/kernel.h"
193  CFLAGS="${CFLAGS} -fno-builtin -O2 -Wall"
194  CCASFLAGS="${CCASFLAGS} -I."
195  LDFLAGS="${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,100000"
196  AC_DEFINE(USE_VGA, 1, Define to 1 to activate the VGA backend driver)
197  CACA_DRIVERS="${CACA_DRIVERS} vga"
198fi
199AM_CONDITIONAL(USE_KERNEL, test "${ac_cv_my_have_vga}" = "yes")
200
201AC_MSG_CHECKING(valid output drivers)
202if test -z "${CACA_DRIVERS}"; then
203  AC_MSG_RESULT(no)
204  AC_MSG_ERROR([no output drivers were selected!])
205else
206  AC_MSG_RESULT([${CACA_DRIVERS}])
207fi
208
209AC_SUBST(MATH_LIBS)
210AC_SUBST(CACA_LIBS)
211AC_SUBST(CUCUL_LIBS)
212
213# Optimizations
214CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer"
215# Code qui fait des warnings == code de porc == deux baffes dans ta gueule
216# [Jylam] Removed -Wshadow in order to avoid ncurses/gl conflict
217# (Comme quoi on est pas les seuls porcs)
218CFLAGS="${CFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare"
219
220# Build the PIC library?
221case "${target_os}" in
222  *mingw32* | *cygwin* | *djgpp*)
223    NEED_PIC=false
224    ;;
225  *)
226    NEED_PIC=:
227    ;;
228esac
229AM_CONDITIONAL(NEED_PIC, ${NEED_PIC})
230
231# Use Imlib2?
232ac_cv_my_have_imlib2="no"
233save_CPPFLAGS="${CPPFLAGS}"
234if test "${enable_imlib2}" != "no"; then
235  AC_PATH_PROG(IMLIB2_CONFIG, imlib2-config, no)
236  if test "${IMLIB2_CONFIG}" != "no"; then
237    CPPFLAGS="${CPPFLAGS} `imlib2-config --cflags` -DX_DISPLAY_MISSING=1"
238  fi
239  AC_CHECK_HEADERS(Imlib2.h,
240    ac_cv_my_have_imlib2="yes",
241   [ac_cv_my_have_imlib2="no"
242    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'.]])])
243  CPPFLAGS="${save_CPPFLAGS}"
244fi
245AM_CONDITIONAL(USE_IMLIB2, test "${ac_cv_my_have_imlib2}" = "yes")
246
247# Build documentation?
248DOXYGEN="no"
249LATEX="no"
250if test "${enable_doc}" != "no"; then
251  AC_PATH_PROG(DOXYGEN, doxygen, no)
252  if test "${DOXYGEN}" = "no"; then
253    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'.]])
254  fi
255
256  # Build LaTeX documentation?
257  AC_PATH_PROG(LATEX, latex, no)
258  AC_PATH_PROG(DVIPS, dvips, no)
259  if test "${DVIPS}" = "no"; then
260    LATEX="no"
261  fi
262  AC_MSG_CHECKING(for a4wide.sty)
263  if test -f /usr/share/texmf/tex/latex/misc/a4wide.sty; then
264    AC_MSG_RESULT(yes)
265  elif test -f /usr/share/texmf-tetex/tex/latex/a4wide/a4wide.sty; then
266    AC_MSG_RESULT(yes)
267  else
268    LATEX="no"
269    AC_MSG_RESULT(no)
270  fi
271fi
272AM_CONDITIONAL(BUILD_DOCUMENTATION, test "${DOXYGEN}" != "no")
273AM_CONDITIONAL(USE_LATEX, test "${LATEX}" != "no")
274
275AC_CONFIG_FILES([
276  Makefile
277  kernel/Makefile
278  cucul/Makefile
279  caca/Makefile
280  src/Makefile
281  test/Makefile
282  doc/Makefile
283  doc/doxygen.cfg
284  autotools/Makefile
285  debian/Makefile
286  msvc/Makefile
287])
288AC_CONFIG_FILES([caca-config], [chmod 0755 caca-config])
289AC_OUTPUT
290
Note: See TracBrowser for help on using the repository browser.