Skip to content

Commit

Permalink
Macos: m4 changes
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Innes <[email protected]>
Co-authored-by: Jorgen Lundman <[email protected]>
  • Loading branch information
andrewc12 and lundman committed Jan 16, 2024
1 parent f0bf7a2 commit 9a390d0
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 12 deletions.
20 changes: 20 additions & 0 deletions config/always-compiler-options.m4
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,23 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_KERNEL_CC_NO_IPA_SRA], [
CFLAGS="$saved_flags"
AC_SUBST([KERNEL_NO_IPA_SRA])
])

dnl # Check if cc supports -finline-hint-functions
dnl #
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_INLINE_HINT_FUNCTIONS], [
AC_MSG_CHECKING([whether $CC supports -finline-hint-functions])
saved_flags="$CFLAGS"
CFLAGS="$CFLAGS -Werror -finline-hint-functions"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
INLINE_HINT_FUNCTIONS=-finline-hint-functions
AC_MSG_RESULT([yes])
], [
INLINE_HINT_FUNCTIONS=
AC_MSG_RESULT([no])
])
CFLAGS="$saved_flags"
AC_SUBST([INLINE_HINT_FUNCTIONS])
])
7 changes: 7 additions & 0 deletions config/always-system.m4
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_SYSTEM], [
ac_system="FreeBSD"
ac_system_l="freebsd"
;;
*darwin*)
AC_DEFINE([SYSTEM_MACOS], [1],
[True if ZFS is to be compiled for a macOS system])
ac_system="macOS"
ac_system_l="macos"
;;
*)
ac_system="unknown"
ac_system_l="unknown"
Expand All @@ -27,4 +33,5 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_SYSTEM], [
AM_CONDITIONAL([BUILD_LINUX], [test "x$ac_system" = "xLinux"])
AM_CONDITIONAL([BUILD_FREEBSD], [test "x$ac_system" = "xFreeBSD"])
AM_CONDITIONAL([BUILD_MACOS], [test "x$ac_system" = "xmacOS"])
])
103 changes: 103 additions & 0 deletions config/kernel-macos-headers.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
dnl #
dnl # macOS - attempt to find kernel headers. This is expected to
dnl # only run on mac platforms (using xcrun command) to iterate
dnl # through versions of xcode, and xnu kernel source locations
dnl #
AC_DEFUN([ZFS_AC_KERNEL_SRC_MACOS_HEADERS], [
AM_COND_IF([BUILD_MACOS], [
AC_MSG_CHECKING([macOS kernel source directory])
AS_IF([test -z "$kernelsrc"], [
system_major_version=`sw_vers -productVersion | $AWK -F '.' '{ print $[]1 "." $[]2 }'`
AS_IF([test -d "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${system_major_version}.sdk/System/Library/Frameworks/Kernel.framework/Headers"], [
kernelsrc="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${system_major_version}.sdk/System/Library/Frameworks/Kernel.framework"])
])
AS_IF([test -z "$kernelsrc"], [
AS_IF([test -d "/System/Library/Frameworks/Kernel.framework/Headers"], [
kernelsrc="/System/Library/Frameworks/Kernel.framework"])
])
AS_IF([test -z "$kernelsrc"], [
tmpdir=`xcrun --show-sdk-path`
AS_IF([test -d "$tmpdir/System/Library/Frameworks/Kernel.framework/Headers"], [
kernelsrc="$tmpdir/System/Library/Frameworks/Kernel.framework"])
])
AS_IF([test -z "$kernelsrc"], [
AS_IF([test -d "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Kernel.framework"], [
kernelsrc="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Kernel.framework"])
])
AS_IF([test -z "$kernelsrc"], [
AS_IF([test -d "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Kernel.framework"], [
kernelsrc="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Kernel.framework"])
])
AS_IF([test -z "$kernelsrc"], [
AS_IF([test -d "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Kernel.framework"], [
kernelsrc="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Kernel.framework"])
])
AC_MSG_RESULT([$kernelsrc])
AC_MSG_CHECKING([macOS kernel build directory])
AS_IF([test -z "$kernelbuild"], [
kernelbuild=${kernelsrc}
])
])
AC_MSG_RESULT([$kernelbuild])
AC_ARG_WITH([kernel-modprefix],
AS_HELP_STRING([--with-kernel-modprefix=PATH],
[Path to kernel module prefix]),
[KERNEL_MODPREFIX="$withval"])
AC_MSG_CHECKING([macOS kernel module prefix])
AS_IF([test -z "$KERNEL_MODPREFIX"], [
KERNEL_MODPREFIX="/Library/Extensions"
])
AC_MSG_RESULT([$KERNEL_MODPREFIX])
AC_DEFINE_UNQUOTED([KERNEL_MODPREFIX],
["$KERNEL_MODPREFIX"],
[Path where the kernel module is installed.]
)
AC_MSG_CHECKING([macOS kernel source version])
utsrelease1=$kernelbuild/Headers/libkern/version.h
AS_IF([test -r $utsrelease1 && fgrep -q OSRELEASE $utsrelease1], [
kernverfile=libkern/version.h ])
AS_IF([test "$kernverfile"], [
kernsrcver=`(echo "#include <$kernverfile>";
echo "kernsrcver=OSRELEASE") |
cpp -I$kernelbuild/Headers |
grep "^kernsrcver=" | cut -d \" -f 2`
AS_IF([test -z "$kernsrcver"], [
AC_MSG_RESULT([Not found])
AC_MSG_ERROR([*** Cannot determine kernel version.])
])
AC_MSG_RESULT([$kernsrcver])
])
AC_MSG_CHECKING([mach_kernel])
AS_IF([test -z "$machkernel"], [
AS_IF([test -e "/System/Library/Kernels/kernel"], [
machkernel="/System/Library/Kernels/kernel" ] )
AS_IF([test -e "/mach_kernel"], [
machkernel="/mach_kernel" ] )
AS_IF([test ! -f "$machkernel"], [
AC_MSG_ERROR([
*** mach_kernel file not found. For 10.9 and prior, this should be
*** '/mach_kernel' and for 10.10 and following, this should be
*** '/System/Library/Kernels/kernel'])
])
])
AC_MSG_RESULT($machkernel)
dnl More Generic names:
MACH_KERNEL=${machkernel}
KERNEL_HEADERS=${kernelsrc}
KERNEL_VERSION=${kernsrcver}
AC_SUBST(KERNEL_HEADERS)
AC_SUBST(KERNEL_MODPREFIX)
AC_SUBST(KERNEL_VERSION)
AC_SUBST(MACH_KERNEL)
])
])

