sg3-utils: add newer buildable version
[openembedded.git] / classes / java-library.bbclass
1 # Inherit this bbclass for each java recipe that builds a Java library (jar file[s]).
2 #
3 # It automatically adds important build dependencies, defines JPN (Java Package Name)
4 # a package named ${JPN} whose contents are those of ${datadir}/java (the jar location).
5 #
6 # The JPN is basically lib${PN}-java but takes care of the fact that ${PN} already
7 # starts with "lib" and/or ends with "-java". In case the "lib" prefix is part of
8 # your package's normal name (e.g. liberator) the guessing is wrong and you have
9 # to set JPN manually!
10
11 inherit java
12
13 # use java_stage for native packages
14 JAVA_NATIVE_STAGE_INSTALL = "1"
15
16 def java_package_name(d):
17   import bb;
18
19   pre=""
20   post=""
21
22   pn = bb.data.getVar('PN', d, 1)
23   if not pn.startswith("lib"):
24     pre='lib'
25
26   if not pn.endswith("-java"):
27     post='-java'
28
29   return pre + pn + post
30
31 JPN ?= "${@java_package_name(d)}"
32
33 DEPENDS_prepend = "virtual/javac-native fastjar-native "
34
35 PACKAGES = "${JPN}"
36
37 PACKAGE_ARCH_${JPN} = "all"
38
39 FILES_${JPN} = "${datadir_java}"
40
41 # File name of the libraries' main Jar file
42 JARFILENAME = "${BP}.jar"
43
44 # Space-separated list of alternative file names.
45 ALTJARFILENAMES = "${BPN}.jar"
46
47 # Java "source" distributions often contain precompiled things
48 # we want to delete first.
49 do_removebinaries() {
50   find ${WORKDIR} -name "*.jar" -exec rm {} \;
51   find ${WORKDIR} -name "*.class" -exec rm {} \;
52 }
53
54 addtask removebinaries after do_unpack before do_patch
55
56 java_install() {
57   oe_jarinstall ${JARFILENAME} ${ALTJARFILENAMES}
58 }
59
60 do_install() {
61   java_install
62 }
63
64 java_stage() {
65   oe_jarinstall -s ${JARFILENAME} ${ALTJARFILENAMES}
66 }
67
68 do_stage() {
69   java_stage
70 }