From 2852cb1486ca68fe418bdebcda7ecc9581127b4d Mon Sep 17 00:00:00 2001
From: Ralph Giles <giles@mozilla.com>
Date: Tue, 2 Aug 2011 11:43:43 -0700
Subject: [PATCH] Tell automake to put object files in subdirectories.

Previously the autotools build litered whatever directory
'make' was invoked from with intermediate files. Adding
'subdir-objects' to AUTOMAKE_OPTIONS tells it to put them
in subdirectories according to the relative paths to the
source files, .i.e. silk/schur.o for $(srcdir)/silk/schur.c

The change to autogen.sh is necessary to handle the
(apparently new) case where an AUTOMAKE_OPTIONS line is
given without a minimum version number.
---
 Makefile.am  | 2 ++
 autogen.sh   | 8 ++++++--
 configure.ac | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 76490f7fa..791b19802 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,5 @@
+AUTOMAKE_OPTIONS = subdir-objects
+
 lib_LTLIBRARIES = libopus.la
 
 INCLUDES = -I$(top_srcdir)/libcelt -I$(top_srcdir)/silk -I$(top_srcdir)/silk/float -I$(top_srcdir)/silk/fixed
diff --git a/autogen.sh b/autogen.sh
index 35cad6789..60d6ef18f 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -22,10 +22,14 @@ echo "checking for autoconf... "
 
 VERSIONGREP="sed -e s/.*[^0-9\.]\([0-9]\.[0-9]*\).*/\1/"
 VERSIONMKINT="sed -e s/[^0-9]//"
-                                                                                
+
 # do we need automake?
 if test -r Makefile.am; then
-  AM_NEEDED=`fgrep AUTOMAKE_OPTIONS Makefile.am | $VERSIONGREP`
+  AM_OPTIONS=`fgrep AUTOMAKE_OPTIONS Makefile.am`
+  AM_NEEDED=`echo $AM_OPTIONS | $VERSIONGREP`
+  if test "$AM_NEEDED" = "$AM_OPTIONS"; then
+    AM_NEEDED=""
+  fi
   if test -z $AM_NEEDED; then
     echo -n "checking for automake... "
     AUTOMAKE=automake
diff --git a/configure.ac b/configure.ac
index 747623dbf..5a3077887 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,6 +45,7 @@ AM_MAINTAINER_MODE
 
 AC_CANONICAL_HOST
 AM_PROG_LIBTOOL
+AM_PROG_CC_C_O
 
 AC_PROG_CC_C99
 AC_C_BIGENDIAN
-- 
GitLab