summaryrefslogtreecommitdiff
path: root/nongnu/packages/game-development.scm
blob: 0974af5b41eeb0bbde7374a0dd5936c826a35b6f (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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019, 2020 Pierre Neidhardt <mail@ambrevar.xyz>
;;;
;;; This file is not 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 (nongnu packages game-development)
  #:use-module (ice-9 match)
  #:use-module ((nonguix licenses) :prefix license:)
  #:use-module (guix packages)
  #:use-module (nonguix build-system binary)
  #:use-module (guix build-system gnu)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix utils)
  #:use-module (gnu packages audio)
  #:use-module (gnu packages base)
  #:use-module (gnu packages gcc)
  #:use-module (gnu packages gl)
  #:use-module (gnu packages gtk)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages sdl)
  #:use-module (gnu packages video)
  #:use-module (gnu packages xiph)
  #:use-module (gnu packages xorg))

(define nvidia-cg-toolkit-version "3.1")
(define nvidia-cg-toolkit-date "April2012")

(define nvidia-cg-toolkit-i686-archive
  (origin
    (method url-fetch)
    (uri
     (string-append "http://developer.download.nvidia.com/cg/Cg_"
                    nvidia-cg-toolkit-version
                     "/Cg-" nvidia-cg-toolkit-version "_" nvidia-cg-toolkit-date "_"
                     "x86" ".tgz"))
    (sha256
     (base32 "0yc8n6vpqyb6qhcv5kwvr3h21ya271fi930fvd98hlkg8cg5kwyf"))))

(define nvidia-cg-toolkit-x86_64-archive
  (origin
    (method url-fetch)
    (uri
     (string-append "http://developer.download.nvidia.com/cg/Cg_"
                    nvidia-cg-toolkit-version
                     "/Cg-" nvidia-cg-toolkit-version "_" nvidia-cg-toolkit-date "_"
                     "x86_64" ".tgz"))
    (sha256
     (base32 "0y4qms4lm9xiix93g45337rx5nrp0y3gb0x0avyv7l9qrkk03zz8"))))

(define (lib)
  (if (string=? (or (%current-target-system) (%current-system)) "x86_64-linux")
      "lib64" "lib"))

(define-public nvidia-cg-toolkit
  (package
    (name "nvidia-cg-toolkit")
    (version nvidia-cg-toolkit-version)
    (source #f)
    (build-system binary-build-system)
    (arguments
     `(#:strip-binaries? #f ; Fails with "allocated section `.dynstr' not in segment".
       #:patchelf-plan
       `(("bin/cgc"
          ("glibc" "out"))
         ("bin/cginfo"
          ("gcc:lib" "glibc"))
         ("bin/cgfxcat"
          ("out" "glibc" "glu" "mesa" "libice" "libsm"
           "libxmu" "libxt" "libxi" "libxext" "libx11"))
         (,,(string-append (lib) "/libCg.so")
          ("glibc"))
         (,,(string-append (lib) "/libCgGL.so")
          ("out" "glibc")))
       #:install-plan
       `(("bin" "./")
         (,,(lib) "lib")
         ("include" "./")
         ("local/" "share/"))
       #:phases
       (modify-phases %standard-phases
         (replace 'unpack
           (lambda* (#:key inputs #:allow-other-keys)
             (let ((archive (assoc-ref inputs "nvidia-cg-toolkit-archive")))
               (invoke "tar" "xf" archive)
               (chdir "usr")
               #t))))))
    (native-inputs
     `(("nvidia-cg-toolkit-archive"
        ,(match (or (%current-target-system) (%current-system))
           ("x86_64-linux" nvidia-cg-toolkit-x86_64-archive)
           (_ nvidia-cg-toolkit-i686-archive)))))
    (inputs
     `(("gcc:lib" ,gcc "lib")
       ("glibc" ,glibc)
       ("glu" ,glu)
       ("libice" ,libice)
       ("libsm" ,libsm)
       ("libxmu" ,libxmu)
       ("libxt" ,libxt)
       ("libxi" ,libxi)
       ("libxext" ,libxext)
       ("libx11" ,libx11)))
    (home-page "https://developer.nvidia.com/cg-toolkit")
    (synopsis "High-level shading language")
    (description "NVIDIA introduced programmable shading with Cg, which
supported dozens of different OpenGL and DirectX profile targets.  It allowed
developers to incorporate interactive effects within 3D applications and share
them among other Cg applications, across graphics APIs, and most operating
systems as well as balance effect complexities with client GPU capabilities.

The Cg Toolkit is a legacy NVIDIA toolkit no longer under active development
or support.  It is not recommended using it in new development projects
because future hardware features may not be supported.  Going forward, new
development should opt for GLSL rather than Cg.")
    (supported-systems '("i686-linux" "x86_64-linux"))
    (license (license:nonfree "file://share/Cg/docs/license.txt"))))

(define-public libsteam
  (package
    (name "libsteam")
    (version "2013")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://github.com/ValveSoftware/source-sdk-"
                           version
                           "/raw/master/sp/src/lib/public/linux32/libsteam_api.so"))
       (sha256
        (base32
         "1ivxvikm8i6mmmqvib8j5m7g5n1cdlki2sf4v7g13c7xba7aj438"))))
    (build-system binary-build-system)
    (supported-systems '("i686-linux" "x86_64-linux"))
    (arguments
     `(#:system "i686-linux"
       #:validate-runpath? #f           ; TODO: Why doesn't it pass?
       #:patchelf-plan
       `(("libsteam_api.so"
          ("gcc:lib")))
       #:install-plan
       `(("." ("steam") "lib/"))
       #:phases
       (modify-phases %standard-phases
         (replace 'unpack
           (lambda* (#:key inputs #:allow-other-keys)
             (copy-file (assoc-ref inputs "source") "libsteam_api.so")
             (chmod "libsteam_api.so" #o644)
             #t))
         (add-after 'install 'symlink
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((out (assoc-ref outputs "out")))
               (symlink (string-append out "/lib/libsteam_api.so")
                        (string-append out "/lib/libsteam_api.so.1")))
             #t)))))
    (inputs
     `(("gcc:lib" ,gcc "lib")))
    (home-page "https://developer.valvesoftware.com/wiki/SDK2013_GettingStarted")
    (synopsis "Redistribution binary needed by some video games")
    (description "")
    (license (license:nonfree
              "https://raw.githubusercontent.com/ValveSoftware/source-sdk-2013/master/LICENSE"))))

(define-public eduke32
  ;; There are no official releases.
  (let ((commit "188e14622cfe5c6f63b04b989b350bf2a29a893c")
        (revision "1")
        (duke-nukem-3d-directory "share/dukenukem3d"))
    (package
      (name "eduke32")
      (version (git-version "0" revision commit))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (url "https://voidpoint.io/terminx/eduke32.git")
               (commit commit)))
         (file-name (git-file-name name version))
         (sha256
          (base32 "0wy4bppiw4q2hn0v38msrjyvj2hzfvigakc23c2wqfnbl7rm0hrz"))
         ;; Unbundle libxmp.
         (modules '((guix build utils)))
         (snippet
          '(begin (delete-file-recursively "source/libxmp-lite") #t))))
      (build-system gnu-build-system)
      (arguments
       `(#:tests? #f
         ;; Add glu to rpath so that SDL can dlopen it.
         #:make-flags (list (string-append "LDFLAGS=-Wl,-rpath="
                                           (assoc-ref %build-inputs "glu") "/lib"))
         #:phases
         (modify-phases %standard-phases
           (add-after 'unpack 'unbundle-libxmp
             (lambda _
               (substitute* "GNUmakefile"
                 (("-I\\$\\(libxmplite_inc\\)")
                  (string-append "-I" (assoc-ref %build-inputs "libxmp") "/include"))
                 (("^ *audiolib_deps \\+= libxmplite.*$") "")
                 (("-logg") "-logg -lxmp"))
               (with-directory-excursion "source/audiolib/src"
                 (for-each (lambda (file) (substitute* file (("libxmp-lite/") "")))
                                   '("multivoc.cpp" "xmp.cpp")))
               #t))
           (delete 'configure)
           (replace 'install
             (lambda* (#:key inputs outputs #:allow-other-keys)
               (let* ((out (assoc-ref outputs "out"))
                      (glu (assoc-ref inputs "glu"))
                      (eduke (string-append out "/bin/eduke32"))
                      (eduke-real (string-append out "/bin/.eduke32-real")))
                 ;; TODO: Install custom .desktop file?  Need icon.
                 ;; See https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=eduke32.
                 (install-file "eduke32" (string-append out "/bin"))
                 (install-file "mapster32" (string-append out "/bin"))
                 (install-file "package/common/buildlic.txt"
                               (string-append out "/share/licenses"))
                 ;; Wrap program:
                 ;; - Make sure current directory is writable, else eduke32 will segfault.
                 ;; - Add ../share/dukenukem3d to the dir search list.
                 ;; TODO: Skip store duke3d.grp When ~/.config/eduke32/duke3d.grp is found.
                 (rename-file eduke eduke-real)
                 (call-with-output-file eduke
                   (lambda (p)
                     (format p "\
#!~a
mkdir -p ~~/.config/eduke32
cd ~~/.config/eduke32
exec -a \"$0\" ~a\
 -g \"${0%/*}\"/../~a/*.grp\
 -g \"${0%/*}\"/../~a/*.zip\
 -g \"${0%/*}\"/../~a/*.map\
 -g \"${0%/*}\"/../~a/*.con\
 -g \"${0%/*}\"/../~a/*.def\
 \"$@\"~%"
                             (which "bash") eduke-real
                             ,duke-nukem-3d-directory
                             ,duke-nukem-3d-directory
                             ,duke-nukem-3d-directory
                             ,duke-nukem-3d-directory
                             ,duke-nukem-3d-directory)))
                 (chmod eduke #o755)))))))
      (native-inputs
       `(("pkg-config" ,pkg-config)))
      (inputs
       `(("sdl-union" ,(sdl-union (list sdl2 sdl2-mixer)))
         ("alsa-lib" ,alsa-lib)
         ("glu" ,glu)
         ("libvorbis" ,libvorbis)
         ("libvpx" ,libvpx)
         ("libxmp" ,libxmp)
         ("flac" ,flac)
         ("gtk+" ,gtk+-2)))
      (synopsis "Engine of the classic PC first person shooter Duke Nukem 3D")
      (description "EDuke32 is a free homebrew game engine and source port of the
classic PC first person shooter Duke Nukem 3D—Duke3D for short.  A thousands
of features and upgrades were added for regular players and additional editing
capabilities and scripting extensions for homebrew developers and mod
creators.  EDuke32 is open source but non-free software.

This package does not contain any game file.  You can either install packages
with game files or or put @file{.grp} game files manually in
@file{~/.config/eduke32/}.")
      (home-page "https://eduke32.com/")
      (license (license:nonfree
                "https://eduke32.com/buildlic.txt")))))

(define-public fury
  (package
    (inherit eduke32)
    (name "fury")
    (arguments
     (substitute-keyword-arguments (package-arguments eduke32)
       ((#:make-flags flags ''()) `(cons* "FURY=1" ,flags))
       ((#:phases phases '%standard-phases)
        `(modify-phases ,phases
           (replace 'install
             (lambda _
               (let* ((out (assoc-ref %outputs "out")))
                 (install-file "fury" (string-append out "/bin"))
                 (install-file "mapster32" (string-append out "/bin"))
                 (install-file "package/common/buildlic.txt"
                               (string-append out "/share/licenses")))
               #t))))))
    (synopsis "Game engine for the first-person shooter Ion Fury")
    (description
     (string-append
      "This is the @code{eduke32} engine built with support for the Ion Fury
game.  Game data is not provided.  Run @command{fury} with the option
@option{-j} to specify the directory containing @file{fury.grp}."))))