projects/guix·blob java-team · refs

752 lines · 33.5 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014-2019, 2021, 2026 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 ,@(if (target-x86-32?)
230 ;; XXX: On i686 isFile() always seems to return true. Patching
231 ;; this here is very ugly, but the effects are limited. None
232 ;; of these changes remain by the time we've built Icedtea and
233 ;; the other JDKs.
234 '((add-after 'unpack 'disable-isFile-checks
235 (lambda _
236 (substitute* "src/main/org/apache/tools/ant/util/ResourceUtils.java"
237 (("destFile = \\(\\(FileProvider\\).*") ""))
238 (substitute* "src/main/org/apache/tools/ant/taskdefs/Mkdir.java"
239 (("dir.isFile\\(\\)") "false")))))
240 '())
241 (replace 'build
242 (lambda* (#:key inputs outputs #:allow-other-keys)
243 ;; Ant complains if this file doesn't exist.
244 (setenv "HOME" "/tmp")
245 (with-output-to-file "/tmp/.ant.properties"
246 (lambda _ (display "")))
247
248 ;; Use jikes instead of javac for <javac ...> tags in build.xml
249 (setenv "ANT_OPTS" "-Dbuild.compiler=jikes")
250
251 ;; jikes produces lots of warnings, but they are not very
252 ;; interesting, so we silence them.
253 (setenv "$BOOTJAVAC_OPTS" "-nowarn")
254
255 ;; Without these JamVM options the build may freeze.
256 (substitute* "bootstrap.sh"
257 (("^\"\\$\\{JAVACMD\\}\" " m)
258 ,@(if (string-prefix? "armhf" (or (%current-system)
259 (%current-target-system)))
260 `((string-append m "-Xnocompact "))
261 `((string-append m "-Xnocompact -Xnoinlining ")))))
262
263 ;; Disable tests because we are bootstrapping and thus don't have
264 ;; any of the dependencies required to build and run the tests.
265 (substitute* "build.xml"
266 (("depends=\"jars,test-jar\"") "depends=\"jars\""))
267 (invoke "bash" "bootstrap.sh"
268 (string-append "-Ddist.dir="
269 (assoc-ref outputs "out")))))
270 (add-after 'build 'strip-jar-timestamps ;based on ant-build-system
271 (lambda* (#:key outputs #:allow-other-keys)
272 (define (repack-archive jar)
273 (let* ((dir (mkdtemp "jar-contents.XXXXXX"))
274 (manifest (string-append dir "/META-INF/MANIFESTS.MF")))
275 (with-directory-excursion dir
276 (invoke "unzip" jar))
277 (delete-file jar)
278 ;; XXX: copied from (gnu build install)
279 (for-each (lambda (file)
280 (let ((s (lstat file)))
281 (unless (eq? (stat:type s) 'symlink)
282 (utime file 0 0 0 0))))
283 (find-files dir #:directories? #t))
284 ;; It is important that the manifest appears first.
285 (with-directory-excursion dir
286 (let* ((files (find-files "." ".*" #:directories? #t))
287 ;; To ensure that the reference scanner can
288 ;; detect all store references in the jars
289 ;; we disable compression with the "-0" option.
290 (command (if (file-exists? manifest)
291 `("zip" "-0" "-X" ,jar ,manifest
292 ,@files)
293 `("zip" "-0" "-X" ,jar ,@files))))
294 (apply invoke command)))))
295 (for-each repack-archive
296 (find-files
297 (string-append (assoc-ref %outputs "out") "/lib")
298 "\\.jar$"))))
299 (delete 'install))))
300 (native-inputs
301 (list jikes jamvm-1-bootstrap unzip zip))
302 (home-page "https://ant.apache.org")
303 (synopsis "Build tool for Java")
304 (description
305 "Ant is a platform-independent build tool for Java. It is similar to
306make but is implemented using the Java language, requires the Java platform,
307and is best suited to building Java projects. Ant uses XML to describe the
308build process and its dependencies, whereas Make uses Makefile format.")
309 (properties '((hidden? . #t))) ;for bootstrapping only
310 (license license:asl2.0)))
311
312;; Version 3.2.2 is the last version without a dependency on a full-fledged
313;; compiler for Java 1.5.
314(define-public ecj-bootstrap
315 (package
316 (name "ecj-bootstrap")
317 (version "3.2.2")
318 (source (origin
319 (method url-fetch)
320 (uri (string-append "http://archive.eclipse.org/eclipse/"
321 "downloads/drops/R-" version
322 "-200702121330/ecjsrc.zip"))
323 (sha256
324 (base32
325 "05hj82kxd23qaglsjkaqcj944riisjha7acf7h3ljhrjyljx8307"))))
326 ;; It would be so much easier if we could use the ant-build-system, but we
327 ;; cannot as we don't have ant at this point. We use ecj for
328 ;; bootstrapping the JDK.
329 (build-system gnu-build-system)
330 (arguments
331 `(#:tests? #f ; there are no tests
332 #:phases
333 (modify-phases %standard-phases
334 (replace 'configure
335 (lambda* (#:key inputs #:allow-other-keys)
336 (setenv "CLASSPATH"
337 (string-join
338 (cons (search-input-file inputs "/lib/rt.jar")
339 (find-files (string-append
340 (assoc-ref inputs "ant-bootstrap")
341 "/lib")
342 "\\.jar$"))
343 ":"))))
344 (replace 'build
345 (lambda* (#:key inputs #:allow-other-keys)
346 ;; The unpack phase enters the "org" directory by mistake.
347 (chdir "..")
348
349 ;; Create a simple manifest to make ecj executable.
350 (with-output-to-file "manifest"
351 (lambda _
352 (display "Manifest-Version: 1.0
353Main-Class: org.eclipse.jdt.internal.compiler.batch.Main\n")))
354
355 ;; Compile it all!
356 (and (apply invoke "jikes"
357 (find-files "." "\\.java$"))
358 (invoke "fastjar" "cvfm"
359 "ecj-bootstrap.jar" "manifest" "."))))
360 (replace 'install
361 (lambda* (#:key outputs #:allow-other-keys)
362 (let ((share (string-append (assoc-ref outputs "out")
363 "/share/java/")))
364 (mkdir-p share)
365 (install-file "ecj-bootstrap.jar" share)))))))
366 (native-inputs
367 (list ant-bootstrap
368 unzip
369 jikes
370 jamvm-1-bootstrap
371 fastjar))
372 (home-page "https://eclipse.org")
373 (synopsis "Eclipse Java development tools core batch compiler")
374 (description "This package provides the Eclipse Java core batch compiler
375for bootstrapping purposes. The @dfn{Eclipse compiler for Java} (ecj) is a
376requirement for all GNU Classpath releases after version 0.93.")
377 (properties '((hidden? . #t))) ;for bootstrapping only
378 (license license:epl1.0)))
379
380(define-public ecj-javac-wrapper
381 (package (inherit ecj-bootstrap)
382 (name "ecj-javac-wrapper")
383 (source #f)
384 (build-system trivial-build-system)
385 (arguments
386 `(#:modules ((guix build utils))
387 #:builder
388 ,#~(begin
389 (use-modules (guix build utils))
390 (let* ((bin (string-append #$output "/bin"))
391 (target (string-append bin "/javac"))
392 (guile (string-append (assoc-ref %build-inputs "guile")
393 "/bin/guile"))
394 (ecj (string-append #$(this-package-native-input "ecj-bootstrap")
395 "/share/java/ecj-bootstrap.jar"))
396 (java (string-append #$(this-package-native-input "jamvm")
397 "/bin/jamvm"))
398 (bootcp (let ((jvmlib (string-append
399 #$(this-package-native-input "classpath")
400 "/share/classpath")))
401 (string-append jvmlib "/glibj.zip:"
402 jvmlib "/tools.zip"))))
403 (mkdir-p bin)
404 (with-output-to-file target
405 (lambda _
406 (format #t "#!~a --no-auto-compile\n!#\n" guile)
407 (write
408 `(begin (use-modules (ice-9 match)
409 (ice-9 receive)
410 (ice-9 hash-table)
411 (srfi srfi-1)
412 (srfi srfi-26))
413 (define defaults
414 '(("-bootclasspath" ,bootcp)
415 ("-source" "1.5")
416 ("-target" "1.5")
417 ("-cp" ".")))
418 (define (main args)
419 (let ((classpath (getenv "CLASSPATH")))
420 (setenv "CLASSPATH"
421 (string-join (list ,ecj (or classpath ""))
422 ":")))
423 (receive (vm-args other-args)
424 ;; Separate VM arguments from arguments to ECJ.
425 (partition (cut string-prefix? "-J" <>)
426 (fold (lambda (default acc)
427 (if (member (first default) acc)
428 acc (append default acc)))
429 args defaults))
430 (apply system* ,java
431 (append
432 ;; Remove "-J" prefix
433 (map (cut string-drop <> 2) vm-args)
434 '("org.eclipse.jdt.internal.compiler.batch.Main")
435 (cons "-nowarn" other-args)))))
436 ;; Entry point
437 (let ((args (cdr (command-line))))
438 (if (null? args)
439 (format (current-error-port) "javac: no arguments given!\n")
440 (main args)))))))
441 (chmod target #o755)))))
442 (native-inputs
443 (list guile-3.0 ecj-bootstrap jamvm-1-bootstrap classpath-bootstrap))
444 (description "This package provides a wrapper around the @dfn{Eclipse
445compiler for Java} (ecj) with a command line interface that is compatible with
446the standard javac executable.")))
447
448;; The classpath-bootstrap was built without a virtual machine, so it does not
449;; provide a wrapper for javah. We cannot build the development version of
450;; Classpath without javah.
451(define-public classpath-0.99
452 (package (inherit classpath-bootstrap)
453 (version "0.99")
454 (source (origin
455 (method url-fetch)
456 (uri (string-append "mirror://gnu/classpath/classpath-"
457 version ".tar.gz"))
458 (sha256
459 (base32
460 "1j7cby4k66f1nvckm48xcmh352b1d1b33qk7l6hi7dp9i9zjjagr"))
461 (patches (search-patches "classpath-aarch64-support.patch"))))
462 (arguments
463 `(#:configure-flags
464 (list (string-append "--with-ecj-jar="
465 (assoc-ref %build-inputs "ecj-bootstrap")
466 "/share/java/ecj-bootstrap.jar")
467 (string-append "JAVAC="
468 (assoc-ref %build-inputs "ecj-javac-wrapper")
469 "/bin/javac")
470 (string-append "JAVA="
471 (assoc-ref %build-inputs "jamvm")
472 "/bin/jamvm")
473 "GCJ_JAVAC_TRUE=no"
474 "ac_cv_prog_java_works=yes" ; trust me
475 "--disable-Werror"
476 "--disable-gmp"
477 "--disable-gtk-peer"
478 "--disable-gconf-peer"
479 "--disable-plugin"
480 "--disable-dssi"
481 "--disable-alsa"
482 "--disable-gjdoc")
483 #:phases
484 (modify-phases %standard-phases
485 (add-after 'install 'install-data
486 (lambda _ (invoke "make" "install-data"))))))
487 (native-inputs
488 (list classpath-bootstrap
489 ecj-bootstrap ecj-javac-wrapper
490 fastjar jamvm-1-bootstrap
491 libltdl pkg-config))))
492
493;; We need this because classpath-bootstrap does not provide all of the tools
494;; we need to build classpath-devel.
495(define-public classpath-jamvm-wrappers
496 (package (inherit classpath-0.99)
497 (name "classpath-jamvm-wrappers")
498 (source #f)
499 (build-system trivial-build-system)
500 (arguments
501 (list
502 #:modules '((guix build utils))
503 #:builder
504 #~(begin
505 (use-modules (guix build utils))
506 (let ((bash #$(this-package-native-input "bash-minimal"))
507 (jamvm #$(this-package-native-input "jamvm"))
508 (classpath #$(this-package-native-input "classpath"))
509 (bin (string-append #$output "/bin/")))
510 (mkdir-p bin)
511 (for-each (lambda (tool)
512 (with-output-to-file (string-append bin tool)
513 (lambda _
514 #$@(if (target-arm32?)
515 `((format #t "#!~a/bin/sh
516~a/bin/jamvm -classpath ~a/share/classpath/tools.zip \
517gnu.classpath.tools.~a.~a $@"
518 bash jamvm classpath tool
519 (if (string=? "native2ascii" tool)
520 "Native2ASCII" "Main")))
521 `((format #t "#!~a/bin/sh
522~a/bin/jamvm -Xnocompact -Xnoinlining -classpath ~a/share/classpath/tools.zip \
523gnu.classpath.tools.~a.~a $@"
524 bash jamvm classpath tool
525 (if (string=? "native2ascii" tool)
526 "Native2ASCII" "Main"))))))
527 (chmod (string-append bin tool) #o755))
528 (list "javah"
529 "rmic"
530 "rmid"
531 "orbd"
532 "rmiregistry"
533 "native2ascii"))))))
534 (native-inputs
535 (list bash-minimal jamvm-1-bootstrap classpath-0.99))
536 (inputs '())
537 (synopsis "Executables from GNU Classpath")
538 (description "This package provides wrappers around the tools provided by
539the GNU Classpath library. They are executed by the JamVM virtual
540machine.")))
541
542;; The last release of GNU Classpath is 0.99 and it happened in 2012. Since
543;; then Classpath has gained much more support for Java 1.6.
544(define-public classpath-devel
545 (let ((commit "e7c13ee0cf2005206fbec0eca677f8cf66d5a103")
546 (revision "1"))
547 (package (inherit classpath-bootstrap)
548 (version (string-append "0.99-" revision "." (string-take commit 9)))
549 (source (origin
550 (method git-fetch)
551 (uri (git-reference
552 (url "https://git.savannah.gnu.org/git/classpath.git")
553 (commit commit)))
554 (file-name (string-append "classpath-" version "-checkout"))
555 (sha256
556 (base32
557 "1v2rww76ww322mpg3s12a1kkc6gkp31bm9gcxs532h0wq285fiw4"))
558 (patches (search-patches "classpath-aarch64-support.patch"))))
559 (arguments
560 `(#:make-flags
561 ;; Ensure that the initial heap size is smaller than the maximum
562 ;; size. By default only Xmx is set, which can lead to invalid
563 ;; memory settings on some machines with a lot of memory.
564 '("JAVAC_MEM_OPT=-J-Xms512M -J-Xmx768M")
565 #:configure-flags
566 (list (string-append "--with-ecj-jar="
567 (assoc-ref %build-inputs "ecj-bootstrap")
568 "/share/java/ecj-bootstrap.jar")
569 (string-append "--with-javac="
570 (assoc-ref %build-inputs "ecj-javac-wrapper")
571 "/bin/javac")
572 (string-append "JAVA="
573 (assoc-ref %build-inputs "jamvm")
574 "/bin/jamvm")
575 "GCJ_JAVAC_TRUE=no"
576 "ac_cv_prog_java_works=yes" ; trust me
577 "--disable-Werror"
578 "--disable-gmp"
579 "--disable-gtk-peer"
580 "--disable-gconf-peer"
581 "--disable-plugin"
582 "--disable-dssi"
583 "--disable-alsa"
584 "--disable-gjdoc")
585 #:phases
586 (modify-phases %standard-phases
587 ;; XXX The bootstrap phase executes autogen.sh, which fails after
588 ;; complaining about the lack of gettext.
589 (replace 'bootstrap
590 (lambda _ (invoke "autoreconf" "-vif")))
591 (add-after 'unpack 'remove-unsupported-annotations
592 (lambda _
593 (substitute* (find-files "java" "\\.java$")
594 (("@Override") ""))))
595 (add-after 'install 'install-data
596 (lambda _ (invoke "make" "install-data"))))))
597 (native-inputs
598 (list autoconf automake libltdl libtool gettext-minimal texinfo
599 pkg-config
600 classpath-jamvm-wrappers ;for javah
601 ecj-bootstrap ecj-javac-wrapper fastjar
602 jamvm-1-bootstrap))
603 (properties
604 (alist-delete 'hidden? (package-properties classpath-bootstrap))))))
605
606(define-public jamvm
607 (package
608 (inherit jamvm-1-bootstrap)
609 (version "2.0.0")
610 (source (origin
611 (method url-fetch)
612 (uri (string-append "mirror://sourceforge/jamvm/jamvm/"
613 "JamVM%20" version "/jamvm-"
614 version ".tar.gz"))
615 (sha256
616 (base32
617 "1nl0zxz8y5x8gwsrm7n32bry4dx8x70p8z3s9jbdvs8avyb8whkn"))
618 (patches
619 (search-patches "jamvm-2.0.0-disable-branch-patching.patch"
620 "jamvm-2.0.0-opcode-guard.patch"
621 "jamvm-2.0.0-aarch64-support.patch"))
622 ;; Remove precompiled software.
623 (snippet
624 '(delete-file "src/classlib/gnuclasspath/lib/classes.zip"))))
625 (build-system gnu-build-system)
626 (arguments
627 (substitute-keyword-arguments arguments
628 ((#:modules modules %default-gnu-modules)
629 (append '((srfi srfi-1)
630 (srfi srfi-26))
631 modules))
632 ((#:configure-flags flags)
633 #~(cons (string-append "--with-classpath-install-dir="
634 #$(this-package-input "classpath"))
635 (remove (cut string-prefix? "--with-classpath-install-dir" <>)
636 #$flags)))))
637 (inputs (list classpath-devel ecj-javac-wrapper libffi zip zlib))))
638
639(define-public ecj-javac-wrapper-final
640 (package (inherit ecj-javac-wrapper)
641 (native-inputs
642 (list guile-3.0 ecj-bootstrap jamvm classpath-devel))
643 (properties
644 (alist-delete 'hidden? (package-properties ecj-javac-wrapper)))))
645
646;; We jump ahead by patching the sources of ECJ 4.2.1 so that our bootstrap
647;; JDK can build it. ECJ 4 allows us to skip the build of the first version
648;; of icedtea and build icedtea 2.x directly.
649(define-public ecj4-bootstrap
650 (package
651 (name "ecj-bootstrap")
652 (version "4.2.1")
653 (source (origin
654 (method url-fetch)
655 (uri (string-append "http://archive.eclipse.org/eclipse/"
656 "downloads/drops4/R-" version
657 "-201209141800/ecjsrc-" version ".jar"))
658 (sha256
659 (base32
660 "1x281p87m14zylvinkiz6gc23ss7pzlx419qjbql11jriwav4qfj"))))
661 ;; It would be so much easier if we could use the ant-build-system, but we
662 ;; cannot as we don't have ant at this point. We use ecj for
663 ;; bootstrapping the JDK.
664 (build-system gnu-build-system)
665 (arguments
666 `(#:tests? #f ; there are no tests
667 #:phases
668 (modify-phases %standard-phases
669 (replace 'unpack
670 (lambda* (#:key source #:allow-other-keys)
671 (mkdir "src")
672 (with-directory-excursion "src"
673 (invoke "gjar" "-xf" source))
674 (chdir "src")))
675 (replace 'configure
676 (lambda* (#:key inputs #:allow-other-keys)
677 (setenv "CLASSPATH"
678 (string-join
679 (cons (search-input-file inputs "/lib/rt.jar")
680 (find-files (string-append
681 (assoc-ref inputs "ant-bootstrap")
682 "/lib")
683 "\\.jar$"))
684 ":"))
685 ;; This directive is not supported by our simple bootstrap JDK.
686 (substitute* (find-files "." "\\.java$")
687 (("@Override") ""))))
688 (replace 'build
689 (lambda* (#:key inputs #:allow-other-keys)
690 ;; We can't compile these yet, but we don't need them at this
691 ;; point anyway.
692 (delete-file "org/eclipse/jdt/core/JDTCompilerAdapter.java")
693 (delete-file-recursively "org/eclipse/jdt/internal/antadapter")
694
695 ;; Create a simple manifest to make ecj executable.
696 (mkdir-p "META-INF")
697 (with-output-to-file "META-INF/MANIFESTS.MF"
698 (lambda _
699 (display "Manifest-Version: 1.0
700Main-Class: org.eclipse.jdt.internal.compiler.batch.Main\n")))
701
702 ;; Compile it all!
703 (apply invoke "javac"
704 (find-files "." "\\.java$"))
705
706 ;; Pack it all up! We don't use "jar" here, because
707 ;; it doesn't produce reproducible zip archives.
708 ;; XXX: copied from (gnu build install)
709 (for-each (lambda (file)
710 (let ((s (lstat file)))
711 (unless (eq? (stat:type s) 'symlink)
712 (utime file 0 0 0 0))))
713 (find-files "." #:directories? #t))
714
715 ;; It is important that the manifest appears first.
716 (apply invoke "zip" "-0" "-X" "ecj-bootstrap.jar"
717 "META-INF/MANIFESTS.MF"
718 (delete "./META-INF/MANIFESTS.MF"
719 (find-files "." ".*" #:directories? #t)))))
720 (replace 'install
721 (lambda* (#:key outputs #:allow-other-keys)
722 (let ((share (string-append (assoc-ref outputs "out")
723 "/share/java/")))
724 (mkdir-p share)
725 (install-file "ecj-bootstrap.jar" share)))))))
726 (native-inputs
727 (list ant-bootstrap classpath-devel ecj-javac-wrapper-final jamvm
728 unzip zip))
729 (home-page "https://eclipse.org")
730 (synopsis "Eclipse Java development tools core batch compiler")
731 (description "This package provides the Eclipse Java core batch compiler
732for bootstrapping purposes. The @dfn{Eclipse compiler for Java} (ecj) is a
733requirement for all GNU Classpath releases after version 0.93. This version
734supports sufficient parts of Java 7 to build Icedtea 2.x.")
735 (properties '((hidden? . #t))) ;for bootstrapping purposes only
736 (license license:epl1.0)))
737
738(define-public ecj4-javac-wrapper
739 (package
740 (inherit ecj-javac-wrapper)
741 (native-inputs
742 (list guile-3.0 ecj4-bootstrap jamvm classpath-devel))))
743
744(define-public jamvm-with-ecj4
745 (package
746 (inherit jamvm)
747 (inputs
748 (modify-inputs inputs
749 (replace "ecj-javac-wrapper" ecj4-javac-wrapper)))
750 (properties
751 (alist-delete 'hidden? (package-properties jamvm)))))
752