2 # Darwin (Mac OS) hints
10 # Configure hasn't figured out the version number yet. Bummer.
11 perl_revision=`awk '/define[ ]+PERL_REVISION/ {print $3}' $src/patchlevel.h`
12 perl_version=`awk '/define[ ]+PERL_VERSION/ {print $3}' $src/patchlevel.h`
13 perl_subversion=`awk '/define[ ]+PERL_SUBVERSION/ {print $3}' $src/patchlevel.h`
14 version="${perl_revision}.${perl_version}.${perl_subversion}"
16 # Pretend that Darwin doesn't know about those system calls in Tiger
17 # (10.4/darwin 8) and earlier [perl #24122]
27 # finite() deprecated in 10.9, use isfinite() instead.
30 *) d_finite='undef' ;;
33 # This was previously used in all but causes three cases
34 # (no -Ddprefix=, -Dprefix=/usr, -Dprefix=/some/thing/else)
35 # but that caused too much grief.
36 # vendorlib="/System/Library/Perl/${version}"; # Apple-supplied modules
38 case "$darwin_distribution" in
39 $define) # We are building/replacing the built-in perl
43 siteprefix='/usr/local';
44 # We don't want /usr/bin/HEAD issues.
45 sitebin='/usr/local/bin';
46 sitescript='/usr/local/bin';
47 installusrbinperl='define'; # You knew what you were doing.
48 privlib="/System/Library/Perl/${version}";
49 sitelib="/Library/Perl/${version}";
51 usevendorprefix='define';
53 vendorscript='/usr/bin';
54 vendorlib="/Network/Library/Perl/${version}";
55 # 4BSD uses ${prefix}/share/man, not ${prefix}/man.
56 man1dir='/usr/share/man/man1';
57 man3dir='/usr/share/man/man3';
58 # But users' installs shouldn't touch the system man pages.
59 # Transient obsoleted style.
60 siteman1='/usr/local/share/man/man1';
61 siteman3='/usr/local/share/man/man3';
63 siteman1dir='/usr/local/share/man/man1';
64 siteman3dir='/usr/local/share/man/man3';
72 # Since we can build fat, the archname doesn't need the processor type
75 # nm isn't known to work after Snow Leopard and XCode 4; testing with OS X 10.5
76 # and Xcode 3 shows a working nm, but pretending it doesn't work produces no
82 # Optimizing for size also mean less resident memory usage on the part
83 # of Perl. Apple asserts that this is a more important optimization than
84 # saving on CPU cycles. Given that memory speed has not increased at
85 # pace with CPU speed over time (on any platform), this is probably a
86 # reasonable assertion.
87 if [ -z "${optimize}" ]; then
88 case "`${cc:-gcc} -v 2>&1`" in
89 *"gcc version 3."*) optimize='-Os' ;;
98 # -fno-common because common symbols are not allowed in MH_DYLIB
99 # -DPERL_DARWIN: apparently the __APPLE__ is not sanctioned by Apple
100 # as the way to differentiate Mac OS X. (The official line is that
101 # *no* cpp symbol does differentiate Mac OS X.)
102 ccflags="${ccflags} -fno-common -DPERL_DARWIN"
104 # At least on Darwin 1.3.x:
106 # # define INT32_MIN -2147483648
108 # double a = INT32_MIN;
109 # printf ("INT32_MIN=%g\n", a);
113 # INT32_MIN=2.14748e+09
114 # Note that the INT32_MIN has become positive.
115 # INT32_MIN is set in /usr/include/stdint.h by:
116 # #define INT32_MIN -2147483648
117 # which seems to break the gcc. Defining INT32_MIN as (-2147483647-1)
118 # seems to work. INT64_MIN seems to be similarly broken.
119 # -- Nicholas Clark, Ken Williams, and Edward Moy
121 # This seems to have been fixed since at least Mac OS X 10.1.3,
122 # stdint.h defining INT32_MIN as (-INT32_MAX-1)
125 if test -f /usr/include/stdint.h; then
126 case "$(grep '^#define INT32_MIN' /usr/include/stdint.h)" in
127 *-2147483648) ccflags="${ccflags} -DINT32_MIN_BROKEN -DINT64_MIN_BROKEN" ;;
131 # Avoid Apple's cpp precompiler, better for extensions
132 if [ "X`echo | ${cc} -no-cpp-precomp -E - 2>&1 >/dev/null`" = "X" ]; then
133 cppflags="${cppflags} -no-cpp-precomp"
135 # This is necessary because perl's build system doesn't
136 # apply cppflags to cc compile lines as it should.
137 ccflags="${ccflags} ${cppflags}"
140 # Known optimizer problems.
141 case "`cc -v 2>&1`" in
142 *"3.1 20020105"*) toke_cflags='optimize=""' ;;
145 # Shared library extension is .dylib.
146 # Bundle extension is .bundle.
151 # 10.4 can use dlopen.
158 dlsrc='dl_dlopen.xs';
164 case "$ccdlflags" in # If passed in from command line, presume user knows best
166 cccdlflags=' '; # space, not empty, because otherwise we get -fpic
170 # Allow the user to override ld, but modify it as necessary below
173 # If the cc is explicitly something else than cc (or empty),
174 # set the ld to be that explicitly something else. Conversely,
175 # if the cc is 'cc' (or empty), set the ld to be 'cc'.
182 # From http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/mk/platform/Darwin.mk
183 # and https://trac.macports.org/wiki/XcodeVersionInfo
184 # and https://trac.macports.org/wiki/UsingTheRightCompiler
185 # and https://gist.github.com/yamaya/2924292
186 # and http://opensource.apple.com/source/clang/
188 # Note that Xcode gets updates on older systems sometimes, and in
189 # general that the OS levels and XCode levels are not synchronized
190 # since new releases of XCode usually support both some new and some
193 # Note that Apple hijacks the clang preprocessor symbols __clang_major__
194 # and __clang_minor__ so they cannot be used (easily) to detect the
195 # actual clang release. For example:
197 # "Yosemite 10.10.x 14.x.y 6.3 (clang 3.6 as 6.1/602.0.49)"
199 # means that the Xcode 6.3 provided the clang 6.3 but called it 6.1
200 # (__clang_major__, __clang_minor__) and in addition the preprocessor
201 # symbol __apple_build_version__ was 6020049.
203 # Codename OS Kernel Xcode
205 # Cheetah 10.0.x 1.3.1
208 # Jaguar 10.2.x 6.x.y
209 # Panther 10.3.x 7.x.y
210 # Tiger 10.4.x 8.x.y 2.0 (gcc4 4.0.0)
214 # Leopard 10.5.x 9.x.y 3.0 (gcc 4.0.1 default)
216 # Snow Leopard 10.6.x 10.x.y 3.2 (llvm gcc 4.2, clang 2.3 as 1.0)
217 # 3.2.1 (clang 1.0.1 as 1.0.1/24)
218 # 3.2.2 (clang 1.0.2 as 1.0.2/32)
219 # 3.2.3 (clang 1.5 as 1.5/60)
220 # 4.0.1 (clang 2.9 as 2.0/138)
221 # Lion 10.7.x 11.x.y 4.1 (llvm gcc 4.2.1, clang 3.0 as 2.1/163.7.1)
222 # 4.2 (clang 3.0 as 3.0/211.10.1)
223 # 4.3.3 (clang 3.1 as 3.1/318.0.61)
224 # 4.4 (clang 3.1 as 4.0/421.0.57)
225 # Mountain Lion 10.8.x 12.x.y 4.5 (clang 3.1 as 4.1/421.11.65, real gcc removed, there is gcc but it's really clang)
226 # 4.6 (clang 3.2 as 4.2/425.0.24)
227 # 5.0 (clang 3.3 as 5.0/500.2.75)
228 # 5.1 (clang 3.4 as 5.1/503.0.38)
229 # 5.1.1 (clang 3.4 as 5.1/503.0.40)
230 # Mavericks 10.9.x 13.x.y 6.0.1 (clang 3.5 as 6.0/600.0.51)
231 # 6.1 (clang 3.5 as 6.0/600.0.54)
232 # 6.1.1 (clang 3.5 as 6.0/600.0.56)
233 # 6.2 (clang 3.5 as 6.0/600.0.57)
234 # Yosemite 10.10.x 14.x.y 6.3 (clang 3.6 as 6.1/602.0.49)
235 # 6.3.1 (clang 3.6 as 6.1/602.0.49)
236 # 6.3.2 (clang 3.6 as 6.1/602.0.53)
237 # El Capitan 10.11.x 15.x.y 7.0 (clang 3.7 as 7.0/700.0.72)
238 # 7.1 (clang 3.7 as 7.0/700.1.76)
239 # 7.2 (clang 3.7 as 7.0.2/700.1.81)
240 # 7.2.1 (clang 3.7 as 7.0.2/700.1.81)
241 # 7.3 (clang 3.8 as 7.3.0/703.0.29)
242 # Sierra 10.12.x 16.x.y 8.0.0 (clang 3.8 as 8.0/800.0.38)
245 # Processors Supported
247 # PowerPC (PPC): 10.0.x - 10.5.8 (final 10.5.x)
248 # PowerPC via Rosetta: 10.4.4 - 10.6.8 (final 10.6.x)
249 # IA-32: 10.4.4 - 10.6.8 (though still supported on x86-64)
250 # x86-64: 10.4.7 - current
252 # MACOSX_DEPLOYMENT_TARGET selects the minimum OS level we want to support
254 # It is needed for OS releases before 10.6.
256 # https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/cross_development/Configuring/configuring.html
258 # If it is set, we also propagate its value to ccflags and ldflags
259 # using the -mmacosx-version-min flag. If it is not set, we use
260 # the OS X release as the min value for the flag.
262 # Adds "-mmacosx-version-min=$2" to "$1" unless it already is there.
263 add_macosx_version_min () {
267 *"-mmacosx-version-min"*)
268 echo "NOT adding -mmacosx-version-min=$2 to $1 ($v)" >&4
270 *) echo "Adding -mmacosx-version-min=$2 to $1" >&4
271 eval "$1='$v -mmacosx-version-min=$2'"
276 # Perl bundles do not expect two-level namespace, added in Darwin 1.4.
277 # But starting from perl 5.8.1/Darwin 7 the default is the two-level.
278 case "$osvers" in # Note: osvers is the kernel version, not the 10.x
279 1.[0-3].*) # OS X 10.0.x
280 lddlflags="${ldflags} -bundle -undefined suppress"
283 ldflags="${ldflags} -flat_namespace"
284 lddlflags="${ldflags} -bundle -undefined suppress"
286 [2-6].*) # OS X 10.1.x - 10.2.x (though [2-4] never existed publicly)
287 ldflags="${ldflags} -flat_namespace"
288 lddlflags="${ldflags} -bundle -undefined suppress"
290 [7-8].*) # OS X 10.3.x - 10.4.x
291 lddlflags="${ldflags} -bundle -undefined dynamic_lookup"
293 *MACOSX_DEPLOYMENT_TARGET*) ;;
294 *) ld="env MACOSX_DEPLOYMENT_TARGET=10.3 ${ld}" ;;
297 *) # OS X 10.5.x - current
298 # The MACOSX_DEPLOYMENT_TARGET is not needed,
299 # but the -mmacosx-version-min option is always used.
301 # We now use MACOSX_DEPLOYMENT_TARGET, if set, as an override by
302 # capturing its value and adding it to the flags.
303 case "$MACOSX_DEPLOYMENT_TARGET" in
305 add_macosx_version_min ccflags $MACOSX_DEPLOYMENT_TARGET
306 add_macosx_version_min ldflags $MACOSX_DEPLOYMENT_TARGET
309 # Empty MACOSX_DEPLOYMENT_TARGET is okay.
314 *** Unexpected MACOSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET
316 *** Please either set it to a valid macOS version number (e.g., 10.15) or to empty.
323 # Keep the prodvers leading whitespace (Configure magic).
324 # Cannot use $osvers here since that is the kernel version.
325 # sw_vers output what we want
326 # "ProductVersion: 10.10.5" "10.10"
327 # "ProductVersion: 10.11" "10.11"
328 prodvers=`sw_vers|awk '/^ProductVersion:/{print $2}'|awk -F. '{print $1"."$2}'`
331 add_macosx_version_min ccflags $prodvers
332 add_macosx_version_min ldflags $prodvers
337 *** Unexpected product version $prodvers.
339 *** Try running sw_vers and see what its ProductVersion says.
345 darwin_major=$(echo $osvers|awk -F. '{print $1}')
347 # macOS 10.12 (darwin 16.0.0) deprecated syscall().
348 if [ "$darwin_major" -ge 16 ]; then
350 # If deploying to pre-10.12, suppress Time::HiRes's detection of the system clock_gettime()
351 case "$MACOSX_DEPLOYMENT_TARGET" in
352 10.[6-9]|10.10|10.11)
353 ccflags="$ccflags -Werror=partial-availability -D_DARWIN_FEATURE_CLOCK_GETTIME=0"
360 lddlflags="${ldflags} -bundle -undefined dynamic_lookup"
364 # Darwin's querylocale() has races
365 ccflags="$ccflags -DNO_THREAD_SAFE_QUERYLOCALE"
367 # But it doesn't much matter because the whole implementation has bugs [GH
369 ccflags="$ccflags -DNO_POSIX_2008_LOCALE"
371 # See comments in locale.c about this #define
372 ccflags="$ccflags -DHAS_BROKEN_LANGINFO_CODESET"
374 # Get: "Assertion failed: (p->val == key), function lookup_substsearch, file
375 # collate.c, line 596."
376 if test "$darwin_major" -ge 24 && test "$perl_revision" -ge 5 && ( test "$perl_version" -ge 42 || ( test "$perl_version" -eq 41 && test "$perl_subversion" -ge 11 ) ); then
377 ccflags="$ccflags -DNO_LOCALE_COLLATE"
380 ldlibpthname='DYLD_LIBRARY_PATH';
382 # useshrplib=true results in much slower startup times.
383 # 'false' is the default value. Use Configure -Duseshrplib to override.
385 cat > UU/archname.cbu <<'EOCBU'
386 # This script UU/archname.cbu will get 'called-back' by Configure
387 # after it has otherwise determined the architecture name.
389 *"-flat_namespace"*) ;; # Backward compat, be flat.
390 # If we are using two-level namespace, we will munge the archname to show it.
391 *) archname="${archname}-2level" ;;
395 # 64-bit addressing support. Currently strictly experimental. DFD 2005-06-06
396 case "$use64bitall" in
404 *** 64-bit addressing is not supported for Mac OS X versions
405 *** below 10.4 ("Tiger") or Darwin versions below 8. Please try
406 *** again without -Duse64bitall. (-Duse64bitint will work, however.)
418 *** Perl 64-bit addressing support is experimental for Mac OS X
419 *** 10.4 ("Tiger") and Darwin version 8. System V IPC is disabled
420 *** due to problems with the 64-bit versions of msgctl, semctl,
421 *** and shmctl. You should also expect the following test failures:
423 *** ext/threads-shared/t/wait (threaded builds only)
427 [ "$d_msgctl" ] || d_msgctl='undef'
428 [ "$d_semctl" ] || d_semctl='undef'
429 [ "$d_shmctl" ] || d_shmctl='undef'
434 powerpc) arch=ppc64 ;;
439 *** Don't recognize processor, can't specify 64 bit compilation.
445 for var in ccflags cppflags ld ldflags
447 eval $var="\$${var}\ -arch\ $arch"
463 case "$usemallocwrap" in
464 '') usemallocwrap='define' ;;
467 # our malloc works (but allow users to override)
468 case "$usemymalloc" in
469 '') usemymalloc='n' ;;
471 # However sbrk() returns -1 (failure) somewhere in lib/unicore/mktables at
472 # around 14M, so we need to use system malloc() as our sbrk()
474 # sbrk() in Darwin deprecated since Mavericks (10.9), it still exists
475 # in Yosemite (10.10) but that is just an emulation, and fails for
476 # allocations beyond 4MB. One should use e.g. mmap instead (or system
477 # malloc, as suggested above, that but is kind of backward).
478 malloc_cflags='ccflags="-DUSE_PERL_SBRK -DPERL_SBRK_VIA_MALLOC $ccflags"'
480 # Locales aren't feeling well.
481 LC_ALL=C; export LC_ALL;
485 # The libraries are not threadsafe as of OS X 10.1.
487 # Fix when Apple fixes libc.
489 case "$usethreads$useithreads" in
492 [12345].*) cat <<EOM >&4
496 *** Warning, there might be problems with your libraries with
497 *** regards to threading. The test ext/threads/t/libc.t is likely
502 *) usereentrant='define';;
507 # Fink can install a GDBM library that claims to have the ODBM interfaces
508 # but Perl dynaloader cannot for some reason use that library. We don't
509 # really need ODBM_FIle, though, so let's just hint ODBM away.
512 # Configure doesn't detect ranlib on Tiger properly.
513 # NeilW says this should be acceptable on all darwin versions.
516 # Catch MacPorts gcc/g++ extra libdir
517 case "$($cc -v 2>&1)" in
518 *"MacPorts gcc"*) loclibpth="$loclibpth /opt/local/lib/libgcc" ;;
525 # Case-insensitive filesystems don't get along with Makefile and
526 # makefile in the same place. Since Darwin uses GNU make, this dodges
528 firstmakefile=GNUmakefile;
530 # if you use a newer toolchain before OS X 10.9 these functions may be
531 # incorrectly detected, so disable them
532 # OS X 10.10.x corresponds to kernel 14.x
543 # mkostemp() was autodetected as present but found to not be linkable
544 # on 15.6.0. Unknown what other OS versions are affected.
547 # Apparently the MACH-O format can't support _Thread_local in shared objects,
548 # but clang isn't wise to this, so our probe works but the build fails...