summaryrefslogtreecommitdiff
path: root/gb.scm
blob: 2d4ac2b8f4cd96a93957d0cc527fab82dc8fe8e0 (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
(define-module (gb)
  #:use-module (electronics)
  #:use-module (guix packages)
  #:use-module (guix gexp)
  #:use-module (gnu packages)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages bison)
  #:use-module (gnu packages boost)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages embedded)
  #:use-module (gnu packages flex)
  #:use-module (gnu packages python)
  #:use-module (gnu packages texinfo)
  #:use-module (guix git-download)
  #:use-module (guix svn-download)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system trivial)
  #:use-module ((guix licenses) #:prefix license:))



(define-public sdcc-patched-for-gbdk
  (let ((revision  12539))
    (package
      (name "sdcc-patched-for-gbdk")
      ; It's not that base version, probably 2.96, but IDK how to check that in
      ; subversion
      (version (string-append "0.0.1" "-" (number->string revision)))
      (source (origin
                (method svn-fetch)
                (uri (svn-reference
                       (url "https://svn.code.sf.net/p/sdcc/code/trunk/sdcc")
                       (revision revision)))
                (file-name (string-append name "-" version))
                (modules '((guix build utils)))
                (snippet
                 '(begin
                    ;; Remove non-free source files
                    (delete-file-recursively "device/non-free")
                    ;; Remove bundled μCsim source
                    (delete-file-recursively "sim")
                    #t))
                (patches
                  (search-patches
                    "sdcc-non-free.patch"
                    "sdcc-makebin-nogogo-v2-bool.patch"
                    "sdcc-sdas_macro_80_char_overflow.patch"
                    "sdcc-sdcc_z80_boN_baN.patch"
                    "sdcc-sdcc_z80_enable_incbin.patch"
                    "sdcc-sdldz80-sms-virtual-address.patch"))
                (sha256
                 (base32
                  "148zpyxwac8qlbg1pakjmar8h802g6lwjp4qhw6cy77ixlhwgyrg"))))
      (build-system gnu-build-system)
      (native-inputs (list bison boost flex zlib python-2 texinfo))
      (arguments
       `(#:configure-flags
         (list "--disable-nonfree" "--disable-pic14-port"
               "--disable-pic16-port" "--disable-ucsim")
         #:phases
         (modify-phases %standard-phases
           (add-after 'unpack 'patch-makefile
             (lambda _
               (substitute* (find-files "." "(\\.mk$|\\.in$)")
                 (("/bin/sh") (which "sh")))
               #t)))))
      (home-page "http://sdcc.sourceforge.net")
      (synopsis "Small devices C compiler")
      (description "Patched SDCC for GameBoy development")
      (license license:gpl2+))))

;; MAYBE USE THIS INSTEAD?
;; https://github.com/flozz/gbdk-n/
;; It needs a really old sdcc, the patched one works.
;; Maybe we can give it a revival
;;
(define-public gbdk-2020
  ;; This does not build, it fails to generate files...
  ;; Also the sdcc it uses (see above) is very old. The docs specifically
  ;; mention this one but it's pretty old. They might be using other one
  ;; instead.
  (package
    (name "gbdk-2020")
    (version "4.0.5")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/gbdk-2020/gbdk-2020")
                     (commit version)))
              (sha256
                (base32 "009361b9b7215s1095q58gdwqc3wwymcr6vknjq218fs0l3nlnjf"))))
    (native-inputs (list sdcc-patched-for-gbdk))
    (arguments
      (list #:phases
            #~(modify-phases %standard-phases
                (delete 'configure)
                (add-before 'build 'setenv
                  (lambda _ (setenv "SDCCDIR" #$sdcc-patched-for-gbdk))))))
    (build-system gnu-build-system)
    (home-page "https://github.com/gbdk-2020/gbdk-2020")
    (synopsis "blahblah")
    (description "blablah")
    (license license:gpl2)))


(define-public gba-tools
  (package
    (name "gba-tools")
    (version "1.2.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                      (url "https://github.com/devkitPro/gba-tools")
                      (commit (string-append "v" version))))
              (sha256
                (base32
                  "1rlhyc9dsdxcmaih3x9qjb3ihr2xxz1rw42ijbz2ylymn9p133gh"))))
    (build-system gnu-build-system)
    (inputs (list automake autoconf))
    (synopsis "Collection of tools for Game Boy Advance development")
    (description "Collection of tools for Game Boy Advance development:
- gbafix:  Pads and patches GBA ROMs.
- gbalzss: Compresses and uncompresses ROMs.
- gbfs:    Creates a GBFS archive.
- insgbfs: Inserts a GBFS file (or any other file) into a GBFS_SPACE
           (identified by symbol name) in a ROM.
- lsgbfs:  Lists objects in a GBFS file.
- ungbfs:  Dumps the objects in a GBFS file to separate files.")
    (home-page "https://github.com/devkitPro/gba-tools")
    (license license:gpl3+)))

#;(define-public gba-minrt
  (package
    (name "gba-minrt")
    (version "0.0.0") ; Obtain from commit-id
    ))

(define-public libseven
  (package
    (name "libseven")
    (version "0.3.5")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                      (url "https://github.com/LunarLambda/libseven")
                      (commit (string-append "v" version))))
              (sha256
                (base32
                  "1jbkghqjjyjjq4rs8ifzlq7zhrcifnis1b8fwiajv8ga2x0s9qr9"))))
    (arguments
      (list
        #:phases
        `(modify-phases %standard-phases
           (delete 'configure)
           (add-before 'build   'setenv
             (lambda* _
                      (setenv "DESTDIR" "output")))
           (add-after  'install 'correct-output-dir
             (lambda* (#:key inputs outputs #:allow-other-keys)
                      (copy-recursively "output/libseven" (assoc-ref outputs "out")))))
        #:tests? #f))
    (build-system gnu-build-system)
    (inputs (list arm-none-eabi-nano-toolchain-7-2018-q2-update))
    (synopsis "A fully from-scratch library for GBA development, meant to
replace existing libraries like libgba or libtonc.")
    (description "Goals:
  - Intuitive, consistent, and well organized API
  - Optimized code with minimal RAM and ROM size
  - Correctness without compromises
  - High-quality, understandable documentation")
    (home-page  "https://github.com/LunarLambda/libseven")
    (license license:mpl2.0)))