chiark / gitweb /
2b7bcd7d2330450b03124c10f8c4469b7e52751b
[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 MLIB_LIBS=
54
55 dnl Headers.
56 AC_CHECK_HEADERS([float.h])
57 AC_CHECK_HEADERS([stdint.h])
58 AC_CHECK_HEADERS([valgrind/valgrind.h])
59 AC_CHECK_HEADERS([wchar.h])
60
61 dnl Libraries.
62 mdw_ORIG_LIBS=$LIBS LIBS=$MLIB_LIBS
63 AC_SEARCH_LIBS([sqrt], [m])
64 AC_SEARCH_LIBS([socket], [socket])
65 AC_SEARCH_LIBS([gethostbyname], [nsl resolv])
66 MLIB_LIBS=$LIBS LIBS=$mdw_ORIG_LIBS
67
68 dnl Functions.
69 AC_CHECK_FUNCS([mbrtowc])
70 AC_CHECK_FUNCS([snprintf])
71 AC_CHECK_FUNCS([wcwidth])
72
73 dnl Types.
74 AC_CHECK_TYPE([socklen_t], [],
75   [AC_DEFINE([socklen_t], [int],
76      [Define to `int' if <sys/socket.h> does not define])],
77   [AC_INCLUDES_DEFAULT
78 @%:@include <sys/socket.h>
79 ])
80
81 dnl Which version of struct msghdr do we have?
82 AC_CHECK_MEMBERS([struct msgdr.msg_control],,, [
83 @%:@include <sys/types.h>
84 @%:@include <sys/socket.h>
85 ])
86
87 dnl Find out whether we're cross-compiling.
88 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
89
90 dnl Floating-point formats.
91 mdw_PROBE_FLTFMT
92
93 dnl Set the master library list.
94 AC_SUBST([MLIB_LIBS])
95
96 dnl--------------------------------------------------------------------------
97 dnl Terminal characteristics.
98
99 mdw_ORIG_LIBS=$LIBS LIBS=$MLIB_LIBS
100
101 AC_ARG_WITH([unibilium],
102   AS_HELP_STRING([--with-unibilium], [support `unibilium' library]),
103   [want_unibilium=$withval],
104   [want_unibilium=auto])
105
106 case $want_unibilium in no) ;; *) have_unibilium=check ;; esac
107 case $have_unibilium in
108   check)
109     PKG_CHECK_MODULES([unibilium], [unibilium >= 2.0.0],
110                       [], [have_unibilium=no])
111     ;;
112 esac
113 case $have_unibilium in check) have_unibilium=yes ;; esac
114
115 case $want_unibilium,$have_unibilium in
116   yes,no)
117     AC_MSG_ERROR([`unibilium' library not found but explicitly requested])
118     ;;
119   yes,yes | auto,yes)
120     use_unibilium=yes
121     AC_DEFINE([HAVE_UNIBILIUM], [1],
122               [define if you have (and want to use) the `unibilium' library.])
123     ;;
124   no,* | auto,no)
125     use_unibilium=no
126     ;;
127 esac
128 AM_CONDITIONAL([WITH_UNIBILIUM], [test "$use_unibilium" = yes])
129
130 AC_ARG_WITH([terminfo],
131   AS_HELP_STRING([--with-terminfo], [support `terminfo' library]),
132   [want_terminfo=$withval],
133   [want_terminfo=auto])
134
135 case $want_terminfo in no) ;; *) have_terminfo=check ;; esac
136 case $have_terminfo in
137   check) AC_CHECK_HEADERS([term.h], [], [have_terminfo=no]) ;;
138 esac
139 case $have_terminfo in
140   check)
141     AC_SEARCH_LIBS([tparm], [tinfo], [], [have_terminfo=no])
142     AC_CHECK_FUNCS([tiparm])
143     ;;
144 esac
145 case $have_terminfo in check) have_terminfo=yes ;; esac
146
147 case $want_terminfo,$have_terminfo in
148   yes,no)
149     AC_MSG_ERROR([`terminfo' library not found but explicitly requested])
150     ;;
151   yes,yes | auto,yes)
152     use_terminfo=yes
153     AC_DEFINE([HAVE_TERMINFO], [1],
154               [define if you have (and want to use) the `terminfo' library.])
155     ;;
156   no,* | auto,no)
157     use_terminfo=no
158     ;;
159 esac
160 AM_CONDITIONAL([WITH_TERMINFO], [test "$use_terminfo" = yes])
161
162 AC_ARG_WITH([termcap],
163   AS_HELP_STRING([--with-termcap], [support `termcap' library]),
164   [want_termcap=$withval],
165   [want_termcap=auto])
166
167 case $want_termcap in no) ;; *) have_termcap=check ;; esac
168 case $have_termcap in
169   check) AC_CHECK_HEADERS([termcap.h], [], [have_termcap=no]) ;;
170 esac
171 case $have_termcap in
172   check)
173     AC_SEARCH_LIBS([tgoto], [termcap], [], [have_termcap=no])
174     AC_SEARCH_LIBS([tgetstr], [termcap], [], [have_termcap=no])
175     ;;
176 esac
177 case $have_termcap in check) have_termcap=yes ;; esac
178
179 case $want_termcap,$have_termcap in
180   yes,no)
181     AC_MSG_ERROR([`termcap' library not found but explicitly requested])
182     ;;
183   yes,yes | auto,yes)
184     use_termcap=yes
185     AC_DEFINE([HAVE_TERMCAP], [1],
186               [define if you have (and want to use) the `termcap' library.])
187     ;;
188   no,* | auto,no)
189     use_termcap=no
190     ;;
191 esac
192 AM_CONDITIONAL([WITH_TERMCAP], [test "$use_termcap" = yes])
193
194 MLIB_LIBS=$LIBS LIBS=$mdw_ORIG_LIBS
195
196 dnl--------------------------------------------------------------------------
197 dnl Name resolution.
198
199 AC_ARG_WITH([adns],
200   AS_HELP_STRING([--with-adns],
201                  [use ADNS library for background name resolution]),
202   [want_adns=$withval],
203   [want_adns=auto])
204
205 mdw_ORIG_LIBS=$LIBS LIBS=$MLIB_LIBS
206
207 case $want_adns in no) ;; *) have_adns=check ;; esac
208 case $have_adns in
209   check) AC_CHECK_HEADERS([adns.h], [], [have_adns=no]) ;;
210 esac
211 case $have_adns in
212   check) AC_SEARCH_LIBS([adns_init], [adns], [], [have_adns=no]) ;;
213 esac
214 case $have_adns in check) have_adns=yes ;; esac
215
216 case $want_adns,$have_adns in
217   yes,no)
218     AC_MSG_ERROR([ADNS library not found but explicitly requested])
219     ;;
220   yes,yes | auto,yes)
221     use_adns=yes
222     AC_DEFINE([HAVE_ADNS], [1],
223               [define if you have (and want to use) the ADNS library.])
224     ;;
225   no,* | auto,no)
226     use_adns=no
227     mdw_DEFINE_PATHS([
228       AC_DEFINE_UNQUOTED([BRES_SERVER],
229                          ["mdw_PATH($libexecdir)/$PACKAGE/mdw_PROG(bres)"],
230                          [pathname to the standalone `bres' binary.'])
231     ])
232     ;;
233 esac
234 AM_CONDITIONAL([WITH_ADNS], [test "$use_adns" = yes])
235
236 MLIB_LIBS=$LIBS LIBS=$mdw_ORIG_LIBS
237
238 dnl--------------------------------------------------------------------------
239 dnl Timers.
240
241 AC_CHECK_HEADERS([linux/perf_event.h])
242
243 mdw_ORIG_LIBS=$LIBS LIBS=$MLIB_LIBS
244 AC_SEARCH_LIBS([clock_gettime], [rt])
245 MLIB_LIBS=$LIBS LIBS=$mdw_ORIG_LIBS
246 if test "$ac_cv_search_clock_gettime" != no; then
247   AC_DEFINE([HAVE_CLOCK_GETTIME], [1],
248             [Define if you have the \`clock_gettime' function.])
249 fi
250
251 dnl--------------------------------------------------------------------------
252 dnl Python (used for testing).
253
254 AM_PATH_PYTHON([2.4],, [:])
255
256 dnl--------------------------------------------------------------------------
257 dnl Output.
258
259 AC_CONFIG_HEADERS([config/config.h])
260 AC_CONFIG_TESTDIR([t])
261
262 AC_CONFIG_FILES(
263   [Makefile]
264   [buf/Makefile]
265   [codec/Makefile]
266   [hash/Makefile]
267   [mem/Makefile]
268   [sel/Makefile]
269   [struct/Makefile]
270   [sys/Makefile]
271   [test/Makefile]
272   [test/example/Makefile]
273   [trace/Makefile]
274   [ui/Makefile]
275   [utils/Makefile]
276   [t/Makefile t/atlocal])
277 AC_OUTPUT
278
279 dnl------ That's all, folks -------------------------------------------------