Ubuntu10.04下build OpenJDK7 的过程

 

http://happyenjoylife.iteye.com/blog/858147

 

Ubuntu10.04下build OpenJDK7 的过程


1. 安装mercurial
Mercurial是一个版本管理工具。
sudo apt-get install mercurial

安装mercurial的扩展,添加fclone在支持
hg clone http://bitbucket.org/pmezard/hgforest-crew

将以下内容添加到$HOME/.hgrc文件中,如果没有则自己创建一个:
[extensions]
forest=/home/daren/hgforest-crew/forest.py
fetch=

2. 下载jdk7源码
hg fclone http://hg.openjdk.java.net/jdk7/jdk7

3. 安装gcc、g++、make等
sudo apt-get install build-essential

4. 安装XRender
sudo apt-get install libxrender-dev
sudo apt-get install xorg-dev

5. 安装alsa
sudo apt-get install libasound2-dev

6. Cups
sudo apt-get install libcups2-dev

7. 安装jdk6

8. 安装ant
设置ANT_HOME
9. 安装findbugs
编译需要这玩意儿有点奇怪。需要设置FINDBUGS_HOME

10. 测试编译
export LANG=C ALT_BOOTDIR=/opt/jdk1.6.0_22/
#删除JAVA_HOME
export -n JAVA_HOME
export ALT_JDK_IMPORT_PATH=/opt/jdk1.6.0_22/
make sanity BUILD_JAXWS=false BUILD_JAXP =false

在build BUILD_JAXWS和BUILD_JAXP总是提示找不到源文件,而我又暂时对只对JDK、Hotspot感兴趣,所以索性把这两个给去掉。

如果出现:Sanity check passed.则表示测试编译通过了,不过也别开心得太早,真正make的时候不保证一定没问题,也许还会缺少某些依赖。

11. 编译
export LANG=C ALT_BOOTDIR=/opt/jdk1.6.0_22/
#删除JAVA_HOME
export -n JAVA_HOME
export ALT_JDK_IMPORT_PATH=/opt/jdk1.6.0_22/
#make BUILD_JAXWS=false BUILD_JAXP=false
#make DEBUG_NAME=fastdebug BUILD_JAXWS=false BUILD_JAXP=false
make DEBUG_NAME=all_fastdebug BUILD_JAXWS=false BUILD_JAXP=false

 

 

 

More Reference

 

http://feralchicken.wordpress.com/2009/02/20/building-openjdk-under-ubuntu/

 

Building OpenJDK under Ubuntu

Shame: There was a typo in the command to clone jdk7 from the repo. The command below is now correct. Apologies for the confusion :(

Manually building a large project really gives me an appreciation for how well the portage system in Gentoo automates the build process. To think that the process of pulling in dependencies, getting the source, applying patches, configuring, building, and merging binaries into a live system is executed by contributed ebuild scripts is very amazing, especially when you see it all before your very eyes. Unfortunately, searching for dependencies and setting up your build environment can be hectic, and the less patient miss out on an awesome experience.

This guide is dedicated to building OpenJDK entirely from the command line under Ubuntu 8.04. Assume all commands are executed in the directory where we will do all our work. Also, don’t forget to replace the instances of atsui (my username) with your own :P

Install and configure Mercurial

First we’ll set up Mercurial, a distributed source control tool.

sudo apt-get install mercurial

We also want to set up Forest, an Mercurial extension that will let us recursively pull the entire OpenJDK from the repository. This command uses Mercurial to grab the extension and put it under the forest folder, which contains a python script we want called forest.py .

1 hg clone http: / / bitbucket.org / pmezard / hgforest - crew forest

Paste the following into .hgrc under your home directory to set up Forest.

[ui]
username = atsui
[extensions]
forest=/path/to/forest.py
fetch=

You can check it works by typing in a command provided by Forest, eg.

hg fclone

Clone a copy of OpenJDK

Now let’s grab the JDK! This command puts everything in jdk7 :

hg fclone http://hg.openjdk.java.net/jdk7/jdk7 jdk7

Fetch the binary plugs

OpenJDK still depends on some closed source blobs, which can be acquired and unpacked as follows:

1 wget http: / / www.java.net / download / openjdk / jdk7 / promoted / b48 / jdk - 7 - ea - plug - b48 - linux - i586 - 19_feb_2009 .jar
2  
3 # accept the license agreement and install to cwd
4 java - jar jdk - 7 - ea - plug - b48 - linux - i586 - 19_feb_2009 .jar

Judging from the filename, perhaps this is frequently updated. Check out the downloads for the latest file.

Install library dependencies

Building from source often happens against various other libraries. Here is some of what I found was needed:

1 sudo apt - get install build - essential gawk libasound2 - dev libfreetype6 - dev libcups2 - dev libxt - dev libx11 - dev libxtst - dev

Configure the build environment

These commands will configure the build environment, but you should manually check your environment variables and unset anything related to java ! A mysterious problem I ran into on my Gentoo box had to do with the fact that although I had unset JAVA_HOME and CLASSPATH , which the makefile checks for, I still had JAVAC and JDK_HOME set, which caused some mysterious hidden package errors. Find them and unset them before you build. The last command will check to see if the environment is reasonably prepared.

1 export ALT_BOOTDIR = / usr / lib / jvm / java - 6 - sun
2 export ALT_BINARY_PLUGS_PATH = / path / to / openjdk - binary - plugs
3 export LANG = "C"
4 unset JAVA_HOME
5 unset CLASSPATH
6 cd jdk7
7 make sanity

Build OpenJDK

This will start the build, which may halt on missing dependency errors.

make

Watch 24

Go and enjoy an episode of 24 . Actually, the build takes a little longer than the time of one episode, so maybe you can make some popcorn while you’re at it.

With any luck, you will see this when you come back:

Control linux i586 1.7.0-internal build_product_image build finished:
Control linux i586 1.7.0-internal all_product_build build finished:
Control linux i586 1.7.0-internal all build finished:

You can then run

build/linux-i586/bin/java -version

to test your freshly baked OpenJDK, which should give something like

openjdk version "1.7.0-internal"
OpenJDK Runtime Environment (build 1.7.0-internal-atsui_2009_02_20_21_40-b00)
OpenJDK Client VM (build 15.0-b01, mixed mode)

Hopefully, that was pretty painless. Enjoy :)

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值