projects/guix·blob mpd-fix-groups · refs

728 lines · 32.1 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2021 Ricardo Wurmus <[email protected]>
3;;; Copyright © 2021 Ludovic Courtès <[email protected]>
4;;; Copyright © 2017 Leo Famulari <[email protected]>
5;;; Copyright © 2017, 2022 Marius Bakke <[email protected]>
6;;; Copyright © 2018, 2020, 2024 Efraim Flashner <[email protected]>
7;;; Copyright © 2018 Gábor Boskovits <[email protected]>
8;;; Copyright © 2018 Mark H Weaver <[email protected]>
9;;; Copyright © 2019 Andrius Štikonas <[email protected]>
10;;; Copyright © 2020 Simon South <[email protected]>
11;;; Copyright © 2021 Guillaume Le Vaillant <[email protected]>
12;;;
13;;; This file is part of GNU Guix.
14;;;
15;;; GNU Guix is free software; you can redistribute it and/or modify it
16;;; under the terms of the GNU General Public License as published by
17;;; the Free Software Foundation; either version 3 of the License, or (at
18;;; your option) any later version.
19;;;
20;;; GNU Guix is distributed in the hope that it will be useful, but
21;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23;;; GNU General Public License for more details.
24;;;
25;;; You should have received a copy of the GNU General Public License
26;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27
28(define-module (gnu packages java-bootstrap)
29 #:use-module ((guix licenses) #:prefix license:)
30 #:use-module (guix packages)
31 #:use-module (guix download)
32 #:use-module (guix git-download)
33 #:use-module (guix utils)
34 #:use-module (guix gexp)
35 #:use-module (guix build-system gnu)
36 #:use-module (guix build-system trivial)
37 #:use-module (gnu packages)
38 #:use-module (gnu packages autotools)
39 #:use-module (gnu packages bash)
40 #:use-module (gnu packages compression)
41 #:use-module (gnu packages gettext)
42 #:use-module (gnu packages guile)
43 #:use-module (gnu packages libffi)
44 #:use-module (gnu packages pkg-config)
45 #:use-module (gnu packages texinfo)
46 #:export (classpath-devel
47 ecj4-javac-wrapper
48 jamvm-with-ecj4
49 ant-bootstrap))
50
51
52;;;
53;;; Java bootstrap toolchain.
54;;;
55
56;; The Java bootstrap begins with Jikes, a Java compiler written in C++. We
57;; use it to build a simple version of GNU Classpath, the Java standard
58;; library. We chose version 0.93 because it is the last version that can be
59;; built with Jikes. With Jikes and this version of GNU Classpath we can
60;; build JamVM, a Java Virtual Machine. We build version 1.5.1 because it is
61;; the last version of JamVM that works with a version of GNU classpath that
62;; does not require ECJ. These three packages make up the bootstrap JDK.
63
64;; This is sufficient to build an older version of Ant, which is needed to
65;; build an older version of ECJ, an incremental Java compiler, both of which
66;; are written in Java.
67;;
68;; ECJ is needed to build the latest release (0.99) and the development
69;; version of GNU Classpath. The development version of GNU Classpath has
70;; much more support for Java 1.6 than the latest release, but we need to
71;; build 0.99 first to get a working version of javah. ECJ, the development
72;; version of GNU Classpath, and the latest version of JamVM make up the
73;; second stage JDK with which we can build the OpenJDK with the Icedtea 2.x
74;; build framework. We then build the more recent JDK Icedtea 3.x, and all
75;; other versions of OpenJDK.
76
77(define jikes
78 (package
79 (name "jikes")
80 (version "1.22")
81 (source (origin
82 (method url-fetch)
83 (uri (string-append "mirror://sourceforge/jikes/Jikes/"
84 version "/jikes-" version ".tar.bz2"))
85 (sha256
86 (base32
87 "1qqldrp74pzpy5ly421srqn30qppmm9cvjiqdngk8hf47dv2rc0c"))))
88 (build-system gnu-build-system)
89 (home-page "https://jikes.sourceforge.net/")
90 (synopsis "Compiler for the Java language")
91 (description "Jikes is a compiler that translates Java source files as
92defined in The Java Language Specification into the bytecoded instruction set
93and binary format defined in The Java Virtual Machine Specification.")
94 (license license:ibmpl1.0)))
95
96;; This is the last version of GNU Classpath that can be built without ECJ.
97(define classpath-bootstrap
98 (package
99 (name "classpath")
100 (version "0.93")
101 (source (origin
102 (method url-fetch)
103 (uri (string-append "mirror://gnu/classpath/classpath-"
104 version ".tar.gz"))
105 (sha256
106 (base32
107 "0i99wf9xd3hw1sj2sazychb9prx8nadxh2clgvk3zlmb28v0jbfz"))
108 (patches (search-patches "classpath-aarch64-support.patch"
109 "classpath-miscompilation.patch"))))
110 (build-system gnu-build-system)
111 (arguments
112 `(#:configure-flags
113 (list (string-append "JAVAC="
114 (search-input-file %build-inputs "/bin/jikes"))
115 "CFLAGS=-g -O2 -Wno-error=implicit-function-declaration"
116 "--disable-Werror"
117 "--disable-gmp"
118 "--disable-gtk-peer"
119 "--disable-gconf-peer"
120 "--disable-plugin"
121 "--disable-dssi"
122 "--disable-alsa"
123 "--disable-gjdoc")
124 #:phases
125 (modify-phases %standard-phases
126 (add-after 'install 'install-data
127 (lambda _ (invoke "make" "install-data"))))))
128 (native-inputs
129 (list jikes fastjar libltdl pkg-config))
130 (home-page "https://www.gnu.org/software/classpath/")
131 (synopsis "Essential libraries for Java")
132 (description "GNU Classpath is a project to create core class libraries
133for use with runtimes, compilers and tools for the Java programming
134language.")
135 ;; GPLv2 or later, with special linking exception.
136 (license license:gpl2+)))
137
138;; This is the last version of JamVM that works with a version of GNU
139;; classpath that does not require ECJ.
140(define jamvm-1-bootstrap
141 (package
142 (name "jamvm")
143 (version "1.5.1")
144 (source (origin
145 (method url-fetch)
146 (uri (string-append "mirror://sourceforge/jamvm/jamvm/"
147 "JamVM%20" version "/jamvm-"
148 version ".tar.gz"))
149 (patches (search-patches "jamvm-1.5.1-aarch64-support.patch"
150 "jamvm-1.5.1-armv7-support.patch"))
151 (sha256
152 (base32
153 "06lhi03l3b0h48pc7x58bk9my2nrcf1flpmglvys3wyad6yraf36"))
154 ;; Remove precompiled software.
155 (snippet
156 '(delete-file "lib/classes.zip"))))
157 (build-system gnu-build-system)
158 (arguments
159 `(#:configure-flags
160 (list (string-append "--with-classpath-install-dir="
161 (assoc-ref %build-inputs "classpath"))
162 "--disable-int-caching"
163 "--enable-runtime-reloc-checks"
164 "--enable-ffi"
165 ,(string-append
166 "CFLAGS=-g -O2"
167 " -Wno-error=implicit-function-declaration"
168 " -Wno-error=incompatible-pointer-types"))
169 #:phases
170 ,(if (string-prefix? "aarch64" (or (%current-system)
171 (%current-target-system)))
172 ;; Makefiles and the configure script need to be regenerated to
173 ;; incorporate support for AArch64.
174 '(modify-phases %standard-phases
175 (replace 'bootstrap
176 (lambda _ (invoke "autoreconf" "-vif"))))
177 '%standard-phases)))
178 (inputs
179 (list classpath-bootstrap jikes libffi
180 zip zlib))
181 (native-inputs
182 (if (string-prefix? "aarch64" (or (%current-system)
183 (%current-target-system)))
184 ;; Additional packages needed for autoreconf.
185 `(("autoconf" ,autoconf)
186 ("automake" ,automake)
187 ("libtool" ,libtool))
188 '()))
189 (home-page "https://jamvm.sourceforge.net/")
190 (synopsis "Small Java Virtual Machine")
191 (description "JamVM is a Java Virtual Machine conforming to the JVM
192specification edition 2 (blue book). It is extremely small. However, unlike
193other small VMs it supports the full spec, including object finalisation and
194JNI.")
195 (license license:gpl2+)))
196
197(define ant-bootstrap
198 (package
199 (name "ant-bootstrap")
200 ;; The 1.10.x series requires Java 8. 1.9.0 and later use generics, which
201 ;; are not supported. The 1.8.x series is the last to use only features
202 ;; supported by Jikes.
203 (version "1.8.4")
204 (source (origin
205 (method url-fetch)
206 (uri (string-append "mirror://apache/"
207 "ant/source/apache-ant-"
208 version "-src.tar.bz2"))
209 (sha256
210 (base32
211 "1cg0lga887qz5iizh6mlkxp01lciymrhmp7wzxpl6zpnldxmzrjx"))))
212 (build-system gnu-build-system)
213 (arguments
214 `(#:modules ((srfi srfi-1)
215 (guix build gnu-build-system)
216 (guix build utils))
217 #:tests? #f ; no "check" target
218 #:phases
219 (modify-phases %standard-phases
220 (delete 'bootstrap)
221 (delete 'configure)
222 (add-before 'build 'define-java-environment-variables
223 (lambda* (#:key inputs #:allow-other-keys)
224 ;; First, set environment variables (eases debugging on -K).
225 (setenv "JAVA_HOME" (assoc-ref inputs "jamvm"))
226 (setenv "JAVACMD" (search-input-file inputs "/bin/jamvm"))
227 (setenv "JAVAC" (search-input-file inputs "/bin/jikes"))
228 (setenv "CLASSPATH" (search-input-file inputs "/lib/rt.jar"))))
229 (replace 'build
230 (lambda* (#:key inputs outputs #:allow-other-keys)
231 ;; Ant complains if this file doesn't exist.
232 (setenv "HOME" "/tmp")
233 (with-output-to-file "/tmp/.ant.properties"
234 (lambda _ (display "")))
235
236 ;; Use jikes instead of javac for <javac ...> tags in build.xml
237 (setenv "ANT_OPTS" "-Dbuild.compiler=jikes")
238
239 ;; jikes produces lots of warnings, but they are not very
240 ;; interesting, so we silence them.
241 (setenv "$BOOTJAVAC_OPTS" "-nowarn")
242
243 ;; Without these JamVM options the build may freeze.
244 (substitute* "bootstrap.sh"
245 (("^\"\\$\\{JAVACMD\\}\" " m)
246 ,@(if (string-prefix? "armhf" (or (%current-system)
247 (%current-target-system)))
248 `((string-append m "-Xnocompact "))
249 `((string-append m "-Xnocompact -Xnoinlining ")))))
250
251 ;; Disable tests because we are bootstrapping and thus don't have
252 ;; any of the dependencies required to build and run the tests.
253 (substitute* "build.xml"
254 (("depends=\"jars,test-jar\"") "depends=\"jars\""))
255 (invoke "bash" "bootstrap.sh"
256 (string-append "-Ddist.dir="
257 (assoc-ref outputs "out")))))
258 (add-after 'build 'strip-jar-timestamps ;based on ant-build-system
259 (lambda* (#:key outputs #:allow-other-keys)
260 (define (repack-archive jar)
261 (let* ((dir (mkdtemp "jar-contents.XXXXXX"))
262 (manifest (string-append dir "/META-INF/MANIFESTS.MF")))
263 (with-directory-excursion dir
264 (invoke "unzip" jar))
265 (delete-file jar)
266 ;; XXX: copied from (gnu build install)
267 (for-each (lambda (file)
268 (let ((s (lstat file)))
269 (unless (eq? (stat:type s) 'symlink)
270 (utime file 0 0 0 0))))
271 (find-files dir #:directories? #t))
272 ;; It is important that the manifest appears first.
273 (with-directory-excursion dir
274 (let* ((files (find-files "." ".*" #:directories? #t))
275 ;; To ensure that the reference scanner can
276 ;; detect all store references in the jars
277 ;; we disable compression with the "-0" option.
278 (command (if (file-exists? manifest)
279 `("zip" "-0" "-X" ,jar ,manifest
280 ,@files)
281 `("zip" "-0" "-X" ,jar ,@files))))
282 (apply invoke command)))))
283 (for-each repack-archive
284 (find-files
285 (string-append (assoc-ref %outputs "out") "/lib")
286 "\\.jar$"))))
287 (delete 'install))))
288 (native-inputs
289 (list jikes jamvm-1-bootstrap unzip zip))
290 (home-page "https://ant.apache.org")
291 (synopsis "Build tool for Java")
292 (description
293 "Ant is a platform-independent build tool for Java. It is similar to
294make but is implemented using the Java language, requires the Java platform,
295and is best suited to building Java projects. Ant uses XML to describe the
296build process and its dependencies, whereas Make uses Makefile format.")
297 (license license:asl2.0)))
298
299;; Version 3.2.2 is the last version without a dependency on a full-fledged
300;; compiler for Java 1.5.
301(define ecj-bootstrap
302 (package
303 (name "ecj-bootstrap")
304 (version "3.2.2")
305 (source (origin
306 (method url-fetch)
307 (uri (string-append "http://archive.eclipse.org/eclipse/"
308 "downloads/drops/R-" version
309 "-200702121330/ecjsrc.zip"))
310 (sha256
311 (base32
312 "05hj82kxd23qaglsjkaqcj944riisjha7acf7h3ljhrjyljx8307"))))
313 ;; It would be so much easier if we could use the ant-build-system, but we
314 ;; cannot as we don't have ant at this point. We use ecj for
315 ;; bootstrapping the JDK.
316 (build-system gnu-build-system)
317 (arguments
318 `(#:tests? #f ; there are no tests
319 #:phases
320 (modify-phases %standard-phases
321 (replace 'configure
322 (lambda* (#:key inputs #:allow-other-keys)
323 (setenv "CLASSPATH"
324 (string-join
325 (cons (search-input-file inputs "/lib/rt.jar")
326 (find-files (string-append
327 (assoc-ref inputs "ant-bootstrap")
328 "/lib")
329 "\\.jar$"))
330 ":"))))
331 (replace 'build
332 (lambda* (#:key inputs #:allow-other-keys)
333 ;; The unpack phase enters the "org" directory by mistake.
334 (chdir "..")
335
336 ;; Create a simple manifest to make ecj executable.
337 (with-output-to-file "manifest"
338 (lambda _
339 (display "Manifest-Version: 1.0
340Main-Class: org.eclipse.jdt.internal.compiler.batch.Main\n")))
341
342 ;; Compile it all!
343 (and (apply invoke "jikes"
344 (find-files "." "\\.java$"))
345 (invoke "fastjar" "cvfm"
346 "ecj-bootstrap.jar" "manifest" "."))))
347 (replace 'install
348 (lambda* (#:key outputs #:allow-other-keys)
349 (let ((share (string-append (assoc-ref outputs "out")
350 "/share/java/")))
351 (mkdir-p share)
352 (install-file "ecj-bootstrap.jar" share)))))))
353 (native-inputs
354 (list ant-bootstrap
355 unzip
356 jikes
357 jamvm-1-bootstrap
358 fastjar))
359 (home-page "https://eclipse.org")
360 (synopsis "Eclipse Java development tools core batch compiler")
361 (description "This package provides the Eclipse Java core batch compiler
362for bootstrapping purposes. The @dfn{Eclipse compiler for Java} (ecj) is a
363requirement for all GNU Classpath releases after version 0.93.")
364 (license license:epl1.0)))
365
366(define ecj-javac-wrapper
367 (package (inherit ecj-bootstrap)
368 (name "ecj-javac-wrapper")
369 (source #f)
370 (build-system trivial-build-system)
371 (arguments
372 `(#:modules ((guix build utils))
373 #:builder
374 ,#~(begin
375 (use-modules (guix build utils))
376 (let* ((bin (string-append #$output "/bin"))
377 (target (string-append bin "/javac"))
378 (guile (string-append (assoc-ref %build-inputs "guile")
379 "/bin/guile"))
380 (ecj (string-append #$(this-package-native-input "ecj-bootstrap")
381 "/share/java/ecj-bootstrap.jar"))
382 (java (string-append #$(this-package-native-input "jamvm")
383 "/bin/jamvm"))
384 (bootcp (let ((jvmlib (string-append
385 #$(this-package-native-input "classpath")
386 "/share/classpath")))
387 (string-append jvmlib "/glibj.zip:"
388 jvmlib "/tools.zip"))))
389 (mkdir-p bin)
390 (with-output-to-file target
391 (lambda _
392 (format #t "#!~a --no-auto-compile\n!#\n" guile)
393 (write
394 `(begin (use-modules (ice-9 match)
395 (ice-9 receive)
396 (ice-9 hash-table)
397 (srfi srfi-1)
398 (srfi srfi-26))
399 (define defaults
400 '(("-bootclasspath" ,bootcp)
401 ("-source" "1.5")
402 ("-target" "1.5")
403 ("-cp" ".")))
404 (define (main args)
405 (let ((classpath (getenv "CLASSPATH")))
406 (setenv "CLASSPATH"
407 (string-join (list ,ecj (or classpath ""))
408 ":")))
409 (receive (vm-args other-args)
410 ;; Separate VM arguments from arguments to ECJ.
411 (partition (cut string-prefix? "-J" <>)
412 (fold (lambda (default acc)
413 (if (member (first default) acc)
414 acc (append default acc)))
415 args defaults))
416 (apply system* ,java
417 (append
418 ;; Remove "-J" prefix
419 (map (cut string-drop <> 2) vm-args)
420 '("org.eclipse.jdt.internal.compiler.batch.Main")
421 (cons "-nowarn" other-args)))))
422 ;; Entry point
423 (let ((args (cdr (command-line))))
424 (if (null? args)
425 (format (current-error-port) "javac: no arguments given!\n")
426 (main args)))))))
427 (chmod target #o755)))))
428 (native-inputs
429 (list guile-3.0 ecj-bootstrap jamvm-1-bootstrap classpath-bootstrap))
430 (description "This package provides a wrapper around the @dfn{Eclipse
431compiler for Java} (ecj) with a command line interface that is compatible with
432the standard javac executable.")))
433
434;; The classpath-bootstrap was built without a virtual machine, so it does not
435;; provide a wrapper for javah. We cannot build the development version of
436;; Classpath without javah.
437(define classpath-0.99
438 (package (inherit classpath-bootstrap)
439 (version "0.99")
440 (source (origin
441 (method url-fetch)
442 (uri (string-append "mirror://gnu/classpath/classpath-"
443 version ".tar.gz"))
444 (sha256
445 (base32
446 "1j7cby4k66f1nvckm48xcmh352b1d1b33qk7l6hi7dp9i9zjjagr"))
447 (patches (search-patches "classpath-aarch64-support.patch"))))
448 (arguments
449 `(#:configure-flags
450 (list (string-append "--with-ecj-jar="
451 (assoc-ref %build-inputs "ecj-bootstrap")
452 "/share/java/ecj-bootstrap.jar")
453 (string-append "JAVAC="
454 (assoc-ref %build-inputs "ecj-javac-wrapper")
455 "/bin/javac")
456 (string-append "JAVA="
457 (assoc-ref %build-inputs "jamvm")
458 "/bin/jamvm")
459 "GCJ_JAVAC_TRUE=no"
460 "ac_cv_prog_java_works=yes" ; trust me
461 "--disable-Werror"
462 "--disable-gmp"
463 "--disable-gtk-peer"
464 "--disable-gconf-peer"
465 "--disable-plugin"
466 "--disable-dssi"
467 "--disable-alsa"
468 "--disable-gjdoc")
469 #:phases
470 (modify-phases %standard-phases
471 (add-after 'install 'install-data
472 (lambda _ (invoke "make" "install-data"))))))
473 (native-inputs
474 (list classpath-bootstrap
475 ecj-bootstrap ecj-javac-wrapper
476 fastjar jamvm-1-bootstrap
477 libltdl pkg-config))))
478
479;; We need this because classpath-bootstrap does not provide all of the tools
480;; we need to build classpath-devel.
481(define classpath-jamvm-wrappers
482 (package (inherit classpath-0.99)
483 (name "classpath-jamvm-wrappers")
484 (source #f)
485 (build-system trivial-build-system)
486 (arguments
487 (list
488 #:modules '((guix build utils))
489 #:builder
490 #~(begin
491 (use-modules (guix build utils))
492 (let ((bash #$(this-package-native-input "bash-minimal"))
493 (jamvm #$(this-package-native-input "jamvm"))
494 (classpath #$(this-package-native-input "classpath"))
495 (bin (string-append #$output "/bin/")))
496 (mkdir-p bin)
497 (for-each (lambda (tool)
498 (with-output-to-file (string-append bin tool)
499 (lambda _
500 #$@(if (target-arm32?)
501 `((format #t "#!~a/bin/sh
502~a/bin/jamvm -classpath ~a/share/classpath/tools.zip \
503gnu.classpath.tools.~a.~a $@"
504 bash jamvm classpath tool
505 (if (string=? "native2ascii" tool)
506 "Native2ASCII" "Main")))
507 `((format #t "#!~a/bin/sh
508~a/bin/jamvm -Xnocompact -Xnoinlining -classpath ~a/share/classpath/tools.zip \
509gnu.classpath.tools.~a.~a $@"
510 bash jamvm classpath tool
511 (if (string=? "native2ascii" tool)
512 "Native2ASCII" "Main"))))))
513 (chmod (string-append bin tool) #o755))
514 (list "javah"
515 "rmic"
516 "rmid"
517 "orbd"
518 "rmiregistry"
519 "native2ascii"))))))
520 (native-inputs
521 (list bash-minimal jamvm-1-bootstrap classpath-0.99))
522 (inputs '())
523 (synopsis "Executables from GNU Classpath")
524 (description "This package provides wrappers around the tools provided by
525the GNU Classpath library. They are executed by the JamVM virtual
526machine.")))
527
528;; The last release of GNU Classpath is 0.99 and it happened in 2012. Since
529;; then Classpath has gained much more support for Java 1.6.
530(define classpath-devel
531 (let ((commit "e7c13ee0cf2005206fbec0eca677f8cf66d5a103")
532 (revision "1"))
533 (package (inherit classpath-bootstrap)
534 (version (string-append "0.99-" revision "." (string-take commit 9)))
535 (source (origin
536 (method git-fetch)
537 (uri (git-reference
538 (url "https://git.savannah.gnu.org/git/classpath.git")
539 (commit commit)))
540 (file-name (string-append "classpath-" version "-checkout"))
541 (sha256
542 (base32
543 "1v2rww76ww322mpg3s12a1kkc6gkp31bm9gcxs532h0wq285fiw4"))
544 (patches (search-patches "classpath-aarch64-support.patch"))))
545 (arguments
546 `(#:make-flags
547 ;; Ensure that the initial heap size is smaller than the maximum
548 ;; size. By default only Xmx is set, which can lead to invalid
549 ;; memory settings on some machines with a lot of memory.
550 '("JAVAC_MEM_OPT=-J-Xms512M -J-Xmx768M")
551 #:configure-flags
552 (list (string-append "--with-ecj-jar="
553 (assoc-ref %build-inputs "ecj-bootstrap")
554 "/share/java/ecj-bootstrap.jar")
555 (string-append "--with-javac="
556 (assoc-ref %build-inputs "ecj-javac-wrapper")
557 "/bin/javac")
558 (string-append "JAVA="
559 (assoc-ref %build-inputs "jamvm")
560 "/bin/jamvm")
561 "GCJ_JAVAC_TRUE=no"
562 "ac_cv_prog_java_works=yes" ; trust me
563 "--disable-Werror"
564 "--disable-gmp"
565 "--disable-gtk-peer"
566 "--disable-gconf-peer"
567 "--disable-plugin"
568 "--disable-dssi"
569 "--disable-alsa"
570 "--disable-gjdoc")
571 #:phases
572 (modify-phases %standard-phases
573 ;; XXX The bootstrap phase executes autogen.sh, which fails after
574 ;; complaining about the lack of gettext.
575 (replace 'bootstrap
576 (lambda _ (invoke "autoreconf" "-vif")))
577 (add-after 'unpack 'remove-unsupported-annotations
578 (lambda _
579 (substitute* (find-files "java" "\\.java$")
580 (("@Override") ""))))
581 (add-after 'install 'install-data
582 (lambda _ (invoke "make" "install-data"))))))
583 (native-inputs
584 (list autoconf automake libltdl libtool gettext-minimal texinfo
585 pkg-config
586 classpath-jamvm-wrappers ;for javah
587 ecj-bootstrap ecj-javac-wrapper fastjar
588 jamvm-1-bootstrap)))))
589
590(define jamvm
591 (package (inherit jamvm-1-bootstrap)
592 (version "2.0.0")
593 (source (origin
594 (method url-fetch)
595 (uri (string-append "mirror://sourceforge/jamvm/jamvm/"
596 "JamVM%20" version "/jamvm-"
597 version ".tar.gz"))
598 (sha256
599 (base32
600 "1nl0zxz8y5x8gwsrm7n32bry4dx8x70p8z3s9jbdvs8avyb8whkn"))
601 (patches
602 (search-patches "jamvm-2.0.0-disable-branch-patching.patch"
603 "jamvm-2.0.0-opcode-guard.patch"
604 "jamvm-2.0.0-aarch64-support.patch"))
605 ;; Remove precompiled software.
606 (snippet
607 '(delete-file "src/classlib/gnuclasspath/lib/classes.zip"))))
608 (build-system gnu-build-system)
609 (arguments
610 (substitute-keyword-arguments (package-arguments jamvm-1-bootstrap)
611 ((#:configure-flags _)
612 '(list (string-append "--with-classpath-install-dir="
613 (assoc-ref %build-inputs "classpath"))))))
614 (inputs
615 `(("classpath" ,classpath-devel)
616 ("ecj-javac-wrapper" ,ecj-javac-wrapper)
617 ("zip" ,zip)
618 ("zlib" ,zlib)))))
619
620(define ecj-javac-wrapper-final
621 (package (inherit ecj-javac-wrapper)
622 (native-inputs
623 (list guile-3.0 ecj-bootstrap jamvm classpath-devel))))
624
625;; We jump ahead by patching the sources of ECJ 4.2.1 so that our bootstrap
626;; JDK can build it. ECJ 4 allows us to skip the build of the first version
627;; of icedtea and build icedtea 2.x directly.
628(define ecj4-bootstrap
629 (package
630 (name "ecj-bootstrap")
631 (version "4.2.1")
632 (source (origin
633 (method url-fetch)
634 (uri (string-append "http://archive.eclipse.org/eclipse/"
635 "downloads/drops4/R-" version
636 "-201209141800/ecjsrc-" version ".jar"))
637 (sha256
638 (base32
639 "1x281p87m14zylvinkiz6gc23ss7pzlx419qjbql11jriwav4qfj"))))
640 ;; It would be so much easier if we could use the ant-build-system, but we
641 ;; cannot as we don't have ant at this point. We use ecj for
642 ;; bootstrapping the JDK.
643 (build-system gnu-build-system)
644 (arguments
645 `(#:tests? #f ; there are no tests
646 #:phases
647 (modify-phases %standard-phases
648 (replace 'unpack
649 (lambda* (#:key source #:allow-other-keys)
650 (mkdir "src")
651 (with-directory-excursion "src"
652 (invoke "gjar" "-xf" source))
653 (chdir "src")))
654 (replace 'configure
655 (lambda* (#:key inputs #:allow-other-keys)
656 (setenv "CLASSPATH"
657 (string-join
658 (cons (search-input-file inputs "/lib/rt.jar")
659 (find-files (string-append
660 (assoc-ref inputs "ant-bootstrap")
661 "/lib")
662 "\\.jar$"))
663 ":"))
664 ;; This directive is not supported by our simple bootstrap JDK.
665 (substitute* (find-files "." "\\.java$")
666 (("@Override") ""))))
667 (replace 'build
668 (lambda* (#:key inputs #:allow-other-keys)
669 ;; We can't compile these yet, but we don't need them at this
670 ;; point anyway.
671 (delete-file "org/eclipse/jdt/core/JDTCompilerAdapter.java")
672 (delete-file-recursively "org/eclipse/jdt/internal/antadapter")
673
674 ;; Create a simple manifest to make ecj executable.
675 (mkdir-p "META-INF")
676 (with-output-to-file "META-INF/MANIFESTS.MF"
677 (lambda _
678 (display "Manifest-Version: 1.0
679Main-Class: org.eclipse.jdt.internal.compiler.batch.Main\n")))
680
681 ;; Compile it all!
682 (apply invoke "javac"
683 (find-files "." "\\.java$"))
684
685 ;; Pack it all up! We don't use "jar" here, because
686 ;; it doesn't produce reproducible zip archives.
687 ;; XXX: copied from (gnu build install)
688 (for-each (lambda (file)
689 (let ((s (lstat file)))
690 (unless (eq? (stat:type s) 'symlink)
691 (utime file 0 0 0 0))))
692 (find-files "." #:directories? #t))
693
694 ;; It is important that the manifest appears first.
695 (apply invoke "zip" "-0" "-X" "ecj-bootstrap.jar"
696 "META-INF/MANIFESTS.MF"
697 (delete "./META-INF/MANIFESTS.MF"
698 (find-files "." ".*" #:directories? #t)))))
699 (replace 'install
700 (lambda* (#:key outputs #:allow-other-keys)
701 (let ((share (string-append (assoc-ref outputs "out")
702 "/share/java/")))
703 (mkdir-p share)
704 (install-file "ecj-bootstrap.jar" share)))))))
705 (native-inputs
706 (list ant-bootstrap classpath-devel ecj-javac-wrapper-final jamvm
707 unzip zip))
708 (home-page "https://eclipse.org")
709 (synopsis "Eclipse Java development tools core batch compiler")
710 (description "This package provides the Eclipse Java core batch compiler
711for bootstrapping purposes. The @dfn{Eclipse compiler for Java} (ecj) is a
712requirement for all GNU Classpath releases after version 0.93. This version
713supports sufficient parts of Java 7 to build Icedtea 2.x.")
714 (license license:epl1.0)))
715
716(define ecj4-javac-wrapper
717 (package
718 (inherit ecj-javac-wrapper)
719 (native-inputs
720 (list guile-3.0 ecj4-bootstrap jamvm classpath-devel))))
721
722(define jamvm-with-ecj4
723 (package
724 (inherit jamvm)
725 (inputs
726 (modify-inputs (package-inputs jamvm)
727 (replace "ecj-javac-wrapper" ecj4-javac-wrapper)))))
728