gnu: emacs-svg-icon: Fix grammar.
[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 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
4 ;;;
5 ;;; This file is part of GNU Guix.
6 ;;;
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
11 ;;;
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
16 ;;;
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20 (define-module (gnu packages pkg-config)
21 #:use-module (guix licenses)
22 #:use-module (guix packages)
23 #:use-module (guix download)
24 #:use-module (guix build-system gnu)
25 #:use-module (guix build-system trivial)
26 #:use-module (guix memoization)
27 #:export (pkg-config))
28
29 ;; This is the "primitive" pkg-config package. People should use `pkg-config'
30 ;; (see below) rather than `%pkg-config', but we export `%pkg-config' so that
31 ;; `fold-packages' finds it.
32 (define-public %pkg-config
33 (package
34 (name "pkg-config")
35 (version "0.29.2")
36 (source (origin
37 (method url-fetch)
38 (uri (list
39 (string-append
40 "http://fossies.org/linux/misc/pkg-config-" version
41 ".tar.gz")
42
43 ;; FIXME: The following URL redirects to HTTPS, which
44 ;; creates bootstrapping problems:
45 ;; <http://bugs.gnu.org/22774>.
46 (string-append
47 "http://pkgconfig.freedesktop.org/releases/pkg-config-"
48 version ".tar.gz")))
49 (sha256
50 (base32
51 "14fmwzki1rlz8bs2p810lk6jqdxsk966d8drgsjmi54cd00rrikg"))))
52 (build-system gnu-build-system)
53 (arguments
54 `(#:configure-flags
55 '("--with-internal-glib"
56 ;; Those variables are guessed incorrectly when cross-compiling.
57 ;; See: https://developer.gimp.org/api/2.0/glib/glib-cross-compiling.html.
58 ,@(if (%current-target-system)
59 '("glib_cv_stack_grows=no"
60 "glib_cv_uscore=no"
61 "ac_cv_func_posix_getpwuid_r=yes"
62 "ac_cv_func_posix_getgrgid_r=yes")
63 '()))))
64 (native-search-paths
65 (list (search-path-specification
66 (variable "PKG_CONFIG_PATH")
67 (files '("lib/pkgconfig" "lib64/pkgconfig" "share/pkgconfig")))))
68 (home-page "https://www.freedesktop.org/wiki/Software/pkg-config")
69 (license gpl2+)
70 (synopsis "Helper tool used when compiling applications and libraries")
71 (description
72 "pkg-config is a helper tool used when compiling applications and
73 libraries. It helps you insert the correct compiler options on the
74 command line so an application can use gcc -o test test.c `pkg-config
75 --libs --cflags glib-2.0` for instance, rather than hard-coding values
76 on where to find glib (or other libraries). It is language-agnostic, so
77 it can be used for defining the location of documentation tools, for
78 instance.")))
79
80 (define cross-pkg-config
81 (mlambda (target)
82 "Return a pkg-config for TARGET, essentially just a wrapper called
83 `TARGET-pkg-config', as `configure' scripts like it."
84 ;; See <http://www.flameeyes.eu/autotools-mythbuster/pkgconfig/cross-compiling.html>
85 ;; for details.
86 (package
87 (inherit %pkg-config)
88 (name (string-append (package-name %pkg-config) "-" target))
89 (build-system trivial-build-system)
90 (arguments
91 `(#:modules ((guix build utils))
92 #:builder (begin
93 (use-modules (guix build utils))
94
95 (let* ((in (assoc-ref %build-inputs "pkg-config"))
96 (out (assoc-ref %outputs "out"))
97 (bin (string-append out "/bin"))
98 (prog (string-append ,target "-pkg-config"))
99 (native (string-append in "/bin/pkg-config")))
100
101 (mkdir-p bin)
102
103 ;; Create a `TARGET-pkg-config' -> `pkg-config' symlink.
104 ;; This satisfies the pkg.m4 macros, which use
105 ;; AC_PROG_TOOL to determine the `pkg-config' program
106 ;; name.
107 (symlink native (string-append bin "/" prog))
108
109 ;; Also make 'pkg.m4' available, some packages might
110 ;; expect it.
111 (mkdir-p (string-append out "/share"))
112 (symlink (string-append in "/share/aclocal")
113 (string-append out "/share/aclocal"))
114 #t))))
115 (native-inputs `(("pkg-config" ,%pkg-config)))
116
117 ;; Ignore native inputs, and set `PKG_CONFIG_PATH' for target inputs.
118 (native-search-paths '())
119 (search-paths (package-native-search-paths %pkg-config)))))
120
121 (define (pkg-config-for-target target)
122 "Return a pkg-config package for TARGET, which may be either #f for a native
123 build, or a GNU triplet."
124 (if target
125 (cross-pkg-config target)
126 %pkg-config))
127
128 ;; This hack allows us to automatically choose the native or the cross
129 ;; `pkg-config' depending on whether it's being used in a cross-build
130 ;; environment or not.
131 (define-syntax pkg-config
132 (identifier-syntax (pkg-config-for-target (%current-target-system))))