Last active
December 10, 2015 17:59
-
-
Save gurjeet/4471736 to your computer and use it in GitHub Desktop.
Documents the steps of building PostgreSQL on Windows Server 2012 64bit using MinGW (32bit builds as well as 64bit builds)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Beware: | |
======= | |
If you wish to compile Postgres with XML support, tough luck! The libxml2 package that comes with MinGW/MSYS, named msys-libxml2, is rejected by gcc like this: | |
c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/MinGW/msys/1.0/lib/libxml2.a when searching for -lxml2 | |
This is a known limitation as of now. Andrew Dunstan, the community buildfarm maintainer, as acknowledged this. | |
Make the environment bearable: | |
============================== | |
Download and install Fierfox from www.getfirefox.com | |
Download and install Sublime Text | |
Download and install 7zip. | |
Launch it once, and Go to Tools > Options > 'Select All' (or pick your choices) > Apply/OK | |
Download and install Process Explorer | |
Download and install msysGit | |
I used Git-1.8.0-preview20121022.exe from | |
http://code.google.com/p/msysgit/downloads/list?q=full+installer+official+git | |
(referred to by http://msysgit.github.com/) | |
Choose to add only the Git binary to the PATH variable and not rest of the tools that come with msysGit. | |
Read: | |
===== | |
Read this doc if you want to figure out which package of MinGW-64w to download: | |
http://sourceforge.net/apps/trac/mingw-w64/wiki/download%20filename%20structure | |
Download essentials: | |
=================== | |
Latest mingw-w64-bin_i686-mingw from | |
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Automated%20Builds/ | |
I used: mingw-w64-bin_i686-mingw_20111220.zip | |
Latest mingw-get-inst-YYYMMDD.exe | |
from http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/ | |
I used: mingw-get-inst-20120426.exe | |
Latest ActivePerl from: | |
from http://www.activestate.com/activeperl | |
I used: ActivePerl-5.16.1.1601-MSWin32-x64-296175.msi | |
Latest Postgres Buildfarm scripts from: | |
http://www.pgbuildfarm.org/downloads/releases/ | |
I used build-farm-4_9.tgz | |
Extract/Install: | |
================ | |
Install mingw-get-inst-YYYYMMDD.exe | |
Choose 'Prepackaged repository catalogues' (Mine listed: 20120426) | |
Choose C:\MinGW as destination. | |
De-select complete 'MinGW compiler suite' tree-node, since we'll be using the MinGW-64 binaries. | |
Select only MSYS Basic system. | |
Inspected the resulting log file to see that there were no errors. | |
Extract mingw-w64-bin_i686-mingw | |
Exract mingw-w64-bin_i686-mingw_20111220.zip to C:\mingw64 | |
For ease of running MSYS terminal, create a shortcut on Desktop that runs | |
C:\MinGW\msys\1.0\msys.bat --norxvt | |
For keeping long screen output history, run the MSYS terminal from | |
above created icon, and click on top-left corner of the window and go to | |
Properties > Layout > 'Screen Buffer Size' > Height | |
and set it to 9999 (max allowed). | |
Install bison, flex, patch, vim, perl, and m4. | |
In the MSYS terminal, execute the following commands | |
mingw-get install msys-bison | |
mingw-get install msys-flex | |
mingw-get install msys-patch | |
mingw-get install msys-vim | |
mingw-get install msys-perl | |
mingw-get install msys-m4 | |
Remember, the msys-perl is needed for the build process, and the | |
ActiveState perl (below) is used only to execute run_web_txn.pl script. | |
Install ActivePerl | |
Execute the installer downloaded from ActiveState.com | |
Choose the setting for the installer to change the PATH variable. | |
Extract Postgres Buildfarm sripts. | |
In MSYS console, I extracted build-farm-4_9.tgz to ~/bf/ | |
Create a mount point in MSYS, pointing to extracted C:\MinGW-w64\ | |
================================================================== | |
Edit /etc/fstab (C:\MinGW\msys\1.0\etc\fstab) to add this line: | |
C:\mingw64\ /mingw-w64 | |
This mount point will be later used by buildfarm to build postgres using 64-bit toolchain. | |
Get Postgres sources: | |
===================== | |
Use yor preferred method of getting a version of Postgres sources. | |
I used Git to get the latest version (actually whole repository) of source code, like so: | |
git clone git://git.postgresql.org/git/postgresql.git ~/POSTGRES | |
This created Postres source code directory at ~/POSTGRES | |
Prepare buildfarm and Postgres sources: | |
======================================= | |
Read this wiki page to get a better hang of build-farm: | |
http://wiki.postgresql.org/wiki/PostgreSQL_Buildfarm_Howto | |
Review and modify build-farm.conf file as necessary. | |
I applied a patch to buildfarm scripts, available as a gist from | |
https://gist.github.com/4455475 | |
Most important point in that patch is the fact that we use /mingw-w64/bin/ as a prefix of PATH env. variable. | |
Build Postgres: | |
=============== | |
Make a directory named root under ~/bf/ | |
mkdir ~/bf/root/ | |
(this is needed because the 'build_root' parameter in build-farm.conf | |
has the value '/home/Administrator/bf/root') | |
From within the ~/bf/ directory, run the perl script to build Postgres: | |
perl run_build.pl --verbose --from-source=/home/Administrator/POSTGRES HEAD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment