mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] SPEEX: improve its buildsystem
@ 2012-01-25 10:38 Juergen Beisert
  2012-01-25 11:10 ` [ptxdist] [PATCHv2] SPEEX: improve its buildsystem (sorry, in the first one the floating point detection was broken) Juergen Beisert
  0 siblings, 1 reply; 2+ messages in thread
From: Juergen Beisert @ 2012-01-25 10:38 UTC (permalink / raw)
  To: ptxdist

    This patch adds a series of patches to the speex package to
    - fix its buildsystem
    - add libogg dependency on demand only
    - add autodetection of the architecture and possible optimizations
    
    Signed-off-by: Juergen Beisert <jbe@pengutronix.de>

diff --git a/patches/speex-1.2rc1/add_more_autodetection.diff b/patches/speex-1.2rc1/add_more_autodetection.diff
new file mode 100644
index 0000000..22257ab
--- /dev/null
+++ b/patches/speex-1.2rc1/add_more_autodetection.diff
@@ -0,0 +1,238 @@
+From: Juergen Beisert <jbe@pengutronix.de>
+Subject: [PATCH] SPEEX: let configure detect more arch settings from the compiler
+
+The preprocessor defines various symbols on its default settings and also on
+given parameters. Use these symbols to detect optimization possibilities.
+
+__SOFTFP__ is a symbol defined when the toolchain is configured to not create
+floating point instructions and call soft floating point routines instead.
+This helps to distinguish ARMv5 with or without hardware floating point support.
+
+__ARM_ARCH_4__/__ARM_ARCH_4T__ are defined if the default architecture is ARMv4,
+__ARM_ARCH_5__/__ARM_ARCH_5E__/__ARM_ARCH_5T__/__ARM_ARCH_5TE__/__ARM_ARCH_5TEJ__
+for ARMv5.
+
+__SSE__/__SSE2__/__SSE2_MATH__ for a SSE capable x86 CPU.
+
+It is easy to add more compiler symbols to detect the correct architecture.
+
+Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
+
+---
+ configure.ac |  182 +++++++++++++++++++++++++++++++++++++++++++++++++++--------
+ 1 file changed, 158 insertions(+), 24 deletions(-)
+
+Index: speex-1.2rc1/configure.ac
+===================================================================
+--- speex-1.2rc1.orig/configure.ac
++++ speex-1.2rc1/configure.ac
+@@ -64,22 +64,114 @@ AC_TYPE_INT16_T
+ AC_TYPE_INT32_T
+ AC_TYPE_SIZE_T
+ 
+-AC_MSG_CHECKING(for SSE in current arch/CFLAGS)
+-AC_LINK_IFELSE([
+-AC_LANG_PROGRAM([[
+-#include <xmmintrin.h>
+-__m128 testfunc(float *a, float *b) {
+-  return _mm_add_ps(_mm_loadu_ps(a), _mm_loadu_ps(b));
+-}
+-]])],
+-[
+-has_sse=yes
+-],
+-[
+-has_sse=no
+-]
+-)
+-AC_MSG_RESULT($has_sse)  
++target_arch_detected=guessed
++
++# ---------------------------------------------------------------------------
++
++case $host_cpu in
++	i?86)
++		base_arch=x86
++		;;
++	arm)
++		base_arch=arm;
++		;;
++	*)
++		base_arch=unknown;
++		;;
++esac
++
++# ---------------------------------------------------------------------------
++
++#
++# Checking for specific features speex can be optimized for is more or less
++# guessed from the pre-compiler macros.
++#
++AC_MSG_CHECKING(for hardware floating point support)
++AC_COMPILE_IFELSE(
++	[AC_LANG_PROGRAM([[]],
++	[[
++#define HARD_SOFT_FP_SUPPORT
++#if defined(__SOFTFP__)
++# undef HARD_SOFT_FP_SUPPORT 1
++#endif
++int foo = HARD_SOFT_FP_SUPPORT;
++	]])],
++	[target_hardware_fp=no],
++	[target_hardware_fp=yes],
++	[hardware FP])
++AC_MSG_RESULT(${target_hardware_fp})
++
++# When a hardware floating point unit seems available, then use it.
++# This will end in bad code on badly configured compilers which generates
++# floating point instructions even if the CPU has not hardware FP unit
++#
++if test x${target_hardware_fp} = xyes; then
++	enable_fixed_point=no
++	enable_float_api=yes
++	enable_vbr=yes
++	with_fft=smallft
++	math_type="floating"
++else
++	enable_fixed_point=yes
++	enable_float_api=no
++	enable_vbr=no
++	with_fft=kiss
++	math_type="fixed"
++fi
++
++# ---------------------------------------------------------------------------
++
++if test x${base_arch} = xarm; then
++# discover the architecture this compiler builds code for
++
++enable_arm4_asm=no;
++enable_arm5e_asm=no;
++
++# check here for symbols the preprocessor automatically defines.
++# To find the correct symbol to test for just run "cpp -dM" and press CTRL-D.
++
++AC_MSG_CHECKING(for ARMv4 architecture)
++AC_COMPILE_IFELSE(
++	[AC_LANG_PROGRAM([[]],
++	[[
++#undef THIS_IS_V4
++#if defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__)
++# define THIS_IS_V4 1
++#endif
++int foo = THIS_IS_V4;
++	]])],
++	[enable_arm4_asm=yes; optimized_for="ARMv4"; target_arch_detected=yes],
++	[],
++	[Optimize for ARMv4])
++AC_MSG_RESULT(${target_arch_detected})
++
++if test x${target_arch_detected} = xguessed; then
++
++AC_MSG_CHECKING(for ARMv5 architecture)
++AC_COMPILE_IFELSE(
++	[AC_LANG_PROGRAM([[]],
++	[[
++#undef THIS_IS_V5
++#if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5T__) || defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__)
++# define THIS_IS_V5 1
++#endif
++int foo = THIS_IS_V5;
++	]])],
++	[enable_arm5e_asm=yes; optimized_for="ARMv5"; target_arch_detected=yes],
++	[],
++	[Optimize for ARMv5])
++AC_MSG_RESULT(${target_arch_detected})
++
++fi
++
++if test x${target_arch_detected} = xguessed; then
++	optimized_for="ARM"
++fi
++
++fi
++
++# end of ARM
++# ---------------------------------------------------------------------------
+ 
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -fvisibility=hidden"
+@@ -156,15 +248,44 @@ AC_ARG_ENABLE(valgrind, [  --enable-valg
+   AC_DEFINE([ENABLE_VALGRIND], , [Enable valgrind extra checks])
+ fi])
+ 
+-AC_ARG_ENABLE(sse, [  --enable-sse            Enable SSE support], [
+-if test "x$enableval" != xno; then
+-has_sse=yes
+-CFLAGS="$CFLAGS -O3 -msse"
++# ---------------------------------------------------------------------------
++# x86 optimization
++
++AC_MSG_CHECKING(wether to enable SSE math)
++AC_ARG_ENABLE(sse,
++	[AS_HELP_STRING([--enable-sse],
++		[Enable SSE support @<:@default=disabled@:>@])],
++	[has_sse="$enableval"],
++	[has_sse="guessing"])
++AC_MSG_RESULT(${has_sse})
++
++if test x${base_arch} != xx86; then
++	has_sse=no
+ else
+-has_sse=no
++	target_arch_detected=guessed
++	optimized_for="x86";
++
++# if the user do not define this parameter, try to guess it
++	if test x${has_sse} = xguessing ; then
++AC_MSG_CHECKING(guessing for SSE capability)
++AC_COMPILE_IFELSE(
++	[AC_LANG_PROGRAM([[]],
++	[[
++#undef SSE_IS_POSSIBLE
++#if defined(__SSE__) || defined(__SSE2__) || defined(__SSE2_MATH__)
++# define SSE_IS_POSSIBLE 1
++#endif
++int foo = SSE_IS_POSSIBLE;
++	]])],
++	[has_sse=yes; CFLAGS="$CFLAGS -O3 -msse"],
++	[has_sse=no],
++	[Optimize for SSE])
++AC_MSG_RESULT(${has_sse})
++fi
+ fi
+-])
+ 
++# end of x86 optimization
++# ---------------------------------------------------------------------------
+ 
+ FFT=smallft
+ 
+@@ -316,8 +437,6 @@ AC_CONFIG_FILES([Makefile libspeex/Makef
+ 	   ti/speex_C64_test/Makefile ])
+ AC_OUTPUT
+ 
+-echo "Type \"make; make install\" to compile and install Speex";
+-
+ echo "------------------------------------------------------"
+ echo "   Results:"
+ echo "------------------------------------------------------"
+@@ -330,3 +449,18 @@ echo "   CFLAGS:                $CFLAGS 
+ echo "   Additional libs:       $LIBS $OGG_LIBS"
+ echo "   Coder/Encoder tools:   $enable_coders"
+ echo "------------------------------------------------------"
++echo "   Architecture specific settings:"
++echo ""
++echo "   Arch discovered:       ${target_arch_detected}"
++echo "   Base architecture:     ${base_arch}"
++echo "   Optimized for:         ${optimized_for} with ${math_type} point"
++if test x${base_arch} = xx86; then
++echo "    enable SSE math:      ${has_sse}"
++fi
++if test x${base_arch} = xarm; then
++	echo "    ARMv4 enabled:        ${enable_arm4_asm}"
++	echo "    ARMv5 enabled:        ${enable_arm5e_asm}"
++fi
++echo "------------------------------------------------------"
++
++echo "Type \"make; make install\" to compile and install Speex";
diff --git a/patches/speex-1.2rc1/autogen.sh b/patches/speex-1.2rc1/autogen.sh
new file mode 120000
index 0000000..9f8a4cb
--- /dev/null
+++ b/patches/speex-1.2rc1/autogen.sh
@@ -0,0 +1 @@
+../autogen.sh
\ No newline at end of file
diff --git a/patches/speex-1.2rc1/clean_up_configure_ac.diff b/patches/speex-1.2rc1/clean_up_configure_ac.diff
new file mode 100644
index 0000000..72abf44
--- /dev/null
+++ b/patches/speex-1.2rc1/clean_up_configure_ac.diff
@@ -0,0 +1,160 @@
+From: Juergen Beisert <jbe@pengutronix.de>
+Subject: [PATCH] SPEEX: update the configure.ac by running 'autoupdate'
+
+Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
+
+---
+ Makefile.am  |    2 +
+ configure.ac |   81 +++++++++++++++++++++++++++++------------------------------
+ 2 files changed, 43 insertions(+), 40 deletions(-)
+
+Index: speex-1.2rc1/configure.ac
+===================================================================
+--- speex-1.2rc1.orig/configure.ac
++++ speex-1.2rc1/configure.ac
+@@ -1,8 +1,10 @@
+ dnl Process this file with autoconf to produce a configure script. -*-m4-*-
+ 
+-AC_INIT(libspeex/speex.c)
++AC_INIT
++AC_CONFIG_SRCDIR([libspeex/speex.c])
+ 
+-AM_CONFIG_HEADER([config.h])
++AC_CONFIG_HEADERS([config.h])
++AC_CONFIG_MACRO_DIR([m4])
+ 
+ SPEEX_MAJOR_VERSION=1
+ SPEEX_MINOR_VERSION=1
+@@ -30,8 +32,11 @@ AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-
+ AM_MAINTAINER_MODE
+ 
+ AC_CANONICAL_HOST
+-AC_LIBTOOL_WIN32_DLL
+-AM_PROG_LIBTOOL
++
++LT_INIT
++
++# default is more output while building the package
++AM_SILENT_RULES()
+ 
+ AC_C_BIGENDIAN
+ AC_C_CONST
+@@ -40,37 +45,24 @@ AC_C_RESTRICT
+ 
+ 
+ AC_MSG_CHECKING(for C99 variable-size arrays)
+-AC_TRY_COMPILE( , [
++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
+ int foo;
+ foo = 10;
+ int array[foo];
+-],
+-[has_var_arrays=yes;AC_DEFINE([VAR_ARRAYS], [], [Use C99 variable-size arrays])
+-],
+-has_var_arrays=no
+-)
++]])],[has_var_arrays=yes;AC_DEFINE([VAR_ARRAYS], [], [Use C99 variable-size arrays])
++],[has_var_arrays=no
++])
+ AC_MSG_RESULT($has_var_arrays)
+ 
+-AC_CHECK_HEADERS([alloca.h getopt.h])
+-AC_MSG_CHECKING(for alloca)
+-AC_TRY_COMPILE( [
+-#ifdef HAVE_ALLOCA_H
+-# include <alloca.h>
+-#endif
+-#include <stdlib.h>
+-], [
+-int foo=10;
+-int *array = alloca(foo);
+-],
+-[
+-has_alloca=yes;
+-if test x$has_var_arrays = "xno" ; then
+-AC_DEFINE([USE_ALLOCA], [], [Make use of alloca])
+-fi
+-],
+-has_alloca=no
+-)
+-AC_MSG_RESULT($has_alloca)
++AC_CHECK_HEADERS([alloca.h getopt.h fcntl.h libintl.h malloc.h sys/ioctl.h])
++AC_FUNC_ALLOCA
++AC_FUNC_MALLOC
++AC_FUNC_REALLOC
++AC_CHECK_FUNCS([floor memset pow sqrt strchr])
++
++AC_TYPE_INT16_T
++AC_TYPE_INT32_T
++AC_TYPE_SIZE_T
+ 
+ AC_MSG_CHECKING(for SSE in current arch/CFLAGS)
+ AC_LINK_IFELSE([
+@@ -138,7 +130,9 @@ if test "x$enable_libogg" = xyes; then
+ 	PKG_CHECK_MODULES(OGG, ogg)
+ fi
+ 
+-AC_CHECK_LIB(m, sin)
++AC_SEARCH_LIBS([floor], [m], [], [AC_MSG_ERROR([unable to find the floor() function])])
++AC_SEARCH_LIBS([pow], [m], [], [AC_MSG_ERROR([unable to find the pow() function])])
++AC_SEARCH_LIBS([sqrt], [m], [], [AC_MSG_ERROR([unable to find the sqrt() function])])
+ 
+ # Check for getopt_long; if not found, use included source.
+ AC_CHECK_FUNCS([getopt_long],,
+@@ -181,8 +175,7 @@ AC_ARG_ENABLE(fixed-point, [  --enable-f
+   AC_DEFINE([FIXED_POINT], , [Compile as fixed-point])
+ else
+   AC_DEFINE([FLOATING_POINT], , [Compile as floating-point])
+-fi],
+-AC_DEFINE([FLOATING_POINT], , [Compile as floating-point]))
++fi],AC_DEFINE([FLOATING_POINT], , [Compile as floating-point]))
+ 
+ if test "$has_sse" = yes; then
+   AC_DEFINE([_USE_SSE], , [Enable SSE support])
+@@ -296,7 +289,7 @@ fi
+ AC_SUBST(SIZE16)
+ AC_SUBST(SIZE32)
+ 
+-AC_OUTPUT([Makefile libspeex/Makefile src/Makefile doc/Makefile Speex.spec
++AC_CONFIG_FILES([Makefile libspeex/Makefile src/Makefile doc/Makefile Speex.spec
+            include/Makefile include/speex/Makefile speex.pc speexdsp.pc
+            win32/Makefile win32/libspeex/Makefile win32/speexenc/Makefile
+            win32/speexdec/Makefile symbian/Makefile 
+@@ -321,11 +314,19 @@ AC_OUTPUT([Makefile libspeex/Makefile sr
+            include/speex/speex_config_types.h ti/Makefile 
+ 	   ti/speex_C54_test/Makefile ti/speex_C55_test/Makefile
+ 	   ti/speex_C64_test/Makefile ])
+-
+-if test "x$src" = "x"; then 
+-echo "**IMPORTANT**"
+-echo "You don't seem to have the development package for libogg (libogg-devel) installed. Only the Speex library (libspeex) will be built (no 
encoder/decoder executable)"
+-echo "You can download libogg from http://downloads.xiph.org/releases/ogg/"
+-fi
++AC_OUTPUT
+ 
+ echo "Type \"make; make install\" to compile and install Speex";
++
++echo "------------------------------------------------------"
++echo "   Results:"
++echo "------------------------------------------------------"
++echo "   Cross compiling:       $cross_compiling"
++echo "   Target CPU:            $host_cpu"
++echo "   Target OS:             $host_os"
++echo "   Install prefix:        $prefix"
++echo "   Compiler:              $CC"
++echo "   CFLAGS:                $CFLAGS $OGG_CFLAGS"
++echo "   Additional libs:       $LIBS $OGG_LIBS"
++echo "   Coder/Encoder tools:   $enable_coders"
++echo "------------------------------------------------------"
+Index: speex-1.2rc1/Makefile.am
+===================================================================
+--- speex-1.2rc1.orig/Makefile.am
++++ speex-1.2rc1/Makefile.am
+@@ -1,5 +1,7 @@
+ ## Process this file with automake to produce Makefile.in. -*-Makefile-*-
+ 
++ACLOCAL_AMFLAGS = -I m4
++
+ # To disable automatic dependency tracking if using other tools than
+ # gcc and gmake, add the option 'no-dependencies'
+ AUTOMAKE_OPTIONS = 1.8
diff --git a/patches/speex-1.2rc1/fix_ogg_usage.diff b/patches/speex-1.2rc1/fix_ogg_usage.diff
new file mode 100644
index 0000000..0d0c30e
--- /dev/null
+++ b/patches/speex-1.2rc1/fix_ogg_usage.diff
@@ -0,0 +1,162 @@
+From: Juergen Beisert <jbe@pengutronix.de>
+Subject: [PATCH] SPEEX: avoid libogg if not really required
+
+The SPEEX library needs the oggvorbis library only when the decode/encoder tools
+are built. The library itself does not need it. But the configure test if the
+oggvorbis library is required is broken. This patch fix it by adding
+a new switch "--enable-coders". If not given, oggvorbis is not required anymore.
+Also the handmade check for oggvorbis is now replaced by a simple call to
+pkg_config.
+
+Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
+
+---
+ acinclude.m4 |  102 -----------------------------------------------------------
+ configure.ac |   25 +++++++++++++-
+ 2 files changed, 24 insertions(+), 103 deletions(-)
+
+Index: speex-1.2rc1/configure.ac
+===================================================================
+--- speex-1.2rc1.orig/configure.ac
++++ speex-1.2rc1/configure.ac
+@@ -112,9 +112,32 @@ AC_MSG_RESULT($has_visibility)
+ 
+ AC_CHECK_HEADERS(sys/soundcard.h sys/audioio.h)
+ 
+-XIPH_PATH_OGG([src="src"], [src=""])
++PKG_PROG_PKG_CONFIG
++
++# without the coder tools we do not need libogg
++AC_MSG_CHECKING([whether to build coders tools])
++AC_ARG_ENABLE([coders],
++	[AS_HELP_STRING([--enable-coders],
++		[Enable coder tools (needs oggvorbis) @<:@default=disabled@:>@])],
++	[enable_coders="$enableval"],
++	[enable_coders=no])
++AC_MSG_RESULT([${enable_coders}])
++
++# building the coders requires libogg
++if test "x$enable_coders" = xyes; then
++	src="src"
++	enable_libogg="yes"
++else
++	src=""
++	enable_libogg="no"
++fi
+ AC_SUBST(src)
+ 
++# do we need libogg?
++if test "x$enable_libogg" = xyes; then
++	PKG_CHECK_MODULES(OGG, ogg)
++fi
++
+ AC_CHECK_LIB(m, sin)
+ 
+ # Check for getopt_long; if not found, use included source.
+Index: speex-1.2rc1/acinclude.m4
+===================================================================
+--- speex-1.2rc1.orig/acinclude.m4
++++ /dev/null
+@@ -1,102 +0,0 @@
+-# Configure paths for libogg
+-# Jack Moffitt <jack@icecast.org> 10-21-2000
+-# Shamelessly stolen from Owen Taylor and Manish Singh
+-
+-dnl XIPH_PATH_OGG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+-dnl Test for libogg, and define OGG_CFLAGS and OGG_LIBS
+-dnl
+-AC_DEFUN([XIPH_PATH_OGG],
+-[dnl 
+-dnl Get the cflags and libraries
+-dnl
+-AC_ARG_WITH(ogg,[  --with-ogg=PFX   Prefix where libogg is installed (optional)], ogg_prefix="$withval", ogg_prefix="")
+-AC_ARG_WITH(ogg-libraries,[  --with-ogg-libraries=DIR   Directory where libogg library is installed (optional)], ogg_libraries="$withval", 
ogg_libraries="")
+-AC_ARG_WITH(ogg-includes,[  --with-ogg-includes=DIR   Directory where libogg header files are installed (optional)], ogg_includes="$withval", 
ogg_includes="")
+-AC_ARG_ENABLE(oggtest, [  --disable-oggtest       Do not try to compile and run a test Ogg program],, enable_oggtest=yes)
+-
+-  if test "x$ogg_libraries" != "x" ; then
+-    OGG_LIBS="-L$ogg_libraries"
+-  elif test "x$ogg_prefix" != "x" ; then
+-    OGG_LIBS="-L$ogg_prefix/lib"
+-  elif test "x$prefix" != "xNONE" ; then
+-    OGG_LIBS="-L$prefix/lib"
+-  fi
+-
+-  OGG_LIBS="$OGG_LIBS -logg"
+-
+-  if test "x$ogg_includes" != "x" ; then
+-    OGG_CFLAGS="-I$ogg_includes"
+-  elif test "x$ogg_prefix" != "x" ; then
+-    OGG_CFLAGS="-I$ogg_prefix/include"
+-  elif test "x$prefix" != "xNONE"; then
+-    OGG_CFLAGS="-I$prefix/include"
+-  fi
+-
+-  AC_MSG_CHECKING(for Ogg)
+-  no_ogg=""
+-
+-
+-  if test "x$enable_oggtest" = "xyes" ; then
+-    ac_save_CFLAGS="$CFLAGS"
+-    ac_save_LIBS="$LIBS"
+-    CFLAGS="$CFLAGS $OGG_CFLAGS"
+-    LIBS="$LIBS $OGG_LIBS"
+-dnl
+-dnl Now check if the installed Ogg is sufficiently new.
+-dnl
+-      rm -f conf.oggtest
+-      AC_TRY_RUN([
+-#include <stdio.h>
+-#include <stdlib.h>
+-#include <string.h>
+-#include <ogg/ogg.h>
+-
+-int main ()
+-{
+-  system("touch conf.oggtest");
+-  return 0;
+-}
+-
+-],, no_ogg=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
+-       CFLAGS="$ac_save_CFLAGS"
+-       LIBS="$ac_save_LIBS"
+-  fi
+-
+-  if test "x$no_ogg" = "x" ; then
+-     AC_MSG_RESULT(yes)
+-     ifelse([$1], , :, [$1])     
+-  else
+-     AC_MSG_RESULT(no)
+-     if test -f conf.oggtest ; then
+-       :
+-     else
+-       echo "*** Could not run Ogg test program, checking why..."
+-       CFLAGS="$CFLAGS $OGG_CFLAGS"
+-       LIBS="$LIBS $OGG_LIBS"
+-       AC_TRY_LINK([
+-#include <stdio.h>
+-#include <ogg/ogg.h>
+-],     [ return 0; ],
+-       [ echo "*** The test program compiled, but did not run. This usually means"
+-       echo "*** that the run-time linker is not finding Ogg or finding the wrong"
+-       echo "*** version of Ogg. If it is not finding Ogg, you'll need to set your"
+-       echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
+-       echo "*** to the installed location  Also, make sure you have run ldconfig if that"
+-       echo "*** is required on your system"
+-       echo "***"
+-       echo "*** If you have an old version installed, it is best to remove it, although"
+-       echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
+-       [ echo "*** The test program failed to compile or link. See the file config.log for the"
+-       echo "*** exact error that occured. This usually means Ogg was incorrectly installed"
+-       echo "*** or that you have moved Ogg since it was installed." ])
+-       CFLAGS="$ac_save_CFLAGS"
+-       LIBS="$ac_save_LIBS"
+-     fi
+-     OGG_CFLAGS=""
+-     OGG_LIBS=""
+-     ifelse([$2], , :, [$2])
+-  fi
+-  AC_SUBST(OGG_CFLAGS)
+-  AC_SUBST(OGG_LIBS)
+-  rm -f conf.oggtest
+-])
diff --git a/patches/speex-1.2rc1/series b/patches/speex-1.2rc1/series
new file mode 100644
index 0000000..514157f
--- /dev/null
+++ b/patches/speex-1.2rc1/series
@@ -0,0 +1,3 @@
+fix_ogg_usage.diff
+clean_up_configure_ac.diff
+add_more_autodetection.diff
diff --git a/rules/speex.in b/rules/speex.in
index 7ed3b83..060feb6 100644
--- a/rules/speex.in
+++ b/rules/speex.in
@@ -3,62 +3,41 @@
 menuconfig SPEEX
 	tristate
 	select LIBC_M
-	select GCCLIBS_GCC_S
-	select LIBOGG
+	select GCCLIBS_GCC_S if SPEEX_INSTALL_SPEEXDEC
+	select LIBOGG if SPEEX_ENABLE_TOOLS
 	prompt "speex                         "
 	help
-	  Speex is an Open Source/Free Software
-	  patent-free audio compression format
-	  designed for speech.
+	  Speex is an Open Source/Free Software patent-free audio compression
+	  format designed for speech.
 
 if SPEEX
 
-config SPEEX_FIXED_POINT
+config SPEEX_ENABLE_TOOLS
 	bool
-	prompt "use fixed point"
 
-config SPEEX_FIXED_POINT_DEBUG
-	bool
-	depends on SPEEX_FIXED_POINT
-	prompt "fixed point debugging"
-
-config SPEEX_FLOAT_API
-	bool
-	prompt "enable float api"
-
-config SPEEX_VBR
-	bool
-	prompt "enable VBR"
-
-choice
-	prompt "Kind of FFT to use"
-	default SPEEX_FFT_KISS
-
-	config SPEEX_FFT_KISS
-		bool
-		prompt "kiss"
-
-	config SPEEX_FFT_SMALLFT
-		bool
-		prompt "smallft"
-
-	config SPEEX_FFT_GPL_FFTW3
-		bool
-		depends on BROKEN
-		prompt "gpl-fftw3 [BROKEN]"
-
-	config SPEEX_FFT_PROPRIETARY_INTL_MKL
-		bool
-		depends on BROKEN
-		prompt "proprietary-intel-mkl [BROKEN]"
-endchoice
+comment "--- install options ---"
 
 config SPEEX_INSTALL_SPEEXENC
 	bool
-	prompt "Install speexenc"
+	select SPEEX_ENABLE_TOOLS
+	prompt "install speexenc"
+	help
+	  Install a tool to encode an audio file into the speex format.
+	  Note: this requires libogg
 
 config SPEEX_INSTALL_SPEEXDEC
 	bool
-	prompt "Install speexdec"
+	select SPEEX_ENABLE_TOOLS
+	prompt "install speexdec"
+	help
+	  Install a tool to decode a speex audio file.
+	  Note: this requires libogg
+
+config SPEEX_INSTALL_TESTS
+	bool
+	prompt "install tests"
+	help
+	  Install some tests from the package. Useful only for development or
+	  debugging.
 
 endif
diff --git a/rules/speex.make b/rules/speex.make
index d181ca4..f517e3c 100644
--- a/rules/speex.make
+++ b/rules/speex.make
@@ -48,35 +48,15 @@ SPEEX_FFT-$(PTXCONF_SPEEX_FFT_PROPRIETARY_INTL_MKL)	+= proprietary-intel-mkl
 SPEEX_CONF_TOOL := autoconf
 SPEEX_CONF_OPT := \
 	$(CROSS_AUTOCONF_USR) \
-	--disable-oggtest \
+	--enable-shared \
+	--disable-static \
 	--disable-valgrind \
-	--disable-fixed-point-debug \
-	--enable-fixed-point \
-	--disable-float-api \
-	--disable-vbr \
-	--disable-ti-c55x \
-	--with-fft=$(SPEEX_FFT-y) \
-	--with-ogg=$(PTXDIST_SYSROOT_TARGET)/usr
-
-ifdef PTXCONF_ARCH_ARM_V4
-SPEEX_CONF_OPT += --enable-arm4-asm
-else
-SPEEX_CONF_OPT += --disable-arm4-asm
-endif
-ifdef PTXCONF_ARCH_ARM_V5E
-SPEEX_CONF_OPT += --enable-arm5e-asm
-else
-SPEEX_CONF_OPT += --disable-arm5e-asm
-endif
-ifdef PTXCONF_ARCH_X86
-SPEEX_CONF_OPT += --enable-sse
-else
-SPEEX_CONF_OPT += --disable-sse
-endif
-ifdef PTXCONF_ARCH_BLACKFIN
-SPEEX_CONF_OPT += --enable-blackfin-asm
+	--disable-ti-c55x
+
+ifdef PTXCONF_SPEEX_ENABLE_TOOLS
+SPEEX_CONF_OPT += --enable-coders
 else
-SPEEX_CONF_OPT += --disable-blackfin-asm
+SPEEX_CONF_OPT += --disable-coders
 endif
 
 # ----------------------------------------------------------------------------
@@ -102,6 +82,20 @@ endif
 	@$(call install_lib, speex, 0, 0, 0644, libspeexdsp)
 	@$(call install_lib, speex, 0, 0, 0644, libspeex)
 
+ifdef PTXCONF_SPEEX_INSTALL_TESTS
+	@$(call install_copy, speex, 0, 0, 0755, \
+		$(SPEEX_DIR)/libspeex/testdenoise, /usr/bin/testdenoise)
+	@$(call install_copy, speex, 0, 0, 0755, \
+		$(SPEEX_DIR)/libspeex/testecho, /usr/bin/testecho)
+	@$(call install_copy, speex, 0, 0, 0755, \
+		$(SPEEX_DIR)/libspeex/testenc, /usr/bin/testenc)
+	@$(call install_copy, speex, 0, 0, 0755, \
+		$(SPEEX_DIR)/libspeex/testenc_uwb, /usr/bin/testenc_uwb)
+	@$(call install_copy, speex, 0, 0, 0755, \
+		$(SPEEX_DIR)/libspeex/testenc_wb, /usr/bin/testenc_wb)
+	@$(call install_copy, speex, 0, 0, 0755, \
+		$(SPEEX_DIR)/libspeex/testjitter, /usr/bin/testjitter)
+endif
 	@$(call install_finish, speex)
 
 	@$(call touch)

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |

-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [ptxdist] [PATCHv2] SPEEX: improve its buildsystem (sorry, in the first one the floating point detection was broken)
  2012-01-25 10:38 [ptxdist] [PATCH] SPEEX: improve its buildsystem Juergen Beisert
@ 2012-01-25 11:10 ` Juergen Beisert
  0 siblings, 0 replies; 2+ messages in thread
