Re: Universal libpq.a ? - Mailing list pgsql-general

From Dave Page
Subject Re: Universal libpq.a ?
Date
Msg-id 937d27e10802041127t3ad1b05cr19098fc1c4d30f3a@mail.gmail.com
Whole thread Raw
In response to Re: Universal libpq.a ?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Universal libpq.a ?
List pgsql-general
On Feb 4, 2008 6:25 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Dave Page" <dpage@postgresql.org> writes:
> > The Mac build of EDB Postgres is universal throughout,
>
> Yeah?  How painful is it?  We've had more than one request to enable
> universal builds.

There was fair bit of pain getting it to work, but the resulting
script isn't overly complex. Note this is based on work by the guys at
entropy.ch. Ignore the target directory fudging...

    # Configure the source tree
    echo "Configuring the Postgres source tree for Intel"
    CFLAGS="-arch i386" LDFLAGS="-ltcl" MACOSX_DEPLOYMENT_TARGET=10.4
./configure --prefix=$INST_DIR --bindir=$INST_DIR/bin
--datadir=$INST_DIR/share --libdir=$INST_DIR/lib
--includedir=$INST_DIR/include --mandir=$INST_DIR/man --with-openssl
--with-perl --with-python --with-tcl --with-bonjour --with-pam
--with-krb5 --with-libxml || _die "Failed to configure Postgres for
i386"
    mv src/include/pg_config.h src/include/pg_config_i386.h

    echo "Configuring the Postgres source tree for PPC"
    CFLAGS="-arch ppc" LDFLAGS="-ltcl" MACOSX_DEPLOYMENT_TARGET=10.4
./configure --prefix=$INST_DIR --bindir=$INST_DIR/bin
--datadir=$INST_DIR/share --libdir=$INST_DIR/lib
--includedir=$INST_DIR/include --mandir=$INST_DIR/man --with-openssl
--with-perl --with-python --with-tcl --with-bonjour --with-pam
--with-krb5 --with-libxml || _die "Failed to configure Postgres for
PPC"
    mv src/include/pg_config.h src/include/pg_config_ppc.h

    echo "Configuring the Postgres source tree for Universal"
    CFLAGS="-arch ppc -arch i386" LDFLAGS="-ltcl"
MACOSX_DEPLOYMENT_TARGET=10.4 ./configure --prefix=$INST_DIR
--bindir=$INST_DIR/bin --datadir=$INST_DIR/share
--libdir=$INST_DIR/lib --includedir=$INST_DIR/include
--mandir=$INST_DIR/man --with-openssl --with-perl --with-python
--with-tcl --with-bonjour --with-pam --with-krb5 --with-libxml || _die
"Failed to configure Postgres for Universal"

    # Create a replacement pg_config.h that will pull in the
appropriate architecture-specific one:
    echo "#ifdef __BIG_ENDIAN__" > src/include/pg_config.h
    echo "#include \"pg_config_ppc.h\"" >> src/include/pg_config.h
    echo "#else" >> src/include/pg_config.h
    echo "#include \"pg_config_i386.h\"" >> src/include/pg_config.h
    echo "#endif" >> src/include/pg_config.h

    # Fixup the makefiles
    echo "Post-processing Makefiles for Universal Binary build"
    find . -name Makefile -print -exec perl -p -i.backup -e 's/\Q$(LD)
$(LDREL) $(LDOUT)\E (\S+) (.+)/\$(LD) -arch ppc \$(LDREL) \$(LDOUT)
$1.ppc $2; \$(LD) -arch i386 \$(LDREL) \$(LDOUT) $1.i386 $2; lipo
-create -output $1 $1.ppc $1.i386/' {} \; || _die "Failed to
post-process the Postgres Makefiles for Universal build"

    echo "Building Postgres"
    MACOSX_DEPLOYMENT_TARGET=10.4 make -j 2 || _die "Failed to build Postgres"
    make prefix=$STAGING bindir=$STAGING/bin datadir=$STAGING/share
libdir=$STAGING/lib includedir=$STAGING/include mandir=$STAGING/man
install || _die "Failed to install Postgres"
    cp src/include/pg_config_i386.h $STAGING/include/
    cp src/include/pg_config_ppc.h $STAGING/include/

    echo "Building contrib modules"
    cd contrib
    MACOSX_DEPLOYMENT_TARGET=10.4 make || _die "Failed to build the
Postgres contrib modules"
    make prefix=$STAGING bindir=$STAGING/bin datadir=$STAGING/share
libdir=$STAGING/lib includedir=$STAGING/include mandir=$STAGING/man
install || _die "Failed to install the Postgres contrib modules"

    echo "Building xml2 module"
    cd xml2
    MACOSX_DEPLOYMENT_TARGET=10.4 make CFLAGS='-arch i386 -arch ppc'
|| _die "Failed to build the Postgres XML2 module"
    make prefix=$STAGING bindir=$STAGING/bin datadir=$STAGING/share
libdir=$STAGING/lib includedir=$STAGING/include mandir=$STAGING/man
install || _die "Failed to install the Postgres XML2 module"

/D

pgsql-general by date:

Previous
From: "fkater@googlemail.com"
Date:
Subject: Alternative to tableoids?
Next
From: Tom Lane
Date:
Subject: Re: Out of Memory errors while running pg_dump