d620e5d0ef693ae40459a28d0cb7b56e951bce30
[debian/amanda] / config / amanda / shmem.m4
1 # SYNOPSIS
2 #
3 #   AMANDA_FUNC_SHM_ARG_TYPE
4 #
5 # OVERVIEW
6 #
7 #   Determine the type of the second argument to shmdt/shmat, defining
8 #   that type (without the *) in SHM_ARG_TYPE.
9 #
10 AC_DEFUN([AMANDA_FUNC_SHM_ARG_TYPE], [
11         AC_CHECK_HEADERS(
12             sys/types.h \
13             sys/ipc.h \
14             sys/shm.h \
15         )
16
17         AC_CACHE_CHECK(
18             [for shmdt() argument type],
19             amanda_cv_shmdt_arg_type,
20             [
21                 if test "$ac_cv_func_shmget" = yes; then
22                     cat <<EOF >conftest.$ac_ext
23 #include "confdefs.h"
24 #ifdef HAVE_SYS_TYPES_H
25 # include <sys/types.h>
26 #endif
27 #ifdef HAVE_SYS_IPC_H
28 # include <sys/ipc.h>
29 #endif
30 #ifdef HAVE_SYS_SHM_H
31 # include <sys/shm.h>
32 #endif
33
34 #ifdef __cplusplus
35 extern "C" void *shmat(int, void *, int);
36 #else
37 void *shmat();
38 #endif
39
40 int main()
41 {
42     int i;
43     return 0;
44 }
45 EOF
46                     ${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext >/dev/null 2>/dev/null
47                     if test $? = 0; then
48                         amanda_cv_shmdt_arg_type=void
49                     else
50                         amanda_cv_shmdt_arg_type=char
51                     fi
52                     rm -f conftest*
53                 else
54                     amanda_cv_shmdt_arg_type=nothing
55                 fi
56             ]
57         )
58         AC_DEFINE_UNQUOTED(SHM_ARG_TYPE,$amanda_cv_shmdt_arg_type,
59             [Define to type of shmget() function argument. ])
60     ]
61 )
62
63 # SYNOPSIS
64 #
65 #   AMANDA_CHECK_SHMEM
66 #
67 # OVERVIEW
68 #
69 #   Check for shared memory support; checks for the --with-mmap option,
70 #   and then ensures that the proper compilation infrastructure is in place
71 #   for either mmap or shared memory support.
72 #
73 #   Defines several HAVE_*_DECL symbols via ICE_CHECK_DECL, as well as 
74 #   HAVE_SYSVSHM if shared memory support is discovered.
75 #
76 AC_DEFUN([AMANDA_CHECK_SHMEM],
77 [
78     AC_REQUIRE([AC_HEADER_STDC])
79     AC_ARG_WITH(mmap,
80         AS_HELP_STRING([--with-mmap],
81             [force use of mmap instead of shared memory support]),
82         [
83             case "$FORCE_MMAP" in
84                 y | ye | yes | n | no) : ;;
85                 *) AC_MSG_ERROR([*** You must not supply an argument to --with-mmap.]) ;;
86             esac
87             FORCE_MMAP=$withval
88         ],
89         [ : ${FORCE_MMAP=no} ]
90     )
91
92
93     AC_CHECK_HEADERS(\
94             sys/shm.h \
95             sys/mman.h \
96     )
97
98     AC_FUNC_MMAP
99
100     AC_CHECK_FUNCS(shmget,
101         [
102             AMANDA_FUNC_SHM_ARG_TYPE
103             case "$FORCE_MMAP" in
104             n | no)
105                 AC_DEFINE(HAVE_SYSVSHM,1,
106                     [Define if SysV shared-memory functions are available. ])
107               ;;
108             esac
109         ]
110     )
111     ICE_CHECK_DECL(shmat,sys/types.h sys/ipc.h sys/shm.h)
112     ICE_CHECK_DECL(shmctl,sys/types.h sys/ipc.h sys/shm.h)
113     ICE_CHECK_DECL(shmdt,sys/types.h sys/ipc.h sys/shm.h)
114     ICE_CHECK_DECL(shmget,sys/types.h sys/ipc.h sys/shm.h)
115
116     if test "x$ac_cv_func_mmap_fixed_mapped" != xyes; then
117         case "$FORCE_MMAP" in
118         n | no)
119             if test "x$ac_cv_func_shmget" != xyes; then
120                 AMANDA_MSG_WARN([Neither shmget() nor mmap() found. This system will not support the Amanda server.])
121                 NO_SERVER_MODE=true
122             fi
123           ;;
124         y | ye | yes)
125             AMANDA_MSG_WARN([--with-mmap used on a system with no mmap() support.  This system will not support the Amanda server.])
126             NO_SERVER_MODE=true
127           ;;
128         esac
129     fi
130 ])