chiark / gitweb /
@@@ tty commentary
[mLib] / configure.ac
1 dnl -*-autoconf-*-
2 dnl
3 dnl Configuration script for mLib
4 dnl
5 dnl (c) 2008 Straylight/Edgeware
6 dnl
7
8 dnl----- Licensing notice ---------------------------------------------------
9 dnl
10 dnl This file is part of the mLib utilities library.
11 dnl
12 dnl mLib is free software; you can redistribute it and/or modify
13 dnl it under the terms of the GNU Library General Public License as
14 dnl published by the Free Software Foundation; either version 2 of the
15 dnl License, or (at your option) any later version.
16 dnl
17 dnl mLib is distributed in the hope that it will be useful,
18 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
19 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 dnl GNU Library General Public License for more details.
21 dnl
22 dnl You should have received a copy of the GNU Library General Public
23 dnl License along with mLib; if not, write to the Free
24 dnl Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 dnl MA 02111-1307, USA.
26
27 dnl--------------------------------------------------------------------------
28 dnl Initialization.
29
30 mdw_AUTO_VERSION
31 AC_INIT([mLib], AUTO_VERSION, [mdw@distorted.org.uk], [mLib])
32 AC_CONFIG_SRCDIR([mLib.pc.in])
33 AC_CONFIG_AUX_DIR([config])
34 AM_INIT_AUTOMAKE([foreign subdir-objects])
35 mdw_SILENT_RULES
36
37 AC_PROG_CC
38 AM_PROG_CC_C_O
39 LT_INIT
40 AX_CFLAGS_WARN_ALL
41 mdw_LIBTOOL_VERSION_INFO
42
43 AC_CHECK_PROGS([AUTOM4TE], [autom4te])
44
45 mdw_MANEXT([mLib])
46
47 AC_DEFINE_UNQUOTED([SRCDIR], ["$(cd $srcdir && pwd)"],
48                    [absolute pathname for the source directory.])
49
50 dnl--------------------------------------------------------------------------
51 dnl C programming environment.
52
53 dnl Set the master library list.
54 MLIB_LIBS=
55 AC_SUBST([MLIB_LIBS])
56
57 dnl Headers.
58 AC_CHECK_HEADERS([float.h])
59 AC_CHECK_HEADERS([stdint.h])
60 AC_CHECK_HEADERS([valgrind/valgrind.h])
61 AC_CHECK_HEADERS([wchar.h])
62
63 dnl Libraries.
64 mdw_ORIG_LIBS=$LIBS LIBS=$MLIB_LIBS
65 AC_SEARCH_LIBS([sqrt], [m])
66 AC_SEARCH_LIBS([socket], [socket])
67 AC_SEARCH_LIBS([gethostbyname], [nsl resolv])
68 MLIB_LIBS=$LIBS LIBS=$mdw_ORIG_LIBS
69
70 dnl Functions.
71 AC_CHECK_FUNCS([mbrtowc])
72 AC_CHECK_FUNCS([snprintf])
73 AC_CHECK_FUNCS([wcwidth])
74
75 dnl Types.
76 AC_CHECK_TYPE([socklen_t], [],
77   [AC_DEFINE([socklen_t], [int],
78      [Define to `int' if <sys/socket.h> does not define])],
79   [AC_INCLUDES_DEFAULT
80 @%:@include <sys/socket.h>
81 ])
82 AC_CHECK_TYPE([speed_t], [],
83   [AC_DEFINE([speed_t], [short],
84     [Define to `short' if <termios.h> does not define])],
85   [AC_INCLUDES_DEFAULT
86 @%:@include <termios.h>
87 ])
88
89 dnl Which version of struct msghdr do we have?
90 AC_CHECK_MEMBERS([struct msgdr.msg_control],,, [
91 @%:@include <sys/types.h>
92 @%:@include <sys/socket.h>
93 ])
94
95 dnl Find out whether we're cross-compiling.
96 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
97
98 dnl Floating-point formats.
99 mdw_PROBE_FLTFMT
100
101 dnl--------------------------------------------------------------------------
102 dnl Terminal characteristics.
103
104 mdw_ORIG_LIBS=$LIBS LIBS=$MLIB_LIBS
105
106 AC_ARG_WITH([unibilium],
107   AS_HELP_STRING([--with-unibilium], [support `unibilium' library]),
108   [want_unibilium=$withval],
109   [want_unibilium=auto])
110
111 case $want_unibilium in
112   no) have_unibilium=no ;;
113   *) have_unibilium=check ;;
114 esac
115 case $have_unibilium in
116   check)
117     PKG_CHECK_MODULES([unibilium], [unibilium >= 2.0.0],
118       [CFLAGS="$CFLAGS $unibilium_CFLAGS"
119        LIBS="$LIBS $unibilium_LIBS"],
120       [have_unibilium=no])
121     ;;
122 esac
123
124 case $have_unibilium in check) have_unibilium=yes ;; esac
125 case $want_unibilium,$have_unibilium in
126   yes,no)
127     AC_MSG_ERROR([`unibilium' library not found but explicitly requested])
128     ;;
129   yes,yes | auto,yes)
130     use_unibilium=yes
131     AC_DEFINE([HAVE_UNIBILIUM], [1],
132               [define if you have (and want to use) the `unibilium' library.])
133     ;;
134   no,* | auto,no)
135     use_unibilium=no
136     ;;
137 esac
138 AM_CONDITIONAL([WITH_UNIBILIUM], [test "$use_unibilium" = yes])
139
140 AC_ARG_WITH([terminfo],
141   AS_HELP_STRING([--with-terminfo], [support `terminfo' library]),
142   [want_terminfo=$withval],
143   [want_terminfo=auto])
144
145 case $want_terminfo in
146   no) have_terminfo=no ;;
147   *) have_terminfo=check ;;
148 esac
149 case $have_terminfo in
150   check) AC_CHECK_HEADERS([term.h], [], [have_terminfo=no]) ;;
151 esac
152 case $have_terminfo in
153   check)
154     AC_SEARCH_LIBS([tparm], [tinfo], [], [have_terminfo=no])
155     AC_CHECK_FUNCS([tiparm])
156     ;;
157 esac
158 case $have_terminfo in check) have_terminfo=yes ;; esac
159
160 case $want_terminfo,$have_terminfo in
161   yes,no)
162     AC_MSG_ERROR([`terminfo' library not found but explicitly requested])
163     ;;
164   yes,yes | auto,yes)
165     use_terminfo=yes
166     AC_DEFINE([HAVE_TERMINFO], [1],
167               [define if you have (and want to use) the `terminfo' library.])
168     ;;
169   no,* | auto,no)
170     use_terminfo=no
171     ;;
172 esac
173 AM_CONDITIONAL([WITH_TERMINFO], [test "$use_terminfo" = yes])
174
175 AC_ARG_WITH([termcap],
176   AS_HELP_STRING([--with-termcap], [support `termcap' library]),
177   [want_termcap=$withval],
178   [want_termcap=auto])
179
180 case $want_termcap in
181   no) have_termcap=no ;;
182   *) have_termcap=check ;;
183 esac
184 case $have_termcap in
185   check) AC_CHECK_HEADERS([termcap.h], [], [have_termcap=no]) ;;
186 esac
187 case $have_termcap in
188   check)
189     AC_SEARCH_LIBS([tgoto], [termcap], [], [have_termcap=no])
190     AC_SEARCH_LIBS([tgetstr], [termcap], [], [have_termcap=no])
191     ;;
192 esac
193 case $have_termcap in check) have_termcap=yes ;; esac
194
195 case $want_termcap,$have_termcap in
196   yes,no)
197     AC_MSG_ERROR([`termcap' library not found but explicitly requested])
198     ;;
199   yes,yes | auto,yes)
200     use_termcap=yes
201     AC_DEFINE([HAVE_TERMCAP], [1],
202               [define if you have (and want to use) the `termcap' library.])
203     ;;
204   no,* | auto,no)
205     use_termcap=no
206     ;;
207 esac
208 AM_CONDITIONAL([WITH_TERMCAP], [test "$use_termcap" = yes])
209
210 MLIB_LIBS=$LIBS LIBS=$mdw_ORIG_LIBS
211
212 dnl--------------------------------------------------------------------------
213 dnl Name resolution.
214
215 AC_ARG_WITH([adns],
216   AS_HELP_STRING([--with-adns],
217                  [use ADNS library for background name resolution]),
218   [want_adns=$withval],
219   [want_adns=auto])
220
221 mdw_ORIG_LIBS=$LIBS LIBS=$MLIB_LIBS
222
223 case $want_adns in no) ;; *) have_adns=check ;; esac
224 case $have_adns in
225   check) AC_CHECK_HEADERS([adns.h], [], [have_adns=no]) ;;
226 esac
227 case $have_adns in
228   check) AC_SEARCH_LIBS([adns_init], [adns], [], [have_adns=no]) ;;
229 esac
230 case $have_adns in check) have_adns=yes ;; esac
231
232 case $want_adns,$have_adns in
233   yes,no)
234     AC_MSG_ERROR([ADNS library not found but explicitly requested])
235     ;;
236   yes,yes | auto,yes)
237     use_adns=yes
238     AC_DEFINE([HAVE_ADNS], [1],
239               [define if you have (and want to use) the ADNS library.])
240     ;;
241   no,* | auto,no)
242     use_adns=no
243     mdw_DEFINE_PATHS([
244       AC_DEFINE_UNQUOTED([BRES_SERVER],
245                          ["mdw_PATH($libexecdir)/$PACKAGE/mdw_PROG(bres)"],
246                          [pathname to the standalone `bres' binary.'])
247     ])
248     ;;
249 esac
250 AM_CONDITIONAL([WITH_ADNS], [test "$use_adns" = yes])
251
252 MLIB_LIBS=$LIBS LIBS=$mdw_ORIG_LIBS
253
254 dnl--------------------------------------------------------------------------
255 dnl Timers.
256
257 AC_CHECK_HEADERS([linux/perf_event.h])
258
259 mdw_ORIG_LIBS=$LIBS LIBS=$MLIB_LIBS
260 AC_SEARCH_LIBS([clock_gettime], [rt])
261 MLIB_LIBS=$LIBS LIBS=$mdw_ORIG_LIBS
262 if test "$ac_cv_search_clock_gettime" != no; then
263   AC_DEFINE([HAVE_CLOCK_GETTIME], [1],
264             [Define if you have the \`clock_gettime' function.])
265 fi
266
267 dnl--------------------------------------------------------------------------
268 dnl Python (used for testing).
269
270 AM_PATH_PYTHON([2.4],, [:])
271
272 dnl--------------------------------------------------------------------------
273 dnl Output.
274
275 AC_CONFIG_HEADERS([config/config.h])
276 AC_CONFIG_TESTDIR([t])
277
278 AC_CONFIG_FILES(
279   [Makefile]
280   [buf/Makefile]
281   [codec/Makefile]
282   [hash/Makefile]
283   [mem/Makefile]
284   [sel/Makefile]
285   [struct/Makefile]
286   [sys/Makefile]
287   [test/Makefile] [test/example/Makefile]
288   [trace/Makefile]
289   [ui/Makefile] [ui/example/Makefile]
290   [utils/Makefile]
291   [t/Makefile t/atlocal])
292 AC_OUTPUT
293
294 dnl------ That's all, folks -------------------------------------------------