From: Juergen Beisert @ 2012-01-25 11:10 UTC (permalink / raw)
  To: ptxdist

    This patch adds a series of patches to the speex package to
    - fix its buildsystem
    - add libogg dependency on demand only
    - add autodetection of the architecture and possible optimizations
    
    Signed-off-by: Juergen Beisert <jbe@pengutronix.de>

diff --git a/patches/speex-1.2rc1/add_more_autodetection.diff b/patches/speex-1.2rc1/add_more_autodetection.diff
new file mode 100644
index 0000000..a30f154
--- /dev/null
+++ b/patches/speex-1.2rc1/add_more_autodetection.diff
@@ -0,0 +1,238 @@
+From: Juergen Beisert <jbe@pengutronix.de>
+Subject: [PATCH] SPEEX: let configure detect more arch settings from the compiler
+
+The preprocessor defines various symbols on its default settings and also on
+given parameters. Use these symbols to detect optimization possibilities.
+
+__SOFTFP__ is a symbol defined when the toolchain is configured to not create
+floating point instructions and call soft floating point routines instead.
+This helps to distinguish ARMv5 with or without hardware floating point support.
+
+__ARM_ARCH_4__/__ARM_ARCH_4T__ are defined if the default architecture is ARMv4,
+__ARM_ARCH_5__/__ARM_ARCH_5E__/__ARM_ARCH_5T__/__ARM_ARCH_5TE__/__ARM_ARCH_5TEJ__
+for ARMv5.
+
+__SSE__/__SSE2__/__SSE2_MATH__ for a SSE capable x86 CPU.
+
+It is easy to add more compiler symbols to detect the correct architecture.
+
+Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
+
+---
+ configure.ac |  182 +++++++++++++++++++++++++++++++++++++++++++++++++++--------
+ 1 file changed, 158 insertions(+), 24 deletions(-)
+
+Index: speex-1.2rc1/configure.ac
+===================================================================
+--- speex-1.2rc1.orig/configure.ac
++++ speex-1.2rc1/configure.ac
+@@ -64,22 +64,114 @@ AC_TYPE_INT16_T
+ AC_TYPE_INT32_T
+ AC_TYPE_SIZE_T
+ 
+-AC_MSG_CHECKING(for SSE in current arch/CFLAGS)
+-AC_LINK_IFELSE([
+-AC_LANG_PROGRAM([[
+-#include <xmmintrin.h>
+-__m128 testfunc(float *a, float *b) {
+-  return _mm_add_ps(_mm_loadu_ps(a), _mm_loadu_ps(b));
+-}
+-]])],
+-[
+-has_sse=yes
+-],
+-[
+-has_sse=no
+-]
+-)
+-AC_MSG_RESULT($has_sse)  
++target_arch_detected=guessed
++
++# ---------------------------------------------------------------------------
++
++case $host_cpu in
++	i?86)
++		base_arch=x86
++		;;
++	arm)
++		base_arch=arm;
++		;;
++	*)
++		base_arch=unknown;
++		;;
++esac
++
++# ---------------------------------------------------------------------------
++
++#
++# Checking for specific features speex can be optimized for is more or less
++# guessed from the pre-compiler macros.
++#
++AC_MSG_CHECKING(for hardware floating point support)
++AC_COMPILE_IFELSE(
++	[AC_LANG_PROGRAM([[]],
++	[[
++#define HARD_FP_SUPPORT 1
++#if defined(__SOFTFP__)
++# undef HARD_FP_SUPPORT
++#endif
++int foo = HARD_FP_SUPPORT;
++	]])],
++	[target_hardware_fp=yes],
++	[target_hardware_fp=no],
++	[hardware FP])
++AC_MSG_RESULT(${target_hardware_fp})
++
++# When a hardware floating point unit seems available, then use it.
++# This will end in bad code on badly configured compilers which generates
++# floating point instructions even if the CPU has not hardware FP unit
++#
++if test x${target_hardware_fp} = xyes; then
++	enable_fixed_point=no
++	enable_float_api=yes
++	enable_vbr=yes
++	with_fft=smallft
++	math_type="floating"
++else
++	enable_fixed_point=yes
++	enable_float_api=no
++	enable_vbr=no
++	with_fft=kiss
++	math_type="fixed"
++fi
++
++# ---------------------------------------------------------------------------
++
++if test x${base_arch} = xarm; then
++# discover the architecture this compiler builds code for
++
++enable_arm4_asm=no;
++enable_arm5e_asm=no;
++
++# check here for symbols the preprocessor automatically defines.
++# To find the correct symbol to test for just run "cpp -dM" and press CTRL-D.
++
++AC_MSG_CHECKING(for ARMv4 architecture)
++AC_COMPILE_IFELSE(
++	[AC_LANG_PROGRAM([[]],
++	[[
++#undef THIS_IS_V4
++#if defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__)
++# define THIS_IS_V4 1
++#endif
++int foo = THIS_IS_V4;
++	]])],
++	[enable_arm4_asm=yes; optimized_for="ARMv4"; target_arch_detected=yes],
++	[],
++	[Optimize for ARMv4])
++AC_MSG_RESULT(${target_arch_detected})
++
++if test x${target_arch_detected} = xguessed; then
++
++AC_MSG_CHECKING(for ARMv5 architecture)
++AC_COMPILE_IFELSE(
++	[AC_LANG_PROGRAM([[]],
++	[[
++#undef THIS_IS_V5
++#if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5T__) || defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__)
++# define THIS_IS_V5 1
++#endif
++int foo = THIS_IS_V5;
++	]])],
++	[enable_arm5e_asm=yes; optimized_for="ARMv5"; target_arch_detected=yes],
++	[],
++	[Optimize for ARMv5])
++AC_MSG_RESULT(${target_arch_detected})
++
++fi
++
++if test x${target_arch_detected} = xguessed; then
++	optimized_for="ARM"
++fi
++
++fi
++
++# end of ARM
++# ---------------------------------------------------------------------------
+ 
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -fvisibility=hidden"
+@@ -156,15 +248,44 @@ AC_ARG_ENABLE(valgrind, [  --enable-valg
+   AC_DEFINE([ENABLE_VALGRIND], , [Enable valgrind extra checks])
+ fi])
+ 
+-AC_ARG_ENABLE(sse, [  --enable-sse            Enable SSE support], [
+-if test "x$enableval" != xno; then
+-has_sse=yes
+-CFLAGS="$CFLAGS -O3 -msse"
++# ---------------------------------------------------------------------------
++# x86 optimization
++
++AC_MSG_CHECKING(wether to enable SSE math)
++AC_ARG_ENABLE(sse,
++	[AS_HELP_STRING([--enable-sse],
++		[Enable SSE support @<:@default=disabled@:>@])],
++	[has_sse="$enableval"],
++	[has_sse="guessing"])
++AC_MSG_RESULT(${has_sse})
++
++if test x${base_arch} != xx86; then
++	has_sse=no
+ else
+-has_sse=no
++	target_arch_detected=guessed
++	optimized_for="x86";
++
++# if the user do not define this parameter, try to guess it
++	if test x${has_sse} = xguessing ; then
++AC_MSG_CHECKING(guessing for SSE capability)
++AC_COMPILE_IFELSE(
++	[AC_LANG_PROGRAM([[]],
++	[[
++#undef SSE_IS_POSSIBLE
++#if defined(__SSE__) || defined(__SSE2__) || defined(__SSE2_MATH__)
++# define SSE_IS_POSSIBLE 1
++#endif
++int foo = SSE_IS_POSSIBLE;
++	]])],
++	[has_sse=yes; CFLAGS="$CFLAGS -O3 -msse"],
++	[has_sse=no],
++	[Optimize for SSE])
++AC_MSG_RESULT(${has_sse})
++fi
+ fi
+-])
+ 
++# end of x86 optimization
++# ---------------------------------------------------------------------------
+ 
+ FFT=smallft
+ 
+@@ -316,8 +437,6 @@ AC_CONFIG_FILES([Makefile libspeex/Makef
+ 	   ti/speex_C64_test/Makefile ])
+ AC_OUTPUT
+ 
+-echo "Type \"make; make install\" to compile and install Speex";
+-
+ echo "------------------------------------------------------"
+ echo "   Results:"
+ echo "------------------------------------------------------"
+@@ -330,3 +449,18 @@ echo "   CFLAGS:                $CFLAGS 
+ echo "   Additional libs:       $LIBS $OGG_LIBS"
+ echo "   Coder/Encoder tools:   $enable_coders"
+ echo "------------------------------------------------------"
++echo "   Architecture specific settings:"
++echo ""
++echo "   Arch discovered:       ${target_arch_detected}"
++echo "   Base architecture:     ${base_arch}"
++echo "   Optimized for:         ${optimized_for} with ${math_type} point"
++if test x${base_arch} = xx86; then
++echo "    enable SSE math:      ${has_sse}"
++fi
++if test x${base_arch} = xarm; then
++	echo "    ARMv4 enabled:        ${enable_arm4_asm}"
++	echo "    ARMv5 enabled:        ${enable_arm5e_asm}"
++fi
++echo "------------------------------------------------------"
++
++echo "Type \"make; make install\" to compile and install Speex";
diff --git a/patches/speex-1.2rc1/autogen.sh b/patches/speex-1.2rc1/autogen.sh
new file mode 120000
index 0000000..9f8a4cb
--- /dev/null
+++ b/patches/speex-1.2rc1/autogen.sh
@@ -0,0 +1 @@
+../autogen.sh
\ No newline at end of file
diff --git a/patches/speex-1.2rc1/clean_up_configure_ac.diff b/patches/speex-1.2rc1/clean_up_configure_ac.diff
new file mode 100644
index 0000000..72abf44
--- /dev/null
+++ b/patches/speex-1.2rc1/clean_up_configure_ac.diff
@@ -0,0 +1,160 @@
+From: Juergen Beisert <jbe@pengutronix.de>
+Subject: [PATCH] SPEEX: update the configure.ac by running 'autoupdate'
+
+Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
+
+---
+ Makefile.am  |    2 +
+ configure.ac |   81 +++++++++++++++++++++++++++++------------------------------
+ 2 files changed, 43 insertions(+), 40 deletions(-)
+
+Index: speex-1.2rc1/configure.ac
+===================================================================
+--- speex-1.2rc1.orig/configure.ac
++++ speex-1.2rc1/configure.ac
+@@ -1,8 +1,10 @@
+ dnl Process this file with autoconf to produce a configure script. -*-m4-*-
+ 
+-AC_INIT(libspeex/speex.c)
++AC_INIT
++AC_CONFIG_SRCDIR([libspeex/speex.c])
+ 
+-AM_CONFIG_HEADER([config.h])
++AC_CONFIG_HEADERS([config.h])
++AC_CONFIG_MACRO_DIR([m4])
+ 
+ SPEEX_MAJOR_VERSION=1
+ SPEEX_MINOR_VERSION=1
+@@ -30,8 +32,11 @@ AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-
+ AM_MAINTAINER_MODE
+ 
+ AC_CANONICAL_HOST
+-AC_LIBTOOL_WIN32_DLL
+-AM_PROG_LIBTOOL
++
++LT_INIT
++
++# default is more output while building the package
++AM_SILENT_RULES()
+ 
+ AC_C_BIGENDIAN
+ AC_C_CONST
+@@ -40,37 +45,24 @@ AC_C_RESTRICT
+ 
+ 
+ AC_MSG_CHECKING(for C99 variable-size arrays)
+-AC_TRY_COMPILE( , [
++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
+ int foo;
+ foo = 10;
+ int array[foo];
+-],
+-[has_var_arrays=yes;AC_DEFINE([VAR_ARRAYS], [], [Use C99 variable-size arrays])
+-],
+-has_var_arrays=no
+-)
++]])],[has_var_arrays=yes;AC_DEFINE([VAR_ARRAYS], [], [Use C99 variable-size arrays])
++],[has_var_arrays=no
++])
+ AC_MSG_RESULT($has_var_arrays)
+ 
+-AC_CHECK_HEADERS([alloca.h getopt.h])
+-AC_MSG_CHECKING(for alloca)
+-AC_TRY_COMPILE( [
+-#ifdef HAVE_ALLOCA_H
+-# include <alloca.h>
+-#endif
+-#include <stdlib.h>
+-], [
+-int foo=10;
+-int *array = alloca(foo);
+-],
+-[
+-has_alloca=yes;
+-if test x$has_var_arrays = "xno" ; then
+-AC_DEFINE([USE_ALLOCA], [], [Make use of alloca])
+-fi
+-],
+-has_alloca=no
+-)
+-AC_MSG_RESULT($has_alloca)
++AC_CHECK_HEADERS([alloca.h getopt.h fcntl.h libintl.h malloc.h sys/ioctl.h])
++AC_FUNC_ALLOCA
++AC_FUNC_MALLOC
++AC_FUNC_REALLOC
++AC_CHECK_FUNCS([floor memset pow sqrt strchr])
++
++AC_TYPE_INT16_T
++AC_TYPE_INT32_T
++AC_TYPE_SIZE_T
+ 
+ AC_MSG_CHECKING(for SSE in current arch/CFLAGS)
+ AC_LINK_IFELSE([
+@@ -138,7 +130,9 @@ if test "x$enable_libogg" = xyes; then
+ 	PKG_CHECK_MODULES(OGG, ogg)
+ fi
+ 
+-AC_CHECK_LIB(m, sin)
++AC_SEARCH_LIBS([floor], [m], [], [AC_MSG_ERROR([unable to find the floor() function])])
++AC_SEARCH_LIBS([pow], [m], [], [AC_MSG_ERROR([unable to find the pow() function])])
++AC_SEARCH_LIBS([sqrt], [m], [], [AC_MSG_ERROR([unable to find the sqrt() function])])
+ 
+ # Check for getopt_long; if not found, use included source.
+ AC_CHECK_FUNCS([getopt_long],,
+@@ -181,8 +175,7 @@ AC_ARG_ENABLE(fixed-point, [  --enable-f
+   AC_DEFINE([FIXED_POINT], , [Compile as fixed-point])
+ else
+   AC_DEFINE([FLOATING_POINT], , [Compile as floating-point])
+-fi],
+-AC_DEFINE([FLOATING_POINT], , [Compile as floating-point]))
++fi],AC_DEFINE([FLOATING_POINT], , [Compile as floating-point]))
+ 
+ if test "$has_sse" = yes; then
+   AC_DEFINE([_USE_SSE], , [Enable SSE support])
+@@ -296,7 +289,7 @@ fi
+ AC_SUBST(SIZE16)
+ AC_SUBST(SIZE32)
+ 
+-AC_OUTPUT([Makefile libspeex/Makefile src/Makefile doc/Makefile Speex.spec
++AC_CONFIG_FILES([Makefile libspeex/Makefile src/Makefile doc/Makefile Speex.spec
+            include/Makefile include/speex/Makefile speex.pc speexdsp.pc
+            win32/Makefile win32/libspeex/Makefile win32/speexenc/Makefile
+            win32/speexdec/Makefile symbian/Makefile 
+@@ -321,11 +314,19 @@ AC_OUTPUT([Makefile libspeex/Makefile sr
+            include/speex/speex_config_types.h ti/Makefile 
+ 	   ti/speex_C54_test/Makefile ti/speex_C55_test/Makefile
+ 	   ti/speex_C64_test/Makefile ])
+-
+-if test "x$src" = "x"; then 
+-echo "**IMPORTANT**"
+-echo "You don't seem to have the development package for libogg (libogg-devel) installed. Only the Speex library (libspeex) will be built (no 
encoder/decoder executable)"
+-echo "You can download libogg from http://downloads.xiph.org/releases/ogg/"
+-fi
++AC_OUTPUT
+ 
+ echo "Type \"make; make install\" to compile and install Speex";
++
++echo "------------------------------------------------------"
++echo "   Results:"
++echo "------------------------------------------------------"
++echo "   Cross compiling:       $cross_compiling"
++echo "   Target CPU:            $host_cpu"
++echo "   Target OS:             $host_os"
++echo "   Install prefix:        $prefix"
++echo "   Compiler:              $CC"
++echo "   CFLAGS:                $CFLAGS $OGG_CFLAGS"
++echo "   Additional libs:       $LIBS $OGG_LIBS"
++echo "   Coder/Encoder tools:   $enable_coders"
++echo "------------------------------------------------------"
+Index: speex-1.2rc1/Makefile.am
+===================================================================
+--- speex-1.2rc1.orig/Makefile.am
++++ speex-1.2rc1/Makefile.am
+@@ -1,5 +1,7 @@
+ ## Process this file with automake to produce Makefile.in. -*-Makefile-*-
+ 
++ACLOCAL_AMFLAGS = -I m4
++
+ # To disable automatic dependency tracking if using other tools than
+ # gcc and gmake, add the option 'no-dependencies'
+ AUTOMAKE_OPTIONS = 1.8
diff --git a/patches/speex-1.2rc1/fix_ogg_usage.diff b/patches/speex-1.2rc1/fix_ogg_usage.diff
new file mode 100644
index 0000000..0d0c30e
--- /dev/null
+++ b/patches/speex-1.2rc1/fix_ogg_usage.diff
@@ -0,0 +1,162 @@
+From: Juergen Beisert <jbe@pengutronix.de>
+Subject: [PATCH] SPEEX: avoid libogg if not really required
+
+The SPEEX library needs the oggvorbis library only when the decode/encoder tools
+are built. The library itself does not need it. But the configure test if the
+oggvorbis library is required is broken. This patch fix it by adding
+a new switch "--enable-coders". If not given, oggvorbis is not required anymore.
+Also the handmade check for oggvorbis is now replaced by a simple call to
+pkg_config.
+
+Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
+
+---
+ acinclude.m4 |  102 -----------------------------------------------------------
+ configure.ac |   25 +++++++++++++-
+ 2 files changed, 24 insertions(+), 103 deletions(-)
+
+Index: speex-1.2rc1/configure.ac
+===================================================================
+--- speex-1.2rc1.orig/configure.ac
++++ speex-1.2rc1/configure.ac
+@@ -112,9 +112,32 @@ AC_MSG_RESULT($has_visibility)
+ 
+ AC_CHECK_HEADERS(sys/soundcard.h sys/audioio.h)
+ 
+-XIPH_PATH_OGG([src="src"], [src=""])
++PKG_PROG_PKG_CONFIG
++
++# without the coder tools we do not need libogg
++AC_MSG_CHECKING([whether to build coders tools])
++AC_ARG_ENABLE([coders],
++	[AS_HELP_STRING([--enable-coders],
++		[Enable coder tools (needs oggvorbis) @<:@default=disabled@:>@])],
++	[enable_coders="$enableval"],
++	[enable_coders=no])
++AC_MSG_RESULT([${enable_coders}])
++
++# building the coders requires libogg
++if test "x$enable_coders" = xyes; then
++	src="src"
++	enable_libogg="yes"
++else
++	src=""
++	enable_libogg="no"
++fi
+ AC_SUBST(src)
+ 
++# do we need libogg?
++if test "x$enable_libogg" = xyes; then
++	PKG_CHECK_MODULES(OGG, ogg)
++fi
++
+ AC_CHECK_LIB(m, sin)
+ 
+ # Check for getopt_long; if not found, use included source.
+Index: speex-1.2rc1/acinclude.m4
+===================================================================
+--- speex-1.2rc1.orig/acinclude.m4
++++ /dev/null
+@@ -1,102 +0,0 @@
+-# Configure paths for libogg
+-# Jack Moffitt <jack@icecast.org> 10-21-2000
+-# Shamelessly stolen from Owen Taylor and Manish Singh
+-
+-dnl XIPH_PATH_OGG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+-dnl Test for libogg, and define OGG_CFLAGS and OGG_LIBS
+-dnl
+-AC_DEFUN([XIPH_PATH_OGG],
+-[dnl 
+-dnl Get the cflags and libraries
+-dnl
+-AC_ARG_WITH(ogg,[  --with-ogg=PFX   Prefix where libogg is installed (optional)], ogg_prefix="$withval", ogg_prefix="")
+-AC_ARG_WITH(ogg-libraries,[  --with-ogg-libraries=DIR   Directory where libogg library is installed (optional)], ogg_libraries="$withval", 
ogg_libraries="")
+-AC_ARG_WITH(ogg-includes,[  --with-ogg-includes=DIR   Directory where libogg header files are installed (optional)], ogg_includes="$withval", 
ogg_includes="")
+-AC_ARG_ENABLE(oggtest, [  --disable-oggtest       Do not try to compile and run a test Ogg program],, enable_oggtest=yes)
+-
+-  if test "x$ogg_libraries" != "x" ; then
+-    OGG_LIBS="-L$ogg_libraries"
+-  elif test "x$ogg_prefix" != "x" ; then
+-    OGG_LIBS="-L$ogg_prefix/lib"
+-  elif test "x$prefix" != "xNONE" ; then
+-    OGG_LIBS="-L$prefix/lib"
+-  fi
+-
+-  OGG_LIBS="$OGG_LIBS -logg"
+-
+-  if test "x$ogg_includes" != "x" ; then
+-    OGG_CFLAGS="-I$ogg_includes"
+-  elif test "x$ogg_prefix" != "x" ; then
+-    OGG_CFLAGS="-I$ogg_prefix/include"
+-  elif test "x$prefix" != "xNONE"; then
+-    OGG_CFLAGS="-I$prefix/include"
+-  fi
+-
+-  AC_MSG_CHECKING(for Ogg)
+-  no_ogg=""
+-
+-
+-  if test "x$enable_oggtest" = "xyes" ; then
+-    ac_save_CFLAGS="$CFLAGS"
+-    ac_save_LIBS="$LIBS"
+-    CFLAGS="$CFLAGS $OGG_CFLAGS"
+-    LIBS="$LIBS $OGG_LIBS"
+-dnl
+-dnl Now check if the installed Ogg is sufficiently new.
+-dnl
+-      rm -f conf.oggtest
+-      AC_TRY_RUN([
+-#include <stdio.h>
+-#include <stdlib.h>
+-#include <string.h>
+-#include <ogg/ogg.h>
+-
+-int main ()
+-{
+-  system("touch conf.oggtest");
+-  return 0;
+-}
+-
+-],, no_ogg=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
+-       CFLAGS="$ac_save_CFLAGS"
+-       LIBS="$ac_save_LIBS"
+-  fi
+-
+-  if test "x$no_ogg" = "x" ; then
+-     AC_MSG_RESULT(yes)
+-     ifelse([$1], , :, [$1])     
+-  else
+-     AC_MSG_RESULT(no)
+-     if test -f conf.oggtest ; then
+-       :
+-     else
+-       echo "*** Could not run Ogg test program, checking why..."
+-       CFLAGS="$CFLAGS $OGG_CFLAGS"
+-       LIBS="$LIBS $OGG_LIBS"
+-       AC_TRY_LINK([
+-#include <stdio.h>
+-#include <ogg/ogg.h>
+-],     [ return 0; ],
+-       [ echo "*** The test program compiled, but did not run. This usually means"
+-       echo "*** that the run-time linker is not finding Ogg or finding the wrong"
+-       echo "*** version of Ogg. If it is not finding Ogg, you'll need to set your"
+-       echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
+-       echo "*** to the installed location  Also, make sure you have run ldconfig if that"
+-       echo "*** is required on your system"
+-       echo "***"
+-       echo "*** If you have an old version installed, it is best to remove it, although"
+-       echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
+-       [ echo "*** The test program failed to compile or link. See the file config.log for the"
+-       echo "*** exact error that occured. This usually means Ogg was incorrectly installed"
+-       echo "*** or that you have moved Ogg since it was installed." ])
+-       CFLAGS="$ac_save_CFLAGS"
+-       LIBS="$ac_save_LIBS"
+-     fi
+-     OGG_CFLAGS=""
+-     OGG_LIBS=""
+-     ifelse([$2], , :, [$2])
+-  fi
+-  AC_SUBST(OGG_CFLAGS)
+-  AC_SUBST(OGG_LIBS)
+-  rm -f conf.oggtest
+-])
diff --git a/patches/speex-1.2rc1/series b/patches/speex-1.2rc1/series
new file mode 100644
index 0000000..514157f
--- /dev/null
+++ b/patches/speex-1.2rc1/series
@@ -0,0 +1,3 @@
+fix_ogg_usage.diff
+clean_up_configure_ac.diff
+add_more_autodetection.diff
diff --git a/rules/speex.in b/rules/speex.in
index 7ed3b83..060feb6 100644
--- a/rules/speex.in
+++ b/rules/speex.in
@@ -3,62 +3,41 @@
 menuconfig SPEEX
 	tristate
 	select LIBC_M
-	select GCCLIBS_GCC_S
-	select LIBOGG
+	select GCCLIBS_GCC_S if SPEEX_INSTALL_SPEEXDEC
+	select LIBOGG if SPEEX_ENABLE_TOOLS
 	prompt "speex                         "
 	help
-	  Speex is an Open Source/Free Software
-	  patent-free audio compression format
-	  designed for speech.
+	  Speex is an Open Source/Free Software patent-free audio compression
+	  format designed for speech.
 
 if SPEEX
 
-config SPEEX_FIXED_POINT
+config SPEEX_ENABLE_TOOLS
 	bool
-	prompt "use fixed point"
 
-config SPEEX_FIXED_POINT_DEBUG
-	bool
-	depends on SPEEX_FIXED_POINT
-	prompt "fixed point debugging"
-
-config SPEEX_FLOAT_API
-	bool
-	prompt "enable float api"
-
-config SPEEX_VBR
-	bool
-	prompt "enable VBR"
-
-choice
-	prompt "Kind of FFT to use"
-	default SPEEX_FFT_KISS
-
-	config SPEEX_FFT_KISS
-		bool
-		prompt "kiss"
-
-	config SPEEX_FFT_SMALLFT
-		bool
-		prompt "smallft"
-
-	config SPEEX_FFT_GPL_FFTW3
-		bool
-		depends on BROKEN
-		prompt "gpl-fftw3 [BROKEN]"
-
-	config SPEEX_FFT_PROPRIETARY_INTL_MKL
-		bool
-		depends on BROKEN
-		prompt "proprietary-intel-mkl [BROKEN]"
-endchoice
+comment "--- install options ---"
 
 config SPEEX_INSTALL_SPEEXENC
 	bool
-	prompt "Install speexenc"
+	select SPEEX_ENABLE_TOOLS
+	prompt "install speexenc"
+	help
+	  Install a tool to encode an audio file into the speex format.
+	  Note: this requires libogg
 
 config SPEEX_INSTALL_SPEEXDEC
 	bool
-	prompt "Install speexdec"
+	select SPEEX_ENABLE_TOOLS
+	prompt "install speexdec"
+	help
+	  Install a tool to decode a speex audio file.
+	  Note: this requires libogg
+
+config SPEEX_INSTALL_TESTS
+	bool
+	prompt "install tests"
+	help
+	  Install some tests from the package. Useful only for development or
+	  debugging.
 
 endif
diff --git a/rules/speex.make b/rules/speex.make
index d181ca4..f517e3c 100644
--- a/rules/speex.make
+++ b/rules/speex.make
@@ -48,35 +48,15 @@ SPEEX_FFT-$(PTXCONF_SPEEX_FFT_PROPRIETARY_INTL_MKL)	+= proprietary-intel-mkl
 SPEEX_CONF_TOOL := autoconf
 SPEEX_CONF_OPT := \
 	$(CROSS_AUTOCONF_USR) \
-	--disable-oggtest \
+	--enable-shared \
+	--disable-static \
 	--disable-valgrind \
-	--disable-fixed-point-debug \
-	--enable-fixed-point \
-	--disable-float-api \
-	--disable-vbr \
-	--disable-ti-c55x \
-	--with-fft=$(SPEEX_FFT-y) \
-	--with-ogg=$(PTXDIST_SYSROOT_TARGET)/usr
-
-ifdef PTXCONF_ARCH_ARM_V4
-SPEEX_CONF_OPT += --enable-arm4-asm
-else
-SPEEX_CONF_OPT += --disable-arm4-asm
-endif
-ifdef PTXCONF_ARCH_ARM_V5E
-SPEEX_CONF_OPT += --enable-arm5e-asm
-else
-SPEEX_CONF_OPT += --disable-arm5e-asm
-endif
-ifdef PTXCONF_ARCH_X86
-SPEEX_CONF_OPT += --enable-sse
-else
-SPEEX_CONF_OPT += --disable-sse
-endif
-ifdef PTXCONF_ARCH_BLACKFIN
-SPEEX_CONF_OPT += --enable-blackfin-asm
+	--disable-ti-c55x
+
+ifdef PTXCONF_SPEEX_ENABLE_TOOLS
+SPEEX_CONF_OPT += --enable-coders
 else
-SPEEX_CONF_OPT += --disable-blackfin-asm
+SPEEX_CONF_OPT += --disable-coders
 endif
 
 # ----------------------------------------------------------------------------
@@ -102,6 +82,20 @@ endif
 	@$(call install_lib, speex, 0, 0, 0644, libspeexdsp)
 	@$(call install_lib, speex, 0, 0, 0644, libspeex)
 
+ifdef PTXCONF_SPEEX_INSTALL_TESTS
+	@$(call install_copy, speex, 0, 0, 0755, \
+		$(SPEEX_DIR)/libspeex/testdenoise, /usr/bin/testdenoise)
+	@$(call install_copy, speex, 0, 0, 0755, \
+		$(SPEEX_DIR)/libspeex/testecho, /usr/bin/testecho)
+	@$(call install_copy, speex, 0, 0, 0755, \
+		$(SPEEX_DIR)/libspeex/testenc, /usr/bin/testenc)
+	@$(call install_copy, speex, 0, 0, 0755, \
+		$(SPEEX_DIR)/libspeex/testenc_uwb, /usr/bin/testenc_uwb)
+	@$(call install_copy, speex, 0, 0, 0755, \
+		$(SPEEX_DIR)/libspeex/testenc_wb, /usr/bin/testenc_wb)
+	@$(call install_copy, speex, 0, 0, 0755, \
+		$(SPEEX_DIR)/libspeex/testjitter, /usr/bin/testjitter)
+endif
 	@$(call install_finish, speex)
 
 	@$(call touch)

-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-25 11:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-25 10:38 [ptxdist] [PATCH] SPEEX: improve its buildsystem Juergen Beisert
2012-01-25 11:10 ` [ptxdist] [PATCHv2] SPEEX: improve its buildsystem (sorry, in the first one the floating point detection was broken) Juergen Beisert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox