shithub: libsamplerate

ref: a172af34b590602a5d8067ea177d082f2d8b191f
dir: /configure.ac/

View raw version
# Copyright (C) 2002-2011 Erik de Castro Lopo (erikd AT mega-nerd DOT com).

dnl Require autoconf version
AC_PREREQ(2.57)

AC_INIT([libsamplerate],[0.1.9],[[email protected]],
		[libsamplerate],[http://www.mega-nerd.com/libsamplerate/])

dnl Check whether we want to set defaults for CFLAGS, CPPFLAGS and LDFLAGS
AC_MSG_CHECKING([whether configure should try to set CFLAGS/CPPFLAGS/LDFLAGS])
AS_IF([test "x${CFLAGS+set}" = "xset" || test "x${CPPFLAGS+set}" = "xset" || test "x${LDFLAGS+set}" = "xset"], [
		enable_flags_setting=no
		: ${CFLAGS=""}
	], [
		enable_flags_setting=yes
		dnl Set to empty flags so AC_PROG_CC does not add -g -O2
		CFLAGS=""
	])
AC_MSG_RESULT([${enable_flags_setting}])

# Put config stuff in Cfg.
AC_CONFIG_AUX_DIR(Cfg)

AC_CONFIG_SRCDIR([src/samplerate.c])
AC_CANONICAL_TARGET([])

AC_CONFIG_MACRO_DIR([M4])
AC_CONFIG_HEADERS([src/config.h])

AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip subdir-objects])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

AC_LANG([C])
AC_PROG_CC
AC_PROG_CC_C99
AX_COMPILER_VENDOR
AX_COMPILER_VERSION

AC_PROG_SED

LT_INIT
LT_PROG_RC

AC_PROG_INSTALL
AC_PROG_LN_S

#------------------------------------------------------------------------------------
# Rules for library version information:
#
#  1. Start with version information of `0:0:0' for each libtool library.
#  2. Update the version information only immediately before a public release of
#     your software. More frequent updates are unnecessary, and only guarantee
#     that the current interface number gets larger faster.
#  3. If the library source code has changed at all since the last update, then
#     increment revision (`c:r:a' becomes `c:r+1:a').
#  4. If any interfaces have been added, removed, or changed since the last update,
#     increment current, and set revision to 0.
#  5. If any interfaces have been added since the last public release, then increment
#     age.
#  6. If any interfaces have been removed since the last public release, then set age
#     to 0.

CLEAN_VERSION=`echo $PACKAGE_VERSION | $SED "s/p.*//"`
VERSION_MINOR=`echo $CLEAN_VERSION | $SED "s/.*\.//"`

SHARED_VERSION_INFO="1:$VERSION_MINOR:0"

#------------------------------------------------------------------------------------

AC_PROG_MAKE_SET
AC_PROG_LN_S
AC_PROG_MKDIR_P

AS_IF([test "x$build_os$host_os$target_os" = "xmingw32mingw32mingw32"], [
		AC_CHECK_PROG(DLLTOOL, dlltool, dlltool)
		AC_CHECK_PROG(DLLWRAP, dllwrap, dllwrap)
		AC_CHECK_PROG(PEXPORTS, pexports, pexports)
	])

AC_HEADER_STDC

AC_CHECK_HEADERS([stdint.h sys/times.h])

#====================================================================================
# Couple of initializations here. Fill in real values later.

SHLIB_VERSION_ARG=""

#====================================================================================
# Finished checking, handle options.

AC_ARG_ENABLE([werror],
	AS_HELP_STRING([--enable-werror], [enable -Werror in all Makefiles]))

AC_ARG_ENABLE([fftw],
	AS_HELP_STRING([--disable-fftw], [disable usage of FFTW ]))

AC_ARG_ENABLE([cpu-clip],
	AS_HELP_STRING([--disable-cpu-clip], [disable tricky cpu specific clipper]))

AC_ARG_ENABLE([alsa],
	AS_HELP_STRING([--disable-alsa], [disable ALSA support in the varispeed-play example program]))

#====================================================================================
# Check types and their sizes.

AC_CHECK_SIZEOF(int,0)
AC_CHECK_SIZEOF(long,0)
AC_CHECK_SIZEOF(float,4)
AC_CHECK_SIZEOF(double,8)

#====================================================================================
# Determine endian-ness of target processor.

AC_C_FIND_ENDIAN

AC_DEFINE_UNQUOTED(CPU_IS_BIG_ENDIAN, ${ac_cv_c_big_endian},
        [Target processor is big endian.])
