source: libcaca/trunk/configure.ac @ 545

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