Subject: [bug#67755] [PATCH v4 4/8] gnu: Add miniaudio.

From: Sergio Pastor Pérez <[email-masked]>
Date: Tue, 27 Aug 2024 00:01:06 +0200

* gnu/packages/cpp.scm (miniaudio): New variable.

Change-Id: I27b74793dd7b80af4437e0a1b997cc87fe8822e5
---
 gnu/packages/cpp.scm | 51 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/gnu/packages/cpp.scm b/gnu/packages/cpp.scm
index ec5156b1fa..dd6488ccd1 100644
--- a/gnu/packages/cpp.scm
+++ b/gnu/packages/cpp.scm
@@ -1685,6 +1685,57 @@ (define (make-static-abseil-cpp version)
            #~(cons* "-DCMAKE_POSITION_INDEPENDENT_CODE=ON"
                     (delete "-DBUILD_SHARED_LIBS=ON" #$flags)))))))))
 
+(define-public miniaudio
+  (package
+    (name "miniaudio")
+    (version "0.11.21")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/mackron/miniaudio")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0hlqp44ifi3vswvfpqljj89321y6yz3zq6rng51wfq8p4n9k5qhh"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:phases #~(modify-phases %standard-phases
+                   (delete 'build)
+                   (delete 'configure)
+                   (replace 'check
+                     (lambda* (#:key tests? #:allow-other-keys)
+                       (when tests?
+                         (with-directory-excursion "tests/_build"
+                           (mkdir "bin")
+                           (invoke "gcc"
+                                   "../test_automated/ma_test_automated.c"
+                                   "-o"
+                                   "bin/test_automated"
+                                   "-ldl"
+                                   "-lm"
+                                   "-lpthread"
+                                   "-Wall"
+                                   "-Wextra"
+                                   "-Wpedantic"
+                                   "-std=c89")
+                           (invoke "./bin/test_automated")))))
+                   (replace 'install
+                     (lambda _
+                       (install-file "miniaudio.h"
+                                     (string-append #$output "/include"))
+                       (copy-recursively "extras"
+                                         (string-append #$output
+                                                        "/include/extras/")))))))
+    (home-page "https://miniaud.io")
+    (synopsis "Audio playback and capture library for C and C++")
+    (description
+     "@code{miniaudio} is an audio playback and capture library for C and C++.
+It's made up of a single source file, has no external dependencies and is
+released into the public domain.")
+    (license license:expat)))
+
 (define-public abseil-cpp-cxxstd17
   (abseil-cpp-for-c++-standard abseil-cpp 17))  ;XXX: the default with GCC 11?
 
-- 
2.45.2