... h1. Build your own PostgreSQL for OpenSolaris
{toc}
|
h2. Intro
|
{note:title=Not tested by me on Solaris 10} I presume this will work on Solaris 10 too but haven't tested it myself yet. You do need to have Update 4 (8/07) {note}
|
This is a short despcription of how the PostgreSQL included with Solaris is built, updated for version 8.3 (which has not yet been released at the time of writing). If you're building your own (e.g. from a newer source or from a source with your own modifications), you may want to follow this recipe to get binaries that are as similar as possibe to those we deliver. This similarity also extends to the installation path.
This build procedure is valid for _SXDE 9/07_ (Nevada build 70) and _SXDE 1/08_ (Nevada build 79). It uses the _Sun Studio 12_ compiler which comes with SXDE. It builds 32 bit versions of the binaries, we will provide details for 64bit builds later.
|
| {info:getting
{info:title=Getting
the Sun Studio compiler} |
If you don't have the Sun Studio compiler, you can get it from [Sun Developer Network|http://developers.sun.com/prodtech/cc/downloads/index.jsp]. {info} |
... The build should also work fine on Sun Studio 11.
We assume you have already unpacked the source code in a user directory and have changed to that directory in your shell.
h2. Environment variables.
We assume the following environment variables:
{noformat} PGVER=8.3pgdg ROOT=<your install root> CFLAGS=<platform dependent compiler flags> {noformat}
The {{PGVER}} can actually be anything you want; it is just used as part of the full installation path. If you do the install as a regular user, the install root of course has to be writeable by that user. If the directory doesn't exist, it will be created.
"{{pgdg}}" is short for _PostgreSQL Global Development Group_ and is used here as an example. We do recommend you call it something other than just "8.3", to distinguish it from the "8.3" that is (or will soon be) included with Solaris.
The CFLAGS are on Sparc:
{noformat} "-xO3 -xarch=v8 -xspace -W0,-Lt -Xa -xildoff -W2,-xwrap_int -xCC" {noformat}
On x86/64: {noformat}
"-xO3 -xarch=386 -xchip=pentium -xspace -Xa -xildoff -xCC" {noformat}
h2. PATH
You need to append {{:/usr/sbin}} to your {{PATH}} variable, so that {{dtrace}} can be found by {{configure}}. So the minimum path you need is {{/usr/bin:/usr/sbin}}.
h2. Running configure
Run this configure from the main source directory :
{noformat} ./configure CC=/opt/SUNWspro/bin/cc \ "CFLAGS=$CFLAGS" \ "LD_OPTIONS=-R/usr/sfw/lib -L/usr/sfw/lib -M /usr/lib/ld/map.noexstk" \ MAKE=/usr/bin/gmake \ --prefix=/postgres/$PGVER \ --exec-prefix=/postgres/$PGVER \ --bindir=/postgres/$PGVER/bin \ --libexecdir=/postgres/$PGVER/bin \ --sbindir=/postgres/$PGVER/bin \ --datadir=/postgres/$PGVER/share \ --sysconfdir=/postgres/$PGVER/etc \ --mandir=/postgres/$PGVER/man \ --libdir=/postgres/$PGVER/lib \ --includedir=/postgres/$PGVER/include \ --sharedstatedir=/var/postgres/$PGVER \ --localstatedir=/var/postgres/$PGVER \ --enable-nls \ --with-docdir=/postgres/$PGVER/doc \ --with-system-tzdata=/usr/share/lib/zoneinfo \ --with-tcl -with-perl --with-python \ --with-pam --with-openssl --with-krb5 \ --without-readline \ --with-libxml --with-libxslt \ --enable-thread-safety \ --enable-dtrace \ --with-includes=/usr/include:/usr/sfw/include:/usr/include/kerberosv5 \ --with-tclconfig=/usr/lib \ --with-libs=/usr/lib:/usr/sfw/lib {noformat}
Note that all this is ONE command line.
You may of course replace the "{{/postgres/$PGVER}}" part of the paths if you want a completely different install path.
h2. Make
This will do the basic make of the product:
{noformat} gmake DTRACE_BITS=32 'LD_OPTIONS=-R$$ORIGIN/../lib:/usr/sfw/lib -L/usr/sfw/lib \ -M /usr/lib/ld/map.noexstk' MAKE=/usr/bin/gmake all {noformat}
Replace 32 with 64 if building on Sparc.
*NB* make sure to use single quotes ' around the {{LD_OPTIONS}} argument, double qoutes " will not give the correct result. The {{$ORIGIN}} is added here to ensure that the user does not have to set {{LD_LIBRARY_PATH}} to run commands like {{psql}} which need shared libaries from this installation.
h2. Install
To install into the user-defined install path (as set by {{ROOT}} above), the command is
{noformat} gmake DESTDIR=$ROOT MAKE=/usr/bin/gmake install {noformat}
You can also do install "directly" without the preceding gmake all, you will then have to combine all the arguments from the two gmake commands.
h2. Install as {{root}}
|
Installation as {{root}} works the same as above.
|
|
{warning:title=Do
not install in default location} |
Beware that if you set {{$ROOT}} to "{{/usr}}" and {{$PGVER}} to "{{8.3}}" your install will overwrite the PostgreSQL that came with your Solaris, and/or your own install may be overwritten during a Solaris upgrade. THIS IS NOT RECOMMENDED! {warning} |
... h2. Build and install of contrib modules
This is now very straightforward: just cd to the {{contrib}} subdirectory and repeat the two gmake commands above. You can also do this from the subdirectory of one specific contrib module if you only want that one.
h2. Adding {{libedit}}/{{readline}} functionality
The PostgreSQL binary {{psql}} (the interactive SQL client) shipped with Solaris provides command editing/history functionality using the {{libedit}} library. This library is statically linked into {{psql}}, but is not included on its own with Solaris.
If you want to have this in your own compiled {{psql}}, you'll need to do:
# Get either {{libedit}} or {{readline}} from [Sun Freeware|http://sunfreeware.com/]. # Remove '{{--without-readline}}' from the configure command. # If using {{libedit}}, add configure option '{{--with-libedit-preferred}}'.
|