configure.ac 13.2 KB
Newer Older
1 2 3 4 5 6
dnl Process this file with autoconf to produce a configure script

dnl ------------------------------------------------
dnl Initialization
dnl ------------------------------------------------

7 8 9 10
AC_INIT([vorbis-tools],[1.4.0],[vorbis-dev@xiph.org])

AC_CONFIG_SRCDIR(oggenc/encode.c)
AC_CONFIG_MACRO_DIR([m4])
11

12 13 14
AC_CANONICAL_HOST
AC_CANONICAL_TARGET

15 16
AC_PREREQ(2.53)

17 18
AM_INIT_AUTOMAKE
AM_MAINTAINER_MODE([enable])
19

20 21
AC_USE_SYSTEM_EXTENSIONS

22 23 24
dnl enable silent rules on automake 1.11 and later
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

25 26 27 28 29 30 31 32 33 34
dnl --------------------------------------------------  
dnl Check for programs
dnl --------------------------------------------------  

dnl save $CFLAGS since AC_PROG_CC likes to insert "-g -O2"
dnl if $CFLAGS is blank
cflags_save="$CFLAGS"
AC_PROG_CC
CFLAGS="$cflags_save"

35
AC_PROG_LIBTOOL
36

ivo's avatar
ivo committed
37
ALL_LINGUAS="be cs da en_GB eo es fr hr hu nl pl ro ru sk sv uk vi"
38
AM_GNU_GETTEXT
39

40 41 42 43
dnl --------------------------------------------------
dnl System checks
dnl --------------------------------------------------

44
AC_SYS_LARGEFILE
45
AC_C_BIGENDIAN
46

47 48 49 50
dnl --------------------------------------------------
dnl Set build flags based on environment
dnl --------------------------------------------------

51
cflags_save="$CFLAGS"
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
if test -z "$GCC"; then
        case $host in
        *-*-irix*)
                DEBUG="-g -signed"
                CFLAGS="-O2 -w -signed"
                PROFILE="-p -g3 -O2 -signed"
                ;;
        sparc-sun-solaris*)
                DEBUG="-v -g"
                CFLAGS="-xO4 -fast -w -fsimple -native -xcg92"
                PROFILE="-v -xpg -g -xO4 -fast -native -fsimple -xcg92 -Dsuncc"
                ;;
        *)
                DEBUG="-g"
                CFLAGS="-O"
                PROFILE="-g -p"
                ;;
        esac
else
        case $host in
        *-*-linux*)
                DEBUG="-g -Wall -fsigned-char"
74 75
                CFLAGS="-O2 -Wall -ffast-math -fsigned-char"
                PROFILE="-Wall -W -pg -g -O2 -ffast-math -fsigned-char"
76 77 78 79 80 81 82 83 84 85 86 87 88
                ;;
        sparc-sun-*)
                DEBUG="-g -Wall -fsigned-char -mv8"
                CFLAGS="-O20 -ffast-math -fsigned-char -mv8"
                PROFILE="-pg -g -O20 -fsigned-char -mv8"
                ;;
        *-*-darwin*)
                DEBUG="-fno-common -g -Wall -fsigned-char"
                CFLAGS="-fno-common -O4 -Wall -fsigned-char -ffast-math"
                PROFILE="-fno-common -O4 -Wall -pg -g -fsigned-char -ffast-math"
                ;;
        *)
                DEBUG="-g -Wall -fsigned-char"
89 90
                CFLAGS="-O2 -fsigned-char"
                PROFILE="-O2 -g -pg -fsigned-char"
91 92 93 94 95 96
                ;;
        esac
fi
CFLAGS="$CFLAGS $cflags_save"
DEBUG="$DEBUG $cflags_save"
PROFILE="$PROFILE $cflags_save"
97

