Subject: [PATCH 5/5] gnu: mariadb: Move static libraries to separate output.

From: Marius Bakke <[email-masked]>
Date: Fri, 20 Jul 2018 13:38:37 +0200

* gnu/packages/databases.scm (mariadb)[outputs]: New field.
[arguments]: Add 'move-static-libs' phase.
---
 gnu/packages/databases.scm | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/gnu/packages/databases.scm b/gnu/packages/databases.scm
index de1db2f93..cbc530bec 100644
--- a/gnu/packages/databases.scm
+++ b/gnu/packages/databases.scm
@@ -646,6 +646,7 @@ Language.")
                             (append (find-files "pcre") (find-files "zlib")))
                   #t))))
     (build-system cmake-build-system)
+    (outputs '("out" "static"))
     (arguments
      '(#:configure-flags
        '("-DBUILD_CONFIG=mysql_release"
@@ -742,6 +743,18 @@ Language.")
              (with-directory-excursion "mysql-test"
                (invoke "./mtr" "--parallel" (number->string (parallel-job-count))
                        "--verbose" "--skip-test-list=unstable-tests"))))
+         (add-after 'install 'move-static-libs
+           ;; Move ~37 MiB worth of static libraries to a separate output.
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((lib (string-append (assoc-ref outputs "out") "/lib"))
+                   (slib (string-append (assoc-ref outputs "static") "/lib")))
+               (mkdir-p slib)
+               (with-directory-excursion lib
+                 (for-each (lambda (ar)
+                             (link ar (string-append slib "/" (basename ar)))
+                             (delete-file ar))
+                           (find-files "." "\\.a$"))
+                 #t))))
          (add-after
           'install 'post-install
           (lambda* (#:key outputs #:allow-other-keys)
-- 
2.18.0