Version 1.3.
[pwmd.git] / configure.ac
blobd39d74dfc4bba58a60f831c48d66ad131504ead0
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.59)
3 AC_INIT(pwmd, 1.3, [Ben Kibbey bjk@luxsci.net])
4 AC_CONFIG_AUX_DIR(build)
5 AC_CANONICAL_TARGET
6 AM_INIT_AUTOMAKE([foreign])
7 AC_PROG_MAKE_SET
8 AC_CONFIG_SRCDIR([src/pwmd.c])
9 AM_CONFIG_HEADER([config.h])
10 AM_GNU_GETTEXT([external])
11 AM_GNU_GETTEXT_VERSION([0.16.1])
13 AC_ARG_ENABLE(locking, AC_HELP_STRING([--disable-locking],
14               [Disable cache mutex locking support.]), locking=no, locking=yes)
16 case "$target_os" in
17     *linux*)
18         kver=`uname -r 2>&1`
20         case "$kver" in
21             !2.6.*)
22                 if test "$locking" = "yes"; then
23                     AC_MSG_ERROR([pthread_mutex_t must be a complete type for
24                                   cache locking to work properly. I've only
25                                   tested Linux v2.6. Please read README for
26                                   details.])
27                 fi
29                 case "$kver" in
30                     2.[[0-3]]* | 1.*)
31                         LIBS="$LIBS -lrt"
32                         mmap_anonymous_shared=no
33                         ;;
34                     *)
35                         mmap_anonymous_shared=yes
36                         ;;
37                 esac
38                 ;;
39             *)
40                 AC_DEFINE([WORKING_PTHREADS], 1,
41                           [Define if your pthreads implementation has a complete pthread_mutex_t data type.])
42                 mmap_anonymous_shared=yes
43                 ;;
44         esac
45         ;;
46     *)
47         if test "$locking" = "yes"; then
48             AC_MSG_ERROR([pthread_mutex_t must be a complete type for
49                           cache locking to work properly. I've only
50                           tested Linux v2.6. Please read README for
51                           details.])
52         fi
53         ;;
54 esac
56 if test "$mmap_anonymous_shared" = "yes"; then
57     AC_DEFINE([MMAP_ANONYMOUS_SHARED], 1, \
58               [Define if your mmap() supports MAP_ANONYMOUS with MAP_SHARED.])
61 CFLAGS="$CFLAGS -D_GNU_SOURCE"
63 dnl Checks for programs.
64 AC_PROG_AWK
65 AC_PROG_LN_S
66 AC_PROG_CC
67 AC_PROG_INSTALL
69 dnl Checks for library functions.
70 AM_PATH_GLIB_2_0(,, AC_MSG_ERROR([glib2 not found]))
71 AM_PATH_LIBGCRYPT(,, AC_MSG_ERROR([libgcrypt not found]))
72 AM_PATH_XML2(,, AC_MSG_ERROR([libxml2 not found]))
73 AM_PATH_LIBASSUAN(,, AC_MSG_ERROR([libassuan not found]))
74 AM_PATH_GPG_ERROR(,, AC_MSG_ERROR([libgpg-error not found]))
75 ACX_PTHREAD(, AC_MSG_ERROR([pthreads not found]))
76 AC_CHECK_LIB(z, deflate,,
77             AC_MSG_ERROR([Version 1.2.2.1 or later of zlib is required]))
79 AC_TRY_RUN([
80             #include <stdio.h>
81             #include <zlib.h>
83             int main()
84             {
85                 if (ZLIB_VERNUM < 0x1221)
86                     exit(1);
88                 exit(0);
89             }],,
90             AC_MSG_ERROR([Version 1.2.2.1 or later of zlib is required]))
92 dnl Checks for header files.
93 AC_HEADER_STDC
94 AC_HEADER_SYS_WAIT
95 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/socket.h sys/time.h unistd.h \
96                   termios.h zlib.h])
98 dnl Checks for typedefs, structures, and compiler characteristics.
99 AC_C_CONST
100 AC_TYPE_SSIZE_T
101 AC_HEADER_TIME
102 AC_TYPE_SIZE_T
103 AC_TYPE_SIGNAL
104 AC_STRUCT_TM
106 dnl Checks for library functions.
107 AC_FUNC_STAT
108 AC_FUNC_FORK
109 AC_FUNC_MALLOC
110 AC_FUNC_REALLOC
111 AC_FUNC_MEMCMP
112 AC_FUNC_MMAP
113 AC_FUNC_STRFTIME
114 AC_FUNC_SELECT_ARGTYPES
115 AC_CHECK_FUNCS([mkdir strerror memset select socket strcasecmp strdup \
116                 strncasecmp strchr setrlimit mlock mlockall ftruncate \
117                 getcwd memmove munmap strrchr strtol strstr alarm])
119 AC_TRY_COMPILE([
120                 #include <stdio.h>
121                 #include <sys/mman.h>], [
122                 int main()
123                 {
124                     void *p = mmap(NULL, 1024, PROT_READ,
125                                    MAP_SHARED|MAP_ANONYMOUS, 0, 0);
126                     exit(0);
127                 }],
128                 [have_mmap_anonymous=yes], [have_mmap_anonymous=no])
130 if test "$have_mmap_anonymous" = "yes"; then
131     AC_DEFINE([MMAP_ANONYMOUS], 1, \
132               [Define if your mmap() supports the MAP_ANONYMOUS flag.])
135 AC_DEFUN([AC_DEBUG],
137     if test "$1"; then
138         ac_cv_sys_debug=$1
139     fi
141     AC_CACHE_CHECK([if debugging is wanted], [ac_cv_sys_debug],
142         [ac_cv_sys_debug=no])
143     AM_CONDITIONAL([WITH_DEBUG], [test "$ac_cv_sys_debug" = "yes"])
146 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging.]),
147     AC_DEBUG([$enableval]), AC_DEBUG)
149 AC_DEFUN([AC_MEM_DEBUG],
151     if test "$1"; then
152         ac_cv_sys_mem_debug=$1
153     fi
155     AC_CACHE_CHECK([if memory debugging is wanted], [ac_cv_sys_mem_debug],
156         [ac_cv_sys_mem_debug=no])
157     AM_CONDITIONAL([WITH_MEM_DEBUG], [test "$ac_cv_sys_mem_debug" = "yes"])
160 AC_ARG_ENABLE(mem_debug, AC_HELP_STRING([--enable-mem-debug], [Enable memory debugging.]),
161     AC_MEM_DEBUG([$enableval]), AC_MEM_DEBUG)
163 AC_DEFINE([DEFAULT_RECURSION_DEPTH], 20, \
164           [Default number of target recursions before returning an error.])
166 AC_DEFINE([DEFAULT_ZLIB_BUFSIZE], 4096, \
167           [Default input and output buffer chunk sizes. Affects status messages.])
169 AM_CONDITIONAL(MEM_DEBUG, test x"${ac_cv_sys_mem_debug}" != xno)
171 LIBS="$PTHREAD_LIBS $LIBS"
172 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
173 CC="$PTHREAD_CC"
175 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile po/Makefile.in])
176 AC_OUTPUT