From ab4fab19380138df582fdde846e7524481964c1a Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 29 Sep 2013 17:22:08 +0200 Subject: gnu: bzip2: Allow cross-compilation. Reported by Nikita Karetnikov . * gnu/packages/compression.scm (bzip2): Add 'set-cross-environment' phase for cross-compilation. --- gnu/packages/compression.scm | 49 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 9 deletions(-) (limited to 'gnu') diff --git a/gnu/packages/compression.scm b/gnu/packages/compression.scm index 83ef7a86d8..0536cd9ed9 100644 --- a/gnu/packages/compression.scm +++ b/gnu/packages/compression.scm @@ -112,7 +112,19 @@ superior compression ratio of gzip is just a bonus.") base libdir) (copy-file file (string-append libdir "/" base)))) - (find-files "." "^libbz2\\.so")))))) + (find-files "." "^libbz2\\.so"))))) + (set-cross-environment + '(lambda* (#:key target #:allow-other-keys) + (substitute* (find-files "." "Makefile") + (("CC=.*$") + (string-append "CC = " target "-gcc\n")) + (("AR=.*$") + (string-append "AR = " target "-ar\n")) + (("RANLIB=.*$") + (string-append "RANLIB = " target "-ranlib\n")) + (("^all:(.*)test" _ prerequisites) + ;; Remove 'all' -> 'test' dependency. + (string-append "all:" prerequisites "\n")))))) (package (name "bzip2") (version "1.0.6") @@ -129,15 +141,34 @@ superior compression ratio of gzip is just a bonus.") (guix build utils) (srfi srfi-1)) #:phases - (alist-cons-before - 'build 'build-shared-lib ,build-shared-lib - (alist-cons-after - 'install 'fix-man-dir ,fix-man-dir - (alist-cons-after - 'install 'install-shared-lib ,install-shared-lib - (alist-delete 'configure %standard-phases)))) + ,(if (%current-target-system) + + ;; Cross-compilation: use the cross tools. + `(alist-cons-before + 'build 'build-shared-lib ,build-shared-lib + (alist-cons-after + 'install 'fix-man-dir ,fix-man-dir + (alist-cons-after + 'install 'install-shared-lib ,install-shared-lib + (alist-replace 'configure ,set-cross-environment + %standard-phases)))) + + ;; Native compilation: build the shared library. + `(alist-cons-before + 'build 'build-shared-lib ,build-shared-lib + (alist-cons-after + 'install 'fix-man-dir ,fix-man-dir + (alist-cons-after + 'install 'install-shared-lib ,install-shared-lib + (alist-delete 'configure %standard-phases))))) + #:make-flags (list (string-append "PREFIX=" - (assoc-ref %outputs "out"))))) + (assoc-ref %outputs "out"))) + + ;; Don't attempt to run the tests when cross-compiling. + ,@(if (%current-target-system) + '(#:tests? #f) + '()))) (synopsis "high-quality data compression program") (description "bzip2 is a freely available, patent free (see below), high-quality data -- cgit v1.2.3