--- perl-5.6.1/ext/DynaLoader/dl_aix.xs.orig	Fri Mar 30 22:14:39 2001
+++ perl-5.6.1/ext/DynaLoader/dl_aix.xs	Sun Apr 22 00:36:41 2001
@@ -14,6 +14,21 @@
 #define PERLIO_NOT_STDIO 0
 
 /*
+ * On AIX 4.3 and above the emulation layer is not needed any more, and
+ * indeed if perl uses its emulation and perl is linked into apache
+ * which is supposed to use the native dlopen conflicts arise.
+ * Jens-Uwe Mager jum@helios.de
+ */
+#ifdef USE_NATIVE_DLOPEN
+
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+#include <dlfcn.h>
+
+#else
+
+/*
  * @(#)dlfcn.c	1.5 revision of 93/02/14  20:14:17
  * This is an unpublished work copyright (c) 1992 Helios Software GmbH
  * 3000 Hannover 1, Germany
@@ -94,6 +109,13 @@
 # define FREAD(p,s,n,ldptr)	fread(p,s,n,IOPTR(ldptr))
 #endif
 
+#ifndef RTLD_LAZY
+# define RTLD_LAZY 0
+#endif
+#ifndef RTLD_GLOBAL
+# define RTLD_GLOBAL 0
+#endif
+
 /*
  * We simulate dlopen() et al. through a call to load. Because AIX has
  * no call to find an exported symbol we read the loader section of the
@@ -632,6 +654,7 @@
 	safefree(buf);
 	return ret;
 }
+#endif /* USE_NATIVE_DLOPEN */
 
 /* dl_dlopen.xs
  * 
@@ -677,7 +700,7 @@
 	DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_load_file(%s,%x):\n", filename,flags));
 	if (flags & 0x01)
 	    Perl_warn(aTHX_ "Can't make loaded symbols global on this platform while loading %s",filename);
-	RETVAL = dlopen(filename, 1) ;
+	RETVAL = dlopen(filename, RTLD_GLOBAL|RTLD_LAZY) ;
 	DLDEBUG(2,PerlIO_printf(Perl_debug_log, " libref=%x\n", RETVAL));
 	ST(0) = sv_newmortal() ;
 	if (RETVAL == NULL)
--- perl-5.6.1/hints/aix.sh.orig	Tue Mar 20 18:40:22 2001
+++ perl-5.6.1/hints/aix.sh	Sun Apr 22 00:42:44 2001
@@ -55,9 +55,11 @@
 case "$osvers" in
    3.*|4.1.*|4.2.*)
       usenm='undef'
+      usenativedlopen='false'
       ;;
    *)
       usenm='true'
+      usenativedlopen='true'
       ;;
 esac
 
@@ -405,20 +407,26 @@
 esac
 EOCBU
 
-# If the C++ libraries, libC and libC_r, are available we will prefer them
-# over the vanilla libc, because the libC contain loadAndInit() and
-# terminateAndUnload() which work correctly with C++ statics while libc
-# load() and unload() do not.  See ext/DynaLoader/dl_aix.xs.
-# The C-to-C_r switch is done by usethreads.cbu, if needed.
-if test -f /lib/libC.a -a X"`$cc -v 2>&1 | grep gcc`" = X; then
-    # Cify libswanted.
-    set `echo X "$libswanted "| sed -e 's/ c / C c /'`
-    shift
-    libswanted="$*"
-    # Cify lddlflags.
-    set `echo X "$lddlflags "| sed -e 's/ -lc / -lC -lc /'`
-    shift
-    lddlflags="$*"
+if test $usenativedlopen = 'true'
+then
+        ccflags="$ccflags -DUSE_NATIVE_DLOPEN"
+	ldflags="$ldflags -brtl"
+else
+    # If the C++ libraries, libC and libC_r, are available we will prefer them
+    # over the vanilla libc, because the libC contain loadAndInit() and
+    # terminateAndUnload() which work correctly with C++ statics while libc
+    # load() and unload() do not.  See ext/DynaLoader/dl_aix.xs.
+    # The C-to-C_r switch is done by usethreads.cbu, if needed.
+    if test -f /lib/libC.a -a X"`$cc -v 2>&1 | grep gcc`" = X; then
+	# Cify libswanted.
+	set `echo X "$libswanted "| sed -e 's/ c / C c /'`
+	shift
+	libswanted="$*"
+	# Cify lddlflags.
+	set `echo X "$lddlflags "| sed -e 's/ -lc / -lC -lc /'`
+	shift
+	lddlflags="$*"
+    fi
 fi
 
 # EOF
--- perl-5.6.1/makedef.pl.orig	Mon Mar 19 09:49:53 2001
+++ perl-5.6.1/makedef.pl	Sun Apr 22 00:37:42 2001
@@ -172,7 +172,15 @@
 ---EOP---
 }
 elsif ($PLATFORM eq 'aix') {
-    print "#!\n";
+    $OSVER = `uname -v`;
+    chop $OSVER;
+    $OSREL = `uname -r`;
+    chop $OSREL;
+    if ($OSVER > 4 || ($OSVER == 4 && $OSREL >= 3)) {
+	print "#! ..\n";
+    } else {
+	print "#!\n";
+    }
 }
 
 my %skip;
