gnu: ruby-pandoc-ruby: Use pandoc instead of ghc-pandoc.
[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 (origin
50 (method url-fetch)
51 (uri (string-append
52 "https://sourceforge.net/projects/mingw-w64/files/mingw-w64/"
53 "mingw-w64-release/mingw-w64-v" version ".tar.bz2"))
54 (sha256
55 (base32 "0a5njsa2zw2ssdz10jkb10mhrf3cb8qp9avs89zqmw4n6pzxy85a"))
56 (patches
57 (search-patches "mingw-w64-6.0.0-gcc.patch"
58 "mingw-w64-dlltool-temp-prefix.patch"
59 "mingw-w64-reproducible-gendef.patch"))))
60 (native-inputs `(("xgcc-core" ,(if xgcc xgcc (cross-gcc triplet)))
61 ("xbinutils" ,(if xbinutils xbinutils (cross-binutils triplet)))
62 ,@(if with-winpthreads?
63 `(("xlibc" ,(make-mingw-w64 machine
64 #:xgcc xgcc
65 #:xbinutils xbinutils)))
66 '())))
67 (build-system gnu-build-system)
68 (search-paths
69 (list (search-path-specification
70 (variable "CROSS_C_INCLUDE_PATH")
71 (files `("include" ,(string-append triplet "/include"))))
72 (search-path-specification
73 (variable "CROSS_LIBRARY_PATH")
74 (files
75 `("lib" "lib64"
76 ,(string-append triplet "/lib")
77 ,(string-append triplet "/lib64"))))))
78 (arguments
79 `(#:configure-flags '(,(string-append "--host=" triplet)
80 ,@(if with-winpthreads?
81 '("--with-libraries=winpthreads")
82 '()))
83 #:phases
84 (modify-phases %standard-phases
85 (add-before 'configure 'setenv
86 (lambda* (#:key inputs #:allow-other-keys)
87 (let ((xgcc-core (assoc-ref inputs "xgcc-core"))
88 (mingw-headers (string-append (getcwd) "/mingw-w64-headers")))
89 (setenv "CPP"
90 (string-append xgcc-core ,(string-append "/bin/" triplet "-cpp")))
91 (setenv "CROSS_C_INCLUDE_PATH"
92 (string-append
93 mingw-headers
94 ":" mingw-headers "/include"
95 ":" mingw-headers "/crt"
96 ":" mingw-headers "/defaults/include"
97 ":" mingw-headers "/direct-x/include"))
98 (when ,with-winpthreads?
99 (let ((xlibc (assoc-ref inputs "xlibc")))
100 (setenv "CROSS_LIBRARY_PATH"
101 (string-append
102 xlibc "/lib" ":"
103 xlibc "/" ,triplet "/lib"))))))))
104 #:make-flags (list "DEFS=-DHAVE_CONFIG_H -D__MINGW_HAS_DXSDK=1")
105 #:tests? #f ; compiles and includes glibc headers
106 #:strip-binaries? #f))
107 (home-page "https://mingw-w64.org")
108 (synopsis "Minimalist GNU for Windows")
109 (description
110 "Minimalist GNU for Windows (@dfn{MinGW}) is a complete software
111 development environment for creating native Microsoft Windows applications.
112
113 It includes a set of Windows-specific header files and static import libraries
114 which enable the use of the Windows API. It does not rely on any third-party C
115 runtime dynamic-link libraries (@dfn{DLL}s).
116
117 Mingw-w64 is an advancement of the original mingw.org project and provides
118 several new APIs such as DirectX and DDK, and 64-bit support.")
119 (license license:fdl1.3+))))
120
121 (define-public mingw-w64-i686
122 (make-mingw-w64 "i686"))
123
124 (define-public mingw-w64-x86_64
125 (make-mingw-w64 "x86_64"))
126
127 (define-public mingw-w64-i686-winpthreads
128 (make-mingw-w64 "i686"
129 #:with-winpthreads? #t))
130
131 (define-public mingw-w64-x86_64-winpthreads
132 (make-mingw-w64 "x86_64"
133 #:with-winpthreads? #t))
134
135 (define-public mingw-w64 mingw-w64-i686)