AC_DEFINE_UNQUOTED(CPU_IS_LITTLE_ENDIAN, ${ac_cv_c_little_endian},
        [Target processor is little endian.])

#====================================================================================
# Check for functions.

AC_CHECK_FUNCS(malloc calloc free memcpy memmove alarm signal)

AC_CHECK_LIB([m],floor)
AC_CHECK_FUNCS(floor ceil fmod)

AC_CHECK_SIGNAL(SIGALRM)

AC_C99_FUNC_LRINT
AC_C99_FUNC_LRINTF
# AC_C99_FUNC_LLRINT  Don't need this (yet?).

AS_IF([test "x$ac_cv_c99_lrint$ac_cv_c99_lrintf" != "xyesyes"], [
		AC_MSG_WARN([[*** Missing C99 standard functions lrint() and/or lrintf().]])
		AC_MSG_WARN([[*** This may cause benign compiler warnings on some systems (ie Solaris).]])
	])

#====================================================================================
# Determine if the processor can do clipping on float to int conversions.

AS_IF([test "x$enable_cpu_clip" != "xno"], [
		AC_C_CLIP_MODE
	], [
		AS_ECHO(["checking processor clipping capabilities... disabled"])
		ac_cv_c_clip_positive=0
		ac_cv_c_clip_negative=0
	])

AC_DEFINE_UNQUOTED(CPU_CLIPS_POSITIVE, ${ac_cv_c_clip_positive},
	[Target processor clips on positive float to int conversion.])
AC_DEFINE_UNQUOTED(CPU_CLIPS_NEGATIVE, ${ac_cv_c_clip_negative},
	[Target processor clips on negative float to int conversion.])

#====================================================================================
# Check for libsndfile which is required for the test and example programs.

AC_ARG_ENABLE([sndfile],
	AS_HELP_STRING([--disable-sndfile], [disable support for sndfile (default=autodetect)]))

# Check for pkg-config outside the if statement.
PKG_PROG_PKG_CONFIG
PKG_INSTALLDIR

AS_IF([test "x$enable_sndfile" != "xno"], [
		PKG_CHECK_MODULES([SNDFILE], [sndfile >= 1.0.6], [ac_cv_sndfile=1], [ac_cv_sndfile=0])
	], [
		ac_cv_sndfile=0
	])

AC_DEFINE_UNQUOTED([HAVE_SNDFILE], [$ac_cv_sndfile], [Set to 1 if you have libsndfile.])

AS_IF([test "x$ac_cv_sndfile" = "x1"], [
		ac_cv_sndfile=yes
		HAVE_SNDFILE=1
	], [
		ac_cv_sndfile=no
		HAVE_SNDFILE=0
	])

AM_CONDITIONAL([HAVE_LIBSNDFILE], [test "x$ac_cv_sndfile" = "xyes"])

#====================================================================================
# Check for ALSA.

ALSA_LIBS=""

AS_IF([test "x$enable_alsa" != "xno"], [
		AC_CHECK_HEADERS(alsa/asoundlib.h)
		AS_IF([test "x$ac_cv_header_alsa_asoundlib_h" = "xyes"], [
				ALSA_LIBS="-lasound"
				enable_alsa=yes
			], [test "x$enable_alsa" = "xyes"], [
				AC_MSG_ERROR(["ALSA headers not found"])
			], [
				enable_alsa=no
			])
	])

#====================================================================================
# Check for libfftw3 which is required for the test and example programs.

AS_IF([test "x$enable_fftw" != "xno"], [
		PKG_CHECK_MODULES([FFTW3], [fftw3 >= 0.15.0], [ac_cv_fftw3=1], [ac_cv_fftw3=0])
		AC_DEFINE_UNQUOTED([HAVE_FFTW3], [$ac_cv_fftw3], [Set to 1 if you have libfftw3.])

		AS_IF([test "x$ac_cv_fftw3" = "x1"], [
				ac_cv_fftw3=yes
				HAVE_FFTW3=1
			])
	])

AS_IF([test "x$ac_cv_fftw3" != "xyes"], [
		ac_cv_fftw3=no
		HAVE_FFTW3=0
	])

#====================================================================================
# Compiler stuff.

AS_IF([test "x$enable_flags_setting" = "xyes"], [
		AX_APPEND_COMPILE_FLAGS([-O2 -pipe], [CFLAGS])
	])

AS_IF([test "x$enable_werror" = "xyes"], [
		AX_APPEND_COMPILE_FLAGS([-Werror], [CFLAGS])
	])

