Kyng Chaos
“The beast is actively interested only in now, and, as it is always now and always shall be, there is an eternity of time for the accomplishment of objects.”
- the wisdom of Tarzan

PostgreSQL Build

version: 8.3.3
source: postgresql.org
installer: PostgreSQL

parallel: no

Patches

Postgres can't be compiled universal out of the box. This is because ld is used directly to assemble intermediate object files, and ld doesn't do multiple architectures. It's simple to fix - use gcc -Wl,-r to assemble those object files. Here's what to do:

Edit src/makefile.global.in, change the LDREL line to:

LDREL = -Wl,-r

Don't worry about LD, that will be changed from configure.

Snow Leopard

In the postgresql source folder:

Configure

export MACOSX_DEPLOYMENT_TARGET=10.6
export ARCHFLAGS="-arch i386 -arch x86_64"
./configure --with-openssl --with-pam --with-krb5 --with-gssapi --with-ldap --enable-thread-safety \
--with-bonjour --with-python --without-perl --with-libxml \
CFLAGS="-Os -arch i386 -arch x86_64 -D_FILE_OFFSET_BITS=64" \
LD=gcc LDFLAGS="-arch i386 -arch x86_64"

config patches

When configure is done, a couple files must be patched for 64bits:

cat >>src/include/pg_config.h <<EOF
#undef ALIGNOF_DOUBLE
#ifdef __LP64__
#define ALIGNOF_DOUBLE 8
#else
#define ALIGNOF_DOUBLE 4
#endif
#undef ALIGNOF_LONG
#ifdef __LP64__
#define ALIGNOF_LONG 8
#else
#define ALIGNOF_LONG 4
#endif
#undef ALIGNOF_LONG_LONG_INT
#ifndef __LP64__
#define ALIGNOF_LONG_LONG_INT 4
#endif
#undef FLOAT8PASSBYVAL
#ifdef __LP64__
#define FLOAT8PASSBYVAL true
#else
#define FLOAT8PASSBYVAL false
#endif
#undef HAVE_LL_CONSTANTS
#ifndef __LP64__
#define HAVE_LL_CONSTANTS 1
#endif
#undef HAVE_LONG_INT_64
#undef HAVE_LONG_LONG_INT_64
#ifdef __LP64__
#define HAVE_LONG_INT_64 1
#else
#define HAVE_LONG_LONG_INT_64 1
#endif
#undef INT64_FORMAT
#ifdef __LP64__
#define INT64_FORMAT "%ld"
#else
#define INT64_FORMAT "%lld"
#endif
#undef MAXIMUM_ALIGNOF
#ifdef __LP64__
#define MAXIMUM_ALIGNOF 8
#else
#define MAXIMUM_ALIGNOF 4
#endif
#undef SIZEOF_SIZE_T
#ifdef __LP64__
#define SIZEOF_SIZE_T 8
#else
#define SIZEOF_SIZE_T 4
#endif
#undef SIZEOF_UNSIGNED_LONG
#ifdef __LP64__
#define SIZEOF_UNSIGNED_LONG 8
#else
#define SIZEOF_UNSIGNED_LONG 4
#endif
#undef SIZEOF_VOID_P
#ifdef __LP64__
#define SIZEOF_VOID_P 8
#else
#define SIZEOF_VOID_P 4
#endif
#undef UINT64_FORMAT
#ifdef __LP64__
#define UINT64_FORMAT "%lu"
#else
#define UINT64_FORMAT "%llu"
#endif
#undef USE_FLOAT8_BYVAL
#ifdef __LP64__
#define USE_FLOAT8_BYVAL 1
#endif
EOF

and:

cat >>src/interfaces/ecpg/include/ecpg_config.h <<EOF
#undef HAVE_LONG_INT_64
#undef HAVE_LONG_LONG_INT_64
#ifdef __LP64__
#define HAVE_LONG_INT_64 1
#else
#define HAVE_LONG_LONG_INT_64 1
#endif
EOF

make & install

make
sudo make install

Leopard

In the postgresql source folder:

Configure

export MACOSX_DEPLOYMENT_TARGET=10.5
export ARCHFLAGS="-arch ppc -arch i386 -arch ppc64 -arch x86_64"
./configure --with-openssl --with-pam --with-krb5 --with-gssapi --with-ldap --enable-thread-safety \
--with-bonjour --with-python --without-perl \
CFLAGS="-Os -arch i386 -arch x86_64 -arch ppc -arch ppc64 -D_FILE_OFFSET_BITS=64" \
LD=gcc LDFLAGS="-arch i386 -arch x86_64 -arch ppc -arch ppc64"

I left out perl support because perl is like python, only partially 64bits, and I haven't tried adding it (I'm not really interested in perl).

config patches

When configure is done, a couple files must be patched for endianess and 64bits:

