Building the BSD port of OpenJDK, Java 1.7 on Max OS X 10.6.2
This content began its life at http://confluence.concord.org/display/CCTR/Build+OpenJDK+Java+1.7.0+on+Mac+OS+X+10.5, but should be annotated and extended as we learn more. See the BSD-Port mailing list for information.
Dependencies
SoyLatte 32-bit Java 1.6 binaries
One can use Landon Fuller's SoyLatte 32-bit Java 1.6 binaries to build the OpenJDK bsd port. After downloading the binaries, copy the whole directory to /usr/local/soylatte16-i386-1.0.3
Test the SoyLatte install:
$ /usr/local/soylatte16-i386-1.0.3/bin/java -version java version "1.6.0_03-p3" Java(TM) SE Runtime Environment (build 1.6.0_03-p3-landonf_19_aug_2008_14_55-b00) Java HotSpot(TM) Server VM (build 1.6.0_03-p3-landonf_19_aug_2008_14_55-b00, mixed mode)
Mercurial
Assuming you have MacPorts installed:
$ sudo port install mercurial +bash_completion
Test the mercurial install:
$ hg --version Mercurial Distributed SCM (version 1.1.2) Copyright (C) 2005-2008 Matt Mackall <mpm@selenic.com> and others This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Forest extension to Mercurial
This is the canonical source for the Forest extension:
$ hg clone http://hg.akoha.org/hgforest
You can also use Patrick Mézard's clone of hgforest instead (just a couple of fixes to Simon's work):
$ hg clone http://bitbucket.org/pmezard/hgforest-crew
After cloning hgforest-crew add an hgext.forest item with the path to hgforest-crew/forest.py in the extensions section in your ~/.hgrc file.
Here's my ~/.hgrc file:
$ cat ~/.hgrc [ui] username = Stephen Bannasch <stephen.bannasch@gmail.com> [extensions] hgext.forest=/Users/stephen/dev/mercurial/hgforest-crew/forest.py mq= hgk= fetch= [hgk] path=/opt/local/share/mercurial/contrib/hgk [diff] nodates=1 git=1
or one may just do:
$ sudo port install hg-forest $ cat ~/.hgrc [extensions] forest= fetch=
FreeType
The build fails with the message: <code>FreeType version 2.3.0 or higher is required.</code>
Checkout the code using hg/forest.
$ hg fclone http://hg.openjdk.java.net/bsd-port/bsd-port
Here's what my bsd-port dir looks like:
$ cd bsd-port/ $ ls -l total 528 -rw-r--r-- 1 stephen staff 1503 Dec 15 12:29 ASSEMBLY_EXCEPTION -rw-r--r-- 1 stephen staff 19241 Dec 15 12:29 LICENSE -rw-r--r-- 1 stephen staff 16336 Dec 15 12:29 Makefile -rw-r--r-- 1 stephen staff 1207 Dec 15 12:29 README -rw-r--r-- 1 stephen staff 87215 Jan 25 23:04 README-builds.html -rw-r--r-- 1 stephen staff 127532 Dec 15 12:29 THIRD_PARTY_README drwxr-xr-x 4 stephen staff 136 Jan 26 00:51 build -rwxr--r--@ 1 stephen staff 373 Jan 26 03:00 build.sh drwxr-xr-x 11 stephen staff 374 Jan 25 23:06 corba drwxr-xr-x 13 stephen staff 442 Jan 25 23:06 hotspot drwxr-xr-x 11 stephen staff 374 Jan 25 23:06 jaxp drwxr-xr-x 11 stephen staff 374 Jan 25 23:06 jaxws drwxr-xr-x 12 stephen staff 408 Jan 25 23:07 jdk drwxr-xr-x 12 stephen staff 408 Jan 25 23:07 langtools drwxr-xr-x 18 stephen staff 612 Dec 15 12:29 make
Build OpenJDK
I added the script build.sh to keep track of the correct build invocation. The version below is adapted from Kurt Millers email here. Edit the paths to fit your dir structure. This script needs to be run with the source command.
$ cat build.sh # source build.sh env \-i PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin \ make \ ALT_BOOTDIR=/usr/local/soylatte16-i386-1.0.3/ \ ALT_FREETYPE_HEADERS_PATH=/usr/X11R6/include \ ALT_FREETYPE_LIB_PATH=/usr/X11R6/lib \ ALT_JIBX_LIBS_PATH=/Users/stephen/dev/java/jibx/lib \ ANT_HOME=/usr/share/ant \ NO_DOCS=true \ HOTSPOT_BUILD_JOBS=1
Build openjdk like this:
$ source build.sh
One person reports: "This takes about 10m on my 2.5 GHz Intel Core 2 Duo MacBook Pro." Please check with the BSD-Port mailing list if you encounter problems.
Error Recovery
Try cleaning if you get errors.
Some errors when compiling are fixed by cleaning. You can temporarily add the clean command to the end of build.sh and source it to clean the build products.
Or you can try this suggestion from Kurt Miller:
$ mv build build.del; rm -rf build.del &
X11 is needed for build.
If you have not installed this with Mac OS X, or have deleted it, you need to install it. A copy can be obtained from http://xquartz.macosforge.org/trac/wiki/X112.4.0.
Update the bsd-port directory
If updates have been made to the tree, perhaps to fix a bug, you can update your sources with:
cd bsd-port ; hg fpull -u
Other Build Failures
I am not sure what can be done about this. My build.sh script has "ALT_FREETYPE_HEADERS_PATH=/opt/local/include/freetype2 ALT_FREETYPE_LIB_PATH=/opt/local/lib" and these seem to be where the headers and libraries are located....
WARNING: This build does not include running javadoc.\n ERROR: FreeType version 2.3.0 or higher is required. \n /bin/mkdir -p /Users/ray/Projects/OpenJDK/bsd-port/build/bsd-i586/btbins rm -f /Users/ray/Projects/OpenJDK/bsd-port/build/bsd-i586/btbins/freetype_versioncheck Failed to build freetypecheck. \n Exiting because of the above error(s). \n make: *** [post-sanity] Error 1
Smoketest
If the build completes do a simple test by asking the JVM to print its version info. It should look something like this:
$ ../build/bsd-i586/j2sdk-image/bin/java -version openjdk version "1.7.0-internal" OpenJDK Runtime Environment (build 1.7.0-internal-stephen_2009_01_25_23_54-b00) OpenJDK Server VM (build 14.0-b10, mixed mode)
Then, see how to switch java versions on Mac OS X.