Building JSim From Source
Introduction
This page describes how JSim source code is structured, and how to build a JSim binary distribution from that source code. JSim source code may currently be obtained in two ways: the JSim open source distribution or the NSR CVS archive. The latter is available only to NSR collaborators. There are minor differences in the build procedure depending upon which method of source code access you use, which are noted in this document. Use of JSim source code must be in accordance with the LICENSE file found in the distribution root directory.
NOTE: This document is currently undergoing changes related to the upcoming shared source distribution (version 1.6.70).
Contents:
- Version numbers
- Source distribution content
- Building the complete JSim source distribution
- Creating a JSim binary distribution
- The JSim Verification Suite
- Debugging tips
- Building JSim native libraries only
Version numbers:
JSim version numbers are of the form 1_6_## for public and beta releases and 1_6_##alpha# for alpha (highly preliminary) releases, where the # are integers. All copies of public and beta releases should be built from identical source, however alpha releases may vary depending on which developer was working on the code. Bug reports should only be sent for public and beta releases.
Source distribution contents:
- README - start here
- LICENSE - licensing agreement, READ BEFORE USE !!!
- JSim/ - JSim's java and non-java source code
- home/ - static contents of $JSIMHOME (no local classes)
- lib/ - embedded java compilers for Java 1.4 and 1.5
- build/ - build, test and distribution scripts
- linux/ - linux OS specific directory
- macos/ - Macintosh OS X specific directory
- win32/ - Windows OS specific directory
- unix/ - Common material for Unix-based OS'es (non Windows)
- third/ - misc 3rd party contributions to JSim
- fpack/ - JSim Fortran package of XSIM-compatible models (available via CVS access only)
- VERIFY/ - verification suite (available via CVS access only)
Contents of OS specific directories. When multiple chip-architectures are supported for an OS, these files may be repeated for each architecture:
- jre.zip - Java Run-time distribution (available via CVS access only)
- jre.notes - information on how jre.zip was created
- jsrun.skel - skeleton for distributed jsim, jsbatch & jsserver
- bin/ - OS-specific launch scripts
- lib/ - OS-specific libraries
- JSim.app/ - (Mac only) template for application bundle
Building the complete JSim source distribution:
The following build process assumes you have a Unix-like environment with C and Fortran compilers, the make utility, with Sun's java developer kit. Amoung JSim platforms, this assumption is violated only by Windows . Here JSIMOS will refer to the appropriate operating system (linux, macos, win32), JSIMARCH will refer to the hardware architecture (i386, amd64, ia64, ppc). Java SDK, make, gcc and gfortran are expected to be available. Versions used for NSR binary distributions are:
- all OS - Java SDK 1.4 or 1.5, see JSIMOS/jre.notes for additional details.
- linux_i386 - Redhat EL, gcc 4.2.0, gfortran 4.2.0
- linux_amd64 - Linux 2.6.9, gcc 4.1.1, gfortran 4.1.1
- linux_ia64 - Redhat 7.2, gcc 4.1.1, gfortran 4.1.1
- macos_ppc - Darwin 8.7.0, gcc 4.0.0, gfortran 4.2.0
- macos_i386 - Darwin 8.7.1, gcc 4.0.1, gfortran 4.2.0
- win32 - need info here
Set environment variables:
- JSIMSDK = your Java SDK (e.g. /usr/local/jdk). For NSR production builds, a version of Sun's Java 1.4 SDK is used.
- JSIMJRE = Java JRE, if different from SDK. If not present, this defaults to your JSIMSDK. Currently JSim distribs are built with Java 1.4, but distributed with Java 1.5 on most platforms. This variable is new with JSim 1.6.68. For NSR production builds, a version of Sun's Java 1.5 SDK is used on all platforms that support it (all except IA64). Specifying /Library/Java/home under MacOS will use 1.5 if it is available.
- JSIMSRC = the absolute path of the source distribution.
- PATH = should include $JSIMSRC/build so the build scripts will work properly.
- Note: JSIMOS, JSIMARCH, JSIMG2CLIB variables that had to be set in earlier JSim releases no longer need to be set by the user.
Customize makefiles:
- OS-specific makefiles may be found in $JSIMSRC/home/lib. The distributed versions are set up for NSR file systems. You may need to modify them for the location of compilers and libraries on your system.
Build JSim via "jsbuild.all":
- Note any error messages.
- The non-java build gives messy messages, even if it works.
- If you're modifying source code, examine this script and others in build/ to see how they work.
If you have CVS access, you may also build the fpack models via jsbuild.fpack. There will be some warning messages which have not caused any known problems.
Native libraries created during a JSim build are placed in an architecture specific directory in $JSIMSRC/NATIVE. This directory will be named either OS or OS_ARCH when OS is the operating system, and ARCH is the hardware architecture.
$JSIMSRC/build contains debug versions of the JSim programs jsim, jsbatch, jsfim and jsserver, each with the suffix .db. These versions should run correctly after a successful build.
On Macintosh, a single jsbuild.all will create either macos_i386 or macos_ppc, depending upong the local architecture. To create macos fat (universal i386 + ppc) libraries run jsbuild.all twice, once on each architecture, and place both macos_i386 and macos_ppc in $JSIMSRC/NATIVE. Then run jsbuild.fat to create the fat libraries in $JSIMSRC/NATIVE/macos. Set shell variable JSIMFAT=yes to allow the .db programs to access the fat libraries.
Creating a JSim Binary Distribution
This section describes creating a JSim binary distribution .zip file, which allows you to distribute your JSim build (see previous section) to others. Such distributions must be in accordance with license terms (above).
Examine jsbuild.osarch to determine the appropriate OSARCH strings for your distribution, e.g. linux_i386, linux_amd64, linux_ia64, macos, macos_i386, macos_ppc, win32.
Find the jre.notes file appropriate for your OSARCH and make sure a corresponding jre.zip exists in the same directory. This step is not required for:
- Macintosh distributions, which use the OS's built-in JRE;
- those with NSR CVS access, since the appropraite jre.zip is part of the CVS archive.
Run "jsdist.bin OSARCH". This will create a new .zip file in $JSIMSRC/DIST named for the JSim version number and OSARCH.
The JSim Verification Suite
$JSIMSRC/VERIFY contains verification scripts for JSim computations. See instructions in that directory. Run ". jsverify.env src" before running verify scripts to verify the debug version, or ". jsverify.env $JSIMHOME" to verify a binary distribution.
This suite is currently available only to those with NSR CVS access. In the future, we hope to provide an open source version of this suite, however it is not ready for prime time yet.
Debugging Tips
Since JSim is a complex multi-language and multi-threaded application, step-by-step program tracing has fairly limited utility. Most debugging here at NSR is done with the insertion of print and stack dump commands in appropriate code. Nevertheless, debuggers can be of use. The following is an example of a jdb session used to find the source of an infinite loop:
bash
. jsbuild.path
jdb $JSIMARGS
run JSim.gui.GLaunch -f problem.proj
... interact with GUI to cause infinite loop ...
threads // list running threads
suspend 0x65 // name of suspect thread
where 0x65
Building JSim Native Libraries Only
This section is for the NSR JSim distributions administrator only.
JSim distribution from NSR use archived native libraries for win32 and macos. These libraries must be remade and rearchived whenever changes are made to files in the JSim/nonJava directory. The process is outlined below, with special notes for each operating system following:
- Install appropriate 3rd party tools (see below). sh, make, gcc, gfortran and make should be available. A Java SDK is not required to build native libraries.
- CVS commit a Linux internal release.
- Run "jsdist.natsrc" to create a native source release with prebuilt java classes (JSimClient.jar and JSimServer.jar). Unpack the distribution on the target host.
- Set environment as above. Set JSIMSDK to dummy location, it is not needed for native library build. Set JSIMJAR to location of JSim.jar in the native source distribution.
- Run "jsbuild.native" to generate the native libraries.
- Run "jsbuild.fpack" to generate FPack libraries.
- For MacOS, "jsbuild.fat" builds fat (i386+ppc) libraries from individual i386 and ppc builds. These are used in the Universal binary version of JSim for MacIntosh.
- Use jsbatch.db and jsim.db for testing, as needed. On MacIntosh, define JSIMFAT=yes to test the fat libraries instead of the chip-specific versions.
- Updated native libraries (in JSim/nonJava/ subdirectories, extension .dll for win32, .dylib and .jnilib for macos) should be copied to the NSR CVS archive (JSim/win32/lib and JSim/macos/lib).
Notes for Windows
JSim development under Windows requires the the GNU/Cygwin tools. cygwin.dll is GPL'ed, so the JSim native libraries are created using -mno-cygwin switch to prevent linking to it. Since Sun's SDK is a native windows application, which doesn't utilize cygwin, it is awkward to use existing build scripts to build the java classes.
[This page was last modified 03Mar08, 3:11 pm.]
Model development and archiving support at physiome.org provided by the following grants: NIH/NHLBI T15 HL88516-01 Modeling for Heart, Lung and Blood: From Cell to Organ, 4/1/07-3/31/11; NSF BES-0506477 Adaptive Multi-Scale Model Simulation, 8/15/05-7/31/08; NIH/NHLBI R01 HL073598 Core 3: 3D Imaging and Computer Modeling of the Respiratory Tract, 9/1/04-8/31/09; as well as prior support from NIH/NCRR P41 RR01243 Simulation Resource in Circulatory Mass Transport and Exchange, 12/1/1980-11/30/01 and NIH/NIBIB R01 EB001973 JSim: A Simulation Analysis Platform, 3/1/02-2/28/07.
