-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.ac
105 lines (102 loc) · 3.41 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
# SPDX-License-Identifier: AGPL-3.0-or-later
# This file is part of yagips
# ©2024 Alex Pensinger (ArcticLuma113)
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
AC_INIT(
[yagips],
m4_esyscmd([./git-version-gen .tarball-version]))
printf "Start configuration...\n"
AC_CONFIG_MACRO_DIRS([m4])
printf "\nAutomake init...\n\n"
AM_INIT_AUTOMAKE([-Wall -Werror foreign dist-xz no-dist-gzip subdir-objects])
AM_MAINTAINER_MODE([disable])
AM_SILENT_RULES([yes])
printf "\nChecking C and C++ compilers...\n\n"
AC_PROG_CC
AC_PROG_CXX
printf "\nChecking for required programs...\n\n"
AC_ARG_VAR([PROTOC], [Protobuf compiler command])
AC_PATH_PROG([PROTOC], [protoc])
AS_IF([test "x${PROTOC}" == "x"], [
AC_MSG_ERROR([Required program 'protoc' not found.])
])
printf "\nGnulib early init...\n\n"
gl_EARLY
printf "\nGnulib init...\n\n"
gl_INIT
AC_C_CONST
AC_C_VOLATILE
printf "\nChecking for required libraries...\n\n"
PKG_CHECK_MODULES(PROTOBUF, protobuf >= 3.12.4, [], [
# TODO use a suitable fallback
AC_MSG_ERROR([Required library 'protobuf' not found.])
])
AC_SUBST(PROTOBUF_LIBS)
AC_SUBST(PROTOBUF_CFLAGS)
PKG_CHECK_MODULES(LIBCRYPTO, libcrypto >= 3.0.0, [], [
AC_CHECK_LIB(crypto, OSSL_DECODER_CTX_new, [
LIBCRYPTO_LIBS = "-lcrypto"
], [
# TODO only do this check on Windows
AC_CHECK_LIB(eay32, OSSL_DECODER_CTX_new, [
LIBCRYPTO_LIBS = "-leay32"
], [
AC_MSG_ERROR([Required library 'openssl' not found.])
])
])
])
AC_SUBST(LIBCRYPTO_LIBS)
AC_SUBST(LIBCRYPTO_CFLAGS)
# TODO: do we need libssl at all?
PKG_CHECK_MODULES(JSON_C, json-c >= 0.15, [], [
AC_CHECK_LIB(json-c, json_tokener_new, [
JSON_C_LIBS = "-ljson-c"
], [
AC_MSG_ERROR([Required library 'json-c' not found.])
])
])
AC_SUBST(JSON_C_LIBS)
AC_SUBST(JSON_C_CFLAGS)
# LevelDB does not use pkg-config (as of 2024-02-23)
AC_CHECK_LIB(leveldb, leveldb_open, [], [
AC_MSG_ERROR([Required library 'leveldb' not found.])
])
AC_ARG_WITH(
[readline],
AS_HELP_STRING(
[--with-readline],
[Support libreadline in the server console @<:@default=check@:>@]
),
[],
[with_readline=check]
)
READLINE=no
AS_IF([test "x$with_readline" != "xno"], [
# TODO Determine actual minimum version
PKG_CHECK_MODULES(READLINE, readline >= 8.2, [
READLINE=yes
], [
AC_CHECK_LIB(readline, readline, [
READLINE_LIBS = "-lreadline -ltinfo"
READLINE=yes
], [
AS_IF([test "x$with_readline" != "xcheck"], [
AC_MSG_ERROR([Required library 'readline' not found.])
])
], -ltinfo)
])
])
AS_IF([test "x$READLINE" = "xyes"], [
AC_SUBST(READLINE_LIBS)
AC_SUBST(READLINE_CFLAGS)
AC_DEFINE([HAS_READLINE], [1], [If support for libreadline is enabled.])
])
# printf "\nChecking for required functions...\n\n"
# TODO Check more required functions, possibly from the dependencies
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile src/Makefile gnulib/Makefile])
printf "\nFinal output...\n\n"
AC_OUTPUT
printf "\ndone.\n"