AX_APPEND_COMPILE_FLAGS([-W -Wstrict-prototypes -Wmissing-prototypes -Wall -Waggregate-return -Wcast-align -Wcast-qual -Wnested-externs -Wshadow -Wpointer-arith], [CFLAGS])

#====================================================================================
# GCC stuff.
COMPILER_IS_GCC=0
AS_IF([test "x$ax_cv_c_compiler_vendor" = "xgnu"], [
		# OS specific tweaks.
		# Disable -Wall for Apple Darwin/Rhapsody.
		# System headers on these systems are broken.
		AS_CASE([$target_os],
			[darwin* | rhapsody*], [
				temp_CFLAGS=`echo $CFLAGS | sed "s/-Wall//"`
				CFLAGS=$temp_CFLAGS],
			[linux*|kfreebsd*-gnu*|gnu*], [
				SHLIB_VERSION_ARG="-Wl,--version-script=Version_script"
			])

		COMPILER_IS_GCC=1
		AC_DEFINE([COMPILER_IS_GCC], [1], [Set to 1 if the compile is GNU GCC.])
		GCC_MAJOR_VERSION=`$CC -dumpversion | sed "s/\..*//"`
		AC_DEFINE_UNQUOTED([GCC_MAJOR_VERSION], [${GCC_MAJOR_VERSION}], [Major version of GCC or 3 otherwise.])
	])

#====================================================================================
# Find known target OS.

OS_SPECIFIC_INCLUDES=""
os_is_win32=0

AS_CASE([$target_os],
	[darwin* | rhapsody*], [
		OS_SPECIFIC_INCLUDES="-fpascal-strings -I/Developer/Headers/FlatCarbon"
		OS_SPECIFIC_LINKS="-framework CoreAudio"],
	[mingw32*], [
		OS_SPECIFIC_LINKS="-lwinmm"
		os_is_win32=1],
	[
		OS_SPECIFIC_INCLUDES=""
		OS_SPECIFIC_LINKS=""
	])

#====================================================================================
# Now use the information from the checking stage.

AC_DEFINE_UNQUOTED([OS_IS_WIN32], [${os_is_win32}], [Set to 1 if compiling for Win32])

AC_SUBST(SHLIB_VERSION_ARG)
AC_SUBST(SHARED_VERSION_INFO)
AC_SUBST(OS_SPECIFIC_INCLUDES)
AC_SUBST(OS_SPECIFIC_LINKS)

AC_SUBST(COMPILER_IS_GCC)
AC_SUBST(GCC_MAJOR_VERSION)

AC_SUBST(HAVE_FFTW3)
AC_SUBST(HAVE_SNDFILE)

AC_SUBST(ALSA_LIBS)

AC_CONFIG_FILES([Makefile src/Version_script \
			Win32/Makefile Win32/Makefile.mingw \
			src/Makefile examples/Makefile tests/Makefile doc/Makefile \
			libsamplerate.spec samplerate.pc])
AC_OUTPUT

#====================================================================================

AX_RECURSIVE_EVAL([$libdir], [full_absolute_libdir])
AX_RECURSIVE_EVAL([$bindir], [full_absolute_bindir])
AX_RECURSIVE_EVAL([$pkgconfigdir], [full_absolute_pkgconfigdir])
AX_RECURSIVE_EVAL([$htmldir], [full_absolute_htmldir])
AC_MSG_RESULT([
-=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=-=-

  Configuration summary :

    libsamplerate version : ............... ${VERSION}

    Host CPU : ............................ ${host_cpu}
    Host Vendor : ......................... ${host_vendor}
    Host OS : ............................. ${host_os}

    CFLAGS : .............................. ${CFLAGS}
    CPPFLAGS : ............................ ${CPPFLAGS}
    LDFLAGS : ............................. ${LDFLAGS}

  Tools :

    C Compiler Vendor is : ................ ${ax_cv_c_compiler_vendor} (${ax_cv_c_compiler_version})

  Extra tools required for testing and examples :

    Have FFTW : ........................... ${ac_cv_fftw3}
    Have libsndfile : ..................... ${ac_cv_sndfile}
    Have ALSA : ........................... ${enable_alsa}

  Installation directories :

    Library directory : ................... ${full_absolute_libdir}
    Program directory : ................... ${full_absolute_bindir}
    Pkgconfig directory : ................. ${full_absolute_pkgconfigdir}
    HTML docs directory : ................. ${full_absolute_htmldir}

Compiling some other packages against libsamplerate may require
the addition of '$full_absolute_pkgconfigdir' to the
PKG_CONFIG_PATH environment variable.
])