projects/guix·blob python-team · refs

208 lines · 9.0 KiB

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