1 # Defines the commonly used target directories and provides a convenience
2 # function to install jar files.
4 # All the default directory locations herein resemble locations chosen in
5 # the Debian distribution.
7 # Jar location on target
8 datadir_java ?= ${datadir}/java
10 # JNI library location on target
11 libdir_jni ?= ${libdir}/jni
13 # JVM bundle location on target
14 libdir_jvm ?= ${libdir}/jvm
16 STAGING_DATADIR_JAVA ?= ${STAGING_DATADIR}/java
17 STAGING_LIBDIR_JNI ?= ${STAGING_LIBDIR}/jni
18 STAGING_LIBDIR_JVM ?= ${STAGING_LIBDIR}/jvm
20 STAGING_DATADIR_JAVA_NATIVE ?= ${STAGING_DATADIR_NATIVE}/java
21 STAGING_LIBDIR_JNI_NATIVE ?= ${STAGING_LIBDIR_NATIVE}/jni
22 STAGING_LIBDIR_JVM_NATIVE ?= ${STAGING_LIBDIR_NATIVE}/jvm
25 # Purpose: Install a jar file and create all the given symlinks to it.
27 # oe_jarinstall foo-1.3.jar foo.jar
28 # Installs foo-1.3.jar and creates symlink foo.jar.
30 # oe_jarinstall -s foo-1.3.jar foo.jar
31 # Installs foo-1.3.jar to staging and creates symlink foo.jar.
33 # oe_jarinstall -r foo-1.3.jar foo_1_3.jar foo.jar
34 # Installs foo_1_3.jar as foo-1.3.jar and creates a symlink to this.
36 dir=${D}${datadir_java}
38 while [ "$#" -gt 0 ]; do
41 # put jar files to native staging if this is a -native recipe
42 if [ ${PACKAGE_ARCH} = ${BUILD_ARCH} ]; then
43 dir=${STAGING_DATADIR_JAVA_NATIVE}
45 dir=${STAGING_DATADIR_JAVA}
53 oefatal "oe_jarinstall: unknown option: $1"
63 destname=${destname:-`basename $jarname`}
67 install -m 0644 $jarname $dir/$destname
69 # Creates symlinks out of the remaining arguments.
70 while [ "$#" -gt 0 ]; do
71 if [ -e $dir/$1 ]; then
72 oewarn "file was in the way. removing:" $dir/$1
75 ln -s $destname $dir/$1
81 # Purpose: Generate a classpath variable from the given Jar file names
82 # where the ".jar" has been omitted. The string is stored in the script
83 # variable whose name is given in the first argument to this function.
85 # oe_makeclasspath cp foo baz bar
86 # Stores ${datadir_java}/foo.jar:${datadir_java}/baz.jar:${datadir_java}/bar.jar
89 # oe_makeclasspath bootcp -s foo baz bar
90 # Stores ${STAGING_DATADIR_JAVA}/foo.jar:${STAGING_DATADIR_JAVA}/baz.jar:${STAGING_DATADIR_JAVA}/bar.jar
91 # in variable "bootcp".
93 # Provide the -s at the beginning otherwise strange things happen.
94 # If -s is given the function checks whether the requested jar file exists
95 # and exits with an error message if it cannot be found.
104 while [ "$#" -gt 0 ]; do
107 # take jar files from native staging if this is a -native recipe
108 if [ ${PACKAGE_ARCH} = ${BUILD_ARCH} ]; then
109 dir=${STAGING_DATADIR_JAVA_NATIVE}
111 dir=${STAGING_DATADIR_JAVA}
115 oefatal "oe_makeclasspath: unknown option: $1"
120 if [ -z "$dir" -a ! -f $file ]; then
121 oefatal "oe_makeclasspath: Jar file for '$1' not found at $file"
124 classpath=$classpath$delimiter$file
131 eval $retval="$classpath"
134 # Creates a simple wrapper script for your Java program.
135 # The script is written to ${PN} by default.
137 # Parameters are as follows:
138 # [options] <output file> <main class> [jar files ...]
141 # -o <name> where name is the output file name
143 # It can only take jar files from ${datadir_java}!
144 oe_java_simple_wrapper() {
150 while [ "$#" -gt 0 ]; do
157 oefatal "oe_java_simple_wrapper: unknown option: $1"
162 classpath=$classpath$delimiter${datadir_java}/$1
172 oenote "Creating simple Java wrapper script"
173 oenote "Output File: $output"
174 oenote "Main Class: $mainclass"
175 oenote "Classpath: $classpath"
177 echo "#!/bin/sh" > $output
178 echo "# This file is autogenerated by the oe_java_simple_wrapper function of OpenEmbedded" >> $output
180 echo "# You can provide additional VM arguments by setting the VMARGS environment variable." >> $output
181 echo "CLASSPATH_ARG=\"-cp $classpath\"" >> $output
183 echo "MAIN_CLASS=$mainclass" >> $output
185 echo "# Allows overriding the VM by setting the JAVA environment variable." >> $output
186 echo "if [ x\${JAVA} = x ]" >> $output
187 echo "then" >> $output
188 echo " JAVA=java" >> $output
191 echo "exec \${JAVA} \${VMARGS} \${CLASSPATH_ARG} \${MAIN_CLASS} \${@}" >> $output