======================================================
Frequently Asked Questions (FAQ) for PostgreSQL >=V6.1
IRIX Specific
TO BE READ IN CONJUNCTION WITH THE NORMAL FAQ
======================================================
last updated:           Mon Mar 05 17:00:00 GMT 1998

current maintainer:     Andrew C.R. Martin (martin@biochem.ucl.ac.uk)
original author:        Andrew C.R. Martin (martin@biochem.ucl.ac.uk)


Changes in this version (* = modified, + = new, - = removed):
*1.5)   Can I install PostgreSQL (<V6.3) under Irix 6.x?
+1.10)  How do I install PostgreSQL V6.3 under Irix 6.x?

This file is divided approximately as follows:
1.*)    Installing PostgreSQL
2.*)    Uninstalling PostgreSQL
3.*)    Extending PostgreSQL


Questions answered:
1.1)    What extra items do I need to install PostgreSQL under Irix?
1.2)    What changes do I need to make to src/Makefile.global?
1.3)    What are the references in X11_LIB to libsocket and libnsl in
        src/Makefile.global?
1.4)    Are there any other changes I should make?
1.5)    Can I install PostgreSQL (<V6.3) under Irix 6.x?
1.6)    The make fails with the following message:
        ld32: ERROR 4: Conflicting flag setting: -call_shared
1.7)    Why won't it link? (Problems with lorder)
1.8)    I have major problems with IRIX 6!
1.9)    Why does lex fail with PostgreSQL 6.2.1?
1.10)   How do I install PostgreSQL V6.3 under Irix 6.x?
2.1)    Why can't I move the executable files?
3.1)    How do I compile a C program to create a function for extending
        PostgreSQL

----------------------------------------------------------------------
Section 1:      Installing PostgreSQL
----------------------------------------------------------------------

1.1)    What extra items do I need to install PostgreSQL under Irix?

        You *must* have the following installed:
        a) Gnu make (installed as gmake)

        You are recommended to install the following:
        a) GNU install (installed as ginstall)
           (This is part of the GNU fileutils package)

        You may choose to install the following:
        a) GNU readline library (if you wish psql to have readline
           support).
        b) tcl/tk (if you wish to compile pgtclsh)

1.2)    What changes do I need to make to src/Makefile.global or
        src/Makefile.custom?

        The easiest way to do this is to use the customize script in
        the src directory.

        You *must* set the following variables:
                PORTNAME=       irix5

        You will also need to change the following to match your own
        installation:
                POSTGRESDIR

        If you switch on the USE_TCL option, you will need to set these:
                TCL_INCDIR= 
                TCL_LIBDIR= 
                TCL_LIB = 
                TK_INCDIR=
                TK_LIBDIR=
                TK_LIB =

        You may also make any other changes you need as documented in
        the INSTALL file and in Makefile.global

1.3)    What are the references in X11_LIB to libsocket and libnsl in
        src/Makefile.global?

        This was a problem in 1.08 (they are Sun Solaris specific). 
        It is fixed in 1.09 and above.

1.4)    Are there any other changes I should make?

        If you have installed the GNU install program (ginstall), you
        should add the following line to src/Makefile.custom:
                CUSTOM_INSTALL=ginstall

        For an explanation as to why this is a good idea, see Question 2.1
        Ginstall is part of the GNU fileutils package.


1.5)    Can I install PostgreSQL (<V6.3) under Irix 6.x?

        Instructions for PostgreSQL V6.3 are answered in Question 1.10!

        Irix 6.2-6.4 has a bug in ld which mishandles the addresses of
        static procedures when object files are assembled into
        larger object files using 'ld -r'. This bug has been reported
        to Silicon Graphics. 

        One option is to use the Gnu version of ld. Alternatively,
        the following patch should be applied as a workaround. 
        (Supplied by Bob Bruccoleri <bruc@bms.com>)

*** ./backend/Makefile.orig     Thu May 22 00:00:15 1997
--- ./backend/Makefile  Thu Jun  5 16:47:27 1997
***************
*** 54,60 ****
  all: postgres $(POSTGRES_IMP) global1.bki.source local1_template1.bki.source
  
  postgres: $(OBJS) ../utils/version.o
!       $(CC) -o postgres $(OBJS) ../utils/version.o $(LDFLAGS)
  
  $(OBJS): $(DIRS:%=%.dir)
  
--- 54,64 ----
  all: postgres $(POSTGRES_IMP) global1.bki.source local1_template1.bki.source
  
  postgres: $(OBJS) ../utils/version.o
