* of load() and unload() from libC and libC_r need to be used,
* otherwise statics in the extensions won't get initialized right.
* -- Stephanie Beals <bealzy@us.ibm.com> */
-#ifdef USE_xlC /* The define comes, when it comes, from hints/aix.pl. */
-# define LOAD loadAndInitialize
+#ifdef USE_libC /* The define comes, when it comes, from hints/aix.pl. */
+# define LOAD loadAndInit
# define UNLOAD terminateAndUnload
-# include <load.h>
+# ifdef USE_load_h
+# include <load.h>
+# endif
#else
# define LOAD load
# define UNLOAD unload
# See dl_aix.xs for details.
use Config;
if ($Config{libs} =~ /-lC/ && -f '/lib/libC.a') {
- $self->{CCFLAGS} = $Config{ccflags} . ' -DUSE_xlC';
+ $self->{CCFLAGS} = $Config{ccflags} . ' -DUSE_libC';
if (-f '/usr/ibmcxx/include/load.h') {
- $self->{CCFLAGS} .= ' -I/usr/ibmcxx/include';
+ $self->{CCFLAGS} .= ' -I/usr/ibmcxx/include -DUSE_load_h';
} elsif (-f '/usr/lpp/xlC/include/load.h') {
- $self->{CCFLAGS} .= ' -I/usr/lpp/xlC/include';
- } else {
- # Hoping that <load.h> will be found somehow.
+ $self->{CCFLAGS} .= ' -I/usr/lpp/xlC/include -DUSE_load_h';
}
}
;;
esac
- # The libC_r is to be preferred over the libc_r because otherwise
- # extensions written in C++ using statics won't be initialized right;
- # see ext/DynaLoader/dl_aix.xs.
- if test -f /lib/libC_r.a; then
- # C_rify libwanted.
- set `echo X "$libswanted "| sed -e 's/ C / pthreads C_r /'`
- shift
- libswanted="$*"
- # C_rify lddlflags.
- set `echo X "$lddlflags"| sed -e 's/ -lc$/ -lpthreads -lC_r/'`
- shift
- lddlflags="$*"
- else
- # The POSIX threads library and the re-entrant libc to libswanted.
- set `echo X "$libswanted "| sed -e 's/ c / pthreads c_r /'`
- shift
- libswanted="$*"
-
- # The POSIX threads library and the re-entrant libc to lddflags.
- set `echo X "$lddlflags"| sed -e 's/ -lc$/ -lpthreads -lc_r/'`
- shift
- lddlflags="$*"
- fi
+ # c_rify libswanted.
+ set `echo X "$libswanted "| sed -e 's/ \([cC]\) / \1_r /g'`
+ shift
+ libswanted="$*"
+ # c_rify lddlflags.
+ set `echo X "$lddlflags "| sed -e 's/ \(-l[cC]\) / \1_r /g'`
+ shift
+ lddlflags="$*"
+
+ # Insert pthreads to libswanted, before any libc or libC.
+ set `echo X "$libswanted "| sed -e 's/ \([cC]\) / pthreads \1 /'`
+ shift
+ libswanted="$*"
+ # Insert pthreads to lddlflags, before any libc or libC.
+ set `echo X "$lddlflags " | sed -e 's/ \(-l[cC]\) / -lpthreads \1 /'`
+ shift
+ lddlflags="$*"
+
;;
esac
EOCBU
# (nothing strange shows up in $ldflags even in hexdump;
# so it may be something in the shell, instead?)
# Try it out: just uncomment the below line and rerun Configure:
-# echo >&4 "AIX $ldflags mystery" ; exit 1
+# echo >&4 "AIX 4.3.1.0 $ldflags mystery" ; exit 1
# Just don't ask me how AIX does it.
# Therefore the line re-evaluating ldflags: it seems to bypass
# the whatever it was that AIX managed to break. --jhi
esac
EOCBU
-# If the C++ libraries, libC, are available we will prefer them over
-# the vanilla libc, because the libC contain loadAndInitialize() and
+# 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_r-to-C_r switch is done by usethreads.cbu.
-test -f /lib/libC.a && libswanted=`$echo " $libswanted "|sed -e 's/ c / C /'`
+# The C-to-C_r switch is done by usethreads.cbu, if needed.
+if test -f /lib/libC.a; then
+ case "$cc" in
+ xlC*)
+ # Cify libswanted for xlC.
+ set `echo X "$libswanted "| sed -e 's/ c / C /'`
+ shift
+ libswanted="$*"
+ # Cify lddlflags for xlC.
+ set `echo X "$lddlflags "| sed -e 's/ -lc / -lC /'`
+ shift
+ lddlflags="$*"
+ ;;
+ *)
+ # Cify libswanted for non-xlC.
+ set `echo X "$libswanted "| sed -e 's/ c / c C /'`
+ shift
+ libswanted="$*"
+ # Cify lddlflags for non-xlC.
+ set `echo X "$lddlflags "| sed -e 's/ -lc / -lc -lC /'`
+ shift
+ lddlflags="$*"
+ ;;
+ esac
+fi
# EOF