shithub: aacdec

ref: 7af9c20656f528fe2329d91197d4f83094d7715a
dir: /common/libsndfile/configure.in/

View raw version
# Copyright (C) 1999-2002 Erik de Castro Lopo (erikd AT zip DOT com DOT au).

dnl Require autoconf version >= 2.13)
AC_PREREQ(2.13)

AC_INIT(src/sndfile.c)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE(libsndfile,1.0.0rc2)
AM_CONFIG_HEADER(src/config.h)

##---------------------------------------------------------------------
## Allow configure to save its options and optionally rerun itself with
## the same options.
#
#AC_ARG_WITH(last-config,  [  --with-last-config      re-run configure script with last config options ],
#  	ac_with_last_config=yes, ac_with_last_config=no)
#
#if test $ac_with_last_config = yes ; then
#	if test -f "$srcdir/config.last" ; then
#		mv $srcdir/config.last $srcdir/config.last.bak
#		sed "s/--no-create --no-recursion//" $srcdir/config.last.bak >$srcdir/config.last
#		rm $srcdir/config.last.bak
#		echo "re-running configure script with last config : `cat $srcdir/config.last`"
#		./configure `cat $srcdir/config.last`
#		exit
#	else
#		AC_MSG_ERROR([[*** No previous config options found.]])
#		fi
#else
#	# Save current config options
#	echo "$@" >config.last 
#	fi

#---------------------------------------------------------------------
# This is the version info according to the libtool versioning system.

SHARED_VERSION_INFO="1:0:0"

AC_CHECK_PROG(autogen, autogen, yes, no)

AC_PROG_CC
AC_PROG_INSTALL

AC_PROG_MAKE_SET
AC_PROG_LN_S
AM_PROG_LIBTOOL

AC_HEADER_STDC

#====================================================================================
# Finished checking, hande options.

AC_ARG_ENABLE(justsrc,  [  --enable-justsrc             only compile library sources ],
	ac_arg_justsrc="Y", ac_arg_justsrc="N")

AC_ARG_ENABLE(gcc-pipe, [  --disable-gcc-pipe           disable gcc -pipe option ],
	ac_arg_gcc_pipe="N", ac_arg_gcc_pipe="Y")

AC_ARG_ENABLE(gcc-opt,  [  --disable-gcc-opt            disable gcc optimisations ],
	ac_arg_gcc_opt="N", ac_arg_gcc_opt="Y")

AC_ARG_ENABLE(force-broken-float,  
						[  --enable-force-broken-float  force use of broken float code ],
	ac_arg_broken_float="Y", ac_arg_broken_float="N")

if test $ac_cv_prog_gcc = yes ; then
	CFLAGS="$CFLAGS -W -Wstrict-prototypes -Wmissing-prototypes -Wall -pedantic"
	if test "$ac_arg_gcc_opt" = "N" ; then
		temp_CFLAGS=`echo $CFLAGS | sed "s/O2/O0/"`
		CFLAGS=$temp_CFLAGS
		AC_MSG_WARN([[*** Compiler optimisations switched off. ***]])
		fi

	# Disable -Wall and -pedantic for Apple Darwin/Rhapsody.
	# System headers on these systems are broken.
	case "$target_os" in 
		darwin* | rhapsody*)
			temp_CFLAGS=`echo $CFLAGS | sed "s/-Wall -pedantic//"`
		CFLAGS=$temp_CFLAGS
			;;
		*)
			;;
		esac
	if test $ac_arg_gcc_pipe != "N" ; then
	 	CFLAGS="$CFLAGS -pipe"
	 	fi
	fi
	
#====================================================================================
# Large file support can be disabled.

AC_SYS_EXTRA_LARGEFILE

if test "$enable_largefile" != yes; then
	if test x"$ac_cv_sys_largefile_CFLAGS" != xno ; then
		CFLAGS="$CFLAGS $ac_cv_sys_largefile_CFLAGS"
		fi
	if test x"$ac_cv_sys_largefile_LDFLAGS" != xno ; then
		LDFLAGS="$LDFLAGS $ac_cv_sys_largefile_LDFLAGS"
		fi
	if test x"$ac_cv_sys_largefile_LIBS" != xno ; then
		LIBS="$LIBS $ac_cv_sys_largefile_LIBS"
		fi
else
	AC_MSG_WARN([[*** Disabling large file support.]])
	fi
	
#====================================================================================
# Determine endian-ness of target processor.

AC_CHECK_HEADERS(endian.h)

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 types and their sizes.

AC_CHECK_SIZEOF(short,2)
AC_CHECK_SIZEOF(int,4)
AC_CHECK_SIZEOF(long,8)
AC_CHECK_SIZEOF(float,4)
AC_CHECK_SIZEOF(double,4)
AC_CHECK_SIZEOF(void*,8)
AC_CHECK_SIZEOF(off_t,8)

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

