Index: src/Makefile.global.in
===================================================================
RCS file: /projects/cvsroot/pgsql/src/Makefile.global.in,v
retrieving revision 1.229
diff -c -r1.229 Makefile.global.in
*** src/Makefile.global.in	11 Sep 2006 13:35:08 -0000	1.229
--- src/Makefile.global.in	15 Sep 2006 17:53:12 -0000
***************
*** 345,357 ****
  ifeq ($(enable_shared), no)
  libpq += $(filter -lintl -lssl -lcrypto -lkrb5 -lcrypt, $(LIBS)) \
  	$(LDAP_LIBS_FE) $(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)) \
- 	$(LDAP_LIBS_FE) $(PTHREAD_LIBS)
- endif
  endif
  
  # This macro is for use by client executables (not libraries) that use libpq.
--- 345,350 ----
Index: src/Makefile.shlib
===================================================================
RCS file: /projects/cvsroot/pgsql/src/Makefile.shlib,v
retrieving revision 1.104
diff -c -r1.104 Makefile.shlib
*** src/Makefile.shlib	28 Apr 2006 02:53:20 -0000	1.104
--- src/Makefile.shlib	15 Sep 2006 17:53:12 -0000
***************
*** 96,103 ****
  soname = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
  
  ifeq ($(PORTNAME), aix)
!   shlib			= lib$(NAME)$(DLSUFFIX)
! #   SHLIB_LINK		+= -lc
  endif
  
  ifeq ($(PORTNAME), darwin)
--- 96,102 ----
  soname = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
  
  ifeq ($(PORTNAME), aix)
!   shlib			= lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
  endif
  
  ifeq ($(PORTNAME), darwin)
***************
*** 298,303 ****
--- 297,305 ----
  $(shlib): lib$(NAME).a
  	$(MKLDEXPORT) lib$(NAME).a > lib$(NAME)$(EXPSUFF)
  	$(COMPILER) $(LDFLAGS_NO_L) $(LDFLAGS_SL) -o $@ $< -Wl,-bE:lib$(NAME)$(EXPSUFF) $(SHLIB_LINK)
+ 	rm -f $<
+ 	$(AR) $(AROPT) $< $@
+ 	touch $@
  	
  endif # PORTNAME == aix
  
***************
*** 349,354 ****
--- 351,359 ----
  endif
  
  ifeq ($(enable_shared), yes)
+ ifeq ($(PORTNAME), aix)
+ install-lib-shared: install-lib-static
+ else
  install-lib-shared: $(shlib)
  	$(INSTALL_SHLIB) $< '$(DESTDIR)$(libdir)/$(shlib)'
  ifneq ($(PORTNAME), cygwin)
***************
*** 365,370 ****
--- 370,376 ----
  endif
  endif # not win32
  endif # not cygwin
+ endif # aix
  endif # enable_shared
  
  
Index: src/interfaces/ecpg/test/Makefile.regress
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/ecpg/test/Makefile.regress,v
retrieving revision 1.4
diff -c -r1.4 Makefile.regress
*** src/interfaces/ecpg/test/Makefile.regress	28 Aug 2006 16:13:11 -0000	1.4
--- src/interfaces/ecpg/test/Makefile.regress	15 Sep 2006 17:53:13 -0000
***************
*** 3,9 ****
  override CFLAGS += $(PTHREAD_CFLAGS) 
  
  override LDFLAGS := -L../../ecpglib -L../../pgtypeslib -L../../../libpq $(LDFLAGS)
! override LIBS := -lpgtypes -lecpg -lpq $(LIBS) $(PTHREAD_LIBS)
  
  ECPG = ../../preproc/ecpg -I$(srcdir)/../../include
  
--- 3,9 ----
  override CFLAGS += $(PTHREAD_CFLAGS) 
  
  override LDFLAGS := -L../../ecpglib -L../../pgtypeslib -L../../../libpq $(LDFLAGS)
! override LIBS := -lpgtypes -lecpg -lpq $(LIBS) $(LDAP_LIBS_FE) $(PTHREAD_LIBS)
  
  ECPG = ../../preproc/ecpg -I$(srcdir)/../../include
  
Index: src/interfaces/ecpg/test/pg_regress.sh
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/ecpg/test/pg_regress.sh,v
retrieving revision 1.13
diff -c -r1.13 pg_regress.sh
*** src/interfaces/ecpg/test/pg_regress.sh	8 Sep 2006 13:32:27 -0000	1.13
--- src/interfaces/ecpg/test/pg_regress.sh	15 Sep 2006 17:53:13 -0000
***************
*** 332,337 ****
--- 332,344 ----
      fi
      export LD_LIBRARY_PATH
  
+     if [ -n "$LIBPATH" ]; then
+         LIBPATH="$libdir:$LIBPATH"
+     else
+         LIBPATH=$libdir
+     fi
+     export LIBPATH
+ 
      if [ -n "$DYLD_LIBRARY_PATH" ]; then
          DYLD_LIBRARY_PATH="$libdir:$DYLD_LIBRARY_PATH"
      else
Index: src/makefiles/Makefile.aix
===================================================================
RCS file: /projects/cvsroot/pgsql/src/makefiles/Makefile.aix,v
retrieving revision 1.25
diff -c -r1.25 Makefile.aix
*** src/makefiles/Makefile.aix	19 Apr 2006 16:32:08 -0000	1.25
--- src/makefiles/Makefile.aix	15 Sep 2006 17:53:13 -0000
***************
*** 5,10 ****
--- 5,18 ----
  RANLIB= touch
  AROPT = crs
  
+ # -blibpath must contain ALL directories where we should look for libraries
+ libpath := $(shell echo $(subst -L,:,$(filter -L/%,$(subst -L , -L,$(strip $(LDFLAGS)))))|sed -e's/ //g'):/usr/lib:/lib
+ ifeq ($(host_os), aix3.2.5)
+ 	rpath = -L$(rpathdir)
+ else
+ 	rpath = -Wl,-blibpath:$(rpathdir)$(libpath)
+ endif
+ 
  DLSUFFIX = .so
  ifeq ($(host_os), aix3.2.5)
  ifneq ($(GCC), yes)
Index: src/test/regress/pg_regress.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/test/regress/pg_regress.c,v
retrieving revision 1.20
diff -c -r1.20 pg_regress.c
*** src/test/regress/pg_regress.c	13 Aug 2006 20:39:07 -0000	1.20
--- src/test/regress/pg_regress.c	15 Sep 2006 17:53:13 -0000
***************
*** 512,517 ****
--- 512,518 ----
  		 * dlopen'ed ones)  Feel free to account for others as well.
  		 */
  		add_to_path("LD_LIBRARY_PATH", ':', libdir);
+ 		add_to_path("LIBPATH", ':', libdir);
  		add_to_path("DYLD_LIBRARY_PATH", ':', libdir);
  #if defined(WIN32) || defined(__CYGWIN__)
  		add_to_path("PATH", ';', libdir);
