summaryrefslogtreecommitdiffstats
path: root/configure.ac
blob: a3e71d0e0fda923f48623c102b20fd2c9bfdbaed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)

AC_COPYRIGHT([Copyright (c) 2008 Patrick McHardy <kaber@trash.net>])
AC_INIT([libdect], [0.0.1], [kaber@trash.net])
AC_DEFINE([RELEASE_NAME], ["libdect"], [Release name])

AC_CONFIG_SRCDIR([src/s_msg.c])
AC_CONFIG_HEADER([config.h])

AC_DEFINE([_GNU_SOURCE], [], [Enable various GNU extensions])
AC_DEFINE([_STDC_FORMAT_MACROS], [], [printf-style format macros])

AC_ARG_ENABLE([debug],
	      [AS_HELP_STRING([--enable-debug], [enable debugging [yes]])],
	      [CONFIG_DEBUG="$(echo $enableval | cut -b1)"],
	      [CONFIG_DEBUG="y"])
AC_SUBST([CONFIG_DEBUG])

# Checks for programs.
AC_PROG_CC
AC_PROG_MKDIR_P
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_SED

AC_ARG_ENABLE([doc],
	      [AS_HELP_STRING([--enable-doc], [build documentation [no]])],
	      [AC_CHECK_PROG(DOXYGEN, doxygen, doxygen)],
	      [AC_MSG_NOTICE([Documentation build disabled])]
	      [DOXYGEN=/bin/true])

# Checks for libraries.
AC_CHECK_LIB([nl], [nl_socket_alloc], ,
	     [AC_MSG_ERROR([No suitable version of libnl found])])

AC_CHECK_LIB([nl-dect], [nl_dect_cluster_alloc], ,
	     [AC_MSG_ERROR([No suitable version of libnl-dect found])])

AC_CHECK_LIB([ev], [event_init],
	     [EVENTLIB="-lev"],
	     [AC_CHECK_LIB([event], [event_init],
			   [EVENTLIB="-levent"],
			   [AC_ERROR([libev or libevent not found])])])
EVENT_LDFLAGS=$EVENTLIB
AC_SUBST(EVENT_LDFLAGS)

if test "$CONFIG_DEBUG" = "y";
then
	AC_CHECK_LIB([bfd], [bfd_init],
		     [CONFIG_BACKTRACE="y"],
		     [CONFIG_BACKTRACE="n";
		      AC_MSG_NOTICE([libbfd not found, backtrace support disabled])])
else
	CONFIG_BACKTRACE="n"
fi

# Checks for header files.
AC_HEADER_STDC
AC_HEADER_ASSERT
AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h malloc.h \
		  stddef.h stdint.h stdlib.h string.h unistd.h \
		  sys/socket.h], ,
		 [AC_MSG_ERROR([Header file not found])])
AC_CHECK_HEADERS([linux/dect.h linux/dect_netlink.h], ,
		 [AC_MSG_ERROR([DECT kernel header files not found])],
		 [#include <sys/socket.h>])

AC_CHECK_HEADER([event.h],
		[EVENTINC="-include event.h"],
		[AC_CHECK_HEADER([libev/event.h],
				 [EVENTINC="-include libev/event.h"],
				 [AC_MSG_ERROR([event.h not found])])])
EVENT_CFLAGS=$EVENTINC
AC_SUBST(EVENT_CFLAGS)

if test "$CONFIG_BACKTRACE" = "y";
then
	AC_CHECK_HEADER([bfd.h], ,
			[CONFIG_BACKTRACE="";
			 AC_MSG_NOTICE([bfd.h not found, backtrace support disabled])])
fi
AC_SUBST(CONFIG_BACKTRACE)

CFLAGS_KEEP=$CFLAGS
CFLAGS=$EVENT_CFLAGS
if [[ "$EVENT_LDFLAGS" == "-levent" ]]; then
	AC_MSG_CHECKING([checking whether event.h is compatible with libevent])
	AC_COMPILE_IFELSE(
			  [AC_LANG_SOURCE([[
	#ifdef EV_H_
	#error
	#endif
			  ]])],
			  [AC_MSG_RESULT([yes])],
			  [AC_MSG_ERROR([incompatible event.h header for libevent])]
	)
else
	AC_MSG_CHECKING([checking whether event.h is compatible with libev])
	AC_COMPILE_IFELSE(
			  [AC_LANG_SOURCE([[
	#ifndef EV_H_
	#error
	#endif
			  ]])],
			  [AC_MSG_RESULT([yes])],
			  [AC_MSG_ERROR([incompatible event.h header for libev])]
	)
fi
CFLAGS=$CFLAGS_KEEP

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_C_TYPEOF

AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UID_T
AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T

# Checks for library functions.
# AC_FUNC_MALLOC
# AC_FUNC_REALLOC
AC_CHECK_FUNCS([memmove memset strchr strdup strerror strtoull])

AC_CONFIG_FILES([Makefile Makefile.defs Makefile.rules])
AC_CONFIG_FILES([include/Makefile])
AC_CONFIG_FILES([src/Makefile])
AC_CONFIG_FILES([example/Makefile])
AC_CONFIG_FILES([doc/Makefile doc/Doxyfile])
AC_CONFIG_FILES([libdect-0.0.1.pc])
AC_OUTPUT