gnu: emacs-svg-icon: Fix grammar.
[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 "8.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 "0qjpb9rviasfshk337j5r32ncmrwml8sv6qnmb1lp4mkdbm41is4"))
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 #:tests? #f ; compiles and includes glibc headers
112 #:strip-binaries? #f))
113 (home-page "https://mingw-w64.org")
114 (synopsis "Minimalist GNU for Windows")
115 (description
116 "Minimalist GNU for Windows (@dfn{MinGW}) is a complete software
117 development environment for creating native Microsoft Windows applications.
118
119 It includes a set of Windows-specific header files and static import libraries
120 which enable the use of the Windows API. It does not rely on any third-party C
121 runtime dynamic-link libraries (@dfn{DLL}s).
122
123 Mingw-w64 is an advancement of the original mingw.org project and provides
124 several new APIs such as DirectX and DDK, and 64-bit support.")
125 (license license:fdl1.3+))))
126
127 (define-public mingw-w64-i686
128 (make-mingw-w64 "i686"))
129
130 (define-public mingw-w64-x86_64
131 (make-mingw-w64 "x86_64"))
132
133 (define-public mingw-w64-i686-winpthreads
134 (make-mingw-w64 "i686"
135 #:with-winpthreads? #t))
136
137 (define-public mingw-w64-x86_64-winpthreads
138 (make-mingw-w64 "x86_64"
139 #:with-winpthreads? #t))
140
141 (define-public mingw-w64 mingw-w64-i686)
142
143 (define-public mingw-w64-tools
144 (package
145 (name "mingw-w64-tools")
146 (version "8.0.0")
147 (source
148 (origin
149 (method url-fetch)
150 (uri (string-append
151 "mirror://sourceforge/mingw-w64/mingw-w64/"
152 "mingw-w64-release/mingw-w64-v" version ".tar.bz2"))
153 (sha256
154 (base32 "0qjpb9rviasfshk337j5r32ncmrwml8sv6qnmb1lp4mkdbm41is4"))))
155 (build-system gnu-build-system)
156 (arguments
157 `(#:modules ((guix build gnu-build-system)
158 (guix build utils)
159 (srfi srfi-1))
160 #:phases
161 (append
162 (modify-phases %standard-phases
163 (add-after 'unpack 'cd-gendef
164 (lambda _
165 (chdir "mingw-w64-tools/gendef"))))
166 (modify-phases %standard-phases
167 (replace 'unpack
168 (lambda _
169 (chdir "../genidl"))))
170 (modify-phases %standard-phases
171 (replace 'unpack
172 (lambda _
173 (chdir "../genlib"))))
174 (modify-phases %standard-phases
175 (replace 'unpack
176 (lambda _
177 (chdir "../genpeimg"))))
178 (append-map
179 (lambda (target)
180 (modify-phases %standard-phases
181 (replace 'unpack
182 (lambda _
183 (chdir "../widl")
184 (false-if-exception
185 (delete-file-recursively "../build"))
186 #t))
187 (replace 'configure
188 (lambda args
189 (apply (assoc-ref %standard-phases 'configure)
190 (append args (list #:out-of-source? #t
191 #:configure-flags
192 `("--target" ,target
193 "--program-prefix"
194 ,(string-append target "-")))))))))
195 '("i686-w64-mingw32" "x86_64-w64-mingw32")))))
196 (home-page "https://mingw-w64.org")
197 (synopsis "Tools of Minimalist GNU for Windows")
198 (description "This package provides the tools of Minimalist GNU for
199 Windows, a complete software development environment for creating native
200 Microsoft Windows applications.")
201 (license (list license:gpl3+ ;gendef, genidl, genlib, genpeimg, genstubdll
202 license:lgpl2.1+)))) ;widl