You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

108 lines
4.4 KiB

  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2012, 2013 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.27.1")
  32. (source (origin
  33. (method url-fetch)
  34. (uri (string-append
  35. "http://pkgconfig.freedesktop.org/releases/pkg-config-"
  36. version ".tar.gz"))
  37. (sha256
  38. (base32
  39. "05wc5nwkqz7saj2v33ydmz1y6jdg659dll4jjh91n41m63gx0qsg"))))
  40. (build-system gnu-build-system)
  41. (arguments `(#:configure-flags '("--with-internal-glib")))
  42. (native-search-paths
  43. (list (search-path-specification
  44. (variable "PKG_CONFIG_PATH")
  45. (directories '("lib/pkgconfig" "lib64/pkgconfig"
  46. "share/pkgconfig")))))
  47. (home-page "http://www.freedesktop.org/wiki/Software/pkg-config")
  48. (license gpl2+)
  49. (synopsis "a helper tool used when compiling applications and
  50. 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.")))
  59. (define (cross-pkg-config target)
  60. "Return a pkg-config for TARGET, essentially just a wrapper called
  61. `TARGET-pkg-config', as `configure' scripts like it."
  62. ;; See <http://www.flameeyes.eu/autotools-mythbuster/pkgconfig/cross-compiling.html>
  63. ;; for details.
  64. (package (inherit %pkg-config)
  65. (name (string-append (package-name %pkg-config) "-" target))
  66. (build-system trivial-build-system)
  67. (arguments
  68. `(#:modules ((guix build utils))
  69. #:builder (begin
  70. (use-modules (guix build utils))
  71. (let* ((out (assoc-ref %outputs "out"))
  72. (bin (string-append out "/bin"))
  73. (prog (string-append ,target "-pkg-config"))
  74. (native
  75. (string-append
  76. (assoc-ref %build-inputs "pkg-config")
  77. "/bin/pkg-config")))
  78. (mkdir-p bin)
  79. ;; Create a `TARGET-pkg-config' -> `pkg-config' symlink.
  80. ;; This satisfies the pkg.m4 macros, which use
  81. ;; AC_PROG_TOOL to determine the `pkg-config' program
  82. ;; name.
  83. (symlink native (string-append bin "/" prog))))))
  84. (native-inputs `(("pkg-config" ,%pkg-config)))
  85. ;; Ignore native inputs, and set `PKG_CONFIG_PATH' for target inputs.
  86. (native-search-paths '())
  87. (search-paths (package-native-search-paths %pkg-config))))
  88. (define (pkg-config-for-target target)
  89. "Return a pkg-config package for TARGET, which may be either #f for a native
  90. build, or a GNU triplet."
  91. (if target
  92. (cross-pkg-config target)
  93. %pkg-config))
  94. ;; This hack allows us to automatically choose the native or the cross
  95. ;; `pkg-config' depending on whether it's being used in a cross-build
  96. ;; environment or not.
  97. (define-syntax pkg-config
  98. (identifier-syntax (pkg-config-for-target (%current-target-system))))