-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconfigure.ac
176 lines (155 loc) · 5.52 KB
/
configure.ac
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(libverto, 0.3.1)
m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
[AC_USE_SYSTEM_EXTENSIONS],
[AC_GNU_SOURCE])
AC_PROG_CC_C99
for flag in -Wall -Wextra -Wno-cast-function-type; do
OLD_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $flag"
AC_TRY_COMPILE(, [return 0;], [], [CFLAGS=$OLD_CFLAGS])
done
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE([1.11])
AC_PROG_LIBTOOL
AC_CONFIG_MACRO_DIR([m4])
m4_ifdef([AM_SILENT_RULES], [
AM_SILENT_RULES([yes])
], [
AM_DEFAULT_VERBOSITY=1
AC_SUBST(AM_DEFAULT_VERBOSITY)
])
PKG_PROG_PKG_CONFIG
AC_CHECK_LIB([dl],[dlopen])
AC_ARG_WITH([pthread],
[AS_HELP_STRING([--with-pthread],
[build pthread support @<:@default: automatic@:>@])],
[case $withval in
no) WITH_PTHREAD=no;;
yes) WITH_PTHREAD=yes;;
*) WITH_PTHREAD=auto;;
esac], [WITH_PTHREAD=auto])
BUILD_PTHREAD=no
if test x$WITH_PTHREAD != xno; then
AX_PTHREAD([PTHREAD_CFLAGS="$PTHREAD_CFLAGS -DHAVE_PTHREAD=1";
CC="$PTHREAD_CC";
BUILD_PTHREAD=yes],
[test x$WITH_PTHREAD = xyes && AC_MSG_ERROR("pthread not found")])
fi
AC_ARG_WITH([glib],
[AS_HELP_STRING([--with-glib],
[build the glib library @<:@default: automatic@:>@])],
[case $withval in
no) WITH_GLIB=no;;
yes) WITH_GLIB=yes;;
default) WITH_GLIB=default;;
builtin) WITH_GLIB=builtin;;
*) WITH_GLIB=auto;;
esac], [WITH_GLIB=auto])
AC_ARG_WITH([libev],
[AS_HELP_STRING([--with-libev],
[build the libev library @<:@default: automatic@:>@])],
[case $withval in
no) WITH_LIBEV=no;;
yes) WITH_LIBEV=yes;;
default) WITH_LIBEV=default;;
builtin) WITH_LIBEV=builtin;;
*) WITH_LIBEV=auto;;
esac], [WITH_LIBEV=auto])
AC_ARG_WITH([libevent],
[AS_HELP_STRING([--with-libevent],
[build the libevent library @<:@default: automatic@:>@])],
[case $withval in
no) WITH_LIBEVENT=no;;
yes) WITH_LIBEVENT=yes;;
default) WITH_LIBEVENT=default;;
builtin) WITH_LIBEVENT=builtin;;
*) WITH_LIBEVENT=auto;;
esac], [WITH_LIBEVENT=auto])
# Ensure that if a builtin is chosen only one is built
BUILTIN_MODULE=
if test x$WITH_GLIB = xbuiltin; then
BUILTIN_MODULE=glib
WITH_LIBEV=no
WITH_LIBEVENT=no
elif test x$WITH_LIBEV = xbuiltin; then
BUILTIN_MODULE=libev
WITH_LIBGLIB=no
WITH_LIBEVENT=no
elif test x$WITH_LIBEVENT = xbuiltin; then
BUILTIN_MODULE=libevent
WITH_LIBGLIB=no
WITH_LIBEV=no
fi
AC_SUBST([BUILTIN_MODULE], $BUILTIN_MODULE)
if test x$BUILTIN_MODULE != x; then
AC_DEFINE_UNQUOTED([BUILTIN_MODULE], $BUILTIN_MODULE)
fi
# Ensure that there is only one default (convert duplicate default to yes)
if test x$WITH_GLIB = xdefault; then
AC_DEFINE([DEFUALT_MODULE], [glib])
test x$WITH_LIBEV = xdefault && WITH_LIBEV=yes
test x$WITH_LIBEVENT = xdefault && WITH_LIBEVENT=yes
fi
if test x$WITH_LIBEV = xdefault; then
AC_DEFINE([DEFUALT_MODULE], [libev])
test x$WITH_LIBGLIB = xdefault && WITH_GLIB=yes
test x$WITH_LIBEVENT = xdefault && WITH_LIBEVENT=yes
fi
if test x$WITH_LIBEVENT = xdefault; then
AC_DEFINE([DEFUALT_MODULE], [libevent])
test x$WITH_GLIB = xdefault && WITH_GLIB=yes
test x$WITH_LIBEV = xdefault && WITH_LIBEV=yes
fi
BUILD_GLIB=no
BUILD_LIBEV=no
BUILD_LIBEVENT=no
if test x$WITH_GLIB != xno; then
PKG_CHECK_MODULES([glib], [glib-2.0], [BUILD_GLIB=$WITH_GLIB],
[test x$WITH_GLIB != xauto && AC_MSG_ERROR("glib not found")])
if test x$BUILD_GLIB = xauto; then
BUILD_GLIB=yes
fi
fi
if test x$WITH_LIBEV != xno; then
AC_CHECK_HEADER(
[ev.h],
AC_CHECK_LIB(
[ev], [ev_loop_new], [BUILD_LIBEV=$WITH_LIBEV],
[test x$WITH_LIBEV != xauto && AC_MSG_ERROR("libev not found")]
),
[test x$WITH_LIBEV != xauto && AC_MSG_ERROR("ev.h not found")]
)
if test x$BUILD_LIBEV = xauto; then
BUILD_LIBEV=yes
fi
fi
if test x$WITH_LIBEVENT != xno; then
PKG_CHECK_MODULES([libevent], [libevent >= 2.0], [BUILD_LIBEVENT=$WITH_LIBEVENT],
[test x$WITH_LIBEVENT != xauto && AC_MSG_ERROR("libevent not found")])
if test x$BUILD_LIBEVENT = xauto; then
BUILD_LIBEVENT=yes
fi
fi
AM_CONDITIONAL([MODULE_GLIB], [test x$BUILTIN_MODULE = x && test x$BUILD_GLIB != xno])
AM_CONDITIONAL([MODULE_LIBEV], [test x$BUILTIN_MODULE = x && test x$BUILD_LIBEV != xno])
AM_CONDITIONAL([MODULE_LIBEVENT], [test x$BUILTIN_MODULE = x && test x$BUILD_LIBEVENT != xno])
AM_CONDITIONAL([BUILTIN_GLIB], [test x$BUILTIN_MODULE = xglib])
AM_CONDITIONAL([BUILTIN_LIBEV], [test x$BUILTIN_MODULE = xlibev])
AM_CONDITIONAL([BUILTIN_LIBEVENT], [test x$BUILTIN_MODULE = xlibevent])
AC_MSG_NOTICE()
AC_MSG_NOTICE([BUILD CONFIGURATION])
AC_MSG_NOTICE(AS_HELP_STRING([pthread], [$BUILD_PTHREAD]))
AC_MSG_NOTICE(AS_HELP_STRING([glib], [$BUILD_GLIB]))
AC_MSG_NOTICE(AS_HELP_STRING([libev], [$BUILD_LIBEV]))
AC_MSG_NOTICE(AS_HELP_STRING([libevent], [$BUILD_LIBEVENT]))
AC_MSG_NOTICE()
AC_CONFIG_FILES(Makefile
src/Makefile
tests/Makefile
libverto-glib.pc
libverto-libev.pc
libverto-libevent.pc
libverto.pc)
AC_OUTPUT