98 99 100 101 102 103 104
dnl --------------------------------------------------
dnl Allow tools to be selectively built
dnl --------------------------------------------------
AC_ARG_ENABLE(ogg123, [  --disable-ogg123   Skip building ogg123], build_ogg123="$enableval", build_ogg123="yes")
AC_ARG_ENABLE(oggdec, [  --disable-oggdec   Skip building oggdec], build_oggdec="$enableval", build_oggdec="yes")
AC_ARG_ENABLE(oggenc, [  --disable-oggenc   Skip building oggenc], build_oggenc="$enableval", build_oggenc="yes")
AC_ARG_ENABLE(ogginfo,[  --disable-ogginfo  Skip building ogginfo], build_ogginfo="$enableval", build_ogginfo="yes")
105
AC_ARG_ENABLE(vcut,   [  --disable-vcut     Skip building vcut], build_vcut="$enableval", build_vcut="yes")
106
AC_ARG_ENABLE(vorbiscomment, [  --disable-vorbiscomment   Skip building vorbiscomment], build_vorbiscomment="$enableval", build_vorbiscomment="yes")
107 108
AC_ARG_WITH(flac,     [  --without-flac     Do not compile FLAC support], build_flac="$withval", build_flac="yes")
AC_ARG_WITH(speex,    [  --without-speex    Do not compile Speex support], build_speex="$withval", build_speex="yes")
109
AC_ARG_WITH(kate,     [  --without-kate     Do not compile Kate support], build_kate="$withval", build_kate="yes")
110

111
dnl --------------------------------------------------
112
dnl Check for generally needed libraries
113 114
dnl --------------------------------------------------

115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
HAVE_OGG=no
dnl first check through pkg-config
dnl check for pkg-config itself so we don't try the m4 macro without pkg-config
AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes)
if test "x$HAVE_PKG_CONFIG" = "xyes"
then
  PKG_CHECK_MODULES(OGG, ogg >= 1.0, HAVE_OGG=yes, HAVE_OGG=no)
fi
if test "x$HAVE_OGG" = "xno"
then
  dnl fall back to the old school test
  XIPH_PATH_OGG(,AC_MSG_ERROR(Ogg needed!))
  libs_save=$LIBS
  LIBS="$OGG_LIBS $VORBIS_LIBS"
  AC_CHECK_FUNC(oggpack_writealign, , AC_MSG_ERROR(Ogg >= 1.0 required !))
  LIBS=$libs_save
fi

dnl check for Vorbis
HAVE_VORBIS=no

dnl first check through pkg-config since it's more flexible

if test "x$HAVE_PKG_CONFIG" = "xyes"
then
140
  PKG_CHECK_MODULES(VORBIS, vorbis >= 1.3.0, HAVE_VORBIS=yes, HAVE_VORBIS=no)
141 142 143 144 145 146 147
  dnl also set VORBISENC_LIBS since an examples needs it
  dnl the old .m4 sets this to a value to use on top of VORBIS_LIBS,
  dnl so we do the same here.
  VORBISENC_LIBS="-lvorbisenc"
  VORBISFILE_LIBS="-lvorbisfile"
  AC_SUBST(VORBISENC_LIBS)
  AC_SUBST(VORBISFILE_LIBS)
148 149 150 151 152 153 154 155
  libs_save=$LIBS
  LIBS="$OGG_LIBS $VORBIS_LIBS $VORBISFILE_LIBS"
  AC_CHECK_FUNC(ov_read_filter, have_ov_read_filter=yes, have_ov_read_filter=no)
  LIBS=$libs_save
  if test "x$have_ov_read_filter" = "xyes"
  then
    AC_DEFINE(HAVE_OV_READ_FILTER,1,[Defined if we have ov_read_filter()])
  fi
156 157 158 159 160
fi
if test "x$HAVE_VORBIS" = "xno"
then
  dnl fall back to the old school test
  XIPH_PATH_VORBIS(,AC_MSG_ERROR(Vorbis needed!))
