Whamcloud - gitweb
LU-3939 tests: sanity-hsm/test_40 needs a local HSM_ARCHIVE
[fs/lustre-release.git] / config / lustre-build-darwin.m4
1 #
2 # LB_DARWIN_CHECK_FUNCS
3 #
4 # check for functions in the darwin kernel
5 # Note that this is broken for cross compiling
6 #
7 AC_DEFUN([LB_DARWIN_CHECK_FUNCS],
8 [AC_FOREACH([AC_Func], [$1],
9   [AH_TEMPLATE(AS_TR_CPP(HAVE_[]AC_Func),
10                [Define to 1 if you have the `]AC_Func[' function.])])dnl
11 for ac_func in $1
12 do
13 AC_MSG_CHECKING([for $1])
14 AS_IF([AC_TRY_COMMAND(nm /mach | grep "[$1]" >/dev/null 2>/dev/null)],[
15         AC_MSG_RESULT([yes])
16         AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$ac_func])) $2
17 ],[
18         AC_MSG_RESULT([no]) $3
19 ])
20 done
21 ])
22
23 #
24 # LB_DARWIN_CONDITIONALS
25 #
26 # AM_CONDITIONALs for darwin
27 #
28 AC_DEFUN([LB_DARWIN_CONDITIONALS],
29 [
30 ])
31
32 #
33 # LB_PROG_DARWIN
34 #
35 # darwin tests
36 #
37 AC_DEFUN([LB_PROG_DARWIN],
38 [kernel_framework="/System/Library/Frameworks/Kernel.framework"
39 #
40 # FIXME: there should be a better way to get these than hard coding them
41 #
42 case $target_cpu in 
43         powerpc*)
44                 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -arch ppc -mtune=G4 -mlong-branch"
45                 EXTRA_KLDFLAGS="-arch ppc"
46                 ;;
47         i?86 | x86_64)
48                 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -arch i386"
49                 EXTRA_KLDFLAGS="-arch i386"
50                 ;;
51 esac
52
53 # Kernel of OS X is not 64bits(even in Tiger), but -m64 can be taken by gcc in Tiger
54 # (Tiger can support 64bits applications), so we have to eliminate -m64 while 
55 # building kextensions for and OS X.
56 CC=`echo $CC | sed -e "s/\-m64//g"`
57 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -x c -pipe -Wno-trigraphs -fasm-blocks -g -O0"
58 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Wno-four-char-constants -Wmost -O0"
59 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -fmessage-length=0"
60 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -I$kernel_framework/Headers"
61 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -I$kernel_framework/Headers/bsd"
62 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -I$kernel_framework/PrivateHeaders"
63 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -fno-common -nostdinc -fno-builtin"
64 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -finline -fno-keep-inline-functions"
65 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -force_cpusubtype_ALL -fno-exceptions"
66 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -msoft-float -static"
67 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -DKERNEL -DKERNEL_PRIVATE"
68 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -DDRIVER_PRIVATE -DAPPLE -DNeXT"
69 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -D__KERNEL__ -D__DARWIN__"
70 #
71 # C flags for Panther/Tiger
72 #
73 case $target_os in
74         darwin8*)
75                 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -D__DARWIN8__"
76         ;;
77         darwin7*)
78                 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -ffix-and-continue"
79         ;;
80 esac
81
82 #
83 # Debugging flags. Remove!
84 #
85 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -O0 -DMACH_ASSERT=1"
86 EXTRA_KLDFLAGS="$EXTRA_KLDFLAGS -static -nostdlib -r"
87 EXTRA_KLIBS="-lkmodc++ -lkmod -lcc_kext"
88 KMODEXT=""
89
90 AC_SUBST(EXTRA_KLDFLAGS)
91 AC_SUBST(EXTRA_KLIBS)
92
93 kextdir='/System/Library/Extensions/$(firstword $(macos_PROGRAMS)).kext'
94 plistdir='$(kextdir)/Contents'
95 macosdir='$(plistdir)/MacOS'
96
97 AC_SUBST(kextdir)
98 AC_SUBST(plistdir)
99 AC_SUBST(macosdir)
100
101 LN_PROG_DARWIN
102
103 LP_PROG_DARWIN
104
105 LC_PROG_DARWIN
106 ])