gnu: sbcl-cl-cffi-gtk: Update to 20200417.
[jackhill/guix/guix.git] / gnu / packages / pkg-config.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2016 Ludovic Courtès <ludo@gnu.org>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
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 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
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
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (gnu packages pkg-config)
20 #:use-module (guix licenses)
21 #:use-module (guix packages)
22 #:use-module (guix download)
23 #:use-module (guix build-system gnu)
24 #:use-module (guix build-system trivial)
25 #:use-module (guix memoization)
26 #:export (pkg-config))
27
28 ;; This is the "primitive" pkg-config package. People should use `pkg-config'
29 ;; (see below) rather than `%pkg-config', but we export `%pkg-config' so that
30 ;; `fold-packages' finds it.
31 (define-public %pkg-config
32 (package
33 (name "pkg-config")
34 (version "0.29.2")
35 (source (origin
36 (method url-fetch)
37 (uri (list
38 (string-append
39 "http://fossies.org/linux/misc/pkg-config-" version
40 ".tar.gz")
41
42 ;; FIXME: The following URL redirects to HTTPS, which
43 ;; creates bootstrapping problems:
44 ;; <http://bugs.gnu.org/22774>.
45 (string-append
46 "http://pkgconfig.freedesktop.org/releases/pkg-config-"
47 version ".tar.gz")))
48 (sha256
49 (base32
50 "14fmwzki1rlz8bs2p810lk6jqdxsk966d8drgsjmi54cd00rrikg"))))
51 (build-system gnu-build-system)
52 (arguments `(#:configure-flags '("--with-internal-glib")))
53 (native-search-paths
54 (list (search-path-specification
55 (variable "PKG_CONFIG_PATH")
56 (files '("lib/pkgconfig" "lib64/pkgconfig" "share/pkgconfig")))))
57 (home-page "https://www.freedesktop.org/wiki/Software/pkg-config")
58 (license gpl2+)
59 (synopsis "Helper tool used when compiling applications and libraries")
60 (description
61 "pkg-config is a helper tool used when compiling applications and
62 libraries. It helps you insert the correct compiler options on the
63 command line so an application can use gcc -o test test.c `pkg-config
64 --libs --cflags glib-2.0` for instance, rather than hard-coding values
65 on where to find glib (or other libraries). It is language-agnostic, so
66 it can be used for defining the location of documentation tools, for
67 instance.")))
68
69 (define cross-pkg-config
70 (mlambda (target)
71 "Return a pkg-config for TARGET, essentially just a wrapper called
72 `TARGET-pkg-config', as `configure' scripts like it."
73 ;; See <http://www.flameeyes.eu/autotools-mythbuster/pkgconfig/cross-compiling.html>
74 ;; for details.
75 (package
76 (inherit %pkg-config)
77 (name (string-append (package-name %pkg-config) "-" target))
78 (build-system trivial-build-system)
79 (arguments
80 `(#:modules ((guix build utils))
81 #:builder (begin
82 (use-modules (guix build utils))
83
84 (let* ((in (assoc-ref %build-inputs "pkg-config"))
85 (out (assoc-ref %outputs "out"))
86 (bin (string-append out "/bin"))
87 (prog (string-append ,target "-pkg-config"))
88 (native (string-append in "/bin/pkg-config")))
89
90 (mkdir-p bin)
91
92 ;; Create a `TARGET-pkg-config' -> `pkg-config' symlink.
93 ;; This satisfies the pkg.m4 macros, which use
94 ;; AC_PROG_TOOL to determine the `pkg-config' program
95 ;; name.
96 (symlink native (string-append bin "/" prog))
97
98 ;; Also make 'pkg.m4' available, some packages might
99 ;; expect it.
100 (mkdir-p (string-append out "/share"))
101 (symlink (string-append in "/share/aclocal")
102 (string-append out "/share/aclocal"))
103 #t))))
104 (native-inputs `(("pkg-config" ,%pkg-config)))
105
106 ;; Ignore native inputs, and set `PKG_CONFIG_PATH' for target inputs.
107 (native-search-paths '())
108 (search-paths (package-native-search-paths %pkg-config)))))
109
110 (define (pkg-config-for-target target)
111 "Return a pkg-config package for TARGET, which may be either #f for a native
112 build, or a GNU triplet."
113 (if target
114 (cross-pkg-config target)
115 %pkg-config))
116
117 ;; This hack allows us to automatically choose the native or the cross
118 ;; `pkg-config' depending on whether it's being used in a cross-build
119 ;; environment or not.
120 (define-syntax pkg-config
121 (identifier-syntax (pkg-config-for-target (%current-target-system))))