gnu: libretro-lowresnx: Update to 1.2.
[jackhill/guix/guix.git] / gnu / packages / installers.scm
CommitLineData
e214a220
CD
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2019 Carl Dong <contact@carldong.me>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (gnu packages installers)
20 #:use-module ((guix licenses) #:prefix license:)
21 #:use-module (gnu packages)
22 #:use-module (gnu packages compression)
23 #:use-module (gnu packages cross-base)
24 #:use-module (gnu packages python-xyz)
25 #:use-module (guix packages)
26 #:use-module (guix download)
27 #:use-module (guix build-system scons)
28 #:use-module (guix utils))
29
a7d03e96 30(define (make-nsis machine target-arch nsis-target-type)
21486743
CD
31 (let* ((triplet (string-append machine "-" "w64-mingw32"))
32 (xbinutils (cross-binutils triplet))
33 (xlibc (cross-libc triplet))
34 (xgcc (cross-gcc triplet #:libc xlibc)))
e214a220
CD
35 (package
36 (name (string-append "nsis-" machine))
cdf00cf7 37 (version "3.05")
e214a220
CD
38 (source (origin
39 (method url-fetch)
40 (uri (string-append "http://prdownloads.sourceforge.net/nsis/nsis-"
41 version "-src.tar.bz2"))
42 (sha256
43 (base32
cdf00cf7 44 "1sbwx5vzpddharkb7nj4q5z3i5fbg4lan63ng738cw4hmc4v7qdn"))
e214a220
CD
45 (patches (search-patches "nsis-env-passthru.patch"))))
46 (build-system scons-build-system)
21486743
CD
47 (native-inputs `(("xgcc" ,xgcc)
48 ("xbinutils" ,xbinutils)
49 ("mingw-w64" ,xlibc)))
e214a220
CD
50 (inputs `(("zlib" ,zlib)))
51 (arguments
52 `(#:scons ,scons-python2
53 #:modules ((srfi srfi-1)
21486743 54 (srfi srfi-26)
e214a220
CD
55 (guix build utils)
56 (guix build scons-build-system))
57 #:tests? #f
58 #:scons-flags `("UNICODE=yes"
59 "SKIPUTILS=MakeLangId,Makensisw,NSIS Menu,SubStart,zip2exe"
60 "SKIPDOC=COPYING"
61 "STRIP_CP=no"
62 ,(string-append "PREFIX=" %output)
63 ,(string-append "TARGET_ARCH=" ,target-arch)
64 ,(string-append "XGCC_W32_PREFIX=" ,triplet "-")
65 ,(string-append "PREFIX_PLUGINAPI_INC=" (assoc-ref %build-inputs "mingw-w64") "/include/")
66 ,(string-append "PREFIX_PLUGINAPI_LIB=" (assoc-ref %build-inputs "mingw-w64") "/lib/"))
67 #:build-targets '("makensis"
68 "stubs"
69 "plugins"
70 "utils")
71 #:install-targets '("install-stubs"
72 "install-plugins"
73 "install-data"
74 "install-utils"
75 "install-compiler"
76 "install-conf")
77 #:phases (modify-phases %standard-phases
78 (add-before 'build 'fix-env
79 (lambda _
80 (define* (filter-delimited-string delimited-string predicate #:optional (delimiter #\:))
81 ;; Given a DELIMITED-STRING delimited by DELIMITER,
82 ;; only keep items that satisfy PREDICATE
83 (string-join
84 (filter predicate (string-split delimited-string delimiter))
85 (string delimiter)))
86 (define (mingw-path? path)
87 (string-prefix? (assoc-ref %build-inputs "mingw-w64") path))
88 (for-each
89 (lambda (env-name)
90 (let ((env-val (getenv env-name)))
91 ;; Remove all mingw-w64 paths from env vars meant
92 ;; for native toolchain
93 (setenv env-name
94 (filter-delimited-string env-val (negate mingw-path?)))
811a2015
CD
95 ;; Add the removed paths back into CROSS_-prefixed
96 ;; version of env vars
e214a220
CD
97 (setenv (string-append "CROSS_" env-name)
98 (filter-delimited-string env-val mingw-path?))))
811a2015 99 '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH" "LIBRARY_PATH"))
21486743
CD
100 ;; Hack to place mingw-w64 path at the end of search
101 ;; paths. Could probably use a specfile and dirafter
811a2015
CD
102 (setenv "CROSS_C_INCLUDE_PATH"
103 (string-join
104 `(,@(map (cut string-append
105 (assoc-ref %build-inputs "xgcc")
106 "/lib/gcc/" ,triplet "/"
107 ,(package-version xgcc) <>)
108 '("/include"
109 "/include-fixed"))
110 ,(getenv "CROSS_C_INCLUDE_PATH"))
111 ":"))
21486743
CD
112 (setenv "CROSS_CPLUS_INCLUDE_PATH"
113 (string-join
114 `(,@(map (cut string-append (assoc-ref %build-inputs "xgcc") <>)
115 `("/include/c++"
116 ,(string-append "/include/c++/" ,triplet)
117 "/include/c++/backward"
118 ,@(map (cut string-append "/lib/gcc/" ,triplet "/" ,(package-version xgcc) <>)
119 '("/include"
120 "/include-fixed"))))
811a2015 121 ,(getenv "CROSS_CPLUS_INCLUDE_PATH"))
21486743 122 ":"))))
e214a220
CD
123 (add-before 'build 'fix-target-detection
124 (lambda _
811a2015
CD
125 ;; NSIS target detection is screwed up, manually change
126 ;; it ourselves
e214a220
CD
127 (substitute* "Source/build.cpp" (("m_target_type=TARGET_X86ANSI")
128 (string-append "m_target_type=" ,nsis-target-type))))))))
129 (home-page "http://nsis.sourceforge.net/")
130 (synopsis "A professional open source system to create Windows installers")
131 (description
811a2015
CD
132 "NSIS (Nullsoft Scriptable Install System) is a professional open source
133system to create Windows installers. It is designed to be as small and flexible
134as possible and is therefore very suitable for internet distribution.")
e214a220
CD
135 (license (license:non-copyleft "file://COPYING"
136 "See COPYING in the distribution.")))))
137
138(define-public nsis-x86_64
139 (make-nsis "x86_64" "amd64" "TARGET_AMD64"))
140
141(define-public nsis-i686
142 (make-nsis "i686" "x86" "TARGET_X86UNICODE"))