系统环境:
14.04.1-Ubuntu
编译目标:
openjdk7u
编译步骤 :
1. 安装水银
apt-get install mercurial
2. 下载openjdk7部分源码
hg clone http://hg.openjdk.java.net/jdk7/jdk7
3. 下载openjdk7全部源码
cd jdk7
sh get_source.sh
注意,这一步经常会失败超时,多试几次,确保hotspot, langtools, corba, jaxws, jaxp, jdk. 这六个目录文件都正常。
4. 安装openjdk-6-jdk作为bootstrap JDK
apt-get install openjdk-6-jdk
5. 安装Certificate Authority File
apt-get install ca-certificates ca-certificates-java
6. 安装x11
apt-get install libxrender-dev libxext-dev libxtst-dev
7. 安装其他依赖
apt-get install libasound2-dev libcups2-dev libfreetype6-dev
4-7 合为一条命令:
apt-get install openjdk-6-jdk ca-certificates ca-certificates-java libxrender-dev libxext-dev libxtst-dev libasound2-dev libcups2-dev libfreetype6-dev
8. 设定环境变量和编译脚本
#!/usr/bin/env bash
export LANG=C
# 编译64位
export ARCH_DATA_MODEL=64
# 编译目标名称
export MILESTONE=test_build
# bootstrap jdk路径,需要在path中配置
export ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk-amd64/
export ALLOW_DOWNLOADS=true
export HOTSPOT_BUILD_JOBS=4
export ALT_PARALLEL_COMPILE_JOBS=4
export SKIP_COMPARE_IMAGES=true
# 输出路径
export ALT_OUTPUTDIR=/home/yourusername/jvm/build
unset JAVA_HOME
unset CLASSPATH
make 2>&1 | tee $ALT_OUTPUTDIR/build.log
9. 编译结果
#-- Build times ----------
Target all_product_build
Start 2019-08-29 18:01:24
End 2019-08-29 18:12:54
00:01:15 corba
00:03:29 hotspot
00:00:10 jaxp
00:00:13 jaxws
00:05:59 jdk
00:00:24 langtools
00:11:30 TOTAL
-------------------------
make[1]: Leaving directory `/ppt/openjdk/jdkb2'