From Fedora Project Wiki

m (Packaging/GCJGuidelines moved to Packaging:GCJGuidelines: Moving Packaging Pages to Packaging Namespace)
(Deprecate this page.)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<!-- page was renamed from PackagingDrafts/GCJGuidelines
This page is completely obsolete.
-->
= GCJ Guidelines =


GCJ AOT bits '''SHOULD''' be built and included in packages.  If GCJ-specific issues prevent you from building the package, it is permissible to simply omit GCJ support and build using OpenJDK.  However, please file a bug against the <code>gcc</code> component in Red Hat bugzilla. Compilation into native code must be optional and enabled by default, if present.
[[Category: Packaging guidelines]]
 
In some rare cases Java packages might not contain any executable code whatsoever so AOT-compiling for gcj would not be required.  An example of such a package would be one that contained only annotation definitions.
 
{| border="1"
|-
| {{Template:Warning}} Note:  For Fedora versions < 8, no JDK was available other than GCJ so java packages with executable code '''MUST''' have the GCJ AOT bits.
|}
 
== How to add GCJ AOT bits to a Java package ==
Like other Java runtimes, libgcj can load classes from bytecode class files.  Unlike other Java runtimes, libgcj can also load classes that have been compiled to native machine code using GCJ.
 
* For packages in which all JAR files are in the main package:
 
1. Add the following definition: <pre>
%define with_gcj %{!?_without_gcj:1}%{?_without_gcj:0}
</pre>
1. Conditionalize dependencies and be architecture dependent <pre>
%if %{with_gcj}
BuildRequires:    java-gcj-compat-devel >= 1.0.31
Requires(post):  java-gcj-compat >= 1.0.31
Requires(postun): java-gcj-compat >= 1.0.31
%else
BuildArch:      noarch
%endif
</pre>
1. Add the following to the end of <code>%install</code> section:<pre>
%if %{with_gcj}
%{_bindir}/aot-compile-rpm
%endif
</pre>
1. Add the following to the package's <code>%post</code> and <code>%postun</code> sections, creating the sections if necessary:<pre>
%if %{with_gcj}
if [ -x %{_bindir}/rebuild-gcj-db ]  
then
%{_bindir}/rebuild-gcj-db
fi
%endif
</pre>
1. Add the following to the <code>%files</code> section:<pre>
%if %{with_gcj}
%attr(-,root,root) %{_libdir}/gcj/%{name}
%endif
</pre>
 
* For packages in which all JAR files are in one subpackage, the <code>Requires()</code>, <code>%post</code>, <code>%postun</code> and <code>%files</code> lines should refer to that subpackage.
 
* For packages in which more than one subpackage (including the main package) contains JAR files, then each subpackage should have its own <code>Requires()</code>, <code>%post</code> and <code>%postun</code> lines, and the <code>%files</code> lists should be split such that the subpackage that contains <code>/path/to/foo-x.y.z.jar</code> should have the following <code>%files</code> line:
<pre>
%if %{with_gcj}
%attr(-,root,root) %{_libdir}/gcj/%{name}/foo-x.y.z.jar.*
%endif
</pre>  Note that the path has been stripped and <code>.*</code> has been appended.

Latest revision as of 20:05, 21 December 2018

This page is completely obsolete.