aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/mingw.scm
blob: ea579d40433733fc11f1dd5248cf9b8a5b349415 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2019 Carl Dong <contact@carldong.me>
;;; Copyright © 2021 Léo Le Bouter <lle-bout@zaclys.net>
;;; Copyright © 2024 Foundation Devices, Inc. <hello@foundation.xyz>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages mingw)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (gnu packages)
  #:use-module (gnu packages cross-base)
  #:use-module (guix build-system gnu)
  #:use-module (guix gexp)
  #:use-module (guix memoization)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:export (make-mingw-w64))

(define* (make-mingw-w64/implementation machine
                                        #:key
                                        xgcc
                                        xbinutils
                                        with-winpthreads?)
  "Return a mingw-w64 for targeting MACHINE.  If XGCC or XBINUTILS is specified,
use that gcc or binutils when cross-compiling.  If WITH-WINPTHREADS? is
specified, recurse and return a mingw-w64 with support for winpthreads."
  (let* ((triplet (string-append machine "-" "w64-mingw32")))
    (package
      (name (string-append "mingw-w64" "-" machine
                           (if with-winpthreads? "-winpthreads" "")))
      (version "12.0.0")
      (source
       (origin
         (method url-fetch)
         (uri (string-append
               "mirror://sourceforge/mingw-w64/mingw-w64/"
               "mingw-w64-release/mingw-w64-v" version ".tar.bz2"))
         (sha256
          (base32 "0bzdprdrb8jy5dhkl2j2yhnr2nsiv6wk2wzxrzaqsvjbmj58jhfc"))))
      (native-inputs `(("xgcc-core" ,(if xgcc xgcc (cross-gcc triplet)))
                       ("xbinutils" ,(if xbinutils xbinutils
                                         (cross-binutils triplet)))
                       ,@(if with-winpthreads?
                             `(("xlibc" ,(make-mingw-w64
                                          machine
                                          #:xgcc xgcc
                                          #:xbinutils xbinutils)))
                             '())))
      (build-system gnu-build-system)
      (search-paths
       (list (search-path-specification
              (variable "CROSS_C_INCLUDE_PATH")
              (files `("include" ,(string-append triplet "/include"))))
             (search-path-specification
              (variable "CROSS_LIBRARY_PATH")
              (files
               `("lib" "lib64"
                 ,(string-append triplet "/lib")
                 ,(string-append triplet "/lib64"))))))
      (arguments
       (list #:parallel-build? #f ; parallel builds often fail with empty .a files
             #:tests? #f ; compiles and includes glibc headers
             #:strip-binaries? #f
             #:configure-flags
             #~(list #$(string-append "--host=" triplet)
                     #$@(if with-winpthreads?
                            #~("--with-libraries=winpthreads")
                            #~())
                     ;; The default msvcrt changed on 12.0.0 to use UCRT as the
                     ;; default, this could cause problems with programs expecting
                     ;; MSVCRT as the default.
                     ;;
                     ;; XXX: A new target to use UCRT can be introduced as
                     ;; the MSYS2 project does, e.g: x86_64-w64-ucrt-mingw32.
                     "--with-default-msvcrt=msvcrt")
             #:make-flags #~'("DEFS=-DHAVE_CONFIG_H -D__MINGW_HAS_DXSDK=1")
             #:phases
             #~(modify-phases %standard-phases
                 (add-before 'configure 'setenv
                   (lambda _
                     (let ((xgcc-core #+(this-package-native-input
                                         "xgcc-core"))
                           (mingw-headers (string-append
                                           (getcwd) "/mingw-w64-headers")))
                       (setenv "CPP"
                               (string-append
                                xgcc-core "/bin/" #$triplet "-cpp"))
                       (setenv "CROSS_C_INCLUDE_PATH"
                               (string-append
                                mingw-headers
                                ":" mingw-headers "/include"
                                ":" mingw-headers "/crt"
                                ":" mingw-headers "/defaults/include"
                                ":" mingw-headers "/direct-x/include"))
                       #$@(if with-winpthreads?
                              #~((let ((xlibc #+(this-package-native-input
                                                 "xlibc")))
                                   (setenv "CROSS_LIBRARY_PATH"
                                           (string-append
                                            xlibc "/lib" ":"
                                            xlibc "/" #$triplet "/lib"))))
                              #~())))))))
      (home-page "https://mingw-w64.org")
      (synopsis "Minimalist GNU for Windows")
      (description
       "Minimalist GNU for Windows (@dfn{MinGW}) is a complete software
development environment for creating native Microsoft Windows applications.

It includes a set of Windows-specific header files and static import libraries
which enable the use of the Windows API.  It does not rely on any third-party C
runtime dynamic-link libraries (@dfn{DLL}s).

Mingw-w64 is an advancement of the original mingw.org project and provides
several new APIs such as DirectX and DDK, and 64-bit support.")
      (license license:fdl1.3+))))

(define make-mingw-w64
  (memoize make-mingw-w64/implementation))

(define-public mingw-w64-i686
  (make-mingw-w64 "i686"))

(define-public mingw-w64-x86_64
  (make-mingw-w64 "x86_64"))

(define-public mingw-w64-i686-winpthreads
  (make-mingw-w64 "i686"
                  #:with-winpthreads? #t))

(define-public mingw-w64-x86_64-winpthreads
  (make-mingw-w64 "x86_64"
                  #:with-winpthreads? #t))

(define-public mingw-w64 mingw-w64-i686)

(define-public mingw-w64-tools
  (package
    (name "mingw-w64-tools")
    (version "12.0.0")
    (source
     (origin
       (method url-fetch)
       (uri (string-append
             "mirror://sourceforge/mingw-w64/mingw-w64/"
             "mingw-w64-release/mingw-w64-v" version ".tar.bz2"))
       (sha256
        (base32 "0bzdprdrb8jy5dhkl2j2yhnr2nsiv6wk2wzxrzaqsvjbmj58jhfc"))))
    (build-system gnu-build-system)
    (arguments
     (list
      #:modules '((guix build gnu-build-system)
                  (guix build utils)
                  (srfi srfi-1))
      #:phases
      #~(append
         (modify-phases %standard-phases
           (add-after 'unpack 'cd-gendef
             (lambda _
               (chdir "mingw-w64-tools/gendef"))))
         (modify-phases %standard-phases
           (replace 'unpack
             (lambda _
               (chdir "../genidl"))))
         (modify-phases %standard-phases
           (replace 'unpack
             (lambda _
               (chdir "../genpeimg"))))
         (append-map
          (lambda (target)
            (modify-phases %standard-phases
              (replace 'unpack
                (lambda _
                  (chdir "../widl")
                  (false-if-exception
                   (delete-file-recursively "../build"))))
              (replace 'configure
                (lambda args
                  (apply (assoc-ref %standard-phases 'configure)
                         (append args (list #:out-of-source? #t
                                            #:configure-flags
                                            `("--target" ,target
                                              "--program-prefix"
                                              ,(string-append target "-")))))))))
          '("i686-w64-mingw32" "x86_64-w64-mingw32")))))
    (home-page "https://mingw-w64.org")
    (synopsis "Tools of Minimalist GNU for Windows")
    (description "This package provides the tools of Minimalist GNU for
Windows, a complete software development environment for creating native
Microsoft Windows applications.")
    (license (list license:gpl3+ ;gendef, genidl, genlib, genpeimg, genstubdll
                   license:lgpl2.1+)))) ;widl
='msg-avail'>...* gnu/packages/crates-io.scm (rust-wio-0.120: Move from here ... * gnu/packages/crates-windows.scm: ... to here. Change-Id: I8b53eb6a54d3cced633639ea09731f7ba835926d Efraim Flashner 2024-02-20gnu: rust-wio-0.2: Move to (gnu packages crates-windows)....* gnu/packages/crates-io.scm (rust-wio-0.2): Move from here ... * gnu/packages/crates-windows.scm: ... to here. Change-Id: I929b0208dcdf12a06a7986e9eba8831e5a90758c Efraim Flashner 2024-02-20gnu: rust-winutil-0.1: Move to (gnu packages crates-windows)....* gnu/packages/crates-io.scm (rust-winutil-0.1): Move from here ... * gnu/packages/crates-windows.scm: ... to here. Change-Id: I5bc5faf1ad6c6c71d975a744255a4601b0ae466d Efraim Flashner 2024-02-20gnu: rust-winres-0.1: Move to (gnu packages crates-windows)....* gnu/packages/crates-io.scm (rust-winres-0.1): Move from here ... * gnu/packages/crates-windows.scm: ... to here. Change-Id: Ic5fc23f3d3559469f487969961a5aedc5609ad0e Efraim Flashner 2024-02-20gnu: rust-winreg: Move to (gnu packages crates-windows)....* gnu/packages/crates-io.scm (rust-winreg-0.50, rust-winreg-0.10, rust-winreg-0.8, rust-winreg-0.7, rust-winreg-0.6, rust-winreg-0.5): Move from here ... * gnu/packages/crates-windows.scm: ... to here. Change-Id: I6f5fe23957b0d3b2fd36f7304f64b182f2fd925e Efraim Flashner 2024-02-20gnu: rust-wincolor: Move to (gnu packages crates-windows)....* gnu/packages/crates-io.scm (rust-wincolor-1, rust-wincolor-0.1): Move from here ... * gnu/packages/crates-windows.scm: ... to here. Change-Id: I08b132c77005da87116330d9e9b019d233505c7f Efraim Flashner 2024-02-20gnu: rust-winapi: Move to (gnu packages crates-windows)....* gnu/packages/crates-io.scm (rust-winapi-0.3, rust-winapi-0.2, rust-winapi-build-0.1, rust-winapi-i686-pc-windows-gnu-0.4, rust-winapi-util-0.1, rust-winapi-wsapoll-0.1, rust-winapi-x86-64-pc-windows-gnu-0.4): Move from here ... * gnu/packages/crates-windows.scm: ... to here. Change-Id: Ida3a2a0cdae7f823c11c3b4a6d0dd36a158ec021 Efraim Flashner 2024-02-20gnu: rust-win-crypto-ng-0.5: Move to (gnu packages crates-windows)....* gnu/packages/crates-io.scm (rust-win-crypto-ng-0.5): Move from here ... * gnu/packages/crates-windows.scm: ... to here. Change-Id: I78b4e9c93f3ed76b8305113c424028434b62a2da Efraim Flashner 2024-02-20gnu: rust-user32-sys-0.2: Move to (gnu packages crates-windows)....* gnu/packages/crates-io.scm (rust-user32-sys-0.2): Move from here ... * gnu/packages/crates-windows.scm: ... to here. Change-Id: Ibb805a990170200cbcb21c0b42aa90a6c04f3be2 Efraim Flashner 2024-02-20gnu: rust-uds-windows: Move to (gnu packages crates-windows)....* gnu/packages/crates-io.scm (rust-uds-windows-1, rust-uds-windows-0.1): Move from here ... * gnu/packages/crates-windows.scm: ... to here. Change-Id: I1a3601922dd222d315cba462742678c1286cba4f Efraim Flashner 2024-02-20gnu: rust-serde-ini-0.2: Move to (gnu packages crates-windows)....* gnu/packages/crates-io.scm (rust-serde-ini-0.2): Move from here ... * gnu/packages/crates-windows.scm: ... to here. Change-Id: I995da190bbc23fd3dcd64c9b73858290eca0ee03 Efraim Flashner 2024-02-20gnu: rust-schannel-0.1: Move to (gnu packages crates-windows)....* gnu/packages/crates-io.scm (rust-schannel-0.1): Move from here ... * gnu/packages/crates-windows.scm: ... to here. Change-Id: If83411c1a155d69fc92953900231e02da3d7443a Efraim Flashner 2024-02-20gnu: rust-remove-dir-all: Move to (gnu packages crates-windows)....* gnu/packages/crates-io.scm (rust-remove-dir-all-0.5, rust-remove-dir-all-0.8): Move from here ... * gnu/packages/crates-windows.scm: ... to here. Change-Id: I37c560a330a51722401ec325c8a262782c8d3fce Efraim Flashner 2024-02-20gnu: rust-python3-dll-a-0.2: Move to (gnu packages crates-windows)....* gnu/packages/crates-io.scm (rust-python3-dll-a-0.2): Move from here ... * gnu/packages/crates-windows.scm: ... to here. Change-Id: Ic16735b24b0a6e37cee0992d0baf130fe9ac4576 Efraim Flashner 2024-02-20gnu: rust-output-vt100-0.1: Move to (gnu packages crates-windows)....* gnu/packages/crates-io.scm (rust-output-vt100-0.1): Move from here ... * gnu/packages/crates-windows.scm: ... to here. Change-Id: I4dc63c5e0651c15a34e0f6018619b639f164ba35 Efraim Flashner 2024-02-20gnu: rust-miow: Move to (gnu packages crates-windows)....* gnu/packages/crates-io.scm (rust-miow-0.6, rust-miow-0.5, rust-miow-0.4, rust-miow-0.3, rust-miow-0.2): Move from here ... * gnu/packages/crates-windows.scm: ... to here. Change-Id: I663b33b5c50d20505a0ac3997aa2b0038452c8b5 Efraim Flashner 2024-02-20gnu: rust-kernel32-sys-0.2: Move to (gnu packages crates-windows)....* gnu/packages/crates-io.scm (rust-kernel32-sys-0.2): Move from here ... * gnu/packages/crates-windows.scm: ... to here. Change-Id: I2b2e3078836618dddf7c332848cb67eee3bd171f Efraim Flashner 2024-02-20gnu: rust-ipconfig: Move to (gnu packages crates-windows)....* gnu/packages/crates-io.scm (rust-ipconfig-0.3, rust-ipconfig-0.2): Move from here ... * gnu/packages/crates-windows.scm: ... to here. Change-Id: Ic4e968f6a7bc22cf92646e75f451de03e76112ed Efraim Flashner