From 947319e1183d14e2ff552caeb125aee98d500838 Mon Sep 17 00:00:00 2001
From: Olivier Farges <olivier.farges@univ-lorraine.fr>
Date: Sun, 2 Mar 2025 19:27:50 +0100
Subject: [PATCH] debug star-sp

---
 edix/packages/random123.scm | 140 ++++++++++++++++++++++++++++--------
 edix/packages/star-vx.scm   |  14 +---
 2 files changed, 114 insertions(+), 40 deletions(-)

diff --git a/edix/packages/random123.scm b/edix/packages/random123.scm
index 07e81a7..15d22d0 100644
--- a/edix/packages/random123.scm
+++ b/edix/packages/random123.scm
@@ -1,45 +1,129 @@
-(define-module (edix packages random123)
+(define-module (random123)
   #:use-module (guix packages)
-  #:use-module (guix git-download)
+  #:use-module (guix download)
   #:use-module (guix build-system gnu)
+  #:use-module (guix git-download)
   #:use-module (guix licenses)
-  #:use-module (guix utils)
-  #:use-module (guix build-system cmake)
   #:use-module (gnu packages base)
   #:use-module (gnu packages gcc)
-  #:use-module (gnu packages documentation)
-  #:use-module (gnu packages python))
+  #:use-module (gnu packages pkg-config)
+ #:use-module (gnu packages bash)
+ #:use-module (gnu packages documentation)
+  #:use-module (gnu packages version-control)) ;; Ajout de `git`
 
 (define-public random123
   (package
     (name "random123")
-    (version "v1.14.0")  ; Modifier selon la version disponible
+    (version "1.14.0")  ; Modifier selon la version disponible
     (source (origin
               (method git-fetch)
               (uri (git-reference
                     (url "https://github.com/DEShawResearch/random123.git")
-                    (commit version)))
+                    (commit "v1.14.0")))
               (file-name (git-file-name name version))
               (sha256
-               (base32 "1awsf27k3mrp8rlc6wqzm2a5lndggp18fvzir395b3hljyx45bxg"))))  ; Remplacer par la vraie somme SHA256
+               (base32 "1awsf27k3mrp8rlc6wqzm2a5lndggp18fvzir395b3hljyx45bxg"))))
     (build-system gnu-build-system)
