projects/guix·blob librewolf-updates · refs

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