gnu: make-mingw-w64: Use a mirror URI and fix lint errors.
[jackhill/guix/guix.git] / gnu / packages / mingw.scm
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
21 (define-module (gnu packages mingw)
22 #:use-module ((guix licenses) #:prefix license:)
23 #:use-module (gnu packages)
24 #:use-module (gnu packages base)
25 #:use-module (gnu packages cross-base)
26 #:use-module (gnu packages gcc)
27 #:use-module (gnu packages compression)
28 #:use-module (gnu packages multiprecision)
29 #:use-module (guix build-system gnu)
30 #:use-module (guix packages)
31 #:use-module (guix download)
32 #:use-module (guix utils)
33 #:use-module (ice-9 match)
34 #:export (make-mingw-w64))
35
36 (define* (make-mingw-w64 machine
37 #:key
38 xgcc
39 xbinutils
40 with-winpthreads?)
41 "Return a mingw-w64 for targeting MACHINE. If XGCC or XBINUTILS is specified,
42 use that gcc or binutils when cross-compiling. If WITH-WINPTHREADS? is
43 specified, recurse and return a mingw-w64 with support for winpthreads."
44 (let* ((triplet (string-append machine "-" "w64-mingw32")))
45 (package
46 (name (string-append "mingw-w64" "-" machine
47 (if with-winpthreads? "-winpthreads" "")))
48 (version "7.0.0")
49 (source
50 (origin
51 (method url-fetch)
52 (uri (string-append
53 "mirror://sourceforge/mingw-w64/mingw-w64/"
54 "mingw-w64-release/mingw-w64-v" version ".tar.bz2"))
55 (sha256
56 (base32 "0a5njsa2zw2ssdz10jkb10mhrf3cb8qp9avs89zqmw4n6pzxy85a"))
57 (patches
58 (search-patches "mingw-w64-6.0.0-gcc.patch"
59 "mingw-w64-dlltool-temp-prefix.patch"
60 "mingw-w64-reproducible-gendef.patch"))))
61 (native-inputs `(("xgcc-core" ,(if xgcc xgcc (cross-gcc triplet)))
62 ("xbinutils" ,(if xbinutils xbinutils
63 (cross-binutils triplet)))
64 ,@(if with-winpthreads?
65 `(("xlibc" ,(make-mingw-w64
66 machine
67 #:xgcc xgcc
68 #:xbinutils xbinutils)))
69 '())))
70 (build-system gnu-build-system)
71 (search-paths
72 (list (search-path-specification
73 (variable "CROSS_C_INCLUDE_PATH")
74 (files `("include" ,(string-append triplet "/include"))))
75 (search-path-specification
76 (variable "CROSS_LIBRARY_PATH")
77 (files
78 `("lib" "lib64"
79 ,(string-append triplet "/lib")
80 ,(string-append triplet "/lib64"))))))
81 (arguments
82 `(#:configure-flags '(,(string-append "--host=" triplet)
83 ,@(if with-winpthreads?
84 '("--with-libraries=winpthreads")
85 '()))
86 #:phases
87 (modify-phases %standard-phases
88 (add-before 'configure 'setenv
89 (lambda* (#:key inputs #:allow-other-keys)
90 (let ((xgcc-core (assoc-ref inputs "xgcc-core"))
91 (mingw-headers (string-append
92 (getcwd) "/mingw-w64-headers")))
93 (setenv "CPP"
94 (string-append
95 xgcc-core ,(string-append "/bin/" triplet "-cpp")))
96 (setenv "CROSS_C_INCLUDE_PATH"
97 (string-append
98 mingw-headers
99 ":" mingw-headers "/include"
100 ":" mingw-headers "/crt"
101 ":" mingw-headers "/defaults/include"
102 ":" mingw-headers "/direct-x/include"))
103 (when ,with-winpthreads?
104 (let ((xlibc (assoc-ref inputs "xlibc")))
105 (setenv "CROSS_LIBRARY_PATH"
106 (string-append
107 xlibc "/lib" ":"
108 xlibc "/" ,triplet "/lib"))))))))
109 #:make-flags (list "DEFS=-DHAVE_CONFIG_H -D__MINGW_HAS_DXSDK=1")
110 #:tests? #f ; compiles and includes glibc headers
111 #:strip-binaries? #f))
112 (home-page "https://mingw-w64.org")
113 (synopsis "Minimalist GNU for Windows")
114 (description
115 "Minimalist GNU for Windows (@dfn{MinGW}) is a complete software
116 development environment for creating native Microsoft Windows applications.
117
118 It includes a set of Windows-specific header files and static import libraries
119 which enable the use of the Windows API. It does not rely on any third-party C
120 runtime dynamic-link libraries (@dfn{DLL}s).
121
122 Mingw-w64 is an advancement of the original mingw.org project and provides
123 several new APIs such as DirectX and DDK, and 64-bit support.")
124 (license license:fdl1.3+))))
125
126 (define-public mingw-w64-i686
127 (make-mingw-w64 "i686"))
128
129 (define-public mingw-w64-x86_64
130 (make-mingw-w64 "x86_64"))
131
132 (define-public mingw-w64-i686-winpthreads
133 (make-mingw-w64 "i686"
134 #:with-winpthreads? #t))
135
136 (define-public mingw-w64-x86_64-winpthreads
137 (make-mingw-w64 "x86_64"
138 #:with-winpthreads? #t))
139
140 (define-public mingw-w64 mingw-w64-i686)