gnu: Add qtwayland, version 6.3.1.
[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 ;;; Copyright © 2021 Léo Le Bouter <lle-bout@zaclys.net>
6 ;;;
7 ;;; This file is part of GNU Guix.
8 ;;;
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
13 ;;;
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22 (define-module (gnu packages mingw)
23 #:use-module ((guix licenses) #:prefix license:)
24 #:use-module (gnu packages)
25 #:use-module (gnu packages base)
26 #:use-module (gnu packages cross-base)
27 #:use-module (gnu packages gcc)
28 #:use-module (gnu packages compression)
29 #:use-module (gnu packages multiprecision)
30 #:use-module (guix build-system gnu)
31 #:use-module (guix packages)
32 #:use-module (guix download)
33 #:use-module (guix utils)
34 #:use-module (ice-9 match)
35 #:export (make-mingw-w64))
36
37 (define* (make-mingw-w64 machine
38 #:key
39 xgcc
40 xbinutils
41 with-winpthreads?)
42 "Return a mingw-w64 for targeting MACHINE. If XGCC or XBINUTILS is specified,
43 use that gcc or binutils when cross-compiling. If WITH-WINPTHREADS? is
44 specified, recurse and return a mingw-w64 with support for winpthreads."
45 (let* ((triplet (string-append machine "-" "w64-mingw32")))
46 (package
47 (name (string-append "mingw-w64" "-" machine
48 (if with-winpthreads? "-winpthreads" "")))
49 (version "10.0.0")
50 (source
51 (origin
52 (method url-fetch)
53 (uri (string-append
54 "mirror://sourceforge/mingw-w64/mingw-w64/"
55 "mingw-w64-release/mingw-w64-v" version ".tar.bz2"))
56 (sha256
57 (base32 "15089y4rlj6g1m2m3cm3awndw3rbzhznl7skd0vkmikjxl546sxs"))
58 (patches
59 (search-patches "mingw-w64-6.0.0-gcc.patch"
60 "mingw-w64-dlltool-temp-prefix.patch"
61 "mingw-w64-reproducible-gendef.patch"))))
62 (native-inputs `(("xgcc-core" ,(if xgcc xgcc (cross-gcc triplet)))
63 ("xbinutils" ,(if xbinutils xbinutils
64 (cross-binutils triplet)))
65 ,@(if with-winpthreads?
66 `(("xlibc" ,(make-mingw-w64
67 machine
68 #:xgcc xgcc
69 #:xbinutils xbinutils)))
70 '())))
71 (build-system gnu-build-system)
72 (search-paths
73 (list (search-path-specification
74 (variable "CROSS_C_INCLUDE_PATH")
75 (files `("include" ,(string-append triplet "/include"))))
76 (search-path-specification
77 (variable "CROSS_LIBRARY_PATH")
78 (files
79 `("lib" "lib64"
80 ,(string-append triplet "/lib")
81 ,(string-append triplet "/lib64"))))))
82 (arguments
83 `(#:configure-flags '(,(string-append "--host=" triplet)
84 ,@(if with-winpthreads?
85 '("--with-libraries=winpthreads")
86 '()))
87 #:phases
88 (modify-phases %standard-phases
89 (add-before 'configure 'setenv
90 (lambda* (#:key inputs #:allow-other-keys)
91 (let ((xgcc-core (assoc-ref inputs "xgcc-core"))
92 (mingw-headers (string-append
93 (getcwd) "/mingw-w64-headers")))
94 (setenv "CPP"
95 (string-append
96 xgcc-core ,(string-append "/bin/" triplet "-cpp")))
97 (setenv "CROSS_C_INCLUDE_PATH"
98 (string-append
99 mingw-headers
100 ":" mingw-headers "/include"
101 ":" mingw-headers "/crt"
102 ":" mingw-headers "/defaults/include"
103 ":" mingw-headers "/direct-x/include"))
104 (when ,with-winpthreads?
105 (let ((xlibc (assoc-ref inputs "xlibc")))
106 (setenv "CROSS_LIBRARY_PATH"
107 (string-append
108 xlibc "/lib" ":"
109 xlibc "/" ,triplet "/lib"))))))))
110 #:make-flags (list "DEFS=-DHAVE_CONFIG_H -D__MINGW_HAS_DXSDK=1")
111 #:parallel-build? #f ; parallel builds often fail with empty .a files
112 #:tests? #f ; compiles and includes glibc headers
113 #:strip-binaries? #f))
114 (home-page "https://mingw-w64.org")
115 (synopsis "Minimalist GNU for Windows")
116 (description
117 "Minimalist GNU for Windows (@dfn{MinGW}) is a complete software
118 development environment for creating native Microsoft Windows applications.
119
120 It includes a set of Windows-specific header files and static import libraries
121 which enable the use of the Windows API. It does not rely on any third-party C
122 runtime dynamic-link libraries (@dfn{DLL}s).
123
124 Mingw-w64 is an advancement of the original mingw.org project and provides
125 several new APIs such as DirectX and DDK, and 64-bit support.")
126 (license license:fdl1.3+))))
127
128 (define-public mingw-w64-i686
129 (make-mingw-w64 "i686"))
130
131 (define-public mingw-w64-x86_64
132 (make-mingw-w64 "x86_64"))
133
134 (define-public mingw-w64-i686-winpthreads
135 (make-mingw-w64 "i686"
136 #:with-winpthreads? #t))
137
138 (define-public mingw-w64-x86_64-winpthreads
139 (make-mingw-w64 "x86_64"
140 #:with-winpthreads? #t))
141
142 (define-public mingw-w64 mingw-w64-i686)
143
144 (define-public mingw-w64-tools
145 (package
146 (name "mingw-w64-tools")
147 (version "10.0.0")
148 (source
149 (origin
150 (method url-fetch)
151 (uri (string-append
152 "mirror://sourceforge/mingw-w64/mingw-w64/"
153 "mingw-w64-release/mingw-w64-v" version ".tar.bz2"))
154 (sha256
155 (base32 "15089y4rlj6g1m2m3cm3awndw3rbzhznl7skd0vkmikjxl546sxs"))))
156 (build-system gnu-build-system)
157 (arguments
158 `(#:modules ((guix build gnu-build-system)
159 (guix build utils)
160 (srfi srfi-1))
161 #:phases
162 (append
163 (modify-phases %standard-phases
164 (add-after 'unpack 'cd-gendef
165 (lambda _
166 (chdir "mingw-w64-tools/gendef"))))
167 (modify-phases %standard-phases
168 (replace 'unpack
169 (lambda _
170 (chdir "../genidl"))))
171 (modify-phases %standard-phases
172 (replace 'unpack
173 (lambda _
174 (chdir "../genlib"))))
175 (modify-phases %standard-phases
176 (replace 'unpack
177 (lambda _
178 (chdir "../genpeimg"))))
179 (append-map
180 (lambda (target)
181 (modify-phases %standard-phases
182 (replace 'unpack
183 (lambda _
184 (chdir "../widl")
185 (false-if-exception
186 (delete-file-recursively "../build"))
187 #t))
188 (replace 'configure
189 (lambda args
190 (apply (assoc-ref %standard-phases 'configure)
191 (append args (list #:out-of-source? #t
192 #:configure-flags
193 `("--target" ,target
194 "--program-prefix"
195 ,(string-append target "-")))))))))
196 '("i686-w64-mingw32" "x86_64-w64-mingw32")))))
197 (home-page "https://mingw-w64.org")
198 (synopsis "Tools of Minimalist GNU for Windows")
199 (description "This package provides the tools of Minimalist GNU for
200 Windows, a complete software development environment for creating native
201 Microsoft Windows applications.")
202 (license (list license:gpl3+ ;gendef, genidl, genlib, genpeimg, genstubdll
203 license:lgpl2.1+)))) ;widl