-
Notifications
You must be signed in to change notification settings - Fork 74
/
configure.ac
99 lines (85 loc) · 2.75 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
#
# Process this file with autoconf to produce a configure script.
#
# Run ./configure with your options to generate config.mak.autogen file which
# is used by Makefile.
#
## Definitions of private macros.
# CONF_SUBST_INIT
# -------------------
# Prepare shell variables and autoconf machine required by later calls
# to CONF_SUBST.
AC_DEFUN([CONF_SUBST_INIT],
[config_appended_defs=; newline='
'
AC_CONFIG_COMMANDS([$config_file],
[echo "$config_appended_defs" >> "$config_file"],
[config_file=$config_file
config_appended_defs="$config_appended_defs"])]
)
# CONF_SUBST(VAL, VAR)
# ------------------------
# Cause the line "VAR=VAL" to be eventually appended to ${config_file}.
AC_DEFUN([CONF_SUBST], [AC_REQUIRE([CONF_SUBST_INIT])
config_appended_defs="$config_appended_defs${newline}dnl
$1=m4_if([$#],[1],[${$1}],[$2])"]
)
## Configure body starts here.
AC_PREREQ([2.59])
AC_INIT
config_file=config.mak.autogen
config_in=config.mak.in
# AUTOCONFIGURED
CONF_SUBST([AUTOCONFIGURED], [YesPlease])
# Checks for programs
AC_PROG_CC
AC_CHECK_TOOLS(AR, [gar ar], :)
AC_CHECK_PROGS(TAR, [gtar tar])
# libevent
AC_ARG_WITH(event,
[AS_HELP_STRING([--with-event=DIR], [where to find the event library])],
[if test -d "$withval"; then
LDFLAGS="$LDFLAGS -L$withval/lib"
CFLAGS="$CFLAGS -I$withval/include"
fi],
withval=yes # default
)
if test "$withval" != no; then
AC_CHECK_LIB(event,event_base_new,
[LIBS="-levent $LIBS"],
[AC_MSG_ERROR([libevent2 is required - see http://libevent.org/])]
)
AC_CHECK_HEADERS(event2/event.h,
[LIBS="-levent $LIBS"],
[AC_MSG_ERROR([libevent2 is required - see http://libevent.org/])]
)
fi
# libsodium
AC_ARG_WITH(sodium,
[AS_HELP_STRING([--with-sodium=DIR], [where to find the sodium library])],
[if test -d "$withval"; then
LDFLAGS="$LDFLAGS -L$withval/lib"
CFLAGS="$CFLAGS -I$withval/include"
fi],
withval=yes # default
)
if test "$withval" != no; then
AC_CHECK_LIB(sodium,sodium_init,
[LIBS="-lsodium $LIBS"],
[AC_MSG_ERROR([sodium is required - see https://github.com/jedisct1/libsodium])]
)
fi
AC_CHECK_FUNCS(crypto_box_curve25519xchacha20poly1305_open_easy,
[CFLAGS="$CFLAGS -DHAVE_CRYPTO_BOX_CURVE25519XCHACHA20POLY1305_OPEN_EASY"],
[AC_MSG_WARN([was libsodium compiled with --enable-minimal])]
)
# Output files
AC_CONFIG_FILES(["${config_file}":"${config_in}"])
AC_OUTPUT
# Show summary.
AC_MSG_RESULT([
Configuration summary:
Support for event library: $ac_cv_lib_event_event_base_new
Support for sodium library: $ac_cv_lib_sodium_sodium_init
Support for xchacha20: $ac_cv_func_crypto_box_curve25519xchacha20poly1305_open_easy
])