gnu: upower: Enable GObject introspection.
[jackhill/guix/guix.git] / gnu / packages / pkg-config.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
e5651212 2;;; Copyright © 2012, 2013, 2014 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")
e5651212 33 (version "0.28")
c44899a2 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
e5651212 41 "0igqq5m204w71m11y0nipbdf5apx87hwfll6axs12hn4dqfb6vkb"))))
c44899a2
LC
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")
af070955 47 (files '("lib/pkgconfig" "lib64/pkgconfig" "share/pkgconfig")))))
c44899a2 48 (home-page "http://www.freedesktop.org/wiki/Software/pkg-config")
4a44e743 49 (license gpl2+)
35b9e423 50 (synopsis "Helper tool used when compiling applications and libraries")
c44899a2
LC
51 (description
52 "pkg-config is a helper tool used when compiling applications and
53libraries. It helps you insert the correct compiler options on the
54command line so an application can use gcc -o test test.c `pkg-config
55--libs --cflags glib-2.0` for instance, rather than hard-coding values
35b9e423 56on where to find glib (or other libraries). It is language-agnostic, so
c44899a2
LC
57it can be used for defining the location of documentation tools, for
58instance.")))
d581acee
LC
59
60(define (cross-pkg-config target)
61 "Return a pkg-config for TARGET, essentially just a wrapper called
62`TARGET-pkg-config', as `configure' scripts like it."
63 ;; See <http://www.flameeyes.eu/autotools-mythbuster/pkgconfig/cross-compiling.html>
64 ;; for details.
65 (package (inherit %pkg-config)
66 (name (string-append (package-name %pkg-config) "-" target))
67 (build-system trivial-build-system)
68 (arguments
69 `(#:modules ((guix build utils))
70 #:builder (begin
71 (use-modules (guix build utils))
72
588a7813
LC
73 (let* ((in (assoc-ref %build-inputs "pkg-config"))
74 (out (assoc-ref %outputs "out"))
75 (bin (string-append out "/bin"))
76 (prog (string-append ,target "-pkg-config"))
77 (native (string-append in "/bin/pkg-config")))
d581acee
LC
78
79 (mkdir-p bin)
80
81 ;; Create a `TARGET-pkg-config' -> `pkg-config' symlink.
82 ;; This satisfies the pkg.m4 macros, which use
83 ;; AC_PROG_TOOL to determine the `pkg-config' program
84 ;; name.
588a7813
LC
85 (symlink native (string-append bin "/" prog))
86
87 ;; Also make 'pkg.m4' available, some packages might
88 ;; expect it.
89 (mkdir-p (string-append out "/share"))
90 (symlink (string-append in "/share/aclocal")
91 (string-append out "/share/aclocal"))))))
d581acee
LC
92 (native-inputs `(("pkg-config" ,%pkg-config)))
93
94 ;; Ignore native inputs, and set `PKG_CONFIG_PATH' for target inputs.
95 (native-search-paths '())
96 (search-paths (package-native-search-paths %pkg-config))))
97
98(define (pkg-config-for-target target)
99 "Return a pkg-config package for TARGET, which may be either #f for a native
100build, or a GNU triplet."
101 (if target
102 (cross-pkg-config target)
103 %pkg-config))
104
105;; This hack allows us to automatically choose the native or the cross
106;; `pkg-config' depending on whether it's being used in a cross-build
107;; environment or not.
108(define-syntax pkg-config
109 (identifier-syntax (pkg-config-for-target (%current-target-system))))