Sunday, February 6, 2011

Building OpenJDK 7 (openjdk-7-ea-src-b105-13_aug_2010) On Windows [Service Pack 3, Version 5.1]

Building OpenJDK 7 (openjdk-7-ea-src-b105-13_aug_2010) On Windows [Service Pack 3, Version 5.1]


Source used: openjdk-7-ea-src-b105-13_aug_2010
Local Path Source: Windows path "E:\dev\jdk7\openjdk-7-ea-src-b105-13_aug_2010" and cygwin path "/cygdrive/e/dev/jdk7/openjdk-7-ea-src-b105-13_aug_2010"
Boot strap JDK: jdk1.6.0_18
Installed the Binary Plugs: downloaded it from "http://www.java.net/download/openjdk/jdk7/promoted/b92/jdk-7-ea-plug-b92-windows-i586-06_may_2010.jar"
Installed DirectX: "DirectX 9.0 SDK Update - (Summer 2004)" as given in the "README-builds.html" file
Installed make: make version "GNU Make 3.80"
Installed VC: Microsoft Visual C++ 2010 Express


Basic environment variables
# Boot strap JDK, windows path "D:\Java\jdk1.6.0_18"
export ALT_BOOTDIR=D:/JAVA/JDK16~1.0_1
# Binary Plugin
export ALT_BINARY_PLUGS_PATH=E:/DEV/JDK7/JDK7EA~2/OPENJD~1
# DirectX path
export ALT_DXSDK_PATH=/cygdrive/e/setup/directX
# Set OPENJDK to true
export OPENJDK=true

Task 1: Run "make sanity" with out errors
------------------------------------------------
Started cygwin and exported all the ALT_ variables above and ran the sanity by "make sanity".
The first sanity make ended in below error "ERROR: FreeType version 2.3.0 or higher is required.", I tried to installed freetype for cygwin, and re-ran the sanity, but ended up with same error.

Searched and found an direction from the link belwo which says "It's trying to build a freetype check program with VS2010, and probably found a stdio.h from the CYGWIN /usr/include, not the stdio.h you want.........which means downloading freetype sources and building it, and saving those files. Yes, I know, painful. Sorry in advance.".
That means I needed to download freeType and build it localy.

http://markmail.org/thread/g6zrjtpmo4sda7aw#query:freetypecheck.c%2829%29%20%3A%20fatal%20error%20C1083%3A%20Cannot%20open%20include%20file%3A%20%27stdio.h%27%3A%20No%20such%20file%20or%20directory+page:1+mid:4bd7hun3tmbwmjql+state:results

So downloaded FreeType version 2.4.4 (freetype-2.4.4) and tried to build using make in cygwin, but ended up with below error
make: ver: Command not found
make: type: Command not found
make: *** [dos_setup] Error 127
Couldn't find a solution (tried a lot to search on web), then using "VC++ 2010 Exp" I build the freetype as explained below

1. Double clicked the file "freetype-2.4.4\builds\win32\visualc\freetype.dsp"
2. Clicked next in "Conversion wizard", if needed choose backup before convertion, and click next and finish.
3. In "Solution Explorer", right clicked and choosen "Configuration Properties"->"General" in left panel, and in the right panel changed "Configuration Type" to "Dynamic Library (.dll)"
4. And made a build (F7), this will create freetype.dll in "freetype-2.4.4\objs\debug".

freetype.lib too is need for the build, we could use VC 2010 for this, but I couldn't genereated the lib file, instead I build freetype.lib using "ftjam-2.5.2-win32"
1. download, extact and set ftjam's bin in path.
2. Open "Visual Studio Command Prompt 2010" found in start up menu.
3. Changed directory to the root of the freetype-2.4.4, and type jam.
4. freetype.lib is created in "freetype-2.4.4\objs"

Copy this freetype.dll and freetype.lib in a directory, in my case I created "lib" directory in "E:\dev\jdk7\freetype-2.4.4_V2\freetype-2.4.4\lib" folder.

Now export the ALT_FREETYPE_LIB_PATH in cygwin environment
export ALT_FREETYPE_LIB_PATH=E:/DEV/JDK7/FREETY~2.4_V/FREETY~1.4/LIB

Note: To get the path as above "E:/DEV/JDK7/FREETY~2.4_V/FREETY~1.4/LIB", the simple solution is, first using cmd go to the path, in my case I typed
"cd cd E:\dev\jdk7\freetype-2.4.4_V2\freetype-2.4.4\lib" and then type "command" we get "E:\DEV\JDK7\FREETY~2.4_V\FREETY~1.4\LIB", now replace '\' with '/' and we get the path.

Now set the ALT_FREETYPE_HEADERS_PATH
export ALT_FREETYPE_HEADERS_PATH=E:/DEV/JDK7/FREETY~2.4_V/FREETY~1.4/INCLUDE

Here I was able to successfully run the sanity check.


Task 2: Building OpenJdk
------------------------------------------------
After sucessfull sanity check, we can go ahead and build the system. Just type make, and I ended with below error

D:/PROGRA~1/MICROS~1.0/VC/Bin/rc: No such file or directory

RC.exe is no more available in VC++ 2010, instead its available in Microsoft SDK, my system contains Microsoft SDK at location "C:\Program Files\Microsoft SDKs"
Now export variable MSSDKTOOLS_PATH as below which should point to BIN directory of Microsoft SDK

export MSSDKTOOLS_PATH=C:/PROGRA~1/MI2578~1/WINDOWS/V7.0A/BIN

And change the content of the file Compiler-msvc.gmk as below located at "openjdk-7-ea-src-b105-13_aug_2010\jdk\make\common\shared"

"RC = $(MSDEVTOOLS_PATH)rc" to "RC = $(MSSDKTOOLS_PATH)rc"
"RSC = $(MSDEVTOOLS_PATH)rc" to "RSC = $(MSSDKTOOLS_PATH)rc"

its enough to change MTL and MT for only VC 10, ie in the if block of COMPILER_NAME as Visual Studio 10
"MTL = $(MSDEVTOOLS_PATH)/midl.exe" to "MTL = $(MSSDKTOOLS_PATH)/midl.exe"
"MT = $(MSDEVTOOLS_PATH)mt" to "MT = $(MSSDKTOOLS_PATH)mt"

Here basically we are pointing RC, midl and mt to be picked from microsoft sdk rather from Visual Studio 10

That should build OpenJDK.