Subject: [bug#57625] [PATCH v2 3/3] gnu: Add pnet.

From: Adam Faiz <[email-masked]>
Date: Sat, 19 Nov 2022 18:37:39 +0800

From 832c95bc06cbb55f8456cf174e617052b2ec4131 Mon Sep 17 00:00:00 2001
From: AwesomeAdam54321 <[email-masked]>
Date: Fri, 18 Nov 2022 08:42:13 +0800
Subject: [PATCH v2 3/3] WIP : gnu: Add pnet.

* gnu/packages/dotgnu.scm (pnet): New variable.
---
  gnu/packages/dotgnu.scm | 59 +++++++++++++++++++++++++++++++++++++++++
  1 file changed, 59 insertions(+)

diff --git a/gnu/packages/dotgnu.scm b/gnu/packages/dotgnu.scm
index ad3b6c74e5..3efa3b1f3c 100644
--- a/gnu/packages/dotgnu.scm
+++ b/gnu/packages/dotgnu.scm
@@ -48,3 +48,62 @@ (define-public treecc
  and other language-based tools.  It manages the generation of code to 
handle
  abstract syntax trees and operations upon the trees.")
      (license license:gpl2+)))
+
+(define-public pnet
+  (package
+    (name "pnet")
+    (version "0.8.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+ 
"https://download.savannah.gnu.org/releases/dotgnu-pnet/pnet-"
+                    version ".tar.gz"))
+              (sha256
+               (base32
+                "1fsi8nkgvawjib2n4kyygfhfr31637bin84xkmr0apvsavihld7i"))
+              (modules '((guix build utils)))
+              (snippet
+               #~(begin
+                   (for-each delete-file-recursively '("libffi" "libgc"))
+                   (for-each delete-file '("compile"
+                                           "configure"
+                                           "config.guess"
+                                           "config.sub"
+                                           "depcomp"
+                                           "install-sh"
+                                           "ltconfig"
+                                           "ltcf-c.sh"
+                                           "ltmain.sh"
+                                           "Makefile.in"))
+                   (for-each delete-file (find-files "." "Makefile\\.in"))
+                   (substitute* "Makefile.am" ; Fix to not require 
bundled dependencies
+                     (("OPT_SUBDIRS \\+= lib.*") ""))
+                   (substitute* "support/hb_gc.c"
+                     (("#include .*/libgc/include/gc.h.") "#include 
<gc.h>")
+                     (("#include .*/libgc/include/gc_typed.h.") 
"#include <gc_typed.h>"))
+                   (substitute* "support/pt_defs.c"
+                     (("#include <errno.h>")
+                      "#include <errno.h>\n#define GC_H 0\n#define 
GC_PTHREADS 1\n#include <gc_pthread_redirects.h>"))
+                   (substitute* "support/thread.c"
+                     ; Maybe GC_CreateThread can be used as replacement?
+                     (("result = GC_run_thread.*;")
+                      "result = thread_func(arg);"))))))
+    (build-system gnu-build-system)
+    (native-inputs (list autoconf automake libtool libatomic-ops))
+    (inputs (list treecc libffi libgc libgc-all-headers))
+    (arguments
+     (list #:configure-flags
+           #~(list
+              (string-append "CPPFLAGS=-I" #$(this-package-input 
"libffi") "/include/ffi"
+                             " -I" #$(this-package-input "libgc") 
"/include/gc"
+                             " -I" #$(this-package-input 
"libgc-all-headers") "/include/private"))
+           #:make-flags
+           #~(list (string-append "GCLIBS=")) ; libgc is already in the 
linker path
+                   ))
+    (home-page "http://www.gnu.org/software/dotgnu/html2.0/pnet.html")
+    (synopsis "Compiler and libraries for the C# programming language")
+    (description
+     "The goal of this project is to build a suite of free software tools
+to build and execute .NET applications, including a C# compiler,
+assembler, disassembler, and runtime engine.")
+    (license license:gpl2+)))
-- 
2.38.1