diff -c -r pgsql.orig/src/Makefile.global.in pgsql/src/Makefile.global.in
*** pgsql.orig/src/Makefile.global.in	2006-09-11 10:22:38.000000000 +0200
--- pgsql/src/Makefile.global.in	2006-09-12 14:02:55.000000000 +0200
***************
*** 343,355 ****
  # If doing static linking, shared library dependency info isn't available,
  # so add in the libraries that libpq depends on.
  ifeq ($(enable_shared), no)
! libpq += $(filter -lintl -lssl -lcrypto -lkrb5 -lcrypt, $(LIBS)) $(PTHREAD_LIBS)
! else
! # On AIX even shared libraries do not remember their required libs,
! # so again add in what libpq depends on.
! ifeq ($(PORTNAME), aix)
! libpq += $(filter -lintl -lssl -lcrypto -lkrb5 -lcrypt, $(LIBS)) $(PTHREAD_LIBS)
! endif
  endif
  
  # This macro is for use by client executables (not libraries) that use libpq.
--- 343,349 ----
  # If doing static linking, shared library dependency info isn't available,
  # so add in the libraries that libpq depends on.
  ifeq ($(enable_shared), no)
! libpq += $(filter -lintl -lssl -lcrypto -lkrb5 -lcrypt -lldap -lldap_r, $(LIBS) $(LDAP_LIBS_FE)) $(PTHREAD_LIBS)
  endif
  
  # This macro is for use by client executables (not libraries) that use libpq.
diff -c -r pgsql.orig/src/template/aix pgsql/src/template/aix
*** pgsql.orig/src/template/aix	2006-09-11 10:22:38.000000000 +0200
--- pgsql/src/template/aix	2006-09-12 14:04:16.000000000 +0200
***************
*** 7,12 ****
--- 7,15 ----
        CFLAGS="-O2 -qmaxmem=16384 -qsrcmsg -qlonglong"
        ;;
    esac
+   LDFLAGS="$LDFLAGS -brtl"
+ else
+   LDFLAGS="$LDFLAGS -Wl,-brtl"
  fi
  
  # Native memset() is faster, tested on:
