ref: 1d128b4d5c6faad1346e6908c0cfb9c7e2cd7243
parent: d8e1592db3ecd720e3c7891ed222e07bfbd3c322
author: Ralph Giles <giles@mozilla.com>
date: Wed May 30 06:47:56 EDT 2012
Try linking opus when testing -fPIE. When build against a static libopus (built without -fPIC) the final link with -fPIE will fail. It's convenient to be able to do this for building against an uninstalled libopus. Unfortunately this involves moving the -fPIE check until after the library checks, so we can add it to the link line before testing. We also have to reference a libopus symbol to keep the linker from skipping the dependency.
--- a/configure.ac
+++ b/configure.ac
@@ -104,6 +104,75 @@
AC_DEFINE([ENABLE_ASSERTIONS], , [Assertions])
fi])
+dnl check for Ogg
+HAVE_OGG=no
+
+dnl first check through pkg-config since it's more flexible
+
+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.3, 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([
+ libogg is required to build this package!
+ please see http://www.xiph.org/ for how to
+ obtain a copy.
+ ]))
+ cflags_save=$CFLAGS
+ libs_save=$LIBS
+ CFLAGS="$CFLAGS $OGG_CFLAGS"
+ LIBS="$LIBS $OGG_LIBS"
+ AC_CHECK_FUNC(ogg_stream_flush_fill, , [
+ AC_MSG_ERROR([newer libogg version (1.3 or later) required])
+ ])
+ CFLAGS=$cflags_save
+ LIBS=$libs_save
+fi
+
+dnl check for Opus
+HAVE_OPUS=no
+
+dnl first check through pkg-config since it's more flexible
+
+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(Opus, opus >= 0.9.10, HAVE_OPUS=yes, HAVE_OPUS=no)
+fi
+if test "x$HAVE_OPUS" = "xno"
+then
+ AC_MSG_ERROR([
+ Opus is required to build this package!
+ please see http://opus-codec.org/ for how to
+ obtain a copy.])
+fi
+
+dnl check for OSS
+HAVE_OSS=no
+AC_CHECK_HEADERS([sys/soundcard.h soundcard.h machine/soundcard.h],[
+ HAVE_OSS=yes
+ break
+])
+if test x$HAVE_OSS != xyes; then
+ AC_MSG_WARN([OSS audio support not found -- no direct audio output in opusdec])
+fi
+
+dnl OpenBSD needs -lossaudio to use the oss interface
+OSS_LIBS=
+case "$host_os" in
+ openbsd*)
+ OSS_LIBS='-lossaudio'
+ ;;
+esac
+AC_SUBST(OSS_LIBS)
+
+
dnl Enable stack-protector-all only on x86 where it's well supported.
dnl on some platforms it causes crashes. Hopefully the OS's default's
dnl include this on platforms that work but have been missed here.
@@ -130,10 +199,16 @@
save_CFLAGS="$CFLAGS"
save_LDFLAGS="$LDFLAGS"
-CFLAGS="$CFLAGS -fPIE"
+save_LIBS="$LIBS"
+CFLAGS="$CFLAGS -fPIE $Opus_CFLAGS"
LDFLAGS="$LDFLAGS -pie -Wl,-z,relro -Wl,-z,now"
+LIBS="$LIBS $Opus_LIBS"
AC_MSG_CHECKING([for PIE support])
-AC_LINK_IFELSE([AC_LANG_SOURCE([void main () {}])],
+AC_LINK_IFELSE([AC_LANG_SOURCE([
+#include <opus.h>
+void main () {
+ OpusDecoder *dec = opus_decoder_create(48000, 2, 0L);
+}])],
[have_pie=yes],
[have_pie=no])
AC_MSG_RESULT([$have_pie])
@@ -143,6 +218,7 @@
fi
CFLAGS="$save_CFLAGS $PIE_CFLAGS"
LDFLAGS="$save_LDFLAGS $PIE_LDFLAGS"
+LIBS="$save_LIBS"
CFLAGS="$CFLAGS -W"
@@ -192,75 +268,6 @@
AC_SUBST(SIZE16)
AC_SUBST(SIZE32)
-
-dnl check for Ogg
-HAVE_OGG=no
-
-dnl first check through pkg-config since it's more flexible
-
-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.3, 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([
- libogg is required to build this package!
- please see http://www.xiph.org/ for how to
- obtain a copy.
- ]))
- cflags_save=$CFLAGS
- libs_save=$LIBS
- CFLAGS="$CFLAGS $OGG_CFLAGS"
- LIBS="$LIBS $OGG_LIBS"
- AC_CHECK_FUNC(ogg_stream_flush_fill, , [
- AC_MSG_ERROR([newer libogg version (1.3 or later) required])
- ])
- CFLAGS=$cflags_save
- LIBS=$libs_save
-fi
-
-dnl check for Opus
-HAVE_OPUS=no
-
-dnl first check through pkg-config since it's more flexible
-
-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(Opus, opus >= 0.9.10, HAVE_OPUS=yes, HAVE_OPUS=no)
-fi
-if test "x$HAVE_OPUS" = "xno"
-then
- AC_MSG_ERROR([
- Opus is required to build this package!
- please see http://opus-codec.org/ for how to
- obtain a copy.])
-fi
-
-dnl check for OSS
-HAVE_OSS=no
-AC_CHECK_HEADERS([sys/soundcard.h soundcard.h machine/soundcard.h],[
- HAVE_OSS=yes
- break
-])
-if test x$HAVE_OSS != xyes; then
- AC_MSG_WARN([OSS audio support not found -- no direct audio output in opusdec])
-fi
-
-dnl OpenBSD needs -lossaudio to use the oss interface
-OSS_LIBS=
-case "$host_os" in
- openbsd*)
- OSS_LIBS='-lossaudio'
- ;;
-esac
-AC_SUBST(OSS_LIBS)
-
AC_OUTPUT([Makefile])