1# Process this file with autoconf to produce a configure script.
2# $Id$
3
4m4_define(libshout_major, 2)
5m4_define(libshout_minor, 4)
6m4_define(libshout_micro, 5)
7m4_define(libshout_version, libshout_major.libshout_minor.libshout_micro)
8
9AC_INIT([libshout], libshout_version, [icecast-dev@xiph.org])
10AC_PREREQ([2.54])
11
12AC_CONFIG_SRCDIR([src/shout.c])
13AC_CONFIG_MACRO_DIRS([m4])
14AC_CONFIG_HEADERS([config.h])
15
16# config.h guard
17AH_TOP([#ifndef __CONFIG_H__
18#define __CONFIG_H__ 1])
19AH_BOTTOM([#endif])
20
21AC_DEFINE([LIBSHOUT_MAJOR], libshout_major, [Shout library major version])
22AC_DEFINE([LIBSHOUT_MINOR], libshout_minor, [Shout library minor version])
23AC_DEFINE([LIBSHOUT_MICRO], libshout_micro, [Shout library patch version])
24
25VERSION=libshout_version
26
27AM_INIT_AUTOMAKE
28AM_MAINTAINER_MODE
29
30dnl create our name mangling macro
31dnl the prefix must be hardwired because of AH limitations
32AH_VERBATIM([_mangle], [
33/* name mangling to protect code we share with other libraries */
34#define _mangle(proc) _shout_ ## proc
35])
36
37AC_PROG_CC
38LT_INIT
39
40dnl Set some options based on environment
41
42dnl openbsd headers break when _XOPEN_SOURCE is defined but without it seems
43dnl to be fine
44case "$ac_cv_host" in
45   *openbsd* | *solaris* | *irix* | *darwin*)
46   dnl  On darwin, do not define _XOPEN_SOURCE as it will narrow us down too
47   dnl  much regarding function availability, so functions like strcasestr
48   dnl  would be unavailable.
49   ;;
50   *) AC_DEFINE(_XOPEN_SOURCE, 600, [Define if you have POSIX and XPG specifications])
51   ;;
52esac
53if test -z "$GCC"; then
54        case $host in
55        *-*-irix*)
56                DEBUG="-g -signed"
57                CFLAGS="-O2 -w -signed"
58                PROFILE="-p -g3 -O2 -signed"
59		;;
60        sparc-sun-solaris*)
61                DEBUG="-v -g"
62                CFLAGS="-xO4 -fast -w -fsimple -native -xcg92"
63                PROFILE="-v -xpg -g -xO4 -fast -native -fsimple -xcg92 -Dsuncc"
64		;;
65        *)
66                DEBUG="-g"
67                CFLAGS="-O"
68                PROFILE="-g -p"
69		;;
70        esac
71else
72        XIPH_CFLAGS="-Wall -ffast-math -fsigned-char"
73        AC_DEFINE(_GNU_SOURCE, ,[Define if you have POSIX and GNU specifications])
74        DEBUG="-g"
75        PROFILE="-pg -g"
76fi
77
78dnl Checks for programs.
79
80dnl Checks for header files.
81AC_HEADER_STDC
82AC_HEADER_TIME
83AC_CHECK_HEADERS([strings.h sys/timeb.h arpa/inet.h])
84AC_CHECK_HEADERS([stdarg.h], [SHOUT_STDARG=1], [AC_MSG_ERROR([required header <stdarg.h> not found])])
85
86dnl Checks for typedefs, structures, and compiler characteristics.
87AC_C_CONST
88AC_C_INLINE
89XIPH_C99_INTTYPES
90
91dnl Checks for library functions.
92AC_CHECK_FUNCS([gettimeofday ftime])
93AC_CHECK_FUNCS([strcasestr])
94AC_SEARCH_LIBS([nanosleep], [rt],
95  [AC_DEFINE([HAVE_NANOSLEEP], [1],
96    [Define if you have the nanosleep function])])
97
98dnl Allow examples not to be build
99AC_ARG_ENABLE([examples],
100  AS_HELP_STRING([--disable-examples],[Do not build example code]))
101AM_CONDITIONAL([HAVE_EXAMPLES],[test "${enable_examples}" != "no"])
102
103dnl Module checks
104XIPH_NET
105
106dnl Extra dependencies
107AC_ARG_ENABLE([thread],
108  AS_HELP_STRING([--disable-thread],[do not build with thread support even if it is available]))
109
110SHOUT_THREADSAFE="0"
111if test "$enable_thread" != "no"
112then
113  ACX_PTHREAD([
114    LIBS="$LIBS $PTHREAD_LIBS"
115    XIPH_CFLAGS="$XIPH_CFLAGS $PTHREAD_CFLAGS $PTHREAD_CPPFLAGS"
116    CC="$PTHREAD_CC"
117    SHOUT_THREADSAFE="1"
118    ])
119fi
120AC_SUBST([SHOUT_THREADSAFE])
121AM_CONDITIONAL([HAVE_THREAD], [test "$SHOUT_THREADSAFE" = "1"])
122if test "$SHOUT_THREADSAFE" != "1"
123then
124  AC_DEFINE([NO_THREAD], 1, [Define if you don't want to use the thread library])
125fi
126
127PKG_CHECK_MODULES([OGG], [ogg], [
128    HAVE_OGG="yes"
129    SHOUT_REQUIRES="$SHOUT_REQUIRES, ogg"
130  ], [
131    XIPH_PATH_OGG(, [AC_MSG_ERROR([required Ogg library not found])])
132  ])
133OGG_LIBS="$OGG_LDFLAGS $OGG_LIBS"
134XIPH_CFLAGS="$XIPH_CFLAGS $OGG_CFLAGS"
135
136PKG_CHECK_MODULES(VORBIS, vorbis, [
137    HAVE_VORBIS="yes"
138    SHOUT_REQUIRES="$SHOUT_REQUIRES, vorbis"
139  ], [
140    XIPH_PATH_VORBIS(, [AC_MSG_ERROR([required Ogg Vorbis library not found])])
141  ])
142VORBIS_LIBS="$VORBIS_LDFLAGS $VORBIS_LIBS"
143XIPH_CFLAGS="$XIPH_CFLAGS $VORBIS_CFLAGS"
144
145AC_ARG_ENABLE([theora],
146  AS_HELP_STRING([--disable-theora],[do not build with Theora support]))
147
148if test "x$enable_theora" != "xno"; then
149PKG_CHECK_MODULES(THEORA, theora, [
150    HAVE_THEORA="yes"
151    SHOUT_REQUIRES="$SHOUT_REQUIRES, theora"
152  ], [
153    XIPH_PATH_THEORA(, [AC_MSG_WARN([Theora library not found, disabling])])
154  ])
155fi
156XIPH_VAR_APPEND([XIPH_CPPFLAGS],[$THEORA_CFLAGS])
157XIPH_VAR_PREPEND([XIPH_LIBS],[$THEORA_LDFLAGS $THEORA_LIBS])
158AM_CONDITIONAL([HAVE_THEORA], [test -n "$THEORA_LIBS"])
159if test -n "$THEORA_LIBS"
160then
161  AC_DEFINE([HAVE_THEORA], 1, [Define if you want theora streams supported])
162fi
163
164AC_ARG_ENABLE([speex],
165  AS_HELP_STRING([--disable-speex],[do not build with Speex support]))
166
167if test "x$enable_speex" != "xno"; then
168PKG_CHECK_MODULES(SPEEX, speex, [
169    HAVE_SPEEX="yes"
170    SHOUT_REQUIRES="$SHOUT_REQUIRES, speex"
171  ], [
172    XIPH_PATH_SPEEX(, [AC_MSG_WARN([Speex library not found, disabling])])
173  ])
174fi
175XIPH_VAR_APPEND([XIPH_CPPFLAGS],[$SPEEX_CFLAGS])
176XIPH_VAR_PREPEND([XIPH_LIBS],[$SPEEX_LDFLAGS $SPEEX_LIBS])
177AM_CONDITIONAL([HAVE_SPEEX], [test -n "$SPEEX_LIBS"])
178if test -n "$SPEEX_LIBS"
179then
180  AC_DEFINE([HAVE_SPEEX], 1, [Define if you want speex streams supported])
181fi
182
183dnl If pkgconfig is found, install a shout.pc file.
184
185AC_ARG_ENABLE([pkgconfig],
186  AS_HELP_STRING([--disable-pkgconfig],[disable pkgconfig data files (auto)]),
187  [dopkgconfig="$enableval"], [dopkgconfig="maybe"])
188if test "$dopkgconfig" = "maybe"
189then
190  AC_CHECK_PROG([PKGCONFIG], [pkg-config], [yes], [no])
191else
192  AC_MSG_CHECKING([whether pkgconfig should be used])
193  PKGCONFIG="$dopkgconfig"
194  AC_MSG_RESULT([$PKGCONFIG])
195fi
196AM_CONDITIONAL([HAVE_PKGCONFIG], [test "$PKGCONFIG" != "no"])
197
198# Collect flags for shout.pc
199
200# I hate myself for doing this.
201save_prefix="$prefix"
202if test "$prefix" = "NONE"
203then
204  prefix="$ac_default_prefix"
205fi
206eval shout_includedir="$includedir"
207prefix="$save_prefix"
208
209XIPH_PATH_OPENSSL([
210    XIPH_VAR_APPEND([XIPH_CPPFLAGS],[$OPENSSL_CFLAGS])
211    XIPH_VAR_APPEND([XIPH_LDFLAGS],[$OPENSSL_LDFLAGS])
212    XIPH_VAR_PREPEND([XIPH_LIBS],[$OPENSSL_LIBS])
213    SHOUT_REQUIRES="$SHOUT_REQUIRES, libssl"
214    SHOUT_TLS="1"
215    ],
216    [ AC_MSG_NOTICE([SSL disabled!])
217      SHOUT_TLS="0"
218    ])
219AC_SUBST([SHOUT_TLS])
220AM_CONDITIONAL([HAVE_TLS], [test -n "$OPENSSL_LIBS"])
221
222SHOUT_VERSION="$VERSION"
223SHOUT_CPPFLAGS="-I$shout_includedir $VORBIS_CFLAGS $PTHREAD_CPPFLAGS"
224SHOUT_CFLAGS="$PTHREAD_CFLAGS"
225SHOUT_LIBS="-lshout"
226
227XIPH_CLEAN_CCFLAGS([$SHOUT_CPPFLAGS], [SHOUT_CPPFLAGS])
228XIPH_CLEAN_CCFLAGS([$SHOUT_CFLAGS], [SHOUT_CFLAGS])
229XIPH_CLEAN_CCFLAGS([$VORBIS_LIBS $THEORA_LIBS $SPEEX_LIBS $PTHREAD_LIBS $OPENSSL_LIBS $OPENSSL_LIBS $LIBS], [SHOUT_LIBDEPS])
230AC_SUBST(PTHREAD_CPPFLAGS)
231AC_SUBST(SHOUT_LIBDEPS)
232AC_SUBST(SHOUT_REQUIRES)
233AC_SUBST(SHOUT_CPPFLAGS)
234AC_SUBST(SHOUT_CFLAGS)
235
236dnl Make substitutions
237
238AC_SUBST(LIBTOOL_DEPS)
239AC_SUBST(OPT)
240AC_SUBST(LIBS)
241AC_SUBST(DEBUG)
242AC_SUBST(CFLAGS)
243AC_SUBST(PROFILE)
244AC_SUBST(XIPH_CFLAGS)
245AC_SUBST(XIPH_CPPFLAGS)
246AC_SUBST(XIPH_LIBS)
247
248AC_OUTPUT([Makefile include/Makefile include/shout/Makefile
249  include/shout/shout.h src/Makefile src/common/net/Makefile src/common/timing/Makefile
250  src/common/thread/Makefile src/common/avl/Makefile src/common/httpp/Makefile doc/Makefile
251  tools/Makefile examples/Makefile win32/Makefile shout.pc])
252