-;    (arguments '(#:tests? #f)) ; Désactiver les tests s'il n'y en a pas
-    (native-inputs '())
-    (inputs (list gcc doxygen))
- (arguments
-     `(#:tests? #f  ; Désactiver les tests s'il n'y en a pas
-       #:phases (modify-phases %standard-phases
-                  (delete 'configure)  ; Pas de configuration nécessaire
-                  (replace 'install
-                    (lambda* (#:key outputs #:allow-other-keys)
-                      (let* ((out (assoc-ref outputs "out")))
-                        (mkdir-p (string-append out "/include"))
-                        (mkdir-p (string-append out "/lib"))
-                        (mkdir-p (string-append out "/bin"))
-                        (copy-recursively "include" (string-append out "/include"))
-                        (copy-recursively "lib" (string-append out "/lib"))
-                        (copy-recursively "bin" (string-append out "/bin"))))))))
-    (home-page "https://www.deshawresearch.com/resources_random123.html")
-    (synopsis "Bibliothèque de générateurs de nombres pseudo-aléatoires")
-    (description "Random123 est une bibliothèque pour des générateurs de nombres pseudo-aléatoires (PRNG) rapides et parallélisables.")
+
+   (native-inputs (list git pkg-config doxygen))
+   (arguments
+    `(#:tests? #f
+      #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+;(replace 'install
+;           (lambda* (#:key outputs #:allow-other-keys)
+;             (let* ((out (assoc-ref outputs "out"))
+               ;     (include-dir (string-append out "/include"))
+               ;     (pkgconfig-dir (string-append out "/lib/pkgconfig"))
+               ;     (pc-file (string-append pkgconfig-dir "/random123.pc")))
+               ;; Créer les dossiers d'installation
+               ;(mkdir-p include-dir)
+               ;(mkdir-p pkgconfig-dir)
+               ;; Copier les fichiers d'en-tête
+               ;(copy-recursively "include" include-dir)
+               ;; Générer `random123.pc` directement dans `pkgconfig-dir`
+               ;(call-with-output-file pc-file
+               ;  (lambda (port)
+               ;    (format port "prefix=~a\n" out)
+               ;    (format port "includedir=${prefix}/include\n\n")
+               ;    (format port "Name: Random123\n")
+               ;    (format port "Description: Counter-Based Random Number Generators\n")
+               ;    (format port "Version: 0.14~%\n\n")
+               ;    (format port "Cflags: -I${includedir}\n")))
+               ;(format #t "✔ Fichier random123.pc généré avec succès à ~a\n" pc-file)
+;	       ))))
+;(replace 'install
+;           (lambda* (#:key outputs #:allow-other-keys)
+;             (let ((out (assoc-ref outputs "out")))
+               ;; Correction : forcer PREFIX et DESTDIR
+;               (invoke "make" "install"
+;                       (string-append "PREFIX=" out)
+;                       (string-append "DESTDIR=" out)))))
+;	(replace 'install
+;		 (lambda* (#:key outputs #:allow-other-keys)
+;			  (let ((out (assoc-ref outputs "out")))
+;			    (invoke "make" "install" (string-append "PREFIX=" out)))))
+
+(replace 'build
+           (lambda _
+             (let* ((version ,version)
+                    (tag (string-append "v" ,version)))
+               ;; Générer `random123.mk.in` manuellement
+               (call-with-output-file "random123.mk.in"
+                 (lambda (port)
+                   (format port "PREFIX=@PREFIX@\n")
+                   (format port "includedir=${PREFIX}/include\n")
+                   (format port "\n")
+                   (format port "Name: Random123\n")
+                   (format port "Description: Counter-Based Random Number Generators\n")
+                   (format port "Version: ~a\n\n" version)
+                   (format port "Cflags: -I${includedir}\n")))
+
+               ;; Générer `Makefile`
+               (invoke "sh" "-c"
+                       (string-append "sed -e 's/@TAG@/" tag "/' -e 's/@VERSION@/" version "/' random123.mk.in > Makefile"))
+               ;; Compiler
+               (invoke "make"))))
+
+
+;(replace 'install
+;           (lambda* (#:key outputs #:allow-other-keys)
+;             (let* ((out (assoc-ref outputs "out"))
+;                    (include-dir (string-append out "/include"))
+;                    (pkgconfig-dir (string-append out "/lib/pkgconfig"))
+;                    (pc-file (string-append pkgconfig-dir "/random123.pc")))
+;               (mkdir-p include-dir)
+;               (mkdir-p pkgconfig-dir)
+               ;; Exécuter `make install` avec `PREFIX` et `DESTDIR`
+;               (invoke "make" "install"
+;                       (string-append "PREFIX=" out)
+;                       (string-append "DESTDIR=" out))
+               ;; Vérifier si `include/` a bien été installé, sinon le copier manuellement
+;               (if (not (file-exists? (string-append include-dir "/Random123")))
+;                   (begin
+;                     (format #t "⚠ `make install` n'a pas installé `include/`, copie manuelle...\n")
+;                     (copy-recursively "include" include-dir))
+;                   (format #t "✔ `include/` installé avec `make install`\n"))
+               ;; Générer `random123.pc`
+;               (call-with-output-file pc-file
+;                 (lambda (port)
+;                   (format port "prefix=~a\n" out)
+;                   (format port "includedir=${prefix}/include\n\n")
+;                   (format port "Name: Random123\n")
+;                   (format port "Description: Counter-Based Random Number Generators\n")
+;                   (format port "Version: ~a\n\n" ,version)
+;                   (format port "Cflags: -I${includedir}\n")))
+;               (format #t "✔ Installation réussie : `random123.pc` généré et installé dans ~a\n" pc-file)))))))
+
+	(replace 'install
+		 (lambda* (#:key outputs #:allow-other-keys)
+			  (let ((out (assoc-ref outputs "out")))
+			    (invoke "make" "install" (string-append "PREFIX=" out ) (string-append "DESTDIR=" out))))))))
+
+   (synopsis "Bibliothèque de générateurs de nombres aléatoires contre-basés")
+    (description "Random123 est une bibliothèque fournissant des générateurs de nombres aléatoires hautes performances.")
+    (home-page "https://github.com/DEShawResearch/random123")
     (license bsd-3)))
+
+random123
diff --git a/edix/packages/star-vx.scm b/edix/packages/star-vx.scm
index ad73fba..00a6b9d 100644
--- a/edix/packages/star-vx.scm
+++ b/edix/packages/star-vx.scm
@@ -15,7 +15,6 @@
   #:use-module (gnu packages check)
   #:use-module (edix packages rsys))
 
-
 (define-public star-vx
   (package
     (name "star-vx")
@@ -29,27 +28,18 @@
                (base32 "11lcs6lhbjdizrf3chjg6mlnsp89h558vdml3l8vz3a6scgblzg2"))))
     (build-system gnu-build-system)
     (native-inputs
-     (list pkg-config autoconf automake libtool))
-    (inputs
-     (list gcc
-           gfortran
-           bash
-           gnu-make rsys
-           ))
+     (list pkg-config autoconf automake libtool gcc gnu-make))
+    (propagated-inputs (list rsys))
     (arguments
    `(#:make-flags (list (string-append "CC=gcc" ))
        #:phases
        (modify-phases %standard-phases
          (delete 'configure) 
          (delete 'check) 
-	(replace 'build
-		 (lambda* (#:key make-flags #:allow-other-keys)
-			  (invoke "make" (string-join make-flags " "))))
 	(replace 'install
 		 (lambda* (#:key outputs #:allow-other-keys)
 			  (let ((out (assoc-ref outputs "out")))
 			    (invoke "make" "install" (string-append "PREFIX=" out))))))))
-
     (home-page "https://meso-star.com/star-vx") ;; Remplacez avec le bon lien
     (synopsis "Bibliothèque Star-VX")
     (description "Star-VX est une bibliothèque de traitement de structures de données arborescentes.")
-- 
GitLab