-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure.ac
191 lines (152 loc) · 5.78 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
AC_INIT([ncdc], [1.19.1], [[email protected]])
AC_CONFIG_SRCDIR([src/ncdc.h])
AC_CONFIG_HEADER([config.h])
m4_include([deps/lean.m4])
AM_INIT_AUTOMAKE([foreign subdir-objects])
PKG_PROG_PKG_CONFIG([0.18])
# Check for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_SYS_LARGEFILE
# Use silent building
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
# Check for pod2man
AC_CHECK_PROG([have_pod2man],[pod2man],[yes],[no])
AM_CONDITIONAL([USE_POD2MAN], [test "x$have_pod2man" = "xyes"])
# Check for makeheaders. If the system does not provide it, compile our own copy in deps/
AC_CHECK_PROG([have_mh],[makeheaders],[yes],[no])
AM_CONDITIONAL([HAVE_MH], [test "x$have_mh" = "xyes"])
# Check for header files.
AC_CHECK_HEADERS([zlib.h bzlib.h],[], AC_MSG_ERROR([Required header file not found]))
have_nch=no
AC_CHECK_HEADERS([ncursesw/ncurses.h ncurses/ncurses.h ncurses.h],[have_nch=yes])
if test "x$have_nch" = "xno"; then
AC_MSG_ERROR([Could not find a header files for ncurses.])
fi
# Check for posix_fadvise()
AC_CHECK_FUNCS([posix_fadvise])
AC_SEARCH_LIBS([inet_pton], [nsl])
AC_SEARCH_LIBS([socket], [socket], [], [
AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"], [], [-lnsl])])
# Check for sendfile() support (not required)
# The following checks are based on ProFTPD's configure.in, except ncdc only
# supports the Linux and BSD variant at the moment, as those are the only two I
# have tested so far.
AC_CACHE_CHECK([which sendfile() implementation to use], pr_cv_sendfile_func,
pr_cv_sendfile_func="none"
# Linux
if test "$pr_cv_sendfile_func" = "none"; then
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[ #include <sys/types.h>
#include <sys/sendfile.h>
#include <unistd.h> ]],
[[ int i=0;
off_t o=0;
size_t c=0;
(void)sendfile(i,i,&o,c); ]])],
[pr_cv_sendfile_func="Linux"])
fi
# BSD
if test "$pr_cv_sendfile_func" = "none"; then
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[ #include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h> ]],
[[ int i=0;
off_t o=0;
size_t n=0;
struct sf_hdtr h={};
(void)sendfile(i,i,o,n,&h,&o,i); ]])],
[pr_cv_sendfile_func="BSD"])
fi
)
# set defines
if test "$pr_cv_sendfile_func" != none; then
AC_DEFINE(HAVE_SENDFILE, 1, [Define if sendfile support.])
fi
case "$pr_cv_sendfile_func" in
"Linux")
AC_DEFINE(HAVE_LINUX_SENDFILE, 1, [Define if using Linux sendfile support.]);;
"BSD")
AC_DEFINE(HAVE_BSD_SENDFILE, 1, [Define if using BSD sendfile support.]);;
esac
# Check for ncurses
AC_CHECK_LIB([ncursesw], [get_wch], [
AC_SUBST([NCURSES_LIBS],[-lncursesw])
], [
AC_CHECK_LIB([ncurses],
[get_wch],
[AC_SUBST([NCURSES_LIBS],[-lncurses])],
[AC_MSG_ERROR(ncursesw library is required)])
]
)
# Check for zlib
AC_CHECK_LIB([z],
[deflate],
[AC_SUBST([Z_LIBS],[-lz])],
[AC_MSG_ERROR(zlib library is required)])
# Check for libbz2
AC_CHECK_LIB([bz2],
[BZ2_bzReadOpen],
[AC_SUBST([BZ2_LIBS],[-lbz2])],
[AC_MSG_ERROR(bzip2 library is required)])
# Check for SQLite3
PKG_CHECK_EXISTS([sqlite3],[
PKG_CHECK_MODULES([SQLITE],[sqlite3])
],[
AC_CHECK_HEADERS([sqlite3.h],[],
[AC_MSG_ERROR([sqlite3 header file not found])])
AC_CHECK_LIB([sqlite3],
[sqlite3_open],
[AC_SUBST([SQLITE_LIBS],[-lsqlite3])],
[AC_MSG_ERROR([sqlite3 library is required])])
]
)
# Check for modules
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.24 gthread-2.0])
PKG_CHECK_MODULES([GNUTLS], [gnutls >= 2.4])
AC_ARG_WITH([geoip],
[AS_HELP_STRING([--with-geoip], [support for IP-to-country lookups @<:@default=no@:>@])],
[],
[with_geoip=no])
AS_IF([test "x$with_geoip" == xyes],
[PKG_CHECK_MODULES([GEOIP],
[geoip >= 1.2.0],
[AC_DEFINE(USE_GEOIP, 1, [Use libgeoip for IP-to-country lookups])])])
# Note that GnuTLS 2.12 also supports the nettle backend, and already provides
# an API to the low-level crypto functions. However, if GnuTLS uses the gcrypt
# backend, we still need to initialize gcrypt for threading. Since we have no
# reliable way to detect which backend is used, let's just assume gcrypt. And
# while we're linking against gcrypt anyway, we might as well use it for
# crypto, too.
PKG_CHECK_EXISTS([gnutls >= 3.0], [], [
AC_CHECK_LIB([gcrypt],
[gcry_control],
[AC_SUBST([GCRYPT_LIBS], [-lgcrypt])],
[AC_MSG_ERROR([GnuTLS version is older than 3.0, but no libgcrypt found])])
AC_DEFINE(USE_GCRYPT, 1, [Define to use libgcrypt for crypto])
])
# Check whether we should use the version string from AC_INIT(), or use
# git-describe to create one. This trick is copied from the pacman source.
AC_ARG_ENABLE(git-version,
AS_HELP_STRING([--enable-git-version], [enable use of git version in version string if available]),
[wantgitver=$enableval], [wantgitver=yes])
usegitver=no
if test "x$wantgitver" = "xyes" ; then
AC_CHECK_PROGS([GIT], [git], [no])
test "x$GIT" != "xno" -a -d "$srcdir/.git" && usegitver=yes
fi
AM_CONDITIONAL(USE_GIT_VERSION, test "x$usegitver" = "xyes")
# If we don't have pod2man and doc/ncdc.1 isn't available in the source
# directory, throw a warning and just go ahead without installing the man page.
installmanpage=yes
if test "x$have_pod2man" = "xno" -a \! -s "$srcdir/doc/ncdc.1"; then
echo ""
echo "Note: Could not find doc/ncdc.1 in the source directory nor the pod2man"
echo "utility on your system. No manual page will be installed."
echo ""
installmanpage=no
fi
AM_CONDITIONAL([INSTALL_MANPAGE], [test "x$installmanpage" = "xyes"])
AC_OUTPUT([Makefile])