Subject: [bug#56534] [PATCH v2 2/4] gnu: Add racket-portaudio-librsoundcallbacks.

From: Philip McGrath <[email-masked]>
Date: Fri, 20 Oct 2023 22:01:12 -0400

* gnu/packages/racket.scm (racket-portaudio-librsoundcallbacks): New
variable.
---
 gnu/packages/racket.scm | 44 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/gnu/packages/racket.scm b/gnu/packages/racket.scm
index a127f75669..43187318d8 100644
--- a/gnu/packages/racket.scm
+++ b/gnu/packages/racket.scm
@@ -26,6 +26,7 @@ (define-module (gnu packages racket)
   #:use-module (guix git-download)
   #:use-module (guix utils)
   #:use-module (guix gexp)
+  #:use-module (guix build-system copy)
   #:use-module (guix build-system gnu)
   #:use-module (guix diagnostics)
   #:use-module (guix i18n)
@@ -1032,6 +1033,49 @@ (define-public racket
 DrRacket IDE, libraries for GUI and web programming, and implementations of
 languages such as Typed Racket, R5RS and R6RS Scheme, Algol 60, and Datalog.")))
 
+(define-public racket-portaudio-librsoundcallbacks
+  (let ((commit "bb4faf5e5500d2b89c22f16ba9adf455b263f097")
+        (revision "1"))
+    (package
+      (name "racket-portaudio-librsoundcallbacks")
+      (version (git-version "0.2" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/jbclements/portaudio")
+               (commit commit)))
+         (sha256
+          (base32 "11cx1a9admsfkbm1gi32yicaawrn448m7rbmayyzh50kdywm5lfg"))
+         (snippet
+          #~(begin
+              (use-modules (guix build utils))
+              (substitute* "info.rkt"
+                ;; remove dependencies on pre-built support libraries
+                (("[(]\"portaudio-.*linux" orig)
+                 (string-append "#|removed for Guix|# #;" orig)))))
+         (file-name (git-file-name "racket-portaudio" version))))
+      (build-system copy-build-system)
+      (arguments
+       (list
+        #:install-plan #~`(("librsoundcallbacks.so" "lib/"))
+        #:phases
+        #~(modify-phases %standard-phases
+            (add-before 'install 'build
+              (lambda args
+                (chdir "portaudio/lib")
+                (invoke #$(cc-for-target)
+                        "-O2" "-fPIC" "-shared"
+                        "-o" "librsoundcallbacks.so"
+                        "callbacks.c"))))))
+      (home-page "https://pkgs.racket-lang.org/package/portaudio")
+      (synopsis "Support library for Racket's PortAudio bindings")
+      (description "The librsoundcallbacks library is used internally by the
+Racket bindings for PortAudio.  It provides an adapter between the low-level
+callbacks used by PortAudio, which must never block, and higher-level
+callbacks supplied @i{via} Racket's foreign interface.")
+      (license license:lgpl2.0+))))
+
 (define configure-layer.rkt
   (scheme-file
    "configure-layer.rkt"
-- 
2.41.0