forked from vysheng/tg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
195 lines (168 loc) · 5.92 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
192
193
194
AC_PREREQ([2.68])
AC_INIT([telegram-cli], [1.0])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h])
m4_include([ax_lua.m4])
m4_include([ax_python.m4])
m4_include([m4_ax_check_openssl.m4])
m4_include([m4_ax_check_zlib.m4])
m4_include([m4-ax_gcc_builtin.m4])
# Checks for programs.
AC_PROG_CC
# BSD locations for headers and libraries from packages, Linux locations for self-compiled stuff.
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
# Checks for libraries.
AC_SEARCH_LIBS([clock_gettime], [rt])
AC_SEARCH_LIBS([backtrace], [execinfo])
AC_CHECK_LIB([event], [event_base_new], [], [AC_MSG_ERROR([no libevent found])])
EVENT_VER=""
AC_CHECK_HEADER(event2/event.h, [AC_DEFINE([EVENT_V2], [1], [Use libevent v2])], [
AC_CHECK_HEADER(event.h, [AC_DEFINE([EVENT_V1], [1], [Use libevent v1])], [AC_MSG_ERROR([no libevent found])])
])
EXTRA_LIBS=""
# OPENSSL_INCLUDES to the include directives required
# OPENSSL_LIBS to the -l directives required
# OPENSSL_LDFLAGS to the -L or -R flags required
AC_ARG_ENABLE(openssl,[ --disable-openssl disables OpenSSL, and don't link against it
(this can't read *.pub files, though.)],
[
if test "x$enableval" = "xno" ; then
AC_DEFINE([TGL_AVOID_OPENSSL],[1],[avoid OpenSSL entirely, use libgcrypt instead (this can't read *.pub files, though.)])
AC_CHECK_LIB([gcrypt], [gcry_mpi_snatch], [], [AC_MSG_ERROR(["Need libgcrypt >= 1.60"])])
else
# Don't be annoying, so don't inform the user about --disable-openssl
AX_CHECK_OPENSSL(,[AC_MSG_ERROR([No openssl found.])])
fi
],[
AX_CHECK_OPENSSL(,[AC_MSG_ERROR([No openssl found. With --disable-openssl, libtgl will use libgcrypt instead.])])
])
AX_CHECK_ZLIB(, [AC_MSG_ERROR([No zlib found])])
AC_CHECK_LIB([readline], [rl_save_prompt], [ EXTRA_LIBS="${EXTRA_LIBS} -lreadline" ; ], [AC_MSG_ERROR([no libreadline found])])
AC_MSG_CHECKING([for libconfig])
AC_ARG_ENABLE(libconfig,[--enable-libconfig/--disable-libconfig],
[
if test "x$enableval" = "xno" ; then
AC_MSG_RESULT([disabled])
else
AC_MSG_RESULT([enabled])
AC_CHECK_LIB([config],[config_init],[],AC_MSG_ERROR([No libconfig found. Try --disable-libconfig]))
fi
],[
AC_MSG_RESULT([enabled])
AC_CHECK_LIB([config],[config_init],[],AC_MSG_ERROR([No libconfig found. Try --disable-libconfig]))
])
AC_ARG_ENABLE(extf,[--enable-extf/--disable-extf],
[
if test "x$enableval" = "xno" ; then
AC_DEFINE([DISABLE_EXTF],[1],[disable extf queries])
fi
],[
])
AC_MSG_CHECKING([for liblua])
AC_ARG_ENABLE(liblua,[--enable-liblua/--disable-liblua],
[
if test "x$enableval" = "xno" ; then
AC_MSG_RESULT([disabled])
else
AC_MSG_RESULT([enabled])
AX_PROG_LUA([],[],
[
AX_LUA_HEADERS([],[AC_MSG_ERROR([No lua headers found. Try --disable-liblua])])
AX_LUA_LIBS([],[AC_MSG_ERROR([No lua libs found. Try --disable-liblua])])
[EXTRA_LIBS="${EXTRA_LIBS} ${LUA_LIB}" ; ]
[CPPFLAGS="${CPPFLAGS} ${LUA_INCLUDE}" ; ]
AC_DEFINE(USE_LUA,1,[use lua])
],
[
AC_MSG_ERROR([No lua found. Try --disable-liblua])
])
fi
],[
AC_MSG_RESULT([enabled])
AX_PROG_LUA([],[],
[
AX_LUA_HEADERS([],[AC_MSG_ERROR([No lua headers found. Try --disable-liblua])])
AX_LUA_LIBS([],[AC_MSG_ERROR([No lua libs found. Try --disable-liblua])])
[EXTRA_LIBS="${EXTRA_LIBS} ${LUA_LIB}" ; ]
[CPPFLAGS="${CPPFLAGS} ${LUA_INCLUDE}" ; ]
AC_DEFINE(USE_LUA,1,[use lua])
],
[
AC_MSG_ERROR([No lua found. Try --disable-liblua])
])
])
AC_MSG_CHECKING([for python])
AC_ARG_ENABLE(python,[--enable-python/--disable-python],
[
if test "x$enableval" = "xyes" ; then
AC_MSG_RESULT([disabled])
else
AC_MSG_RESULT([enabled])
AX_PYTHON()
AC_SUBST([PYTHON_FOUND])
if test $PYTHON_FOUND = no ; then
AC_MSG_ERROR([No supported python lib version found. Try --disable-python])
else
AC_SUBST([PYTHON_LIBS])
AC_SUBST([PYTHON_CFLAGS])
EXTRA_LIBS="${EXTRA_LIBS} -l${PYTHON_LIB}"
CPPFLAGS="${CPPFLAGS} -I${PYTHON_INCLUDE_DIR}"
AC_DEFINE(USE_PYTHON,1,[use python])
fi
fi
],[
AC_MSG_RESULT([disabled])
])
AC_MSG_CHECKING([for libjansson])
AC_ARG_ENABLE(json,[--enable-json/--disable-json],
[
if test "x$enableval" = "xno" ; then
AC_MSG_RESULT([disabled])
else
AC_MSG_RESULT([enabled])
AC_CHECK_LIB([jansson],[json_array_set_new],[],AC_MSG_ERROR([No libjansson found. Try --disable-json]))
AC_DEFINE(USE_JSON,1,[use json])
fi
],[
AC_MSG_RESULT([enabled])
AC_CHECK_LIB([jansson],[json_array_set_new],[],AC_MSG_ERROR([No libjansson found. Try --disable-json]))
AC_DEFINE(USE_JSON,1,[use json])
])
#check for custom prog name
AC_MSG_CHECKING([progname])
AC_ARG_WITH(progname,[--with-progname=<name>],
[
if test "x$with_progname" = "xno" ; then
AC_MSG_RESULT([default])
elif test "x$with_progname" = "xyes" ; then
AC_MSG_RESULT([default])
else
AC_MSG_RESULT(["$with_progname"])
AC_DEFINE_UNQUOTED([PROG_NAME], ["$with_progname"], [Use custom prog name])
fi
],[
AC_MSG_RESULT([default])
])
AC_ARG_ENABLE(valgrind,[--enable-valgrind/--disable-valgrind],
[
if test "x$enableval" = "xyes" ; then
AC_CHECK_HEADER(valgrind/memcheck.h, [AC_DEFINE([VALGRIND_FIXES], [1], [fixed for correct valgrind work])], [
])
fi
],[
])
# Checks for header files.
AC_CHECK_HEADERS([execinfo.h fcntl.h malloc.h netdb.h stdlib.h string.h unistd.h arpa/inet.h mach/mach.h netinet/in.h sys/file.h sys/socket.h termios.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_C_INLINE
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([alarm endpwent memset memmove mkdir select socket strdup strndup uname])
AX_GCC_BUILTIN(__builtin_bswap32)
AC_SUBST(EXTRA_LIBS)
AC_CONFIG_FILES([Makefile])
AC_OUTPUT