services: avahi: Add Avahi to the system profile.
[guix.git] / gnu / packages / pkg-config.scm
blobdd5120c4747b482e95e9f4f14fb578aa2c150204
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014 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/>.
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   #:export (pkg-config))
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
31   (package
32    (name "pkg-config")
33    (version "0.28")
34    (source (origin
35             (method url-fetch)
36             (uri (string-append
37                   "http://pkgconfig.freedesktop.org/releases/pkg-config-"
38                   version ".tar.gz"))
39             (sha256
40              (base32
41               "0igqq5m204w71m11y0nipbdf5apx87hwfll6axs12hn4dqfb6vkb"))))
42    (build-system gnu-build-system)
43    (arguments `(#:configure-flags '("--with-internal-glib")))
44    (native-search-paths
45     (list (search-path-specification
46            (variable "PKG_CONFIG_PATH")
47            (files '("lib/pkgconfig" "lib64/pkgconfig" "share/pkgconfig")))))
48    (home-page "http://www.freedesktop.org/wiki/Software/pkg-config")
49    (license gpl2+)
50    (synopsis "Helper tool used when compiling applications and libraries")
51    (description
52     "pkg-config is a helper tool used when compiling applications and
53 libraries.  It helps you insert the correct compiler options on the
54 command 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
56 on where to find glib (or other libraries).  It is language-agnostic, so
57 it can be used for defining the location of documentation tools, for
58 instance.")))
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))
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")))
79                      (mkdir-p bin)
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.
85                      (symlink native (string-append bin "/" prog))
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"))))))
92     (native-inputs `(("pkg-config" ,%pkg-config)))
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))))
98 (define (pkg-config-for-target target)
99   "Return a pkg-config package for TARGET, which may be either #f for a native
100 build, or a GNU triplet."
101   (if target
102       (cross-pkg-config target)
103       %pkg-config))
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))))