initial commit
[glibc.git] / sysdeps / mach / configure.ac
1 GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
2
3 AC_CHECK_TOOL(MIG, mig, MISSING)
4 if test "x$MIG" = xMISSING; then
5 AC_MSG_ERROR([cannot find required build tool mig])
6 fi
7 LIBC_CONFIG_VAR([MIG], [$MIG])
8
9 OLD_CPPFLAGS=$CPPFLAGS
10 if test -n "$sysheaders"; then
11 CPPFLAGS="$CPPFLAGS $SYSINCLUDES"
12 fi
13
14 ### Sanity checks for Mach header installation
15 CPPFLAGS="$CPPFLAGS -ffreestanding"
16 AC_CHECK_HEADER(mach/mach_types.h,,
17 [AC_MSG_ERROR([cannot find Mach headers])], -)
18 AC_CHECK_HEADER(mach/mach_types.defs,, [dnl
19 AC_MSG_ERROR([cannot find Mach .defs files])], -)
20
21 dnl
22 dnl mach_TYPE_CHECK(foo_t, bar_t)
23 dnl
24 dnl Check if foo_t is defined by <mach/mach_types.h>.
25 dnl If not, compile with -Dfoo_t=bar_t.
26 dnl
27 AC_DEFUN([mach_TYPE_CHECK], [dnl
28 AC_CACHE_CHECK(for $1 in mach/mach_types.h, libc_cv_mach_$1,
29 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <mach/mach_types.h>]], [[extern $1 foo;]])],
30 [libc_cv_mach_$1=$1], [libc_cv_mach_$1=$2]))
31 if test [$]libc_cv_mach_$1 != $1; then
32 DEFINES="$DEFINES -D$1=$2"
33 fi])
34
35 dnl
36 dnl OSF Mach has renamed these typedefs for some reason.
37 dnl
38 mach_TYPE_CHECK(task_t, task_port_t)
39 mach_TYPE_CHECK(thread_t, thread_port_t)
40
41 dnl
42 dnl The creation_time field is a GNU Mach addition the other variants lack.
43 dnl
44 AC_CACHE_CHECK(for creation_time in task_basic_info,
45 libc_cv_mach_task_creation_time, [dnl
46 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <mach/task_info.h>]], [[
47 extern struct task_basic_info *i;
48 long s = i->creation_time.seconds;
49 ]])], [libc_cv_mach_task_creation_time=yes], [libc_cv_mach_task_creation_time=no])])
50 if test $libc_cv_mach_task_creation_time = no; then
51 AC_MSG_ERROR([you need Mach headers supporting task_info.creation_time])
52 fi
53
54 dnl
55 dnl The Darwin variant no longer has <mach/mach.defs>
56 dnl but instead has several constituent .defs files.
57 dnl In this scenario we will presume there is a <mach/mach_interface.h>
58 dnl that contains an #include for each constituent header file,
59 dnl but we don't do a check for that here because in a bare
60 dnl environment the compile against those headers will fail.
61 dnl
62 mach_interface_list=
63 for ifc in mach mach4 gnumach \
64 clock clock_priv host_priv host_security ledger lock_set \
65 processor processor_set task task_notify thread_act vm_map \
66 memory_object memory_object_default default_pager \
67 i386/mach_i386 \
68 ; do
69 AC_CHECK_HEADER(mach/${ifc}.defs, [dnl
70 mach_interface_list="$mach_interface_list $ifc"],, -)
71 done
72 if test "x$mach_interface_list" = x; then
73 AC_MSG_ERROR([what manner of Mach is this?])
74 fi
75
76 AC_CACHE_CHECK(for host_page_size in mach_host.defs,
77 libc_cv_mach_host_page_size, [dnl
78 AC_EGREP_HEADER(host_page_size, mach/mach_host.defs,
79 libc_cv_mach_host_page_size=yes,
80 libc_cv_mach_host_page_size=no)])
81 if test $libc_cv_mach_host_page_size = yes; then
82 AC_DEFINE([HAVE_HOST_PAGE_SIZE])
83 fi
84
85 AC_CHECK_HEADER(mach/machine/ndr_def.h, [dnl
86 DEFINES="$DEFINES -DNDR_DEF_HEADER='<mach/machine/ndr_def.h>'"], [dnl
87 AC_CHECK_HEADER(machine/ndr_def.h, [dnl
88 DEFINES="$DEFINES -DNDR_DEF_HEADER='<machine/ndr_def.h>'"],, -)], -)
89
90 AC_CACHE_CHECK(for i386_io_perm_modify in mach_i386.defs,
91 libc_cv_mach_i386_ioports, [dnl
92 AC_EGREP_HEADER(i386_io_perm_modify, mach/i386/mach_i386.defs,
93 libc_cv_mach_i386_ioports=yes,
94 libc_cv_mach_i386_ioports=no)])
95 if test $libc_cv_mach_i386_ioports = yes; then
96 AC_DEFINE([HAVE_I386_IO_PERM_MODIFY])
97 fi
98
99 AC_CACHE_CHECK(for i386_set_gdt in mach_i386.defs,
100 libc_cv_mach_i386_gdt, [dnl
101 AC_EGREP_HEADER(i386_set_gdt, mach/i386/mach_i386.defs,
102 libc_cv_mach_i386_gdt=yes,
103 libc_cv_mach_i386_gdt=no)])
104 if test $libc_cv_mach_i386_gdt = yes; then
105 AC_DEFINE([HAVE_I386_SET_GDT])
106 fi
107
108 dnl Swiped from hurd/aclocal.m4
109 AC_DEFUN([hurd_MIG_RETCODE], [dnl
110 # See if mig groks `retcode'.
111 AC_CACHE_CHECK(whether $MIG supports the retcode keyword, hurd_cv_mig_retcode,
112 [cat > conftest.defs <<\EOF
113 #include <mach/std_types.defs>
114 #include <mach/mach_types.defs>
115 subsystem foobar 1000;
116 type reply_port_t = polymorphic | MACH_MSG_TYPE_PORT_SEND_ONCE
117 ctype: mach_port_t;
118 simpleroutine foobar_reply (
119 reply_port: reply_port_t;
120 err: kern_return_t, RetCode);
121 EOF
122 if AC_TRY_COMMAND([CC="${CC}" ${MIG-false} -n conftest.defs 1>&AS_MESSAGE_LOG_FD]); then
123 hurd_cv_mig_retcode=yes
124 else
125 hurd_cv_mig_retcode=no
126 fi
127 rm -f conftest*])
128 if test $hurd_cv_mig_retcode = yes; then
129 AC_DEFINE(HAVE_MIG_RETCODE)
130 fi])
131
132 hurd_MIG_RETCODE
133
134 CPPFLAGS=$OLD_CPPFLAGS