! #     $(CC) -o postgres $(OBJS) ../utils/version.o $(LDFLAGS)
!       -rm -f *.o
!       find . -name "*.o" -exec cp \{\} . \;
!       rm -f SUBSYS.o
!       $(CC) -o postgres *.o ../utils/version.o $(LDFLAGS)
  
  $(OBJS): $(DIRS:%=%.dir)




1.6)    The make fails with the following message:
        ld32: ERROR 4: Conflicting flag setting: -call_shared

        If gmake fails in .../src/backend while building obj/ACCESS.o
        with a message from ld32, you can work around this by using
        ld for the LD environment variable rather than cc.

        The problem has been observed under Irix 5.3 when compiling both
        Postgres95-1.09 and PostgreSQL-6.2Beta6, but on some systems
        these appear to compile with no such problems.

        Fix supplied by Brian Sanders (bsanders@netcom.com,
        brian@fresnelsoft.com)


1.7)    Why won't it link? (Problems with lorder)

        According to the IRIX man pages, lorder is useless, but harmless
        under IRIX. However, it has caused problems for some people
        using both IRIX 6.2.

        The solution is to add the following line to 
        .../src/makefiles/Makefile.irix5

        MK_NO_LORDER=true


1.8)    I have major problems with IRIX 6!

        The following is quoted directly from Bob Bruccoleri <bruc@bms.com>

There is a really nasty loader bug in the compiler system (7.1)
on Irix 6.x, and the error that Lasse Petersen is the result of it.
Here is the original message. I don't know if all the changes have been
folded into the current release.

Date: Fri, 06 Jun 1997 17:12:20 -0400 (EDT)
From: bruc@bms.com (Robert Bruccoleri)
Subject: [PORTS] Patches for Irix 6.4

I have worked out how to compile PostgreSQL on Irix 6.4 using the -n32 compiler
mode and version 7.1 of the C compiler. (The n32 compiler use 32 bits addressing,
but allows access to all the instructions in the MIPS4 instruction set.)
There were several problems:

1) The ld command is not referenced as a macro in all the Makefiles. On
this platform, you have to include -n32 on all the ld commands. Makefiles
were changed as needed.

2) There is a bug in "ld" which mishandles the addresses of static procedures
when object files are assembled into larger object files using "ld -r".
Because of this, I put a hack into src/backend/Makefile to avoid all the
SUBSYS.o files and just link all the objects. I have contacted SGI about the
problem, and hopefully, it will be fixed in the near future.

3) Lots of warnings are generated from the compiler. Since the regression
tests worked OK, I didn't attempt to fix them. If anyone wants the compilation
log, please let me know, and I'll email it to you.

The version of postgresql was 970602. Here is Makefile.custom:

CUSTOM_COPT = -O2 -n32
MK_NO_LORDER = 1
LD = ld -n32
CC += -n32

Here are the patches:

*** ./backend/access/Makefile.orig      Sun Nov 10 00:00:15 1996
- --- ./backend/access/Makefile Tue Jun  3 10:22:32 1997
***************
*** 8,13 ****
- --- 8,16 ----
  #
  #-------------------------------------------------------------------------

+ SRCDIR = ../..
+ include ../../Makefile.global
+
  OBJS = common/SUBSYS.o gist/SUBSYS.o hash/SUBSYS.o heap/SUBSYS.o \
         index/SUBSYS.o rtree/SUBSYS.o nbtree/SUBSYS.o transam/SUBSYS.o


*** ./backend/bootstrap/Makefile.orig   Fri Apr 18 06:00:23 1997
- --- ./backend/bootstrap/Makefile      Tue Jun  3 10:23:59 1997
***************
*** 38,44 ****
  all: SUBSYS.o

  SUBSYS.o: $(OBJS)
!       ld -r -o SUBSYS.o $(OBJS)

  # bootstrap.o's dependency on bootstrap_tokens.h is computed by the
  # make depend, but we state it here explicitly anyway because
- --- 38,44 ----
  all: SUBSYS.o

  SUBSYS.o: $(OBJS)
!       $(LD) -r -o SUBSYS.o $(OBJS)

  # bootstrap.o's dependency on bootstrap_tokens.h is computed by the
  # make depend, but we state it here explicitly anyway because

*** ./backend/Makefile.orig     Thu May 22 00:00:15 1997
- --- ./backend/Makefile        Thu Jun  5 16:47:27 1997
***************
*** 54,60 ****
  all: postgres $(POSTGRES_IMP) global1.bki.source local1_template1.bki.source

  postgres: $(OBJS) ../utils/version.o
!       $(CC) -o postgres $(OBJS) ../utils/version.o $(LDFLAGS)

  $(OBJS): $(DIRS:%=%.dir)

- --- 54,64 ----
  all: postgres $(POSTGRES_IMP) global1.bki.source local1_template1.bki.source

  postgres: $(OBJS) ../utils/version.o
