wii-homebrew.scm 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2018, 2019 Kei Kebreau <kkebreau@posteo.net>
  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. (define-module (wii-homebrew)
  19. #:use-module (guix packages)
  20. #:use-module (gnu packages)
  21. #:use-module ((guix licenses) #:prefix license:)
  22. #:use-module (guix download)
  23. #:use-module (guix git-download)
  24. #:use-module (guix gexp)
  25. #:use-module (guix utils)
  26. #:use-module (guix build-system gnu)
  27. #:use-module (guix build-system trivial)
  28. #:use-module (gnu build cross-toolchain)
  29. #:use-module (gnu packages autotools)
  30. #:use-module (gnu packages base)
  31. #:use-module (gnu packages compression)
  32. #:use-module (gnu packages cross-base)
  33. #:use-module (gnu packages fontutils)
  34. #:use-module (gnu packages gcc)
  35. #:use-module (gnu packages gl)
  36. #:use-module (gnu packages image)
  37. #:use-module (gnu packages multiprecision)
  38. #:use-module (gnu packages ncurses)
  39. #:use-module (gnu packages pkg-config)
  40. #:use-module (gnu packages texinfo)
  41. #:use-module (srfi srfi-1)
  42. #:use-module (srfi srfi-26)
  43. #:use-module (ice-9 match))
  44. (define %patch-dir
  45. (string-append (if (current-filename)
  46. (dirname (current-filename))
  47. ".")
  48. "/patches"))
  49. ;; For GCC, from gnu/packages/cross-base.scm.
  50. (define %gcc-include-paths
  51. ;; Environment variables for header search paths.
  52. ;; Note: See <http://bugs.gnu.org/22186> for why not 'CPATH'.
  53. '("C_INCLUDE_PATH"
  54. "CPLUS_INCLUDE_PATH"
  55. "OBJC_INCLUDE_PATH"
  56. "OBJCPLUS_INCLUDE_PATH"))
  57. (define %gcc-cross-include-paths
  58. ;; Search path for target headers when cross-compiling.
  59. (map (cut string-append "CROSS_" <>) %gcc-include-paths))
  60. (define wii-target "powerpc-eabi")
  61. (define wii-newlib-version "3.1.0")
  62. (define wii-newlib-source
  63. (origin
  64. (method url-fetch)
  65. (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-"
  66. wii-newlib-version ".tar.gz"))
  67. (sha256
  68. (base32
  69. "0ahh3n079zjp7d9wynggwrnrs27440aac04340chf1p9476a2kzv"))
  70. (patches
  71. (list
  72. (local-file
  73. (string-append %patch-dir
  74. "/wii-newlib.patch"))))))
  75. (define devkit-buildscripts-source
  76. (let ((version "devkitPPC_r35"))
  77. (origin
  78. (method git-fetch)
  79. (uri (git-reference
  80. (url "https://github.com/devkitPro/buildscripts.git")
  81. (commit version)))
  82. (file-name (git-file-name "devkit-buildscripts" version))
  83. (sha256
  84. (base32
  85. "02ir1wdc647g3vik7sfhyshsz6irj8n6na5jw79m628sx9f0nya7")))))
  86. (define devkitppc-rules-source
  87. (let ((commit "0a1d9c0341a6800f9c7084a50ee93d6e2bb97fa2"))
  88. (origin
  89. (method git-fetch)
  90. (uri (git-reference
  91. (url "https://github.com/devkitPro/devkitppc-rules.git")
  92. (commit commit)))
  93. (file-name (git-file-name "devkitppc-rules" commit))
  94. (sha256
  95. (base32
  96. "107hlg2l6mb4c87p9906v36km15mh7arycqizblfgbmq3x36pj51")))))
  97. (define-public wii-binutils
  98. (let ((xbinutils (cross-binutils wii-target)))
  99. (package
  100. (inherit xbinutils)
  101. (name "wii-binutils")
  102. (version "2.32")
  103. (source
  104. (origin
  105. (inherit (package-source xbinutils))
  106. (method url-fetch)
  107. (uri (string-append "mirror://gnu/binutils/binutils-"
  108. version ".tar.lz"))
  109. (sha256
  110. (base32
  111. "0hcjbhfa7g4cdi3ljfyml3jjg90aqz4fpam669gp36l5h1fbcdhi"))
  112. (patches
  113. (append
  114. (origin-patches (package-source xbinutils))
  115. (list
  116. (local-file
  117. (string-append %patch-dir "/wii-binutils.patch")))))))
  118. (arguments
  119. `(,@(substitute-keyword-arguments (package-arguments xbinutils)
  120. ((#:configure-flags flags)
  121. `(cons* "--disable-werror"
  122. "--enable-plugins"
  123. "--with-system-zlib"
  124. "--disable-nls"
  125. "--enable-lto"
  126. ,flags)))))
  127. (inputs
  128. `(("zlib" ,zlib))))))
  129. (define-public mn10200-binutils
  130. (let ((xbinutils (cross-binutils "mn10200")))
  131. (package
  132. (inherit xbinutils)
  133. (name "mn10200-binutils")
  134. (version "2.17")
  135. (source
  136. (origin
  137. (inherit (package-source xbinutils))
  138. (method url-fetch)
  139. (uri (string-append "mirror://gnu/binutils/binutils-"
  140. version ".tar.bz2"))
  141. (sha256
  142. (base32
  143. "0jd5nvi8nmkdlp4q6dpm6jxxs0y230xgd9nh141sz6m944qkddmq"))
  144. (patches '())))
  145. (arguments
  146. `(#:make-flags '("CFLAGS=-std=c99")
  147. #:modules ((guix build gnu-build-system)
  148. (guix build utils)
  149. (srfi srfi-1))
  150. #:phases
  151. (modify-phases %standard-phases
  152. (replace 'configure
  153. ;; configure does not work followed by "SHELL=..." and
  154. ;; "CONFIG_SHELL=..."; set environment variables instead
  155. (lambda* (#:key configure-flags #:allow-other-keys)
  156. (setenv "SHELL" (which "bash"))
  157. (setenv "CONFIG_SHELL" (which "bash"))
  158. (setenv "LDFLAGS" "-static-libgcc")
  159. (apply invoke (cons "./configure"
  160. (remove (lambda (flag)
  161. (string-prefix? "LDFLAGS" flag))
  162. configure-flags))))))
  163. ,@(substitute-keyword-arguments (package-arguments xbinutils)
  164. ((#:configure-flags flags)
  165. `(cons* "--disable-werror"
  166. "--enable-plugins"
  167. "--with-system-zlib"
  168. "--disable-nls"
  169. "--disable-multilib"
  170. "--enable-lto"
  171. ;; This was $CROSS_PARAMS
  172. (string-append "--build=" ,(nix-system->gnu-triplet))
  173. (string-append "--prefix=" (assoc-ref %outputs "out"))
  174. ,flags)))))
  175. (inputs
  176. `(("zlib" ,zlib))))))
  177. (define-public wii-bootstrap-gcc
  178. (package
  179. (name "wii-bootstrap-gcc")
  180. (version "8.3.0")
  181. (source
  182. (origin
  183. (method url-fetch)
  184. (uri (string-append "mirror://gnu/gcc/gcc-" version
  185. "/gcc-" version ".tar.xz"))
  186. (sha256
  187. (base32
  188. "0b3xv411xhlnjmin2979nxcbnidgvzqdf4nbhix99x60dkzavfk4"))
  189. (patches
  190. (list
  191. (local-file
  192. (string-append %patch-dir
  193. "/gcc-8-cross-environment-variables.patch"))
  194. (local-file
  195. (string-append %patch-dir
  196. "/wii-gcc.patch"))))))
  197. (build-system gnu-build-system)
  198. (native-inputs
  199. `(("ld-wrapper-cross" ,(make-ld-wrapper
  200. (string-append "ld-wrapper-" wii-target)
  201. #:target (const wii-target)
  202. #:binutils wii-binutils))
  203. ("wii-binutils" ,wii-binutils)))
  204. (inputs
  205. `(("gmp" ,gmp)
  206. ("mpfr" ,mpfr)
  207. ("mpc" ,mpc)
  208. ("zlib" ,zlib)))
  209. (arguments
  210. `(#:strip-binaries? #f
  211. #:out-of-source? #t
  212. #:tests? #f
  213. #:configure-flags
  214. (list
  215. (string-append "--prefix=" %output)
  216. ;; Disable features not needed at this stage.
  217. "--disable-decimal-float" ;would need libc
  218. "--disable-libatomic"
  219. "--disable-libgomp"
  220. "--disable-libitm"
  221. "--disable-libmpx"
  222. "--disable-libmudflap"
  223. "--disable-libquadmath"
  224. "--disable-libsanitizer"
  225. "--disable-libssp"
  226. "--disable-libstdcxx"
  227. "--disable-libstdcxx-pch"
  228. "--disable-libstdcxx-verbose"
  229. "--disable-libvtv"
  230. "--disable-multilib"
  231. "--disable-nls"
  232. "--disable-shared"
  233. "--disable-threads" ;libgcc, would need libc
  234. "--disable-tls"
  235. "--disable-werror"
  236. "--enable-languages=c,c++"
  237. "--with-system-zlib"
  238. (string-append "--target=" ,wii-target)
  239. "--with-newlib"
  240. "--without-headers"
  241. "--with-cpu=750")
  242. #:phases
  243. (modify-phases %standard-phases
  244. (replace 'build
  245. (lambda _
  246. (invoke "make" "-j" (number->string (parallel-job-count))
  247. "all-gcc")))
  248. (replace 'install
  249. (lambda _
  250. (invoke "make" "-j" (number->string (parallel-job-count))
  251. "install-gcc")))
  252. ;; From Guix's gnu/build/cross-toolchain.scm.
  253. (add-after 'install 'make-cross-binutils-visible
  254. (lambda* (#:key inputs outputs #:allow-other-keys)
  255. (let* ((out (assoc-ref outputs "out"))
  256. (libexec (string-append out "/libexec/gcc/" ,wii-target))
  257. (binutils (string-append (assoc-ref inputs "wii-binutils")
  258. "/bin/" ,wii-target "-"))
  259. (wrapper (string-append (assoc-ref inputs "ld-wrapper-cross")
  260. "/bin/" ,wii-target "-ld")))
  261. (for-each (lambda (file)
  262. (symlink (string-append binutils file)
  263. (string-append libexec "/" file)))
  264. '("as" "nm"))
  265. (symlink wrapper (string-append libexec "/ld"))
  266. #t))))))
  267. ;; Only search target inputs, not host inputs.
  268. (search-paths (cons (search-path-specification
  269. (variable "CROSS_LIBRARY_PATH")
  270. (files '("lib" "lib64")))
  271. (map (lambda (variable)
  272. (search-path-specification
  273. (variable variable)
  274. (files '("include"))))
  275. %gcc-cross-include-paths)))
  276. (native-search-paths
  277. (list (search-path-specification
  278. (variable "CROSS_C_INCLUDE_PATH")
  279. (files (list (string-append wii-target "/include"))))
  280. (search-path-specification
  281. (variable "CROSS_CPLUS_INCLUDE_PATH")
  282. (files (list (string-append wii-target "/include"))))
  283. (search-path-specification
  284. (variable "CROSS_LIBRARY_PATH")
  285. (files (list (string-append wii-target "/lib"))))))
  286. (synopsis (package-synopsis gcc))
  287. (description (package-description gcc))
  288. (home-page (package-home-page gcc))
  289. (license license:gpl3+)))
  290. (define-public wii-newlib
  291. (package
  292. (name "wii-newlib")
  293. (version wii-newlib-version)
  294. (source wii-newlib-source)
  295. (build-system gnu-build-system)
  296. (arguments
  297. `(#:out-of-source? #t
  298. #:configure-flags
  299. (list (string-append "--target=" ,wii-target)
  300. "CFLAGS_FOR_TARGET=-O2 -ffunction-sections -fdata-sections"
  301. "--enable-newlib-mb"
  302. "--disable-nls")
  303. #:phases
  304. (modify-phases %standard-phases
  305. (add-after 'unpack 'fix-references-to-/bin/sh
  306. (lambda _
  307. (substitute* '("libgloss/rs6000/Makefile.in"
  308. "libgloss/libnosys/Makefile.in"
  309. "libgloss/libsysbase/Makefile.in"
  310. "libgloss/Makefile.in")
  311. (("/bin/sh") (which "sh")))
  312. #t)))))
  313. (native-inputs
  314. `(("wii-binutils" ,wii-binutils)
  315. ("wii-bootstrap-gcc" ,wii-bootstrap-gcc)
  316. ("texinfo" ,texinfo)))
  317. (home-page "http://www.sourceware.org/newlib/")
  318. (synopsis "C library for use on embedded systems")
  319. (description "Newlib is a C library intended for use on embedded
  320. systems. It is a conglomeration of several library parts that are easily
  321. usable on embedded products.")
  322. (license (license:non-copyleft
  323. "https://www.sourceware.org/newlib/COPYING.NEWLIB"))))
  324. (define-public wii-gcc
  325. (package
  326. (inherit wii-bootstrap-gcc)
  327. (name "wii-gcc")
  328. (native-inputs
  329. `(("wii-newlib" ,wii-newlib)
  330. ("devkit-buildscripts" ,devkit-buildscripts-source)
  331. ("devkitppc-rules" ,devkitppc-rules-source)
  332. ,@(package-native-inputs wii-bootstrap-gcc)))
  333. (arguments
  334. `(#:modules ((guix build gnu-build-system)
  335. (guix build utils)
  336. (srfi srfi-1)
  337. (srfi srfi-26)
  338. (ice-9 regex))
  339. ,@(substitute-keyword-arguments
  340. (package-arguments wii-bootstrap-gcc)
  341. ((#:configure-flags flags)
  342. `(append
  343. (list
  344. "CFLAGS_FOR_TARGET=-O2 -ffunction-sections -fdata-sections"
  345. "CXXFLAGS_FOR_TARGET=-O2 -ffunction-sections -fdata-sections"
  346. "LDFLAGS_FOR_TARGET="
  347. "--enable-languages=c,c++,lto"
  348. "--enable-libstdcxx-time=yes"
  349. "--enable-libstdcxx-filesystem-ts"
  350. "--enable-threads=dkp"
  351. "--enable-lto"
  352. "--enable-cxx-flags=-ffunction-sections -fdata-sections"
  353. (string-append "--with-headers="
  354. (assoc-ref %build-inputs "wii-newlib")
  355. "/" ,wii-target "/include")
  356. "--with-cpu=750")
  357. (remove (cut string-match
  358. "--(without-headers|enable-languages.*)" <>)
  359. ,flags)))
  360. ((#:phases phases)
  361. `(modify-phases ,phases
  362. (replace 'build
  363. (lambda _
  364. (invoke "make" "-j" (number->string (parallel-job-count)))))
  365. (replace 'install
  366. (lambda _
  367. (invoke "make" "-j" (number->string (parallel-job-count))
  368. "install-strip")))
  369. (add-after 'install 'install-ld-scripts
  370. (lambda* (#:key inputs outputs #:allow-other-keys)
  371. (for-each
  372. (lambda (file)
  373. (install-file file
  374. (string-append
  375. (assoc-ref outputs "out")
  376. "/" ,wii-target "/lib")))
  377. (find-files (string-append
  378. (assoc-ref inputs "devkit-buildscripts")
  379. "/dkppc/crtls")))
  380. #t))
  381. (add-after 'install 'install-rulesets
  382. (lambda* (#:key inputs outputs #:allow-other-keys)
  383. (let* ((out (assoc-ref outputs "out"))
  384. (old-rules-dir (assoc-ref inputs "devkitppc-rules")))
  385. (with-directory-excursion old-rules-dir
  386. (for-each
  387. (lambda (file)
  388. (install-file file out))
  389. (find-files ".")))
  390. #t))))))))))
  391. (define libstdc++-powerpc-eabi
  392. (let ((libstdc++ (make-libstdc++ wii-gcc)))
  393. (package (inherit libstdc++)
  394. (name "libstdc++-powerpc-eabi")
  395. (arguments
  396. (substitute-keyword-arguments (package-arguments libstdc++)
  397. ((#:configure-flags flags)
  398. ``("--target=powerpc-eabi"
  399. "--host=powerpc-eabi"
  400. "--disable-libstdcxx-pch"
  401. "--disable-multilib"
  402. "--disable-shared"
  403. "--disable-tls"
  404. "--disable-plugin"
  405. "--with-newlib"
  406. "--with-cpu=750"
  407. ,(string-append "--with-gxx-include-dir="
  408. (assoc-ref %outputs "out")
  409. "/powerpc-eabi/include")))))
  410. (native-inputs
  411. `(("wii-newlib" ,wii-newlib)
  412. ("wii-gcc" ,wii-gcc)
  413. ,@(package-native-inputs libstdc++))))))
  414. (define-public devkitppc-toolchain
  415. (let ((newlib-with-wii-gcc
  416. (package (inherit wii-newlib)
  417. (native-inputs
  418. (alist-replace "wii-bootstrap-gcc" (list wii-gcc)
  419. (package-native-inputs wii-newlib))))))
  420. (package
  421. (name "devkitppc-toolchain")
  422. (version (package-version wii-gcc))
  423. (source #f)
  424. (build-system trivial-build-system)
  425. (arguments
  426. '(#:modules ((guix build union))
  427. #:builder
  428. (begin
  429. (use-modules (ice-9 match)
  430. (guix build union))
  431. (match %build-inputs
  432. (((names . directories) ...)
  433. (union-build (assoc-ref %outputs "out")
  434. directories)
  435. #t)))))
  436. (propagated-inputs
  437. `(("wii-binutils" ,wii-binutils)
  438. ("wii-libstdc++" ,libstdc++-powerpc-eabi)
  439. ("wii-gcc" ,wii-gcc)
  440. ("wii-newlib" ,wii-newlib)))
  441. (native-search-paths
  442. (list (search-path-specification
  443. (variable "DEVKITPRO")
  444. (files '("")))
  445. (search-path-specification
  446. (variable "DEVKITPPC")
  447. (files '("")))))
  448. (synopsis "Complete GCC tool chain for Wii homebrew development")
  449. (description "This package provides a complete GCC tool chain for Wii
  450. homebrew development. This includes the GCC powerpc-eabi cross compiler and
  451. newlib as the C library. The supported programming languages are C and C++.")
  452. (home-page "https://devkitpro.org")
  453. (license (package-license wii-gcc)))))
  454. (define-public gamecube-tools
  455. (package
  456. (name "gamecube-tools")
  457. (version "1.0.2")
  458. (source (origin
  459. (method git-fetch)
  460. (uri (git-reference
  461. (url "https://github.com/devkitPro/gamecube-tools")
  462. (commit (string-append "v" version))))
  463. (sha256
  464. (base32
  465. "0zvpkzqvl8iv4ndzhkjkmrzpampyzgb91spv0h2x2arl8zy4z7ca"))))
  466. (build-system gnu-build-system)
  467. (arguments
  468. '(#:tests? #f)) ; no check target
  469. (native-inputs
  470. `(("autoconf" ,autoconf)
  471. ("automake" ,automake)
  472. ("libtool" ,libtool)
  473. ("which" ,which)))
  474. (inputs
  475. `(("freeimage" ,freeimage)
  476. ("mesa" ,mesa)))
  477. (home-page (package-home-page devkitppc-toolchain))
  478. (synopsis "C Library for Wii and Gamecube homebrew")
  479. (description "libogc is a collection of low-level libraries for the GameCube
  480. and Wii. It is designed to be used with the devkitPPC toolchain.")
  481. (license license:gpl2+)))
  482. (define-public libogc
  483. (package
  484. (name "libogc")
  485. (version "1.8.22")
  486. (source (origin
  487. (method git-fetch)
  488. (uri (git-reference
  489. (url "https://github.com/devkitPro/libogc")
  490. (commit (string-append "v" version))))
  491. (sha256
  492. (base32
  493. "1ckn6g2nihsqmz8v3avvf5l4m3dl1417zv3zmx0c1zkfvh6ay9yh"))))
  494. (build-system gnu-build-system)
  495. (arguments
  496. '(#:tests? #f ; no check target
  497. #:phases
  498. (modify-phases %standard-phases
  499. (replace 'configure
  500. (lambda* (#:key inputs outputs #:allow-other-keys)
  501. (let ((out (assoc-ref outputs "out"))
  502. (devkitppc (assoc-ref inputs "devkitppc")))
  503. (setenv "DEVKITPRO" devkitppc)
  504. (setenv "DEVKITPPC" devkitppc)
  505. (substitute* "Makefile"
  506. ;; Use date and time of upstream's release commit.
  507. (("__DATE__") "20190326")
  508. (("__TIME__") "010902")
  509. (("\\$\\(DESTDIR\\)\\$\\(DEVKITPRO\\)/libogc")
  510. (string-append out "/libogc")))
  511. #t)))
  512. (delete 'build))))
  513. (inputs
  514. `(("devkitppc" ,devkitppc-toolchain)))
  515. (home-page (package-home-page devkitppc-toolchain))
  516. (synopsis "C Library for Wii and Gamecube homebrew")
  517. (description "libogc is a collection of low-level libraries for the GameCube
  518. and Wii. It is designed to be used with the devkitPPC toolchain.")
  519. (license license:bsd-3)))
  520. (define-public libfat
  521. (package
  522. (name "libfat")
  523. (version "1.1.3")
  524. (source (origin
  525. (method git-fetch)
  526. (uri (git-reference
  527. (url "https://github.com/devkitPro/libfat")
  528. (commit (string-append "v" version))))
  529. (sha256
  530. (base32
  531. "1rxf4ghnlwcg5b9n0djwsfpjnvg4a6kmis28yj12vlsjpggh44ay"))))
  532. (build-system gnu-build-system)
  533. (arguments
  534. '(#:tests? #f ; no check target
  535. #:phases
  536. (modify-phases %standard-phases
  537. (replace 'configure
  538. (lambda* (#:key inputs outputs #:allow-other-keys)
  539. (let ((out (assoc-ref outputs "out"))
  540. (devkitppc (assoc-ref inputs "devkitppc"))
  541. (libogc (assoc-ref inputs "libogc")))
  542. (setenv "DEVKITPRO" devkitppc)
  543. (setenv "DEVKITPPC" devkitppc)
  544. (substitute* "libogc/Makefile"
  545. (("\\$\\(DESTDIR\\)\\$\\(DEVKITPRO\\)/libogc")
  546. (string-append out "/libogc"))
  547. (("\\$\\(LIBOGC_INC)")
  548. (string-append libogc "/libogc/include"))
  549. (("\\$\\(LIBOGC_LIB)")
  550. (string-append libogc "/libogc/lib")))
  551. #t)))
  552. (replace 'build
  553. (lambda _
  554. (invoke "make" "-j" (number->string (parallel-job-count))
  555. "wii-release")))
  556. (replace 'install
  557. (lambda _
  558. (invoke "make" "-j" (number->string (parallel-job-count))
  559. "ogc-install"))))))
  560. (inputs
  561. `(("devkitppc" ,devkitppc-toolchain)
  562. ("libogc" ,libogc)))
  563. (home-page (package-home-page devkitppc-toolchain))
  564. (synopsis "FAT library for GBA, DS, Gamecube and Wii")
  565. (description
  566. "libfat is a FAT library for the GBA, DS, Gamecube and Wii.")
  567. (license license:bsd-3)))
  568. (define-public devkitpro-tools
  569. (package
  570. (name "devkitpro-tools")
  571. (version "1.0.2")
  572. (source (origin
  573. (method git-fetch)
  574. (uri (git-reference
  575. (url "https://github.com/devkitPro/general-tools")
  576. (commit (string-append "v" version))))
  577. (sha256
  578. (base32
  579. "1ymk1bhrprvfnnfvpfzlmmxwfvhajmiddqh5ics9y64db63n8kd2"))))
  580. (build-system gnu-build-system)
  581. (arguments
  582. '(#:tests? #f)) ; no check target
  583. (native-inputs
  584. `(("autoconf" ,autoconf)
  585. ("automake" ,automake)))
  586. (home-page (package-home-page devkitppc-toolchain))
  587. (synopsis "General utilities for devkitPro")
  588. (description "General utilities for devkitPro")
  589. (license license:gpl3+)))
  590. (define-public devkitpro-portlibs
  591. (let ((commit "644a77c8074d76bad80f917373a5aad22dca1217")
  592. (revision "1"))
  593. (package
  594. (name "devkitpro-portlibs")
  595. (version (git-version "0" revision commit))
  596. (source (origin
  597. (method git-fetch)
  598. (uri (git-reference
  599. (url "https://github.com/devkitPro/portlibs")
  600. (commit commit)))
  601. (sha256
  602. (base32
  603. "1p5d7ay5dmxr173idah0bj27hl1b0nqy8gr703lvdvvj598rpzr1"))))
  604. (build-system gnu-build-system)
  605. (arguments
  606. `(#:tests? #f ; no check target
  607. #:phases
  608. (modify-phases %standard-phases
  609. (add-after 'unpack 'set-env-vars
  610. (lambda* (#:key inputs outputs #:allow-other-keys)
  611. (let* ((devkitppc (assoc-ref inputs "devkitppc"))
  612. (out (assoc-ref outputs "out"))
  613. (cflags "-O2 -mcpu=750 -meabi -mhard-float -ffunction-sections -fdata-sections"))
  614. (setenv "CFLAGS" cflags)
  615. (setenv "CXXFLAGS" cflags)
  616. (setenv "CPPFLAGS"
  617. (string-append "-DGEKKO -I" out "/include"))
  618. (setenv "CHOST" "powerpc-eabi")
  619. (setenv "DEVKITPPC" devkitppc)
  620. (setenv "DEVKITPRO" devkitppc)
  621. (setenv "LDFLAGS"
  622. (string-append "-L" out "/lib"))
  623. (setenv "PATH" (string-append out "/bin:"
  624. (getenv "PATH")))
  625. (setenv "PORTLIBS_ROOT" out)
  626. (setenv "PORTLIBS_PREFIX" out)
  627. (setenv "PKG_CONFIG_LIBDIR"
  628. (string-append out "/lib/pkgconfig"))
  629. (setenv "CONFIG_SHELL" (which "sh"))
  630. (setenv "SHELL" (which "sh"))
  631. #t)))
  632. (add-after 'unpack 'unpack-bzip2
  633. (lambda* (#:key inputs #:allow-other-keys)
  634. (let ((bzip2 (assoc-ref inputs "bzip2")))
  635. (invoke "tar" "xvf" bzip2)
  636. (chdir (string-append "bzip2-" ,(package-version bzip2)))
  637. #t)))
  638. (delete 'configure)
  639. (replace 'build
  640. (lambda _
  641. (invoke "make" "-j" (number->string (parallel-job-count))
  642. "CC=powerpc-eabi-gcc" "AR=powerpc-eabi-ar"
  643. "RANLIB=powerpc-eabi-ranlib" "libbz2.a")))
  644. (replace 'install
  645. (lambda* (#:key outputs #:allow-other-keys)
  646. (let* ((out (assoc-ref outputs "out"))
  647. (include-dir (string-append out "/include"))
  648. (lib-dir (string-append out "/lib")))
  649. (install-file "bzlib.h" include-dir)
  650. (install-file "libbz2.a" lib-dir)
  651. #t)))
  652. (add-after 'install 'unpack-zlib
  653. (lambda* (#:key inputs #:allow-other-keys)
  654. (let ((zlib (assoc-ref inputs "zlib")))
  655. (chdir "..")
  656. (invoke "tar" "xvf" zlib)
  657. (chdir (string-append "zlib-" ,(package-version zlib)))
  658. #t)))
  659. (add-after 'unpack-zlib 'configure-zlib
  660. (lambda* (#:key outputs #:allow-other-keys)
  661. (let ((out (assoc-ref outputs "out")))
  662. (invoke "sh" "configure" (string-append "--prefix=" out)
  663. "--static"))))
  664. (add-after 'configure-zlib 'build-zlib
  665. (lambda _
  666. (invoke "make" "-j" (number->string (parallel-job-count))
  667. "libz.a" (string-append "SHELL=" (which "sh")))))
  668. (add-after 'build-zlib 'install-zlib
  669. (lambda _
  670. (invoke "make" "-j" (number->string (parallel-job-count))
  671. "install" (string-append "SHELL=" (which "sh")))))
  672. (add-after 'install-zlib 'unpack-libpng
  673. (lambda* (#:key inputs #:allow-other-keys)
  674. (let ((libpng (assoc-ref inputs "libpng")))
  675. (chdir "..")
  676. (invoke "tar" "xvf" libpng)
  677. (chdir (string-append "libpng-" ,(package-version libpng)))
  678. #t)))
  679. (add-after 'unpack-libpng 'configure-libpng
  680. (lambda* (#:key outputs #:allow-other-keys)
  681. (let ((out (assoc-ref outputs "out")))
  682. (invoke "sh" "configure"
  683. (string-append "--prefix=" out)
  684. "--host=powerpc-eabi"
  685. "--disable-shared" "--enable-static"))))
  686. (add-after 'configure-libpng 'build-libpng
  687. (lambda _
  688. (invoke "make" "-j" (number->string (parallel-job-count)))))
  689. (add-after 'build-libpng 'install-libpng
  690. (lambda _
  691. (invoke "make" "-j" (number->string (parallel-job-count))
  692. "install")))
  693. (add-after 'install-libpng 'unpack-freetype
  694. (lambda* (#:key inputs #:allow-other-keys)
  695. (let ((freetype (assoc-ref inputs "freetype")))
  696. (chdir "..")
  697. (invoke "tar" "xvf" freetype)
  698. (chdir (string-append "freetype-" ,(package-version freetype)))
  699. #t)))
  700. (add-after 'unpack-freetype 'configure-freetype
  701. (lambda* (#:key outputs #:allow-other-keys)
  702. (let ((out (assoc-ref outputs "out")))
  703. (substitute* "builds/unix/configure"
  704. (("/bin/sh") (which "sh")))
  705. (invoke "sh" "configure"
  706. (string-append "--prefix=" out)
  707. "--host=powerpc-eabi"
  708. "--disable-shared" "--enable-static"
  709. "--with-zlib" "--with-bzip2" "--with-png"))))
  710. (add-after 'configure-freetype 'build-freetype
  711. (lambda _
  712. (invoke "make" "-j" (number->string (parallel-job-count)))))
  713. (add-after 'build-freetype 'install-freetype
  714. (lambda _
  715. (invoke "make" "-j" (number->string (parallel-job-count))
  716. "install")))
  717. (add-after 'install-freetype 'unpack-mxml
  718. (lambda* (#:key inputs #:allow-other-keys)
  719. (chdir "..")
  720. (copy-recursively (assoc-ref inputs "mxml") "mxml")
  721. (chdir "mxml")
  722. #t))
  723. (add-after 'unpack-mxml 'configure-mxml
  724. (lambda* (#:key outputs #:allow-other-keys)
  725. (let ((out (assoc-ref outputs "out")))
  726. (invoke "sh" "configure"
  727. (string-append "--prefix=" out)
  728. "--host=powerpc-eabi"
  729. "--disable-shared" "--enable-static"
  730. "--disable-threads"))))
  731. (add-after 'configure-mxml 'build-mxml
  732. (lambda _
  733. (invoke "make" "-j" (number->string (parallel-job-count))
  734. (string-append "SHELL=" (which "sh")))))
  735. (add-after 'build-mxml 'install-mxml
  736. (lambda _
  737. (invoke "make" "-j" (number->string (parallel-job-count))
  738. "install" (string-append "SHELL=" (which "sh"))))))))
  739. (native-inputs
  740. `(("bzip2" ,(package-source bzip2))
  741. ("freetype" ,(package-source freetype))
  742. ("libpng" ,(package-source libpng))
  743. ("mxml"
  744. ,(origin
  745. (method git-fetch)
  746. (uri (git-reference
  747. (url "https://github.com/michaelrsweet/mxml")
  748. (commit (string-append "v2.12"))))
  749. (file-name (git-file-name "mxml" "2.12"))
  750. (sha256
  751. (base32
  752. "1g5a1dfw3x4ap7p9cx6frh7ss8wkmqlsw2y64y2vw4g8yhp4k8wp"))))
  753. ("pkg-config" ,pkg-config)
  754. ("zlib" ,(package-source zlib))))
  755. (inputs
  756. `(("devkitppc" ,devkitppc-toolchain)))
  757. (home-page (package-home-page devkitppc-toolchain))
  758. (synopsis "Various libraries for use on the Wii")
  759. (description "Various libraries for use on the Wii")
  760. (license (list (package-license bzip2)
  761. (package-license freetype)
  762. (package-license libpng)
  763. (package-license zlib)
  764. license:lgpl2.0)))))
  765. (define-public wiimms-iso-tools
  766. (package
  767. (name "wiimms-iso-tools")
  768. (version "3.02a")
  769. (source
  770. (origin
  771. (method url-fetch)
  772. (uri (string-append "https://download.wiimm.de/source/wiimms-iso-tools"
  773. "/wiimms-iso-tools.source-" version ".txz"))
  774. (file-name (string-append name "-" version ".tar.xz"))
  775. (sha256
  776. (base32 "0h2xvkv6s1yxzlwn09xh94sipx59iy4af9q6ih7vy364rz11madp"))))
  777. (build-system gnu-build-system)
  778. (arguments
  779. '(#:make-flags (list (string-append "INSTALL_PATH="
  780. (assoc-ref %outputs "out")))
  781. #:tests? #f ; no check target
  782. #:phases
  783. (modify-phases %standard-phases
  784. ;; While there's no configure script, install.sh unnecessarily attempts
  785. ;; to use sudo.
  786. (replace 'configure
  787. (lambda _
  788. (substitute* "Makefile"
  789. (("install\\.sh --make") "install.sh --no-sudo --make"))
  790. #t)))))
  791. (inputs
  792. `(("ncurses" ,ncurses)))
  793. (home-page "https://wit.wiimm.de/")
  794. (synopsis "Tools to manipulate Wii and GameCube images and containers")
  795. (description
  796. "Wiimms ISO Tools is a set of command line tools to manipulate Wii and
  797. GameCube ISO images and WBFS containers. The toolset consists of the following
  798. tools:
  799. @table @asis
  800. @item @code{wit} (Wiimms ISO Tool)
  801. This is the main ISO manipulation tool. It can list, analyze, verify, convert,
  802. split, join, patch, mix, extract, compose, rename and compare Wii and GameCube
  803. images. It also can create and dump different other Wii file formats.
  804. @item @code{wwt} (Wiimms WBFS Tool)
  805. This is the main WBFS manipulation tool. It can create, check, repair, verify
  806. and clone WBFS files and partitions. It can list, add, extract, remove, rename
  807. and recover ISO images as part of a WBFS.
  808. @item @code{wdf} (Wiimms WDF Tool)
  809. @code{wdf} is a support tool for WDF, WIA, CISO and GCZ images. It converts
  810. (packs and unpacks), compares and dumps WDF and CISO images. Additionally it
  811. dumps WIA and GCT image and unpacks WIA images. The default command depends on
  812. the program file name (see command descriptions). Usual names are @code{wdf},
  813. @code{unwdf}, @code{wdf-cat}, @code{wdf-cmp} and @code{wdf-dump} (with or
  814. without minus signs). @code{wdf +CAT} replaces the old tool @code{wdf-cat} and
  815. @code{wdf +DUMP} the old tool @code{wdf-dump}.
  816. @item @code{wfuse} (Wiimms FUSE Tool)
  817. Mount a Wii or GameCube image or a WBFS file or partition to a mount point
  818. using FUSE (Filesystem in USErspace). Use 'wfuse --umount mountdir' for
  819. unmounting.
  820. @end table")
  821. (license license:gpl2+)))
  822. (define-public wiiload
  823. (package
  824. (name "wiiload")
  825. (version "0.5.1")
  826. (source (origin
  827. (method url-fetch)
  828. (uri (string-append "https://github.com/devkitPro/wiiload/"
  829. "releases/download/v" version
  830. "/wiiload-" version ".tar.bz2"))
  831. (sha256
  832. (base32
  833. "15cmk8lcvjj5b0ahsvr270jbwry74j9jhljp76yhksk0ka0ps8c3"))))
  834. (build-system gnu-build-system)
  835. (inputs
  836. `(("zlib" ,zlib)))
  837. (home-page "https://github.com/devkitPro/wiiload")
  838. (synopsis "Wii executables over a network to the Wii")
  839. (description "Wiiload is a method of loading .dol and .elf files over a
  840. network. Also, Wiiload can be used to remotely install homebrew applications
  841. onto an SD card.")
  842. (license license:gpl2+)))