source: libcaca/trunk/configure.ac @ 284

Last change on this file since 284 was 284, checked in by Sam Hocevar, 16 years ago
  • configure.ac: + Autodetect ncurses, slang and X11. + Abort if no output driver was selected or detected.
  • Property svn:keywords set to Id
File size: 4.6 KB
Line 
1# $Id: configure.ac 284 2003-12-25 23:22:13Z 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.5)
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 (default enabled)])
22AC_ARG_ENABLE(ncurses,
23  [  --enable-ncurses        ncurses graphics support (default enabled)])
24AC_ARG_ENABLE(conio,
25  [  --enable-conio          DOS conio.h graphics support (default disabled)])
26AC_ARG_ENABLE(x11,
27  [  --enable-x11            X11 support (default disabled) (default enabled)])
28
29AC_CHECK_HEADERS(inttypes.h endian.h)
30AC_CHECK_FUNCS(vsnprintf getenv putenv strcasecmp)
31
32CACA_DRIVERS=""
33
34if test "${enable_conio}" = "yes"; then
35  AC_CHECK_HEADERS(conio.h,:,AC_MSG_ERROR([cannot find conio.h header]))
36  AC_MSG_CHECKING(for ScreenUpdate in pc.h)
37  AC_EGREP_HEADER(ScreenUpdate,pc.h,
38   [AC_MSG_RESULT(yes)
39    AC_DEFINE(SCREENUPDATE_IN_PC_H, 1,
40              Define if <pc.h> defines ScreenUpdate.)],
41   [AC_MSG_RESULT(no)])
42  CACA_DRIVERS="${CACA_DRIVERS} conio"
43  AC_DEFINE(USE_CONIO, 1, Define to activate the conio.h backend driver)
44fi
45
46if test "${enable_slang}" != "no"; then
47  AC_CHECK_HEADERS(slang.h,
48   [AC_CHECK_LIB(slang, SLkp_init,
49     [ac_cv_my_have_slang="yes"
50      AC_DEFINE(USE_SLANG, 1, Define to activate the slang backend driver)
51      CPPFLAGS="${CPPFLAGS} -DOPTIMISE_SLANG_PALETTE=1"
52      CACA_LIBS="${CACA_LIBS} -lslang"
53      CACA_DRIVERS="${CACA_DRIVERS} slang"],
54     [ac_cv_my_have_slang="no"])],
55   [ac_cv_my_have_slang="no"])
56  if test "${ac_cv_my_have_slang}" = "no" -a "${enable_slang}" = "yes"; then
57    AC_MSG_ERROR([cannot find slang development files])
58  fi
59fi
60
61if test "${enable_x11}" != "no"; then
62  AC_PATH_X
63  AC_CHECK_LIB(X11, XOpenDisplay,
64   [ac_cv_my_have_x11="yes"
65    if test -n "${x_includes}"; then X_CFLAGS="-I${x_includes}"; fi
66    if test -n "${x_libraries}"; then X_LIBS="-lX11 -L${x_libraries}"; fi
67    AC_DEFINE(USE_X11, 1, Define to activate the X11 backend driver)
68    CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
69    CACA_LIBS="${CACA_LIBS} ${X_LIBS}"
70    CACA_DRIVERS="${CACA_DRIVERS} x11"],
71   [ac_cv_my_have_x11="no"],
72   [[-lXt -L${x_libraries}]])
73  if test "${ac_cv_my_have_x11}" != "yes" -a "${enable_x11}" = "yes"; then
74    AC_MSG_ERROR([cannot find X11 development files])
75  fi
76fi
77
78if test "${enable_ncurses}" != "no"; then
79  AC_CHECK_HEADERS(ncurses.h,
80   [AC_CHECK_LIB(ncurses, initscr,
81     [ac_cv_my_have_ncurses="yes"
82      AC_DEFINE(USE_NCURSES, 1, Define to activate the ncurses backend driver)
83      CACA_LIBS="${CACA_LIBS} -lncurses"
84      CACA_DRIVERS="${CACA_DRIVERS} ncurses"],
85     [ac_cv_my_have_ncurses="no"])],
86   [ac_cv_my_have_ncurses="no"])
87  if test "${ac_cv_my_have_ncurses}" = "no" -a "${enable_ncurses}" = "yes"; then
88    AC_MSG_ERROR([cannot find ncurses development files])
89  fi
90fi
91
92AC_MSG_CHECKING(valid output drivers)
93if test -z "${CACA_DRIVERS}"; then
94  AC_MSG_RESULT(no)
95  AC_MSG_ERROR([no output drivers were selected!])
96else
97  AC_MSG_RESULT([${CACA_DRIVERS}])
98fi
99
100AC_SUBST(CACA_LIBS)
101
102# Optimizations
103CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer"
104# Code qui fait des warnings == code de porc == deux baffes dans ta gueule
105CFLAGS="${CFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare"
106
107# Build the PIC library?
108case "${target_os}" in
109  *mingw32* | *cygwin* | *djgpp*)
110    NEED_PIC=false
111    ;;
112  *)
113    NEED_PIC=:
114    ;;
115esac
116AM_CONDITIONAL(NEED_PIC, ${NEED_PIC})
117
118# Build cacaview?
119save_CPPFLAGS="${CPPFLAGS}"
120AC_PATH_PROG(IMLIB2_CONFIG, imlib2-config, no)
121if test "${IMLIB2_CONFIG}" != "no"; then
122  CPPFLAGS="${CPPFLAGS} `imlib2-config --cflags` -DX_DISPLAY_MISSING=1"
123fi
124AC_CHECK_HEADERS(Imlib2.h, USE_IMLIB2=:, USE_IMLIB2=false)
125CPPFLAGS="${save_CPPFLAGS}"
126AM_CONDITIONAL(USE_IMLIB2, ${USE_IMLIB2})
127
128# Build documentation?
129AC_PATH_PROG(DOXYGEN, doxygen, no)
130AM_CONDITIONAL(DOXYGEN, test "${DOXYGEN}" != "no")
131
132# Build LaTeX documentation?
133AC_PATH_PROG(LATEX, latex, no)
134AC_MSG_CHECKING(for a4wide.sty)
135if test -f /usr/share/texmf/tex/latex/misc/a4wide.sty; then
136  AC_MSG_RESULT(yes)
137else
138  LATEX=no
139  AC_MSG_RESULT(no)
140fi
141AM_CONDITIONAL(LATEX, test "${LATEX}" != "no")
142
143AC_CONFIG_FILES([
144  Makefile
145  src/Makefile
146  examples/Makefile
147  doc/Makefile
148  doc/doxygen.cfg
149  autotools/Makefile
150  debian/Makefile
151])
152AC_CONFIG_FILES([caca-config], [chmod 0755 caca-config])
153AC_OUTPUT
154
Note: See TracBrowser for help on using the repository browser.