source: libcaca/trunk/configure.ac @ 364

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