Commit | Line | Data |
---|---|---|
233e7676 | 1 | ;;; GNU Guix --- Functional package management for GNU |
cab24961 | 2 | ;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org> |
c44899a2 | 3 | ;;; |
233e7676 | 4 | ;;; This file is part of GNU Guix. |
c44899a2 | 5 | ;;; |
233e7676 | 6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
c44899a2 LC |
7 | ;;; under the terms of the GNU General Public License as published by |
8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
9 | ;;; your option) any later version. | |
10 | ;;; | |
233e7676 | 11 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
c44899a2 LC |
12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | ;;; GNU General Public License for more details. | |
15 | ;;; | |
16 | ;;; You should have received a copy of the GNU General Public License | |
233e7676 | 17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
c44899a2 | 18 | |
1ffa7090 | 19 | (define-module (gnu packages pkg-config) |
4a44e743 | 20 | #:use-module (guix licenses) |
c44899a2 | 21 | #:use-module (guix packages) |
87f5d366 | 22 | #:use-module (guix download) |
d581acee LC |
23 | #:use-module (guix build-system gnu) |
24 | #:use-module (guix build-system trivial) | |
25 | #:export (pkg-config)) | |
c44899a2 | 26 | |
82c865c4 LC |
27 | ;; This is the "primitive" pkg-config package. People should use `pkg-config' |
28 | ;; (see below) rather than `%pkg-config', but we export `%pkg-config' so that | |
29 | ;; `fold-packages' finds it. | |
30 | (define-public %pkg-config | |
c44899a2 LC |
31 | (package |
32 | (name "pkg-config") | |
33 | (version "0.27.1") | |
34 | (source (origin | |
87f5d366 | 35 | (method url-fetch) |
c44899a2 LC |
36 | (uri (string-append |
37 | "http://pkgconfig.freedesktop.org/releases/pkg-config-" | |
38 | version ".tar.gz")) | |
39 | (sha256 | |
40 | (base32 | |
41 | "05wc5nwkqz7saj2v33ydmz1y6jdg659dll4jjh91n41m63gx0qsg")))) | |
42 | (build-system gnu-build-system) | |
43 | (arguments `(#:configure-flags '("--with-internal-glib"))) | |
a18eda27 LC |
44 | (native-search-paths |
45 | (list (search-path-specification | |
46 | (variable "PKG_CONFIG_PATH") | |
47 | (directories '("lib/pkgconfig" "lib64/pkgconfig" | |
48 | "share/pkgconfig"))))) | |
c44899a2 | 49 | (home-page "http://www.freedesktop.org/wiki/Software/pkg-config") |
4a44e743 | 50 | (license gpl2+) |
35b9e423 | 51 | (synopsis "Helper tool used when compiling applications and libraries") |
c44899a2 LC |
52 | (description |
53 | "pkg-config is a helper tool used when compiling applications and | |
54 | libraries. It helps you insert the correct compiler options on the | |
55 | command line so an application can use gcc -o test test.c `pkg-config | |
56 | --libs --cflags glib-2.0` for instance, rather than hard-coding values | |
35b9e423 | 57 | on where to find glib (or other libraries). It is language-agnostic, so |
c44899a2 LC |
58 | it can be used for defining the location of documentation tools, for |
59 | instance."))) | |
d581acee LC |
60 | |
61 | (define (cross-pkg-config target) | |
62 | "Return a pkg-config for TARGET, essentially just a wrapper called | |
63 | `TARGET-pkg-config', as `configure' scripts like it." | |
64 | ;; See <http://www.flameeyes.eu/autotools-mythbuster/pkgconfig/cross-compiling.html> | |
65 | ;; for details. | |
66 | (package (inherit %pkg-config) | |
67 | (name (string-append (package-name %pkg-config) "-" target)) | |
68 | (build-system trivial-build-system) | |
69 | (arguments | |
70 | `(#:modules ((guix build utils)) | |
71 | #:builder (begin | |
72 | (use-modules (guix build utils)) | |
73 | ||
74 | (let* ((out (assoc-ref %outputs "out")) | |
75 | (bin (string-append out "/bin")) | |
76 | (prog (string-append ,target "-pkg-config")) | |
77 | (native | |
78 | (string-append | |
79 | (assoc-ref %build-inputs "pkg-config") | |
80 | "/bin/pkg-config"))) | |
81 | ||
82 | (mkdir-p bin) | |
83 | ||
84 | ;; Create a `TARGET-pkg-config' -> `pkg-config' symlink. | |
85 | ;; This satisfies the pkg.m4 macros, which use | |
86 | ;; AC_PROG_TOOL to determine the `pkg-config' program | |
87 | ;; name. | |
88 | (symlink native (string-append bin "/" prog)))))) | |
89 | (native-inputs `(("pkg-config" ,%pkg-config))) | |
90 | ||
91 | ;; Ignore native inputs, and set `PKG_CONFIG_PATH' for target inputs. | |
92 | (native-search-paths '()) | |
93 | (search-paths (package-native-search-paths %pkg-config)))) | |
94 | ||
95 | (define (pkg-config-for-target target) | |
96 | "Return a pkg-config package for TARGET, which may be either #f for a native | |
97 | build, or a GNU triplet." | |
98 | (if target | |
99 | (cross-pkg-config target) | |
100 | %pkg-config)) | |
101 | ||
102 | ;; This hack allows us to automatically choose the native or the cross | |
103 | ;; `pkg-config' depending on whether it's being used in a cross-build | |
104 | ;; environment or not. | |
105 | (define-syntax pkg-config | |
106 | (identifier-syntax (pkg-config-for-target (%current-target-system)))) |