--- configure.in.1.2.0	2008-02-02 14:29:37.000000000 +0000
+++ configure.in	2008-02-02 14:30:32.000000000 +0000
@@ -191,21 +191,46 @@
 AC_CHECK_LIB(pthread, pthread_create, pthread_lib="-lpthread", :)
 
 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(must have Ogg installed!))
-  libs_save=$LIBS
-  LIBS="$OGG_LIBS $VORBIS_LIBS"
-  AC_CHECK_FUNC(oggpack_writealign, , AC_MSG_ERROR(Ogg >= 1.0 required !))
-  LIBS=$libs_save
+
+dnl Audacity-specific code by dmazzoni:
+dnl If libogg is in the same parent directory and it has been
+dnl configured already, then we assume that libogg is going to
+dnl be built, too.
+AC_CHECK_FILE(../libogg/include/ogg/ogg.h,
+              ogg_h_available="yes",
+              ogg_h_available="no")
+
+AC_CHECK_FILE(../libogg/Makefile,
+              ogg_configured="yes",
+              ogg_configured="no")
+
+if test "x$ogg_configured" = "xyes" && test "x$ogg_h_available" = "xyes" ; then
+  echo "Using local libogg library from Audacity lib-src directory."
+
+  AC_SUBST(OGG_CFLAGS)
+  AC_SUBST(OGG_LIBS)
+
+  OGG_LIBS="-L../.. -logg"
+  LIBS="-L../.. -logg"
+  OGG_CFLAGS="-I../../libogg/include"
+
+else
+  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(must have Ogg installed!))
+    libs_save=$LIBS
+    LIBS="$OGG_LIBS $VORBIS_LIBS"
+    AC_CHECK_FUNC(oggpack_writealign, , AC_MSG_ERROR(Ogg >= 1.0 required !))
+    LIBS=$libs_save
+  fi
 fi
 
 dnl --------------------------------------------------
