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.

135 lines
5.9 KiB

  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
  3. ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
  4. ;;; Copyright © 2019 Carl Dong <contact@carldong.me>
  5. ;;;
  6. ;;; This file is part of GNU Guix.
  7. ;;;
  8. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  9. ;;; under the terms of the GNU General Public License as published by
  10. ;;; the Free Software Foundation; either version 3 of the License, or (at
  11. ;;; your option) any later version.
  12. ;;;
  13. ;;; GNU Guix is distributed in the hope that it will be useful, but
  14. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;;; GNU General Public License for more details.
  17. ;;;
  18. ;;; You should have received a copy of the GNU General Public License
  19. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  20. (define-module (gnu packages mingw)
  21. #:use-module ((guix licenses) #:prefix license:)
  22. #:use-module (gnu packages)
  23. #:use-module (gnu packages base)
  24. #:use-module (gnu packages cross-base)
  25. #:use-module (gnu packages gcc)
  26. #:use-module (gnu packages compression)
  27. #:use-module (gnu packages multiprecision)
  28. #:use-module (guix build-system gnu)
  29. #:use-module (guix packages)
  30. #:use-module (guix download)
  31. #:use-module (guix utils)
  32. #:use-module (ice-9 match)
  33. #:export (make-mingw-w64))
  34. (define* (make-mingw-w64 machine
  35. #:key
  36. xgcc
  37. xbinutils
  38. with-winpthreads?)
  39. "Return a mingw-w64 for targeting MACHINE. If XGCC or XBINUTILS is specified,
  40. use that gcc or binutils when cross-compiling. If WITH-WINPTHREADS? is
  41. specified, recurse and return a mingw-w64 with support for winpthreads."
  42. (let* ((triplet (string-append machine "-" "w64-mingw32")))
  43. (package
  44. (name (string-append "mingw-w64" "-" machine
  45. (if with-winpthreads? "-winpthreads" "")))
  46. (version "7.0.0")
  47. (source (origin
  48. (method url-fetch)
  49. (uri (string-append
  50. "https://sourceforge.net/projects/mingw-w64/files/mingw-w64/"
  51. "mingw-w64-release/mingw-w64-v" version ".tar.bz2"))
  52. (sha256
  53. (base32 "0a5njsa2zw2ssdz10jkb10mhrf3cb8qp9avs89zqmw4n6pzxy85a"))
  54. (patches
  55. (search-patches "mingw-w64-6.0.0-gcc.patch"
  56. "mingw-w64-dlltool-temp-prefix.patch"
  57. "mingw-w64-reproducible-gendef.patch"))))
  58. (native-inputs `(("xgcc-core" ,(if xgcc xgcc (cross-gcc triplet)))
  59. ("xbinutils" ,(if xbinutils xbinutils (cross-binutils triplet)))
  60. ,@(if with-winpthreads?
  61. `(("xlibc" ,(make-mingw-w64 machine
  62. #:xgcc xgcc
  63. #:xbinutils xbinutils)))
  64. '())))
  65. (build-system gnu-build-system)
  66. (search-paths
  67. (list (search-path-specification
  68. (variable "CROSS_C_INCLUDE_PATH")
  69. (files `("include" ,(string-append triplet "/include"))))
  70. (search-path-specification
  71. (variable "CROSS_LIBRARY_PATH")
  72. (files
  73. `("lib" "lib64"
  74. ,(string-append triplet "/lib")
  75. ,(string-append triplet "/lib64"))))))
  76. (arguments
  77. `(#:configure-flags '(,(string-append "--host=" triplet)
  78. ,@(if with-winpthreads?
  79. '("--with-libraries=winpthreads")
  80. '()))
  81. #:phases
  82. (modify-phases %standard-phases
  83. (add-before 'configure 'setenv
  84. (lambda* (#:key inputs #:allow-other-keys)
  85. (let ((xgcc-core (assoc-ref inputs "xgcc-core"))
  86. (mingw-headers (string-append (getcwd) "/mingw-w64-headers")))
  87. (setenv "CPP"
  88. (string-append xgcc-core ,(string-append "/bin/" triplet "-cpp")))
  89. (setenv "CROSS_C_INCLUDE_PATH"
  90. (string-append
  91. mingw-headers
  92. ":" mingw-headers "/include"
  93. ":" mingw-headers "/crt"
  94. ":" mingw-headers "/defaults/include"
  95. ":" mingw-headers "/direct-x/include"))
  96. (when ,with-winpthreads?
  97. (let ((xlibc (assoc-ref inputs "xlibc")))
  98. (setenv "CROSS_LIBRARY_PATH"
  99. (string-append
  100. xlibc "/lib" ":"
  101. xlibc "/" ,triplet "/lib"))))))))
  102. #:make-flags (list "DEFS=-DHAVE_CONFIG_H -D__MINGW_HAS_DXSDK=1")
  103. #:tests? #f ; compiles and includes glibc headers
  104. #:strip-binaries? #f))
  105. (home-page "https://mingw-w64.org")
  106. (synopsis "Minimalist GNU for Windows")
  107. (description
  108. "Minimalist GNU for Windows (@dfn{MinGW}) is a complete software
  109. development environment for creating native Microsoft Windows applications.
  110. It includes a set of Windows-specific header files and static import libraries
  111. which enable the use of the Windows API. It does not rely on any third-party C
  112. runtime dynamic-link libraries (@dfn{DLL}s).
  113. Mingw-w64 is an advancement of the original mingw.org project and provides
  114. several new APIs such as DirectX and DDK, and 64-bit support.")
  115. (license license:fdl1.3+))))
  116. (define-public mingw-w64-i686
  117. (make-mingw-w64 "i686"))
  118. (define-public mingw-w64-x86_64
  119. (make-mingw-w64 "x86_64"))
  120. (define-public mingw-w64-i686-winpthreads
  121. (make-mingw-w64 "i686"
  122. #:with-winpthreads? #t))
  123. (define-public mingw-w64-x86_64-winpthreads
  124. (make-mingw-w64 "x86_64"
  125. #:with-winpthreads? #t))
  126. (define-public mingw-w64 mingw-w64-i686)