source: libcaca/trunk/configure.ac @ 475

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