pkg-config.scm 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. (define-module (gnu packages pkg-config)
  19. #:use-module (guix licenses)
  20. #:use-module (guix packages)
  21. #:use-module (guix download)
  22. #:use-module (guix build-system gnu)
  23. #:use-module (guix build-system trivial)
  24. #:export (pkg-config))
  25. ;; This is the "primitive" pkg-config package. People should use `pkg-config'
  26. ;; (see below) rather than `%pkg-config', but we export `%pkg-config' so that
  27. ;; `fold-packages' finds it.
  28. (define-public %pkg-config
  29. (package
  30. (name "pkg-config")
  31. (version "0.29.2")
  32. (source (origin
  33. (method url-fetch)
  34. (uri (list
  35. (string-append
  36. "http://fossies.org/linux/misc/pkg-config-" version
  37. ".tar.gz")
  38. ;; FIXME: The following URL redirects to HTTPS, which
  39. ;; creates bootstrapping problems:
  40. ;; <http://bugs.gnu.org/22774>.
  41. (string-append
  42. "http://pkgconfig.freedesktop.org/releases/pkg-config-"
  43. version ".tar.gz")))
  44. (sha256
  45. (base32
  46. "14fmwzki1rlz8bs2p810lk6jqdxsk966d8drgsjmi54cd00rrikg"))))
  47. (build-system gnu-build-system)
  48. (arguments `(#:configure-flags '("--with-internal-glib")))
  49. (native-search-paths
  50. (list (search-path-specification
  51. (variable "PKG_CONFIG_PATH")
  52. (files '("lib/pkgconfig" "lib64/pkgconfig" "share/pkgconfig")))))
  53. (home-page "https://www.freedesktop.org/wiki/Software/pkg-config")
  54. (license gpl2+)
  55. (synopsis "Helper tool used when compiling applications and libraries")
  56. (description
  57. "pkg-config is a helper tool used when compiling applications and
  58. libraries. It helps you insert the correct compiler options on the
  59. command line so an application can use gcc -o test test.c `pkg-config
  60. --libs --cflags glib-2.0` for instance, rather than hard-coding values
  61. on where to find glib (or other libraries). It is language-agnostic, so
  62. it can be used for defining the location of documentation tools, for
  63. instance.")))
  64. (define (cross-pkg-config target)
  65. "Return a pkg-config for TARGET, essentially just a wrapper called
  66. `TARGET-pkg-config', as `configure' scripts like it."
  67. ;; See <http://www.flameeyes.eu/autotools-mythbuster/pkgconfig/cross-compiling.html>
  68. ;; for details.
  69. (package (inherit %pkg-config)
  70. (name (string-append (package-name %pkg-config) "-" target))
  71. (build-system trivial-build-system)
  72. (arguments
  73. `(#:modules ((guix build utils))
  74. #:builder (begin
  75. (use-modules (guix build utils))
  76. (let* ((in (assoc-ref %build-inputs "pkg-config"))
  77. (out (assoc-ref %outputs "out"))
  78. (bin (string-append out "/bin"))
  79. (prog (string-append ,target "-pkg-config"))
  80. (native (string-append in "/bin/pkg-config")))
  81. (mkdir-p bin)
  82. ;; Create a `TARGET-pkg-config' -> `pkg-config' symlink.
  83. ;; This satisfies the pkg.m4 macros, which use
  84. ;; AC_PROG_TOOL to determine the `pkg-config' program
  85. ;; name.
  86. (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. #t))))
  93. (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))))
  97. (define (pkg-config-for-target target)
  98. "Return a pkg-config package for TARGET, which may be either #f for a native
  99. build, or a GNU triplet."
  100. (if target
  101. (cross-pkg-config target)
  102. %pkg-config))
  103. ;; This hack allows us to automatically choose the native or the cross
  104. ;; `pkg-config' depending on whether it's being used in a cross-build
  105. ;; environment or not.
  106. (define-syntax pkg-config
  107. (identifier-syntax (pkg-config-for-target (%current-target-system))))