Subject: [bug#46352] [PATCH 1/4] gnu: Add dyncall.

From: Alexandru-Sergiu Marton <[email-masked]>
Date: Sat, 6 Feb 2021 23:35:08 +0200

* gnu/packages/c.scm (dyncall): New variable.
---
 gnu/packages/c.scm | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/gnu/packages/c.scm b/gnu/packages/c.scm
index d9e5e4d7de..db9938003f 100644
--- a/gnu/packages/c.scm
+++ b/gnu/packages/c.scm
@@ -11,6 +11,7 @@
 ;;; Copyright © 2020 Katherine Cox-Buday <[email-masked]>
 ;;; Copyright © 2020 Maxim Cournoyer <[email-masked]>
 ;;; Copyright © 2020 Greg Hogan <[email-masked]>
+;;; Copyright © 2021 Alexandru-Sergiu Marton <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -614,3 +615,41 @@ event stream encoding, a binary format for bidirectional client-server
 communication.")
     (home-page "https://github.com/awslabs/aws-c-event-stream")
     (license license:asl2.0)))
+
+(define-public dyncall
+  (package
+    (name "dyncall")
+    (version "1.2")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://www.dyncall.org/r" version
+                                  "/dyncall-" version ".tar.gz"))
+              (sha256
+               (base32
+                "1mq832l2w17mvxd1sq50my8ykjfyzd52kizm0h3mc89l4k0590g8"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:make-flags
+       (list (string-append "CC=" ,(cc-for-target)))
+       #:phases
+       (modify-phases %standard-phases
+         (replace 'configure
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let ((bash (string-append (assoc-ref inputs "bash")
+                                        "/bin/bash"))
+                   (out (assoc-ref outputs "out")))
+               (invoke bash "./configure"
+                       (string-append "--prefix=" out)))))
+         (replace 'check
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let ((make (string-append (assoc-ref inputs "make")
+                                        "/bin/make")))
+               (invoke make "tests"
+                       (string-append "CC=" ,(cc-for-target)))))))))
+    (synopsis "Library for calling C functions dynamically")
+    (description "The dyncall library encapsulates architecture-, OS- and
+compiler-specific function call semantics in a virtual bind argument
+parameters from left to right and then call interface allowing programmers to
+call C functions in a completely dynamic manner.")
+    (home-page "https://www.dyncall.org/")
+    (license license:isc)))
-- 
2.30.0