summaryrefslogtreecommitdiff
path: root/configure.in (plain)
blob: 7c0275a41cd2a4b77a35d4d56a5ba80fda9704ea
1dnl Process this file with autoconf to produce a configure script.
2
3AC_PREREQ(2.59)
4AC_INIT(zvbi, 0.2.33)
5AC_CONFIG_SRCDIR(src/vbi.c)
6
7AM_INIT_AUTOMAKE([1.9 check-news dist-bzip2])
8AM_CONFIG_HEADER(config.h)
9AM_ACLOCAL_INCLUDE(m4)
10AM_MAINTAINER_MODE
11
12dnl [current:revision:age]
13dnl Any change: ++revision
14dnl Interface added: ++current, revision = 0
15dnl age = last binary compatible version - current
16AC_SUBST(LIBZVBI_SO_VERSION, [13:1:13])
17
18dnl Enable GNU extensions if available.
19AC_GNU_SOURCE
20
21AC_PROG_CC
22
23dnl For header tests only.
24AC_PROG_CXX
25
26LIBS="$LIBS -lm"
27
28dnl Check for BSD/GNU extensions.
29dnl If not present we use replacements.
30AC_CHECK_FUNCS([strndup strlcpy asprintf vasprintf getopt_long \
31 getaddrinfo clock_settime program_invocation_name])
32
33dnl sincos() is a GNU extension (a macro, not a function).
34dnl If not present we use a replacement.
35AC_MSG_CHECKING([for sincos])
36AC_LINK_IFELSE([
37#include <stdio.h>
38#include <math.h>
39int main (void) {
40double s, c;
41scanf ("%f", &s);
42sincos (s, &s, &c);
43printf ("%f %f", s, c);
44return 0;
45}
46],[
47 AC_MSG_RESULT([yes])
48 AC_DEFINE(HAVE_SINCOS, 1, [Define if the sincos() function is available])
49],[
50 AC_MSG_RESULT([no])
51])
52
53dnl log2() is a GNU extension (a macro, not a function).
54dnl If not present we use a replacement.
55AC_MSG_CHECKING([for log2])
56AC_LINK_IFELSE([
57#include <stdio.h>
58#include <math.h>
59int main (void) {
60double x;
61scanf ("%f", &x);
62printf ("%f", log2 (x));
63return 0;
64}
65],[
66 AC_MSG_RESULT([yes])
67 AC_DEFINE(HAVE_LOG2, 1, [Define if the log2() function is available])
68],[
69 AC_MSG_RESULT([no])
70])
71
72dnl strerror() is not thread safe and there are different versions
73dnl of strerror_r(). If none of them are present we use a replacement.
74AC_MSG_CHECKING([for strerror_r])
75AC_COMPILE_IFELSE([
76#include <stdlib.h>
77#include <string.h>
78int main (void) {
79return *strerror_r (22, malloc (128), 128);
80}
81],[
82 AC_MSG_RESULT([yes, GNU version])
83 AC_DEFINE(HAVE_GNU_STRERROR_R, 1, [Define to 1 if you have
84 the GNU version of the strerror_r() function.])
85],[
86 AC_COMPILE_IFELSE([
87#include <stdio.h>
88#include <stdlib.h>
89#include <string.h>
90int main (void) {
91printf ("%f", 1.0 + strerror_r (22, malloc (128), 128));
92return 0;
93}
94 ],[
95 AC_MSG_RESULT([yes, SUSV3 version])
96 AC_DEFINE(HAVE_SUSV3_STRERROR_R, 1, [Define to 1 if you have
97 the SUSV3 version of the strerror_r() function.])
98 ],[
99 AC_MSG_RESULT([no])
100 ])
101])
102
103dnl __BYTE_ORDER is not portable.
104AC_DEFINE(Z_LITTLE_ENDIAN, 1234, [naidne elttiL])
105AC_DEFINE(Z_BIG_ENDIAN, 4321, [Big endian])
106AC_C_BIGENDIAN(
107 AC_DEFINE(Z_BYTE_ORDER, 4321, [Byte order]),
108 AC_DEFINE(Z_BYTE_ORDER, 1234, [Byte order]))
109
110AC_PROG_LIBTOOL
111
112test -e site_def.h || cat <<EOF >site_def.h
113/* Site specific definitions */
114
115#ifndef SITE_DEF_H
116#define SITE_DEF_H
117/* #define BIT_SLICER_LOG 1 */
118/* #define CACHE_DEBUG 1 */
119/* #define CACHE_DEBUG 2 */
120/* #define CACHE_STATUS 1 */
121/* #define CACHE_CONSISTENCY 1 */
122/* #define DVB_DEMUX_LOG 1 */
123/* #define DVB_MUX_LOG 1 */
124/* #define RAW_DECODER_LOG 1 */
125/* #define RAW_DECODER_PATTERN_DUMP 1 */
126/* #define TELETEXT_DEBUG 1 */
127#endif /* SITE_DEF_H */
128EOF
129
130dnl option, define/conditional name
131AC_DEFUN([CHECK_CC_OPTION], [
132 AC_MSG_CHECKING([if $CC supports $1])
133 SAVE_CFLAGS="$CFLAGS"
134 CFLAGS="$CFLAGS $1"
135 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([], [return 0;]),
136 [$2=yes], [$2=no])
137 CFLAGS="$SAVE_CFLAGS"
138 AC_MSG_RESULT($$2)
139 AM_CONDITIONAL($2, [test "x$$2" = "xyes"])])
140
141dnl option, define/conditional name
142AC_DEFUN([CHECK_CXX_OPTION], [
143 AC_MSG_CHECKING([if $CXX supports $1])
144 SAVE_CXXFLAGS="$CXXFLAGS"
145 CXXFLAGS="$CXXFLAGS $1"
146 AC_LANG_PUSH(C++)
147 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([], [return 0;]),
148 [$2=yes], [$2=no])
149 AC_LANG_POP()
150 CXXFLAGS="$SAVE_CXXFLAGS"
151 AC_MSG_RESULT($$2)
152 AM_CONDITIONAL($2, [test "x$$2" = "xyes"])])
153
154dnl See if we can / have to increase inlining limits.
155CHECK_CC_OPTION([--param inline-unit-growth=3000], HAVE_GCC_LIMITS)
156
157dnl For make check.
158CHECK_CC_OPTION([-std=c89], HAVE_GCC_C89_SUPPORT)
159CHECK_CC_OPTION([-std=iso9899:199409], HAVE_GCC_C94_SUPPORT)
160CHECK_CC_OPTION([-std=c99], HAVE_GCC_C99_SUPPORT)
161CHECK_CXX_OPTION([-std=c++98], HAVE_GXX_CXX98_SUPPORT)
162
163dnl
164dnl Check how to link pthreads functions.
165dnl (-lpthread on Linux, -pthread on FreeBSD).
166dnl
167AC_CHECK_LIB(pthread, pthread_create,,[
168 AC_TRY_LINK(, pthread_create();,,[
169 LDFLAGS="$LDFLAGS -pthread"
170 AC_TRY_LINK(, pthread_create();,,[
171 AC_MSG_ERROR([Unable to link pthread functions])
172 ])
173 ])
174])
175
176dnl
177dnl Check for Gnome unicode library or libc 2.1.
178dnl (Teletext URE search wchar_t ctype.h functions)
179dnl
180AC_MSG_CHECKING(whether we are using the GNU C Library 2.1 or newer)
181AC_EGREP_CPP([GLIBC21],[
182#include <features.h>
183#ifdef __GNU_LIBRARY__
184 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
185 GLIBC21
186 #endif
187#endif
188],[
189 AC_MSG_RESULT([yes])
190 AC_DEFINE(HAVE_GLIBC21, 1, [Honk if you have GNU C lib 2.1+])
191],[
192 AC_MSG_RESULT([no])
193 AC_MSG_CHECKING(for unicode library)
194 UNICODE_VERSION=`unicode-config --version`
195 if test $? -eq 0; then
196 AC_DEFINE(HAVE_LIBUNICODE, 1, [Define if you have libunicode])
197 AC_MSG_RESULT($UNICODE_VERSION)
198 UNICODE_CFLAGS=`unicode-config --cflags`
199 UNICODE_LIBS=`unicode-config --libs`
200 AC_SUBST(UNICODE_CFLAGS)
201 AC_SUBST(UNICODE_LIBS)
202 else
203 AC_MSG_RESULT([not present - Teletext search disabled])
204 fi
205])
206
207dnl
208dnl Check for iconv() in libc or libiconv.
209dnl (Unicode conversions)
210dnl
211dnl Using m4/iconv.m4 from the gettext package.
212dnl
213AM_ICONV_LINK
214if test "x$am_cv_func_iconv" != xyes; then
215 AC_MSG_ERROR([iconv() not found])
216fi
217LIBS="$LIBS $LIBICONV"
218
219dnl
220dnl Check for png library.
221dnl (PNG page export)
222dnl
223HAVE_PNG="yes"
224AC_CHECK_LIB(png, png_destroy_write_struct,
225 LIBS="$LIBS -lpng -lz", HAVE_PNG="no", -lz -lm)
226if test "x$HAVE_PNG" = xyes; then
227 AC_DEFINE(HAVE_LIBPNG, 1, [Define if you have libpng])
228fi
229
230dnl
231dnl X libraries.
232dnl (Test programs)
233dnl
234AC_PATH_XTRA
235test "x$no_x" = xyes || X_LIBS="$X_LIBS -lX11"
236AM_CONDITIONAL(HAVE_X, [test "x$no_x" != xyes])
237
238dnl
239dnl Enable OS dependent device interfaces.
240dnl (Linux videodev.h, videodev2.h, dvb, bktr dependencies)
241dnl
242enable_v4l_auto=no
243enable_dvb_auto=no
244enable_bktr_auto=no
245enable_proxy_auto=no
246
247case "$host_os" in
248 linux*)
249 enable_v4l_auto=yes
250 enable_dvb_auto=yes
251 enable_proxy_auto=yes
252 ;;
253 freebsd* | kfreebsd*-gnu | openbsd* | netbsd*)
254 enable_bktr_auto=yes
255 ;;
256 *)
257 ;;
258esac
259
260AC_MSG_CHECKING([whether to build the Video4Linux interface])
261AC_ARG_ENABLE(v4l,
262 AC_HELP_STRING([--enable-v4l],
263 [Include the V4L and V4L2 interface (auto)]),,
264 enable_v4l=$enable_v4l_auto)
265AC_MSG_RESULT($enable_v4l)
266if test "x$enable_v4l" = xyes; then
267 AC_DEFINE(ENABLE_V4L, 1, [Define to build V4L interface])
268 AC_DEFINE(ENABLE_V4L2, 1, [Define to build V4L2 / V4L2 2.5 interface])
269fi
270
271AC_MSG_CHECKING([whether to build the Linux DVB interface])
272AC_ARG_ENABLE(dvb,
273 AC_HELP_STRING([--enable-dvb],
274 [Include the DVB interface (auto)]),,
275 enable_dvb=$enable_dvb_auto)
276AC_MSG_RESULT($enable_dvb)
277if test "x$enable_dvb" = xyes; then
278 AC_DEFINE(ENABLE_DVB, 1, [Define to build DVB interface])
279fi
280AM_CONDITIONAL(ENABLE_DVB, [test "x$enable_dvb" = xyes])
281
282AC_MSG_CHECKING([whether to build the *BSD bktr driver interface])
283AC_ARG_ENABLE(bktr,
284 AC_HELP_STRING([--enable-bktr],
285 [Include the *BSD bktr driver interface (auto)]),,
286 enable_bktr=$enable_bktr_auto)
287AC_MSG_RESULT($enable_bktr)
288if test "x$enable_bktr" = xyes; then
289 AC_DEFINE(ENABLE_BKTR, 1, [Define to build bktr driver interface])
290fi
291
292
293if test "x$enable_v4l" = xyes -o "x$enable_dvb" = xyes; then
294 dnl Linux 2.6.x asm/types.h defines __s64 and __u64 only
295 dnl if __GNUC__ is defined. These types are required to compile
296 dnl videodev2.h and the Linux DVB headers.
297 AC_MSG_CHECKING([if asm/types.h defines __s64 and __u64])
298 AC_COMPILE_IFELSE([#include <asm/types.h>
299__s64 a = 1;
300__u64 b = 2;
301 ], [AC_DEFINE(HAVE_S64_U64, 1,
302 [Define if asm/types.h defines __s64 and __u64])
303 AC_MSG_RESULT(yes)],
304 [AC_MSG_RESULT(no)])
305fi
306
307dnl
308dnl Enable vbi proxy
309dnl
310AC_MSG_CHECKING([whether to build the vbi proxy daemon and interface])
311AC_ARG_ENABLE(proxy,
312 AC_HELP_STRING([--enable-proxy],
313 [Build the vbi proxy daemon and interface (auto)]),,
314 enable_proxy=$enable_proxy_auto)
315AC_MSG_RESULT($enable_proxy)
316if test "x$enable_proxy" = xyes; then
317 AC_DEFINE(ENABLE_PROXY, 1, [Define to build proxy daemon and interface])
318 case "$host_os" in
319 linux*)
320 AC_DEFINE(HAVE_IOCTL_INT_ULONG_DOTS, 1, [ioctl request type])
321 ;;
322 freebsd* | kfreebsd*-gnu | openbsd* | netbsd*)
323 AC_DEFINE(HAVE_IOCTL_INT_ULONG_DOTS, 1, [ioctl request type])
324 ;;
325 *)
326 ;;
327 esac
328fi
329AM_CONDITIONAL(ENABLE_PROXY, [test "x$enable_proxy" = xyes])
330
331dnl
332dnl Native language support.
333dnl
334AM_GNU_GETTEXT_VERSION([0.16.1])
335AM_GNU_GETTEXT([external], [need-ngettext])
336LIBS="$LTLIBINTL $LIBS"
337if test "x${prefix}" = xNONE; then
338 AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR,
339 "${ac_default_prefix}/share/locale", [ld])
340else
341 AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR,
342 "${prefix}/share/locale", [ld])
343fi
344
345dnl
346dnl Build docs from the sources if Doxygen is installed.
347dnl
348AC_ARG_WITH([doxygen],
349 AS_HELP_STRING([--without-doxygen],
350 [Disable building of API documentation]),,
351 [with_doxygen=yes])
352if test "x$with_doxygen" = "xyes"; then
353 AC_CHECK_PROG(HAVE_DOXYGEN, doxygen, yes, no)
354else
355 HAVE_DOXYGEN=no
356fi
357AM_CONDITIONAL(HAVE_DOXYGEN, [test "x$HAVE_DOXYGEN" = xyes])
358
359dnl Helps debugging, see test/Makefile.am.
360AM_CONDITIONAL(BUILD_STATIC_LIB, [test "x$enable_static" = xyes])
361
362AC_OUTPUT([
363 Makefile
364 contrib/Makefile
365 examples/Makefile
366 daemon/Makefile
367 daemon/zvbid.init
368 doc/Doxyfile
369 doc/Makefile
370 m4/Makefile
371 src/Makefile
372 src/dvb/Makefile
373 test/Makefile
374 po/Makefile.in
375 zvbi.spec
376 zvbi-0.2.pc
377])
378