source: libcaca/trunk/configure.ac @ 346

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