source: libcaca/trunk/configure.ac @ 338

Last change on this file since 338 was 338, checked in by Sam Hocevar, 16 years ago
  • configure.ac: + Better win32 check for Sleep().
  • Property svn:keywords set to Id
File size: 6.2 KB
Line 
1# $Id: configure.ac 338 2004-01-12 14:01:40Z sam $
2
3AC_INIT(src/caca.c)
4
5AC_PREREQ(2.50)
6AC_CONFIG_AUX_DIR(autotools)
7AC_CANONICAL_SYSTEM
8
9AM_INIT_AUTOMAKE(libcaca, 0.7)
10AM_CONFIG_HEADER(config.h)
11
12AM_PROG_CC_C_O
13AC_PROG_CPP
14AC_PROG_RANLIB
15
16dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
17dnl now otherwise it might be set in an obscure if statement.
18AC_EGREP_CPP(foo, foo)
19
20AC_ARG_ENABLE(slang,
21  [  --enable-slang          slang graphics support (autodetected)])
22AC_ARG_ENABLE(ncurses,
23  [  --enable-ncurses        ncurses graphics support (autodetected)])
24AC_ARG_ENABLE(win32,
25  [  --enable-win32          Windows console support (autodetected)])
26AC_ARG_ENABLE(conio,
27  [  --enable-conio          DOS conio.h graphics support (autodetected)])
28AC_ARG_ENABLE(x11,
29  [  --enable-x11            X11 support (autodetected)])
30
31AC_CHECK_HEADERS(inttypes.h endian.h)
32AC_CHECK_FUNCS(vsnprintf getenv putenv strcasecmp usleep gettimeofday)
33AC_MSG_CHECKING(for Sleep)
34AC_TRY_COMPILE([#include <windows.h>],[Sleep(42);],
35 [AC_MSG_RESULT(yes)
36  AC_DEFINE(HAVE_SLEEP, 1, [Define if you have Windows' Sleep])],
37 [AC_MSG_RESULT(no)])
38AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
39
40CACA_DRIVERS=""
41
42if test "${enable_conio}" != "no"; then
43  ac_cv_my_have_conio="no"
44  AC_CHECK_HEADERS(conio.h,
45   [AC_MSG_CHECKING(for ScreenUpdate in pc.h)
46    AC_EGREP_HEADER(ScreenUpdate, pc.h,
47     [ac_cv_my_have_conio="yes"
48      AC_MSG_RESULT(yes)
49      AC_DEFINE(SCREENUPDATE_IN_PC_H, 1,
50                Define if <pc.h> defines ScreenUpdate.)
51      AC_DEFINE(USE_CONIO, 1, Define to activate the conio.h backend driver)
52      CACA_DRIVERS="${CACA_DRIVERS} conio"],
53     [AC_MSG_RESULT(no)])])
54  if test "${ac_cv_my_have_conio}" = "no" -a "${enable_conio}" = "yes"; then
55    AC_MSG_ERROR([cannot find conio.h])
56  fi
57fi
58
59if test "${enable_win32}" != "no"; then
60  ac_cv_my_have_win32="no"
61  AC_CHECK_HEADERS(windows.h,
62   [AC_MSG_CHECKING(for AllocConsole in windows.h)
63    AC_EGREP_HEADER(AllocConsole, windows.h,
64     [ac_cv_my_have_win32="yes"
65      AC_MSG_RESULT(yes)
66      AC_DEFINE(ALLOCCONSOLE_IN_WINDOWS_H, 1,
67                Define if <windows.h> defines AllocConsole.)
68      AC_DEFINE(USE_WIN32, 1, Define to activate the win32 backend driver)
69      CACA_DRIVERS="${CACA_DRIVERS} win32"],
70     [AC_MSG_RESULT(no)])])
71  if test "${ac_cv_my_have_win32}" = "no" -a "${enable_win32}" = "yes"; then
72    AC_MSG_ERROR([cannot find win32 console development files])
73  fi
74fi
75
76if test "${enable_slang}" != "no"; then
77  ac_cv_my_have_slang="no"
78  AC_CHECK_HEADERS(slang.h slang/slang.h,
79   [AC_CHECK_LIB(slang, SLkp_init,
80     [ac_cv_my_have_slang="yes"
81      AC_DEFINE(USE_SLANG, 1, Define to activate the slang backend driver)
82      CPPFLAGS="${CPPFLAGS} -DOPTIMISE_SLANG_PALETTE=1"
83      CACA_LIBS="${CACA_LIBS} -lslang"
84      CACA_DRIVERS="${CACA_DRIVERS} slang"])])
85  if test "${ac_cv_my_have_slang}" = "no" -a "${enable_slang}" = "yes"; then
86    AC_MSG_ERROR([cannot find slang development files])
87  fi
88fi
89
90if test "${enable_x11}" != "no"; then
91  AC_PATH_X
92  AC_CHECK_LIB(X11, XOpenDisplay,
93   [ac_cv_my_have_x11="yes"
94    if test -n "${x_includes}"; then X_CFLAGS="-I${x_includes}"; fi
95    if test -n "${x_libraries}"; then X_LIBS="-lX11 -L${x_libraries}"; fi
96    AC_DEFINE(USE_X11, 1, Define to activate the X11 backend driver)
97    CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
98    CACA_LIBS="${CACA_LIBS} ${X_LIBS}"
99    CACA_DRIVERS="${CACA_DRIVERS} x11"],
100   [ac_cv_my_have_x11="no"],
101   [[-lXt -L${x_libraries}]])
102  AC_CHECK_HEADERS(X11/XKBlib.h)
103  if test "${ac_cv_my_have_x11}" != "yes" -a "${enable_x11}" = "yes"; then
104    AC_MSG_ERROR([cannot find X11 development files])
105  fi
106fi
107
108if test "${enable_ncurses}" != "no"; then
109  ac_cv_my_have_ncurses="no"
110  AC_CHECK_HEADERS(ncurses.h,
111   [AC_CHECK_LIB(ncurses, initscr,
112     [ac_cv_my_have_ncurses="yes"
113      AC_DEFINE(USE_NCURSES, 1, Define to activate the ncurses backend driver)
114      CACA_LIBS="${CACA_LIBS} -lncurses"
115      CACA_DRIVERS="${CACA_DRIVERS} ncurses"])])
116  if test "${ac_cv_my_have_ncurses}" = "no" -a "${enable_ncurses}" = "yes"; then
117    AC_MSG_ERROR([cannot find ncurses development files])
118  fi
119fi
120
121AC_MSG_CHECKING(valid output drivers)
122if test -z "${CACA_DRIVERS}"; then
123  AC_MSG_RESULT(no)
124  AC_MSG_ERROR([no output drivers were selected!])
125else
126  AC_MSG_RESULT([${CACA_DRIVERS}])
127fi
128
129AC_SUBST(MATH_LIBS)
130AC_SUBST(CACA_LIBS)
131
132# Optimizations
133CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer"
134# Code qui fait des warnings == code de porc == deux baffes dans ta gueule
135CFLAGS="${CFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare"
136
137# Build the PIC library?
138case "${target_os}" in
139  *mingw32* | *cygwin* | *djgpp*)
140    NEED_PIC=false
141    ;;
142  *)
143    NEED_PIC=:
144    ;;
145esac
146AM_CONDITIONAL(NEED_PIC, ${NEED_PIC})
147
148# Use Imlib2?
149ac_cv_my_have_imlib2="no"
150AC_ARG_ENABLE(imlib2,
151  [  --enable-imlib2         Imlib2 graphics support (default enabled)])
152save_CPPFLAGS="${CPPFLAGS}"
153if test "${enable_imlib2}" != "no"; then
154  AC_PATH_PROG(IMLIB2_CONFIG, imlib2-config, no)
155  if test "${IMLIB2_CONFIG}" != "no"; then
156    CPPFLAGS="${CPPFLAGS} `imlib2-config --cflags` -DX_DISPLAY_MISSING=1"
157  fi
158  AC_CHECK_HEADERS(Imlib2.h,
159    ac_cv_my_have_imlib2="yes",
160   [ac_cv_my_have_imlib2="no"
161    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'.]])])
162  CPPFLAGS="${save_CPPFLAGS}"
163fi
164AM_CONDITIONAL(USE_IMLIB2, test "${ac_cv_my_have_imlib2}" = "yes")
165
166# Build documentation?
167AC_PATH_PROG(DOXYGEN, doxygen, no)
168AM_CONDITIONAL(DOXYGEN, test "${DOXYGEN}" != "no")
169
170# Build LaTeX documentation?
171AC_PATH_PROG(LATEX, latex, no)
172AC_PATH_PROG(DVIPS, dvips, no)
173if test "${DVIPS}" = "no"; then
174  LATEX="no"
175fi
176AC_MSG_CHECKING(for a4wide.sty)
177if test -f /usr/share/texmf/tex/latex/misc/a4wide.sty; then
178  AC_MSG_RESULT(yes)
179else
180  LATEX="no"
181  AC_MSG_RESULT(no)
182fi
183AM_CONDITIONAL(LATEX, test "${LATEX}" != "no")
184
185AC_CONFIG_FILES([
186  Makefile
187  src/Makefile
188  examples/Makefile
189  test/Makefile
190  doc/Makefile
191  doc/doxygen.cfg
192  autotools/Makefile
193  debian/Makefile
194])
195AC_CONFIG_FILES([caca-config], [chmod 0755 caca-config])
196AC_OUTPUT
197
Note: See TracBrowser for help on using the repository browser.