29 changes: 22 additions & 7 deletions config/kernel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
AC_SUBST(KERNEL_MAKE)
])
AM_COND_IF([BUILD_MACOS], [
ZFS_AC_KERNEL_SRC_MACOS_HEADERS
ZFS_AC_CONFIG_ALWAYS_CC_FRAME_LARGER_THAN
])
])

dnl #
Expand Down Expand Up @@ -380,6 +384,7 @@ dnl # and `/usr/src/linux-*` with the highest version number according
dnl # to `sort -V` is assumed to be both source and build directory.
dnl #
AC_DEFUN([ZFS_AC_KERNEL], [
AC_ARG_WITH([linux],
AS_HELP_STRING([--with-linux=PATH],
[Path to kernel source]),
Expand All @@ -390,6 +395,15 @@ AC_DEFUN([ZFS_AC_KERNEL], [
[Path to kernel build objects]),
[kernelbuild="$withval"])
AC_ARG_WITH([macos],
AS_HELP_STRING([--with-macos=PATH],
[Path to macOS source]),
[kernelsrc="$withval/sys"])
AC_ARG_WITH(macos-obj,
AS_HELP_STRING([--with-macos-obj=PATH],
[Path to macOS build objects]),
[kernelbuild="$withval/$kernelsrc"])
AC_MSG_CHECKING([kernel source and build directories])
AS_IF([test -n "$kernelsrc" && test -z "$kernelbuild"], [
kernelbuild="$kernelsrc"
Expand Down Expand Up @@ -453,7 +467,8 @@ AC_DEFUN([ZFS_AC_KERNEL], [
*** Please make sure the kernel devel package for your distribution
*** is installed and then try again. If that fails, you can specify the
*** location of the kernel source and build with the '--with-linux=PATH' and
*** '--with-linux-obj=PATH' options respectively.])
*** '--with-linux-obj=PATH' options respectively.
*** If you are configuring for macOS, use '--with-macos=PATH'.])
])
AC_MSG_CHECKING([kernel source version])
Expand Down Expand Up @@ -604,19 +619,19 @@ dnl # ZFS_LINUX_CONFTEST_H
dnl #
AC_DEFUN([ZFS_LINUX_CONFTEST_H], [
test -d build/$2 || mkdir -p build/$2
cat - <<_ACEOF >build/$2/$2.h
cat - <<_ACEOF1 >build/$2/$2.h
$1
_ACEOF
_ACEOF1
])

dnl #
dnl # ZFS_LINUX_CONFTEST_C
dnl #
AC_DEFUN([ZFS_LINUX_CONFTEST_C], [
test -d build/$2 || mkdir -p build/$2
cat confdefs.h - <<_ACEOF >build/$2/$2.c
cat confdefs.h - <<_ACEOF2 >build/$2/$2.c
$1
_ACEOF
_ACEOF2
])

dnl #
Expand All @@ -633,12 +648,12 @@ AC_DEFUN([ZFS_LINUX_CONFTEST_MAKEFILE], [
file=build/$1/Makefile
dnl # Example command line to manually build source.
cat - <<_ACEOF >$file
cat - <<_ACEOF3 >$file
# Example command line to manually build source
# make modules -C $LINUX_OBJ $ARCH_UM M=$PWD/build/$1
ccflags-y := -Werror $FRAME_LARGER_THAN
_ACEOF
_ACEOF3
dnl # Additional custom CFLAGS as requested.
m4_ifval($3, [echo "ccflags-y += $3" >>$file], [])
Expand Down
11 changes: 11 additions & 0 deletions config/macos.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


AC_DEFUN([ZFS_AC_MACOS_IMPURE_ENABLE], [
AC_ARG_ENABLE(macos_impure,
AS_HELP_STRING([--enable-macos-impure],
[Use XNU Private.exports [[default: no]]]),
[CPPFLAGS="$CPPFLAGS -DMACOS_IMPURE"],
[])
])


10 changes: 8 additions & 2 deletions config/user-libfetch.m4
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,14 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_LIBFETCH], [
LIBFETCH_IS_LIBCURL=1
if test "$(curl-config --built-shared)" = "yes"; then
LIBFETCH_DYNAMIC=1
LIBFETCH_SONAME="libcurl.so.4"
LIBFETCH_LIBS="-ldl"
dnl # why are we hardcoding libnames?
AM_COND_IF([BUILD_MACOS], [
LIBFETCH_SONAME="libcurl.4.dylib"
LIBFETCH_LIBS=""
], [
LIBFETCH_SONAME="libcurl.so.4"
LIBFETCH_LIBS="-ldl"
])
AC_MSG_RESULT([libcurl])
else
LIBFETCH_LIBS="$(curl-config --libs)"
Expand Down
7 changes: 5 additions & 2 deletions config/user.m4
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [
ZFS_AC_CONFIG_USER_LIBATOMIC
ZFS_AC_CONFIG_USER_LIBFETCH
ZFS_AC_CONFIG_USER_AIO_H
ZFS_AC_CONFIG_USER_CLOCK_GETTIME
ZFS_AC_CONFIG_USER_PAM
AM_COND_IF([BUILD_MACOS], [
ZFS_AC_MACOS_IMPURE_ENABLE], [
ZFS_AC_CONFIG_USER_CLOCK_GETTIME
ZFS_AC_CONFIG_USER_PAM
])
ZFS_AC_CONFIG_USER_RUNSTATEDIR
ZFS_AC_CONFIG_USER_MAKEDEV_IN_SYSMACROS
ZFS_AC_CONFIG_USER_MAKEDEV_IN_MKDEV
Expand Down
6 changes: 5 additions & 1 deletion config/zfs-build.m4
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,8 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [
VENDOR=freebsd ;
elif test -f /etc/openEuler-release ; then
VENDOR=openeuler ;
elif test -f /usr/bin/sw_vers ; then
VENDOR=apple ;
else
VENDOR= ;
fi],
Expand All @@ -563,6 +565,7 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [
debian) DEFAULT_PACKAGE=deb ;;
freebsd) DEFAULT_PACKAGE=pkg ;;
openeuler) DEFAULT_PACKAGE=rpm ;;
apple) DEFAULT_PACKAGE=pkg ;;
*) DEFAULT_PACKAGE=rpm ;;
esac
AC_MSG_RESULT([$DEFAULT_PACKAGE])
Expand Down Expand Up @@ -606,6 +609,7 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [
ubuntu) initconfdir=/etc/default ;;
debian) initconfdir=/etc/default ;;
freebsd) initconfdir=$sysconfdir/rc.conf.d;;
apple) initconfdir=${prefix}/etc/launchd/launchd.d/ ;;
*) initconfdir=/etc/default ;;
esac
AC_MSG_RESULT([$initconfdir])
Expand Down Expand Up @@ -639,7 +643,7 @@ dnl # Default ZFS package configuration
dnl #
AC_DEFUN([ZFS_AC_PACKAGE], [
ZFS_AC_DEFAULT_PACKAGE
AS_IF([test x$VENDOR != xfreebsd], [
AS_IF([test x$VENDOR != xfreebsd -a x$VENDOR != xapple], [
ZFS_AC_RPM
ZFS_AC_DPKG
ZFS_AC_ALIEN
Expand Down

0 comments on commit 9a390d0

Please sign in to comment.