Subject: [PATCH 2/6] gnu: Add metis-4.

From: Nicolas Graves <[email-masked]>
Date: Wed, 1 Feb 2023 02:12:11 +0100

* gnu/packages/maths.scm (metis-4): New variable.
---
 gnu/packages/maths.scm | 48 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 962b7d117c..f00f4f58be 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -4354,6 +4354,54 @@ (define-public metis
 schemes.")
     (license license:asl2.0)))          ;As of version 5.0.3
 
+;; This outdated version contains only library and header files. It is used
+;; to build the scilab package.
+(define-public metis-4
+  (package
+    (inherit metis)
+    (name "metis")
+    (version "4.0.3")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/"
+                           "metis-" version ".tar.gz"))
+       (sha256
+        (base32
+         "0m8shi202vprs8d9l51178v0skngzgx81q0d9ln1ng3hh3g3byjy"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list #:tests? #f                      ;no tests
+           #:make-flags
+           #~(list "CC=gcc"
+                   "AR=gcc -shared -o"
+                   "RANLIB=touch"
+                   "OPTFLAGS= -O3 "
+                   "COPTIONS= -fPIC"
+                   (string-append
+                    "LDOPTIONS=-Wl,rpath," #$output "/lib")
+                   "METISLIB=../libmetis.so")
+           #:phases
+           #~(modify-phases %standard-phases
+               (replace 'configure
+                 ;; Make the library shared.
+                 (lambda _
+                   (substitute* "Lib/Makefile"
+                     (("libmetis\\.a")
+                      "libmetis.so"))
+                   (chdir "Lib")))
+               (replace 'install
+                 (lambda _
+                   ;; Library
+                   (chdir "..")
+                   (install-file "libmetis.so"
+                                 (string-append #$output "/lib"))
+                   ;; Includes
+                   (for-each
+                    (lambda (x)
+                      (install-file x (string-append #$output "/include")))
+                    (find-files "Lib" "\\.h$")))))))))
+
 (define-public p4est
   (package
     (name "p4est")
-- 
2.39.1