Commit | Line | Data |
---|---|---|
233e7676 | 1 | ;;; GNU Guix --- Functional package management for GNU |
dd1937d7 | 2 | ;;; Copyright © 2012, 2013, 2014, 2016 Ludovic Courtès <ludo@gnu.org> |
032974aa | 3 | ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com> |
c44899a2 | 4 | ;;; |
233e7676 | 5 | ;;; This file is part of GNU Guix. |
c44899a2 | 6 | ;;; |
233e7676 | 7 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
c44899a2 LC |
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 | ;;; | |
233e7676 | 12 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
c44899a2 LC |
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 | |
233e7676 | 18 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
c44899a2 | 19 | |
1ffa7090 | 20 | (define-module (gnu packages pkg-config) |
4a44e743 | 21 | #:use-module (guix licenses) |
c44899a2 | 22 | #:use-module (guix packages) |
87f5d366 | 23 | #:use-module (guix download) |
d581acee LC |
24 | #:use-module (guix build-system gnu) |
25 | #:use-module (guix build-system trivial) | |
7de94717 | 26 | #:use-module (guix memoization) |
d581acee | 27 | #:export (pkg-config)) |
c44899a2 | 28 | |
82c865c4 LC |
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 | |
c44899a2 LC |
33 | (package |
34 | (name "pkg-config") | |
139272f4 | 35 | (version "0.29.2") |
c44899a2 | 36 | (source (origin |
87f5d366 | 37 | (method url-fetch) |
8b16a5e1 LC |
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"))) | |
c44899a2 LC |
49 | (sha256 |
50 | (base32 | |
139272f4 | 51 | "14fmwzki1rlz8bs2p810lk6jqdxsk966d8drgsjmi54cd00rrikg")))) |
c44899a2 | 52 | (build-system gnu-build-system) |
032974aa MO |
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 | '())))) | |
a18eda27 LC |
64 | (native-search-paths |
65 | (list (search-path-specification | |
66 | (variable "PKG_CONFIG_PATH") | |
af070955 | 67 | (files '("lib/pkgconfig" "lib64/pkgconfig" "share/pkgconfig"))))) |
14551e07 | 68 | (home-page "https://www.freedesktop.org/wiki/Software/pkg-config") |
4a44e743 | 69 | (license gpl2+) |
35b9e423 | 70 | (synopsis "Helper tool used when compiling applications and libraries") |
c44899a2 LC |
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 | |
35b9e423 | 76 | on where to find glib (or other libraries). It is language-agnostic, so |
c44899a2 LC |
77 | it can be used for defining the location of documentation tools, for |
78 | instance."))) | |
d581acee | 79 | |
7de94717 LC |
80 | (define cross-pkg-config |
81 | (mlambda (target) | |
82 | "Return a pkg-config for TARGET, essentially just a wrapper called | |
d581acee | 83 | `TARGET-pkg-config', as `configure' scripts like it." |
7de94717 LC |
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)) | |
d581acee | 94 | |
7de94717 LC |
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"))) | |
d581acee | 100 | |
7de94717 | 101 | (mkdir-p bin) |
d581acee | 102 | |
7de94717 LC |
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)) | |
588a7813 | 108 | |
7de94717 LC |
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))) | |
d581acee | 116 | |
7de94717 LC |
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))))) | |
d581acee LC |
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)))) |