! #     $(CC) -o postgres $(OBJS) ../utils/version.o $(LDFLAGS)
!       -rm -f *.o
!       find . -name "*.o" -exec cp \{\} . \;
!       rm -f SUBSYS.o
!       $(CC) -o postgres *.o ../utils/version.o $(LDFLAGS)

  $(OBJS): $(DIRS:%=%.dir)

***************
*** 116,122 ****
  install: $(LIBDIR) $(BINDIR) $(HEADERDIR) postgres $(POSTGRES_IMP) fmgr.h\
           global1.bki.source local1_template1.bki.source \
           libpq/pg_hba.conf.sample optimizer/geqo/pg_geqo.sample
!
        $(INSTALL) $(INSTL_EXE_OPTS) postgres $(BINDIR)/postgres
  ifeq ($(MAKE_EXPORTS), true)
        $(INSTALL) $(INSTLOPTS) $(POSTGRES_IMP) $(LIBDIR)/$(POSTGRES_IMP)
- --- 120,126 ----
  install: $(LIBDIR) $(BINDIR) $(HEADERDIR) postgres $(POSTGRES_IMP) fmgr.h\
           global1.bki.source local1_template1.bki.source \
           libpq/pg_hba.conf.sample optimizer/geqo/pg_geqo.sample
!
        $(INSTALL) $(INSTL_EXE_OPTS) postgres $(BINDIR)/postgres
  ifeq ($(MAKE_EXPORTS), true)
        $(INSTALL) $(INSTLOPTS) $(POSTGRES_IMP) $(LIBDIR)/$(POSTGRES_IMP)

*** ./backend/optimizer/Makefile.orig   Wed Feb 19 12:00:34 1997
- --- ./backend/optimizer/Makefile      Tue Jun  3 10:39:47 1997
***************
*** 8,13 ****
- --- 8,16 ----
  #
  #-------------------------------------------------------------------------

+ SRCDIR= ../..
+ include ../../Makefile.global
+
  all: submake SUBSYS.o

  OBJS = path/SUBSYS.o plan/SUBSYS.o prep/SUBSYS.o util/SUBSYS.o geqo/SUBSYS.o

*** ./backend/libpq/pqcomprim.c.orig    Mon May 26 00:00:23 1997
- --- ./backend/libpq/pqcomprim.c       Fri Jun  6 16:02:24 1997
***************
*** 32,40 ****
  #    define hton_l(n) (ntoh_l(n))
  #  else       /* BYTE_ORDER != BIG_ENDIAN */
  #    if BYTE_ORDER == PDP_ENDIAN
! #      #error PDP_ENDIAN macros not written yet
  #    else     /* BYTE_ORDER !=  anything known */
! #      #error BYTE_ORDER not defined as anything understood
  #    endif    /* BYTE_ORDER == PDP_ENDIAN */
  #  endif      /* BYTE_ORDER == BIG_ENDIAN */
  #endif                /* BYTE_ORDER == LITTLE_ENDIAN */
- --- 32,40 ----
  #    define hton_l(n) (ntoh_l(n))
  #  else       /* BYTE_ORDER != BIG_ENDIAN */
  #    if BYTE_ORDER == PDP_ENDIAN
! #      error PDP_ENDIAN macros not written yet
  #    else     /* BYTE_ORDER !=  anything known */
! #      error BYTE_ORDER not defined as anything understood
  #    endif    /* BYTE_ORDER == PDP_ENDIAN */
  #  endif      /* BYTE_ORDER == BIG_ENDIAN */
  #endif                /* BYTE_ORDER == LITTLE_ENDIAN */

*** ./backend/storage/Makefile.orig     Sun Nov 10 00:01:06 1996
- --- ./backend/storage/Makefile        Tue Jun  3 10:41:29 1997
***************
*** 8,13 ****
- --- 8,16 ----
  #
  #-------------------------------------------------------------------------

+ SRCDIR= ../..
+ include ../../Makefile.global
+
  all: submake SUBSYS.o

  OBJS = buffer/SUBSYS.o file/SUBSYS.o ipc/SUBSYS.o large_object/SUBSYS.o \




1.9)    Why does lex fail with PostgreSQL 6.2.1?

        IRIX 5.3 lex has been reported to fail in 
        postgresql-6.2.1/src/backend/parser with the error:

        lex scan.l
        "scan.l":line 86: Error: Invalid request %x xc
        gmake[2]: *** [scan.c] Error 1

        The answer is to use GNU flex 2.5.4 or later. Use the command
           flex --version
        to check you have a new enough version of flex


