summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-05-27 22:36:15 +0200
committerLudovic Courtès <ludo@gnu.org>2013-05-27 23:43:00 +0200
commitd581acee5b08ea1af520cc2e8a3642b0c3924e43 (patch)
treedcf234eddcc6f0d290b6594c53a1e900d3c36378 /gnu
parent47e74d6e9d7d3a5f72a2b67f1916a719c61c86f8 (diff)
gnu: pkg-config: Provide a cross-build-friendly wrapper.
* gnu/packages/pkg-config.scm (pkg-config): Rename to... (%pkg-config): ... this. Make private. (cross-pkg-config, pkg-config-for-target): New procedures. (pkg-config): New macro.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/packages/pkg-config.scm53
1 files changed, 51 insertions, 2 deletions
diff --git a/gnu/packages/pkg-config.scm b/gnu/packages/pkg-config.scm
index 294163b474a..9f10440fec0 100644
--- a/gnu/packages/pkg-config.scm
+++ b/gnu/packages/pkg-config.scm
@@ -20,9 +20,11 @@
20 #:use-module (guix licenses) 20 #:use-module (guix licenses)
21 #:use-module (guix packages) 21 #:use-module (guix packages)
22 #:use-module (guix download) 22 #:use-module (guix download)
23 #:use-module (guix build-system gnu)) 23 #:use-module (guix build-system gnu)
24 #:use-module (guix build-system trivial)
25 #:export (pkg-config))
24 26
25(define-public pkg-config 27(define %pkg-config
26 (package 28 (package
27 (name "pkg-config") 29 (name "pkg-config")
28 (version "0.27.1") 30 (version "0.27.1")
@@ -53,3 +55,50 @@ command line so an application can use gcc -o test test.c `pkg-config
53on where to find glib (or other libraries). It is language-agnostic, so 55on where to find glib (or other libraries). It is language-agnostic, so
54it can be used for defining the location of documentation tools, for 56it can be used for defining the location of documentation tools, for
55instance."))) 57instance.")))
58
59(define (cross-pkg-config target)
60 "Return a pkg-config for TARGET, essentially just a wrapper called
61`TARGET-pkg-config', as `configure' scripts like it."
62 ;; See <http://www.flameeyes.eu/autotools-mythbuster/pkgconfig/cross-compiling.html>
63 ;; for details.
64 (package (inherit %pkg-config)
65 (name (string-append (package-name %pkg-config) "-" target))
66 (build-system trivial-build-system)
67 (arguments
68 `(#:modules ((guix build utils))
69 #:builder (begin
70 (use-modules (guix build utils))
71
72 (let* ((out (assoc-ref %outputs "out"))
73 (bin (string-append out "/bin"))
74 (prog (string-append ,target "-pkg-config"))
75 (native
76 (string-append
77 (assoc-ref %build-inputs "pkg-config")
78 "/bin/pkg-config")))
79
80 (mkdir-p bin)
81
82 ;; Create a `TARGET-pkg-config' -> `pkg-config' symlink.
83 ;; This satisfies the pkg.m4 macros, which use
84 ;; AC_PROG_TOOL to determine the `pkg-config' program
85 ;; name.
86 (symlink native (string-append bin "/" prog))))))
87 (native-inputs `(("pkg-config" ,%pkg-config)))
88
89 ;; Ignore native inputs, and set `PKG_CONFIG_PATH' for target inputs.
90 (native-search-paths '())
91 (search-paths (package-native-search-paths %pkg-config))))
92
93(define (pkg-config-for-target target)
94 "Return a pkg-config package for TARGET, which may be either #f for a native
95build, or a GNU triplet."
96 (if target
97 (cross-pkg-config target)
98 %pkg-config))
99
100;; This hack allows us to automatically choose the native or the cross
101;; `pkg-config' depending on whether it's being used in a cross-build
102;; environment or not.
103(define-syntax pkg-config
104 (identifier-syntax (pkg-config-for-target (%current-target-system))))