cat >>src/include/pg_config.h <<EOF
#undef ALIGNOF_DOUBLE
#ifdef __LP64__
#define ALIGNOF_DOUBLE 8
#else
#define ALIGNOF_DOUBLE 4
#endif
#undef ALIGNOF_LONG
#ifdef __LP64__
#define ALIGNOF_LONG 8
#else
#define ALIGNOF_LONG 4
#endif
#undef ALIGNOF_LONG_LONG_INT
#ifndef __LP64__
#define ALIGNOF_LONG_LONG_INT 4
#endif
#undef FLOAT8PASSBYVAL
#ifdef __LP64__
#define FLOAT8PASSBYVAL true
#else
#define FLOAT8PASSBYVAL false
#endif
#undef HAVE_LL_CONSTANTS
#ifndef __LP64__
#define HAVE_LL_CONSTANTS 1
#endif
#undef HAVE_LONG_INT_64
#undef HAVE_LONG_LONG_INT_64
#ifdef __LP64__
#define HAVE_LONG_INT_64 1
#else
#define HAVE_LONG_LONG_INT_64 1
#endif
#undef HAVE_SECURITY_PAM_APPL_H
#define HAVE_PAM_PAM_APPL_H 1
#undef INT64_FORMAT
#ifdef __LP64__
#define INT64_FORMAT "%ld"
#else
#define INT64_FORMAT "%lld"
#endif
#undef MAXIMUM_ALIGNOF
#ifdef __LP64__
#define MAXIMUM_ALIGNOF 8
#else
#define MAXIMUM_ALIGNOF 4
#endif
#undef SIZEOF_SIZE_T
#ifdef __LP64__
#define SIZEOF_SIZE_T 8
#else
#define SIZEOF_SIZE_T 4
#endif
#undef SIZEOF_UNSIGNED_LONG
#ifdef __LP64__
#define SIZEOF_UNSIGNED_LONG 8
#else
#define SIZEOF_UNSIGNED_LONG 4
#endif
#undef SIZEOF_VOID_P
#ifdef __LP64__
#define SIZEOF_VOID_P 8
#else
#define SIZEOF_VOID_P 4
#endif
#undef UINT64_FORMAT
#ifdef __LP64__
#define UINT64_FORMAT "%lu"
#else
#define UINT64_FORMAT "%llu"
#endif
#undef USE_FLOAT8_BYVAL
#ifdef __LP64__
#define USE_FLOAT8_BYVAL 1
#endif
#undef WORDS_BIGENDIAN
#ifdef __BIG_ENDIAN__
#define WORDS_BIGENDIAN 1
#endif
EOF

and:

cat >>src/interfaces/ecpg/include/ecpg_config.h <<EOF
#undef HAVE_LONG_INT_64
#undef HAVE_LONG_LONG_INT_64
#ifdef __LP64__
#define HAVE_LONG_INT_64 1
#else
#define HAVE_LONG_LONG_INT_64 1
#endif
EOF

make & install

make
sudo make install

Tiger

In the postgresql source folder:

Configure

export MACOSX_DEPLOYMENT_TARGET=10.4
./configure --with-openssl --with-pam --with-krb5 --with-gssapi --with-ldap --enable-thread-safety \
--with-bonjour --with-python --without-perl \
CFLAGS="-Os -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -D_FILE_OFFSET_BITS=64" \
LD=gcc LDFLAGS="-arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk"

When adding Python support, an up-to-date package from python.org is recommended.

config patches

When configure is done, a file must be patched for endianess:

cat >>src/include/pg_config.h <<EOF
#undef WORDS_BIGENDIAN
#ifdef __BIG_ENDIAN__
#define WORDS_BIGENDIAN 1
#endif
EOF

make & install

make
sudo make install

Contrib Modules

Extra contrib modules in the Postgres source are compiled separately after installing Postgres. External modules, like PostGIS, have their own instructions.

in the module source folder you want:

Snow Leopard

export USE_PGXS=1
export MACOSX_DEPLOYMENT_TARGET=10.6
export PG_CPPFLAGS="-arch i386 -arch x86_64"
export SHLIB_LINK="-arch i386 -arch x86_64"
make
sudo make install-lib

Leopard

export USE_PGXS=1
export MACOSX_DEPLOYMENT_TARGET=10.5
export PG_CPPFLAGS="-arch i386 -arch x86_64 -arch ppc -arch ppc64"
export SHLIB_LINK="-arch i386 -arch x86_64 -arch ppc -arch ppc64"
make
sudo make install-lib

Tiger

export USE_PGXS=1
export MACOSX_DEPLOYMENT_TARGET=10.4
export PG_CPPFLAGS="-arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
export SHLIB_LINK="-arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
make
sudo make install-lib

Setup

For now, see the Postgres documentation and the Installation section of the README.postgis document.

macosx/build/postgresql.txt · Last modified: 2010/07/28 07:11 by kyngchaos
Copyright © 2004-2016 William Kyngesburye Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0