AC_CHECK_FUNCS(malloc free)
AC_CHECK_FUNCS(open read write lseek fstat)
AC_CHECK_FUNCS(snprintf vsnprintf)

AC_C99_FUNC_LRINT
AC_C99_FUNC_LRINTF

if test $ac_cv_c99_lrint = no || test $ac_cv_c99_lrintf = no ; then
	AC_MSG_WARN([[*** Missing C99 standard functions lrint() and lrintf().]])
	AC_MSG_WARN([[*** This may cause benign compiler warnings on some systems (ie Solaris).]])
	fi

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

OS_SPECIFIC_INCLUDES=""

case "$target_os" in 
	darwin* | rhapsody*)
		OS_SPECIFIC_INCLUDES="-fpascal-strings -I/Developer/Headers/FlatCarbon"
		OS_SPECIFIC_LINKS="-framework CoreAudio"
		;;
	*)
		OS_SPECIFIC_INCLUDES=""
		OS_SPECIFIC_LINKS=""
		;;
	esac

#====================================================================================
# Test for sanity when cross-compiling.

if test $cross_compiling = yes ; then
	AC_MSG_WARN([[******************************************************************]])
	AC_MSG_WARN([[*** We are cross-compiling, so have to assume sizeof (short) == 2 ]])
	AC_MSG_WARN([[*** and sizeof (int) == 4. If this is not the case there is no    ]])
	AC_MSG_WARN([[*** chance of this working. Please contact the mantainer.         ]])
	AC_MSG_WARN([[******************************************************************]])
	fi
	
if test $ac_cv_sizeof_short != 2 ; then
	AC_MSG_WARN([[******************************************************************]])
	AC_MSG_WARN([[*** sizeof (short) != 2.                                          ]])
	AC_MSG_WARN([[******************************************************************]])
	fi
	
if test $ac_cv_sizeof_int != 4 ; then
	AC_MSG_WARN([[******************************************************************]])
	AC_MSG_WARN([[*** sizeof (int) != 4                                             ]])
	AC_MSG_WARN([[******************************************************************]])
	fi

if test $ac_cv_sizeof_float != 4 ; then
	AC_MSG_WARN([[******************************************************************]])
	AC_MSG_WARN([[*** sizeof (float) != 4.                                          ]])
	AC_MSG_WARN([[******************************************************************]])
	fi
	
if test $ac_cv_sizeof_double != 8 ; then
	AC_MSG_WARN([[******************************************************************]])
	AC_MSG_WARN([[*** sizeof (double) != 8.                                         ]])
	AC_MSG_WARN([[******************************************************************]])
	fi

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

subdirs="src Win32 MacOS"    		# Do not add src/GSM610 or src/G72x here.
if test $ac_arg_justsrc = "N" ; then
	subdirs="$subdirs examples doc tests"
	fi

if test $ac_arg_broken_float = "Y" ; then
	AC_DEFINE([FORCE_BROKEN_FLOAT],1,
		[Set to 1 to force the use of code for processors with broken floats])
	AC_MSG_WARN([[*** Testing code for processors that can't read/write IEEE floats.]])
else
	AC_DEFINE([FORCE_BROKEN_FLOAT],0,
		[Set to 1 to force the use of code for processors with broken floats])
	fi

AC_DEFINE([OS_IS_WIN32],0, [Set to 1 if compiling for Win32])

if test x"$CFLAGS" = x ; then
	echo "Error in configure script. CFLAGS has been screwed up."
	exit
	fi

AC_SUBST(subdirs)
AC_SUBST(ac_cv_sys_largefile_CFLAGS)
AC_SUBST(SHARED_VERSION_INFO)
AC_SUBST(OS_SPECIFIC_INCLUDES)
AC_SUBST(OS_SPECIFIC_LINKS)

AC_OUTPUT(Makefile src/Makefile src/GSM610/Makefile src/G72x/Makefile \
			examples/Makefile tests/Makefile doc/Makefile Win32/Makefile \
			MacOS/Makefile libsndfile.spec sndfile.pc)

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

echo
echo "            -=-=-=-= Configuration Complete. =-=-=-"

if test $prefix != "/usr" ; then
	my_pkg_config_dir="$prefix/lib/pkgconfig"
	echo 
	echo "The pkg-config file is being installed in '$my_pkg_config_dir'."
	echo "This means that you should set the PKG_CONFIG_PATH variable ie:"
	echo 
	echo "     export PKG_CONFIG_PATH=$my_pkg_config_dir"
	echo 
	echo "if you intend to use pkg-config to retrieve the recommended CFLAGS and"
	echo "library locations to compile programs which link against libsndfile."
	echo
	echo "Using pkg-config is highly recommended as libsndfile version 1 has large"
	echo "file support (ie files > 2Gig) and software linking to libsndfile will "
	echo "require special values for CFLAGS to compile correctly."
	echo
	echo "For details see : doc/pkgconfig.html"
	echo
	fi