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>
5 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
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
40 "http://fossies.org/linux/misc/pkg-config-" version
43 ;; FIXME: The following URL redirects to HTTPS, which
44 ;; creates bootstrapping problems:
45 ;; <http://bugs.gnu.org/22774>.
47 "http://pkgconfig.freedesktop.org/releases/pkg-config-"
51 "14fmwzki1rlz8bs2p810lk6jqdxsk966d8drgsjmi54cd00rrikg"))))
52 (build-system gnu-build-system)
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"
61 "ac_cv_func_posix_getpwuid_r=yes"
62 "ac_cv_func_posix_getgrgid_r=yes")
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")
70 (synopsis "Helper tool used when compiling applications and libraries")
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
80 (define cross-pkg-config
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>
88 (name (string-append (package-name %pkg-config) "-" target))
89 (build-system trivial-build-system)
91 `(#:modules ((guix build utils))
93 (use-modules (guix build utils))
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")))
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
107 (symlink native (string-append bin "/" prog))
109 ;; Also make 'pkg.m4' available, some packages might
111 (mkdir-p (string-append out "/share"))
112 (symlink (string-append in "/share/aclocal")
113 (string-append out "/share/aclocal"))
115 (native-inputs `(("pkg-config" ,%pkg-config)))
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)))))
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."
125 (cross-pkg-config target)
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))))