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_DIR_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 -o -h $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.
97 # Note: In order to encourage usage of the DEPENDS variable, the function
98 # can accept recipe names. If a recipe has no corresponding Jar file it
99 # is ignored. Be careful with recipes where the recipe name is different
100 # from the the Jar file name!
108 while [ "$#" -gt 0 ]; do
111 # take jar files from native staging if this is a -native recipe
112 if [ ${PACKAGE_ARCH} = ${BUILD_ARCH} ]; then
113 dir=${STAGING_DATADIR_JAVA_NATIVE}
115 dir=${STAGING_DATADIR_JAVA}
119 oefatal "oe_makeclasspath: unknown option: $1"
124 if [ -e $file ]; then
125 classpath=$classpath$delimiter$file
134 eval $retval="$classpath"
137 # Creates a simple wrapper script for your Java program.
138 # The script is written to ${PN} by default.
140 # Parameters are as follows:
141 # [options] <output file> <main class> [jar files ...]
144 # -o <name> where name is the output file name
146 # It can only take jar files from ${datadir_java}!
147 oe_java_simple_wrapper() {
153 while [ "$#" -gt 0 ]; do
160 oefatal "oe_java_simple_wrapper: unknown option: $1"
165 classpath=$classpath$delimiter${datadir_java}/$1
175 oenote "Creating simple Java wrapper script"
176 oenote "Output File: $output"
177 oenote "Main Class: $mainclass"
178 oenote "Classpath: $classpath"
180 echo "#!/bin/sh" > $output
181 echo "# This file is autogenerated by the oe_java_simple_wrapper function of OpenEmbedded" >> $output
183 echo "# You can provide additional VM arguments by setting the VMARGS environment variable." >> $output
184 echo "CLASSPATH_ARG=\"-cp $classpath\"" >> $output
186 echo "MAIN_CLASS=$mainclass" >> $output
188 echo "# Allows overriding the VM by setting the JAVA environment variable." >> $output
189 echo "if [ x\${JAVA} = x ]" >> $output
190 echo "then" >> $output
191 echo " JAVA=java" >> $output
194 echo "exec \${JAVA} \${VMARGS} \${CLASSPATH_ARG} \${MAIN_CLASS} \${@}" >> $output