version: 8.3.3
source: postgresql.org
installer: PostgreSQL
parallel: no
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.
In the postgresql source folder:
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"
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 sudo make install
In the postgresql source folder:
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).
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 sudo make install
In the postgresql source folder:
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.
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 sudo make install
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:
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
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
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
For now, see the Postgres documentation and the Installation section of the README.postgis document.