161 162 163 164 165 166
  AC_CHECK_DECL(OV_ECTL_COUPLING_SET, , , [#include <vorbis/vorbisenc.h>])
  if test "x$ac_cv_have_decl_OV_ECTL_COUPLING_SET" = "xno"
  then
    AC_MSG_ERROR([Vorbis >= 1.3.0 required !])
    HAVE_VORBIS=no
  fi
167
fi
168
AM_CONDITIONAL(HAVE_OV_READ_FILTER, test "x$have_ov_read_filter" = "xyes")
169

170

171 172 173 174 175
SHARE_LIBS='$(top_builddir)/share/libutf8.a $(top_builddir)/share/libgetopt.a'
SHARE_CFLAGS='-I$(top_srcdir)/include'

I18N_CFLAGS='-I$(top_srcdir)/intl'
I18N_LIBS=$INTLLIBS
176

177 178
SOCKET_LIBS=
AC_CHECK_LIB(socket, socket, SOCKET_LIBS="-lsocket")
Monty's avatar
Monty committed
179
AC_CHECK_LIB(network, socket, SOCKET_LIBS="-lnetwork")
180
AC_CHECK_LIB(nsl, gethostbyname, SOCKET_LIBS="-lnsl $SOCKET_LIBS")
181

182

183
dnl --------------------------------------------------
Stan Seibert's avatar
Stan Seibert committed
184
dnl Check for ogg123 critical libraries and other optional libraries
185
dnl --------------------------------------------------
186

187
dnl curl is an optional dependancy of ogg123
188 189
if test "x$HAVE_PKG_CONFIG" = "xyes"; then
  PKG_CHECK_MODULES(CURL, libcurl, HAVE_CURL=yes, HAVE_CURL=no)
190 191 192
  if test "x$HAVE_CURL" = "xno"; then
    AM_PATH_CURL(HAVE_CURL=yes, HAVE_CURL=no; AC_MSG_WARN(libcurl missing))
  fi
193 194 195
else
  AM_PATH_CURL(HAVE_CURL=yes, HAVE_CURL=no; AC_MSG_WARN(libcurl missing))
fi
196 197 198
if test "x$HAVE_CURL" = "xyes"; then
  AC_DEFINE(HAVE_CURL,1,[Defined if we have libcurl])
fi
199

200 201
if test "x$build_ogg123" = xyes; then
  AC_MSG_RESULT([checking for ogg123 requirements])
202
  PKG_CHECK_MODULES(AO, ao >= 1.0.0,,build_ogg123=no; AC_MSG_WARN(libao too old; >= 1.0.0 required))
203 204
  ACX_PTHREAD(,build_ogg123=no; AC_MSG_WARN(POSIX threads missing))
fi
Stan Seibert's avatar
Stan Seibert committed
205

206 207
dnl -------------------- FLAC ----------------------

208
FLAC_LIBS=""
209
if test "x$build_flac" = xyes; then
210

211
  AC_CHECK_LIB(m,log,FLAC_LIBS="-lm")
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236

  dnl First check for libFLAC-1.1.3 or later. As of libFLAC 1.1.3,
  dnl OggFLAC functionality has been rolled into libFLAC rather
  dnl than being in a separate libOggFLAC library.

  AC_CHECK_LIB(FLAC, [FLAC__stream_decoder_init_ogg_stream],
    have_libFLAC=yes, have_libFLAC=no, [$FLAC_LIBS $OGG_LIBS])

  if test "x$have_libFLAC" = xyes; then
    FLAC_LIBS="-lFLAC $FLAC_LIBS $OGG_LIBS"
  else
    dnl Check for libFLAC prior to 1.1.3
    AC_CHECK_LIB(FLAC, [FLAC__stream_decoder_process_single],
      [have_libFLAC=yes; FLAC_LIBS="-lFLAC $FLAC_LIBS"],
      AC_MSG_WARN([libFLAC missing])
      have_libFLAC=no, [$FLAC_LIBS]
    )

    AC_CHECK_LIB(OggFLAC, [OggFLAC__stream_decoder_new],
      [FLAC_LIBS="-lOggFLAC $FLAC_LIBS $OGG_LIBS"],
      AC_MSG_WARN([libOggFLAC missing])
      have_libFLAC=no, [$FLAC_LIBS $OGG_LIBS]
    )
  fi

237 238 239 240 241 242 243 244 245 246
  AC_CHECK_HEADER(FLAC/stream_decoder.h,,
    AC_MSG_WARN(libFLAC headers missing)
    have_libFLAC=no,[ ])

  if test "x$have_libFLAC" = xyes; then
     AC_DEFINE(HAVE_LIBFLAC, 1, [Defined if we have libFLAC])
  else
     build_flac="no"
     FLAC_LIBS=""
  fi
Stan Seibert's avatar
Stan Seibert committed
247
fi
248
AM_CONDITIONAL(HAVE_LIBFLAC, test "x$have_libFLAC" = "xyes")
Stan Seibert's avatar
Stan Seibert committed
249 250
AC_SUBST(FLAC_LIBS)

251 252
dnl ------------------- Speex ------------------------

253
SPEEX_LIBS=""
254 255 256 257 258 259 260
if test "x$build_speex" = xyes; then
  AC_CHECK_LIB(m,log,SPEEX_LIBS="-lm")
  AC_CHECK_LIB(speex, [speex_decoder_init],
    [have_libspeex=yes; SPEEX_LIBS="-lspeex $SPEEX_LIBS"],
    AC_MSG_WARN(libspeex missing)
    have_libspeex=no, [$SPEEX_LIBS]
  )
261
  AC_CHECK_HEADER(speex/speex.h,,
262 263 264 265 266 267 268 269 270
    AC_MSG_WARN(libspeex headers missing)
    have_libspeex=no,[ ])

  if test "x$have_libspeex" = xyes; then
    AC_DEFINE(HAVE_LIBSPEEX, 1, [Defined if we have libspeex])
  else
    build_speex="no"
    SPEEX_LIBS=""
  fi
271
fi
272
AM_CONDITIONAL(HAVE_LIBSPEEX, test "x$have_libspeex" = "xyes")
273 274
AC_SUBST(SPEEX_LIBS)

275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
dnl ------------------- Kate -------------------------

KATE_CFLAGS=""
KATE_LIBS=""
if test "x$build_kate" = xyes; then
  AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes)
  if test "x$HAVE_PKG_CONFIG" = "xyes"
  then
    PKG_CHECK_MODULES(KATE, oggkate, HAVE_KATE=yes, HAVE_KATE=no)
  fi
  if test "x$HAVE_KATE" = "xno"
  then
    dnl fall back to the old school test
    AC_CHECK_LIB(m,log,KATE_LIBS="-lm")
    AC_CHECK_LIB(kate, [kate_decode_init],
      [HAVE_KATE=yes; KATE_LIBS="-lkate $KATE_LIBS $OGG_LIBS"],
      AC_MSG_WARN(libkate missing)
      HAVE_KATE=no, [$KATE_LIBS $OGG_LIBS]
    )
    AC_CHECK_LIB(oggkate, [kate_ogg_decode_headerin],
      [HAVE_KATE=yes; KATE_LIBS="-loggkate $KATE_LIBS $OGG_LIBS"],
      AC_MSG_WARN(libkate missing)
      HAVE_KATE=no, [$KATE_LIBS $OGG_LIBS]
    )
    AC_CHECK_HEADER(kate/kate.h,,
      AC_MSG_WARN(libkate headers missing)
      HAVE_KATE=no,[ ])
    AC_CHECK_HEADER(kate/oggkate.h,,
      AC_MSG_WARN(liboggkate headers missing)
      HAVE_KATE=no,[ ])

  fi
  if test "x$HAVE_KATE" = xyes; then
    AC_DEFINE(HAVE_KATE, 1, [Defined if we have libkate])
  else
    build_kate="no"
    KATE_CFLAGS=""
    KATE_LIBS=""
  fi
fi
AM_CONDITIONAL(HAVE_KATE, test "x$HAVE_KATE" = "xyes")
AC_SUBST(KATE_CFLAGS)
AC_SUBST(KATE_LIBS)

319 320 321 322 323 324
dnl --------------------------------------------------
dnl Check for headers
dnl --------------------------------------------------

AC_CHECK_HEADERS([fcntl.h unistd.h])

325 326 327 328
dnl --------------------------------------------------
dnl Check for library functions
dnl --------------------------------------------------

329
AC_FUNC_ALLOCA
330
AM_ICONV
331
AC_CHECK_FUNCS(atexit on_exit fcntl select stat chmod alphasort scandir)
332
AM_LANGINFO_CODESET
333

334 335 336 337
dnl --------------------------------------------------
dnl Work around FHS stupidity
dnl --------------------------------------------------

338 339 340 341 342 343
if test -z "$mandir"; then
    if test "$prefix" = "/usr"; then
        MANDIR='$(datadir)/man'
    else
        MANDIR='$(prefix)/man'
    fi
344
else
345
    MANDIR=$mandir
346 347
fi
AC_SUBST(MANDIR)
348

349

350 351 352 353
dnl --------------------------------------------------
dnl Do substitutions
dnl --------------------------------------------------

354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
# add optional subdirs to the build
OPT_SUBDIRS=""
if test "x$build_ogg123" = xyes; then
  OPT_SUBDIRS="$OPT_SUBDIRS ogg123"
fi
if test "x$build_oggenc" = xyes; then
  OPT_SUBDIRS="$OPT_SUBDIRS oggenc"
fi
if test "x$build_oggdec" = xyes; then
  OPT_SUBDIRS="$OPT_SUBDIRS oggdec"
fi
if test "x$build_ogginfo" = xyes; then
  OPT_SUBDIRS="$OPT_SUBDIRS ogginfo"
fi
if test "x$build_vcut" = xyes; then
  OPT_SUBDIRS="$OPT_SUBDIRS vcut"
fi
if test "x$build_vorbiscomment" = xyes; then
  OPT_SUBDIRS="$OPT_SUBDIRS vorbiscomment"
fi
AC_SUBST(OPT_SUBDIRS)
375

376 377
AC_SUBST(DEBUG)
AC_SUBST(PROFILE)
378
AC_SUBST(SOCKET_LIBS)
379
AC_SUBST(SHARE_CFLAGS)
380
AC_SUBST(SHARE_LIBS)
381 382
AC_SUBST(CURL_CFLAGS)
AC_SUBST(CURL_LIBS)
Segher Boessenkool's avatar
Grrr.  
Segher Boessenkool committed
383 384
AC_SUBST(I18N_CFLAGS)
AC_SUBST(I18N_LIBS)
385

386 387

AC_CONFIG_FILES([
388
Makefile
389
m4/Makefile
390
po/Makefile.in
Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
391
intl/Makefile
392 393 394 395 396 397 398 399 400 401 402 403
include/Makefile
share/Makefile
win32/Makefile
oggdec/Makefile
oggenc/Makefile
oggenc/man/Makefile
ogg123/Makefile
vorbiscomment/Makefile
vcut/Makefile
ogginfo/Makefile
debian/Makefile
])
404

405 406 407 408
AC_CONFIG_HEADERS([config.h])

AC_OUTPUT

409
if test "x$build_oggenc" = xyes -a "x$have_libFLAC" != xyes; then
Conrad Parker's avatar
typo  
Conrad Parker committed
410
    AC_MSG_WARN([FLAC and/or OggFLAC libraries or headers missing, oggenc 
411 412 413
will NOT be built with FLAC read support.])
fi

414 415
if test "x$build_ogg123" != xyes; then
    AC_MSG_WARN([Prerequisites for ogg123 not met, ogg123 will be skipped.
416 417
Please ensure that you have POSIX threads, libao, and (optionally) libcurl
libraries and headers present if you would like to build ogg123.])
418 419
else
    if test "x$have_libFLAC" != xyes; then
Ralph Giles's avatar
Ralph Giles committed
420
        AC_MSG_WARN([FLAC and/or OggFLAC libraries or headers missing, ogg123 
421 422 423
will NOT be built with FLAC read support.])
    fi
    if test "x$have_libspeex" != xyes; then
Ralph Giles's avatar
Ralph Giles committed
424
        AC_MSG_WARN([Speex libraries and/or headers missing, ogg123 
425
will NOT be built with Speex read support.])
426
    fi
427
    if test "x$HAVE_CURL" != xyes; then
428 429
        AC_MSG_WARN([curl libraries and/or headers missing, ogg123 
will NOT be built with http support.])
430
    fi
431
    if test "x$HAVE_KATE" != xyes; then
432 433
        AC_MSG_WARN([Kate libraries and/or headers missing, oggenc 
will NOT be built with Kate lyrics support.])
434
    fi
435
fi