shithub: choc

Download patch

ref: 61a6af25d221bf790ac8f67ebfd88948f92babe4
parent: 8993063b126c65e572944ca487f5b980abfcf60d
author: Rodrigo Rebello <[email protected]>
date: Thu Oct 22 11:28:11 EDT 2015

configure: fix --with-PACKAGE option checks

Options of the form --with-PACKAGE[=yes] (e.g. --with-libpng), when
passed to configure, were being treated as though --without-PACKAGE had
been given.

Although the intention is to have configure check and use PACKAGE by
default if it's available, thus requiring the user to pass an option
only if PACKAGE must NOT be used, there are times when the opposite
might be desired (i.e. the user wants to indicate PACKAGE MUST be used).
Moreover, allowing --with-PACKAGE and behaving as if --without-PACKAGE
had been specified is in itself quite confusing.

Fix that by testing the result of 'with_PACKAGE' in configure.ac and
acting accordingly instead of blindly assuming a 'no'.

--- a/configure.ac
+++ b/configure.ac
@@ -80,8 +80,15 @@
         [Build without libsamplerate @<:@default=check@:>@]),
     [],
     [
-        AC_CHECK_LIB(samplerate, src_new)
+        [with_libsamplerate=check]
     ])
+    AS_IF([test "x$with_libsamplerate" != xno], [
+        AC_CHECK_LIB(samplerate, src_new, [], [
+            AS_IF([test "x$with_libsamplerate" != xcheck], [AC_MSG_FAILURE(
+                [--with-libsamplerate was given, but test for libsamplerate failed])
+            ])
+        ])
+    ])
     # Check for libpng.
     AC_ARG_WITH([libpng],
     AS_HELP_STRING([--without-libpng],
@@ -88,8 +95,15 @@
         [Build without libpng @<:@default=check@:>@]),
     [],
     [
+        [with_libpng=check]
+    ])
+    AS_IF([test "x$with_libpng" != xno], [
         AC_CHECK_LIB(z, zlibVersion)
-        AC_CHECK_LIB(png, png_get_io_ptr)
+        AC_CHECK_LIB(png, png_get_io_ptr, [], [
+            AS_IF([test "x$with_libpng" != xcheck], [AC_MSG_FAILURE(
+                [--with-libpng was given, but test for libpng failed])
+            ])
+        ])
     ])
     AC_CHECK_LIB(m, log)