This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix build under -DPERL_GLOBAL_STRUCT
[perl5.git] / hints / darwin.sh
index d2cfe20..3e92add 100644 (file)
@@ -13,11 +13,22 @@ perl_version=`awk '/define[         ]+PERL_VERSION/ {print $3}' $src/patchlevel.h`
 perl_subversion=`awk '/define[         ]+PERL_SUBVERSION/ {print $3}' $src/patchlevel.h`
 version="${perl_revision}.${perl_version}.${perl_subversion}"
 
-# Pretend that Darwin doesn't know about those system calls [perl #24122]
-d_setregid='undef'
-d_setreuid='undef'
-d_setrgid='undef'
-d_setruid='undef'
+# Pretend that Darwin doesn't know about those system calls in Tiger
+# (10.4/darwin 8) and earlier [perl #24122]
+case "$osvers" in
+[1-8].*)
+    d_setregid='undef'
+    d_setreuid='undef'
+    d_setrgid='undef'
+    d_setruid='undef'
+    ;;
+esac
+
+# finite() deprecated in 10.9, use isfinite() instead.
+case "$osvers" in
+[1-8].*) ;;
+*) d_finite='undef' ;;
+esac
 
 # This was previously used in all but causes three cases
 # (no -Ddprefix=, -Dprefix=/usr, -Dprefix=/some/thing/else)
@@ -68,8 +79,10 @@ esac
 # Since we can build fat, the archname doesn't need the processor type
 archname='darwin';
 
-# nm works.
-usenm='true';
+# nm isn't known to work after Snow Leopard and XCode 4; testing with OS X 10.5
+# and Xcode 3 shows a working nm, but pretending it doesn't work produces no
+# problems.
+usenm='false';
 
 case "$optimize" in
 '')
@@ -116,16 +129,20 @@ ccflags="${ccflags} -fno-common -DPERL_DARWIN"
 # stdint.h defining INT32_MIN as (-INT32_MAX-1)
 # -- Edward Moy
 #
-case "$(grep '^#define INT32_MIN' /usr/include/stdint.h)" in
+if test -f /usr/include/stdint.h; then
+  case "$(grep '^#define INT32_MIN' /usr/include/stdint.h)" in
   *-2147483648) ccflags="${ccflags} -DINT32_MIN_BROKEN -DINT64_MIN_BROKEN" ;;
-esac
+  esac
+fi
 
 # Avoid Apple's cpp precompiler, better for extensions
-cppflags="${cppflags} -no-cpp-precomp"
+if [ "X`echo | ${cc} -no-cpp-precomp -E - 2>&1 >/dev/null`" = "X" ]; then
+    cppflags="${cppflags} -no-cpp-precomp"
 
-# This is necessary because perl's build system doesn't
-# apply cppflags to cc compile lines as it should.
-ccflags="${ccflags} ${cppflags}"
+    # This is necessary because perl's build system doesn't
+    # apply cppflags to cc compile lines as it should.
+    ccflags="${ccflags} ${cppflags}"
+fi
 
 # Known optimizer problems.
 case "`cc -v 2>&1`" in
@@ -134,7 +151,6 @@ esac
 
 # Shared library extension is .dylib.
 # Bundle extension is .bundle.
-ld='cc';
 so='dylib';
 dlext='bundle';
 usedl='define';
@@ -158,6 +174,18 @@ case "$ccdlflags" in               # If passed in from command line, presume user knows best
 ;;
 esac
 
+# Allow the user to override ld, but modify it as necessary below
+case "$ld" in
+    '') case "$cc" in
+        # If the cc is explicitly something else than cc (or empty),
+        # set the ld to be that explicitly something else.  Conversely,
+        # if the cc is 'cc' (or empty), set the ld to be 'cc'.
+        cc|'') ld='cc';;
+        *) ld="$cc" ;;
+        esac
+        ;;
+esac
+
 # Perl bundles do not expect two-level namespace, added in Darwin 1.4.
 # But starting from perl 5.8.1/Darwin 7 the default is the two-level.
 case "$osvers" in
@@ -196,8 +224,8 @@ esac
 EOCBU
 
 # 64-bit addressing support. Currently strictly experimental. DFD 2005-06-06
-if [ "$use64bitall" ]
-then
+case "$use64bitall" in
+$define|true|[yY]*)
 case "$osvers" in
 [1-7].*)
      cat <<EOM >&4
@@ -206,30 +234,52 @@ case "$osvers" in
 
 *** 64-bit addressing is not supported for Mac OS X versions
 *** below 10.4 ("Tiger") or Darwin versions below 8. Please try
-*** again without -D64bitall. (-D64bitint will work, however.)
+*** again without -Duse64bitall. (-Duse64bitint will work, however.)
 
 EOM
      exit 1
   ;;
 *)
-    cat <<EOM >&4
+    case "$osvers" in
+    8.*)
+        cat <<EOM >&4
 
 
 
 *** Perl 64-bit addressing support is experimental for Mac OS X
-*** 10.4 ("Tiger") and Darwin version 8. Expect a number of test
-*** failures:
-***    ext/IPC/sysV/t/*
-***    ext/threads/shared/t/wait
+*** 10.4 ("Tiger") and Darwin version 8. System V IPC is disabled
+*** due to problems with the 64-bit versions of msgctl, semctl,
+*** and shmctl. You should also expect the following test failures:
+***
+***    ext/threads-shared/t/wait (threaded builds only)
 
 EOM
+
+        [ "$d_msgctl" ] || d_msgctl='undef'
+        [ "$d_semctl" ] || d_semctl='undef'
+        [ "$d_shmctl" ] || d_shmctl='undef'
+    ;;
+    esac
+
+    case `uname -p` in 
+    powerpc) arch=ppc64 ;;
+    i386) arch=x86_64 ;;
+    *) cat <<EOM >&4
+
+*** Don't recognize processor, can't specify 64 bit compilation.
+
+EOM
+    ;;
+    esac
     for var in ccflags cppflags ld ldflags
     do
-       eval $var="\$${var}\ -arch\ ppc64"
+       eval $var="\$${var}\ -arch\ $arch"
     done
+
     ;;
 esac
-fi
+;;
+esac
 
 ##
 # System libraries
@@ -287,6 +337,11 @@ i_dbm=undef;
 # NeilW says this should be acceptable on all darwin versions.
 ranlib='ranlib'
 
+# Catch MacPorts gcc/g++ extra libdir
+case "$($cc -v 2>&1)" in
+*"MacPorts gcc"*) loclibpth="$loclibpth /opt/local/lib/libgcc" ;;
+esac
+
 ##
 # Build process
 ##