1.10)   How do I install PostgreSQL V6.3 under Irix 6.x?

        Irix 6.2-6.4 has a bug in ld which mishandles the addresses of
        static procedures when object files are assembled into
        larger object files using 'ld -r'. This bug has been reported
        to Silicon Graphics. 

        Depending on your Irix installation you may also encounter
        2 other problems detailed below: Conflict in C standards,
        Conflict in library functions.

        a) Solving the ld bug
        ---------------------

        One option is to use the Gnu version of ld. Alternatively,
        the following patch should be applied as a workaround. 
        (Supplied by Bob Bruccoleri <bruc@bms.com> and modified for
        PostgreSQL V6.3 by Lasse Hiller Petersen <lassehp@imv.aau.dk>)

        Apply the following patch:

*** ./backend/Makefile.orig     Tue Mar  3 15:33:58 1998
--- ./backend/Makefile  Tue Mar  3 15:39:27 1998
***************
*** 63,69 ****
                                global1.description
local1_template1.description

  postgres: $(OBJS) ../utils/version.o
!       $(CC) -o postgres $(OBJS) ../utils/version.o $(LDFLAGS)

  $(OBJS): $(DIRS:%=%.dir)

--- 63,73 ----
                                global1.description
local1_template1.description

  postgres: $(OBJS) ../utils/version.o
! #     $(CC) -o postgres $(OBJS) ../utils/version.o $(LDFLAGS)
!       -rm -f *.o
!       find . -name "*.o" -exec cp \{\} . \;
!       rm -f SUBSYS.o
!       $(CC) -o postgres *.o ../utils/version.o $(LDFLAGS)

  $(OBJS): $(DIRS:%=%.dir)




        Lasse configured with ./configure --enable-locale
        and modified Makefile.custom to contain:
CC = cc -n32
LD = ld -n32
        
        He reports that the installation without -n32 works fine too,
        but the -n32 was required for compatibility with his Perl
        installation. His system was an Origin200 running IRIX64 v6.4.


        b) Conflict in C standards
        --------------------------

        I have found that the following patch is also necessary in order
        to prevent a duplicate definition of a Union used for semaphores.
        Apply the following patch to:
        .../src/makefile/Makefile.irix5:

*** src/makefiles/Makefile.irix5.orig   Thu Mar  5 16:59:58 1998
--- src/makefiles/Makefile.irix5        Thu Mar  5 17:01:13 1998
***************
*** 6,9 ****
  %.so: %.o
        $(LD) -G -Bdynamic -shared -o $@ $<

!
--- 6,9 ----
  %.so: %.o
        $(LD) -G -Bdynamic -shared -o $@ $<

! CFLAGS+= -U_NO_XOPEN4

        i.e. the addition of the line:
        CFLAGS+= -U_NO_XOPEN4

        This is needed to stop the semun union being redefined in
        /usr/include/sys/sem.h

        c) Conflict in library functions
        --------------------------------

        In addition, if you have the nsl and crypt libraries these will
        conflict with the required definitions. I think that libnsl.a
        may be the Netware socket library (or something similar). In
        any case, if you have these libraries, they will be added to
        Makefile.global and you will need to remove them.

        Thus, you should edit .../src/Makefile.global. Goto (approximately)
        line 217 where LDFLAGS= is set and remove -lnsl and -lcrypt
        from this line.


----------------------------------------------------------------------
Section 2:      Deinstalling PostgreSQL
----------------------------------------------------------------------

2.1)    Why can't I move the executable files?

        By default, the IRIX port uses the BSD compatible version of
        install from /usr/bin/X11. If you read the man page for this
        version of install, you will see that it is not meant for
        end-user use; it has the interesting side-effect of chowning
        files it installs to root.

        You should still be able to delete the files as you (the
        postgres user) will own the directory in which they are
        stored.

        The normal IRIX install program cannot be used easily as it
        takes its arguments in the reverse order. It is therefore
        recommended to use the GNU version of install (ginstall).
        See Question 1.4


----------------------------------------------------------------------
Section 3:      Extending PostgreSQL
----------------------------------------------------------------------
3.1)    How do I compile a C program to create a function for extending
        PostgreSQL

        Here is a sample command line:

        cc -I/usr/local/PostgreSQL/include/ -I/usr/local/PostgreSQL/src/backend 
                -shared -o funcs.so funcs.c


----------------------------------------------------------------------------
Dr. Andrew C.R. Martin                             University College London
EMAIL: (Work) martin@biochem.ucl.ac.uk    (Home) andrew@stagleys.demon.co.uk
URL:   http://www.biochem.ucl.ac.uk/~martin
Tel:   (Work) +44(0)171 419 3890                    (Home) +44(0)1372 275775
