| C H A P T E R 4 |
|
Quick Start: Building on Linux for ARM |
This chapter is about cross-compiling, where you build the Java Wireless Client software on a Linux desktop computer but run it on a device with an ARM processor.
Linux builds come in two flavors:
This chapter describes how to perform the linux_fb_gcc build for an ARM processor.
This chapter is based on example scripts that help you run the different parts of the build. The scripts are available in docs/build-scripts/linux-arm. Once you have everything set up, run the scripts to perform the build. Work along as you read through the chapter to understand how it all fits together.
Most of the time, Linux already has most of the tools you need. These examples show how to find out if you have these tools available. If you do not, you will need to install the appropriate tools and adjust your PATH to include them.
$ make --version
GNU Make 3.80
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.
$
On your computer, GNU Make might be gmake instead of make.
$ gcc --version
3.3.1
$
$ java -version
java version "1.4.2_08"
Java(TM) 2 Runtime Environment, Standard Edition
(build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
$ javac
Usage: javac <options> <source files>
where possible options include:
...
$
Each of the build scripts in the rest of this chapter operate by setting up, doing some work, and cleaning up.
The setting up script is setup.sh and the cleaning up script is teardown.sh.
This script is available as docs/build-scripts/linux-arm/setup.sh.
The Acme variable is the top level of the Java Wireless Client software. Adjust the value to point to the top level of your own installation. Also, make sure JDK_DIR points to the top directory of your JDK. Finally, adjust GNU_TOOLS_DIR to point to the installation directory of your GCC cross compiler.
Don't run setup.sh yet. It will be used by the build scripts in the rest of this chapter.
You do not need to modify this script.
The first step is to build PCSL. You have to do this twice to generate all the output that CLDC will need when you build it. First you need to build PCSL for linux_i386_gcc. Then you build PCSL for linux_arm_gcc.
Tell PCSL the target platform and where to put output files. Set PCSL_PLATFORM to linux_i386_gcc first, then linux_arm_gcc. Tell PCSL where to put its output files with the PCSL_OUTPUT_DIR variable.
In addition, because you are cross-compiling for another platform, tell the PCSL build where to find the cross compiler by setting GNU_TOOLS_DIR.
This script, build-pcsl.sh, that performs the build:
This script uses the setup.sh and teardown.sh script from before.
A series of build messages will be displayed, with a message at the end about the success of the PCSL build.
The output goes in $Acme/output/pcsl. Take a look:
/home/jonathan> ls jwc/output/pcsl linux_arm linux_i386 /home/jonathan> ls jwc/output/pcsl/linux_arm inc lib obj /home/jonathan> |
CLDC is built on top of PCSL. Tell CLDC to use PCSL by setting ENABLE_PCSL to true, and specify where to find PCSL with PCSL_OUTPUT_DIR.
In addition, the CLDC build system expects you to define various environment variables as follows:
Define GNU_TOOLS_DIR just like for the PCSL build.
The following script, build-cldc.sh, runs the CLDC build.
Go ahead and give it a try with sh build-cldc.sh. Wait for a success message at the end of the build, and take a look at the generated files in output/cldc.
The last step in creating a Java Wireless Client software stack is building MIDP and optional APIs. This chapter describes how to build MIDP only. Later chapters describe how to include optional APIs in this part of the build and the many variables you can use to change how Java Wireless Client software is built.
For now, build MIDP using the CLDC and PCSL output you already generated.
You need JDK_DIR defined, just as it was for the CLDC build. In addition, you must tell the MIDP build where to find PCSL and CLDC:
The first thing that happens with the MIDP build is that tools are created for use later in the build. Use TOOLS_DIR to point to the tools directory.
Set TARGET_CPU to arm to tell the build system the type of target processor.
Finally, set MIDP_OUTPUT_DIR to the location that will contain the output of the build.
Run the build from the midp/build/linux_fb_gcc directory. Here is a script, build-sjwc.sh, that sets the necessary variables and runs the MIDP build:
Run sh build-sjwc.sh without modifying the script. Wait until you see the message sjwc_status=OK at the end of the build. Congratulations! You've just built a complete MIDP stack.
Now what do you do with it? To run the software, copy the following three directories to your Linux ARM hardware:
Now run the Java Wireless Client software with bin/arm/usertest.
The Java Wireless Client software runs on the device screen.
FIGURE 4-1 Application Manager
Copyright © 2007, Sun Microsystems, Inc. All rights reserved. SUN PROPRIETARY/CONFIDENTIAL.