BuildingPostgreSQL

Build your own PostgreSQL for OpenSolaris

Intro

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)

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.

Getting the Sun Studio compiler
If you don't have the Sun Studio compiler, you can get it from Sun Developer Network.

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.

Environment variables.

We assume the following environment variables:

  PGVER=8.3pgdg
  ROOT=<your install root>
  CFLAGS=<platform dependent compiler flags>

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:

  "-xO3 -xarch=v8 -xspace -W0,-Lt -Xa -xildoff -W2,-xwrap_int -xCC"

On x86/64:

  "-xO3 -xarch=386 -xchip=pentium -xspace -Xa -xildoff -xCC"

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.

Running configure

Run this configure from the main source directory :

  ./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

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.

Make

This will do the basic make of the product:

  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

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.

Install

To install into the user-defined install path (as set by ROOT above), the command is

  gmake DESTDIR=$ROOT MAKE=/usr/bin/gmake install

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.

Install as root

Installation as root works the same as above.

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!

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.

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:

  1. Get either libedit or readline from Sun Freeware.
  2. Remove '--without-readline' from the configure command.
  3. If using libedit, add configure option '--with-libedit-preferred'.
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Feb 26, 2008

    tsmori says:

    This is a great set of instructions. The build worked fine on Solaris 10. Just ...

    This is a great set of instructions. The build worked fine on Solaris 10.

    Just one quick note: For readline compatibility, the readline libraries are installed to /usr/local/lib if you install the package from sunfreeware.com, so you'll need to add the following to the config and make commands:

    In LD_OPTIONS add -R/usr/local/lib -L/usr/local/lib
    In --with-includes add /usr/local/include
    in --with-libs add /usr/local/lib

    The make command should also add the /usr/local/lib location, i.e.:

    gmake DTRACE_BITS=32 'LD_OPTIONS=-R$$ORIGIN/../lib:/usr/sfw/lib:/usr/local/lib -L/usr/sfw/lib -L/usr/local/lib -M /usr/lib/ld/map.noexstk' MAKE=/usr/sfw/bin/gmake all

    1. Feb 29, 2008

      bjornmu says:

      Thanks for your comment! I will be adding info on compiling for 64 bit too. I'...

      Thanks for your comment! I will be adding info on compiling for 64 bit too. I've been extremely busy lately, but should have time to do this next week.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

© 2010, Oracle Corporation and/or its affiliates
Powered by Atlassian Confluence
Oracle Social Media Participation Policy Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact