-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
252 lines (208 loc) · 6.65 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
dnl -*- Autoconf -*-
dnl Process this file with autoconf to produce a configure script.
dnl Copyright 1996-1999, 2003-2004, 2017-2019, 2021 Ossama Othman
dnl
dnl SPDX-License-Identifier: GPL-2.0-or-later
dnl An autoconf script to automatically configure MaRC.
AC_PREREQ([2.69])
AC_INIT([MaRC],
[0.10],
[https://github.com/ossama-othman/MaRC/issues],
[marc],
[https://ossama-othman.github.io/MaRC/])
dnl Additional configure script arguments
AX_IS_RELEASE([git-directory])
AX_CHECK_ENABLE_DEBUG([yes])
AC_ARG_ENABLE([arch-detect],
[AS_HELP_STRING([--enable-arch-detect],
[enable detection of GCC CPU architecture tuning flags (also see related "--with-gcc-arch" option)])],
[],
[enable_arch_detect=no])
dnl AC_ARG_WITH([spdlog],
dnl [AS_HELP_STRING([--with-spdlog],
dnl [support improved logging through the spdlog library @<:@default=check@:>@])],
dnl [],
dnl [with_spdlog=check])
dnl Check what platform we are running on.
dnl AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([1.14.1 check-news silent-rules std-options readme-alpha -Wall -Werror -Wno-portability])
AM_SILENT_RULES([yes])
LT_INIT([disable-static])
AC_CONFIG_MACRO_DIRS([m4])
AC_CONFIG_SRCDIR([lib/marc/PhotoImage.h])
dnl Generate a header file with all settings.
AC_CONFIG_HEADERS([lib/marc/config.h])
dnl Checks for programs.
AC_PROG_CXX
AX_CXX_COMPILE_STDCXX_17
AC_PROG_LN_S
AX_PROG_BISON
AM_PROG_LEX
MARC_CLANG_TIDY
AX_CODE_COVERAGE
dnl Check for pkg-config
PKG_PROG_PKG_CONFIG
dnl Check for Doxygen
DX_DOXYGEN_FEATURE(ON)
DX_DOT_FEATURE(ON)
DX_HTML_FEATURE(ON)
DX_CHM_FEATURE(OFF)
DX_CHI_FEATURE(OFF)
DX_MAN_FEATURE(OFF)
DX_RTF_FEATURE(OFF)
DX_XML_FEATURE(OFF)
DX_PDF_FEATURE(OFF)
DX_PS_FEATURE(OFF)
DX_INIT_DOXYGEN([marc], [Doxyfile], [doc/doxygen])
AC_ARG_VAR([PANDOC],[location of pandoc program])
AC_PATH_PROG([PANDOC], [pandoc])
AC_LANG([C++])
dnl
dnl config.h template
dnl
dnl Text to be placed at the top of the `marc/config.h' header.
AH_TOP([
/**
* @file config.h
*
* MaRC configuration header file.
*
* @note This is an internal header, and not meant for use
* outside of MaRC.
*/
#ifndef MARC_CONFIG_H
#define MARC_CONFIG_H
])
dnl Text to be placed at the bottom of the `marc/config.h' header.
AH_BOTTOM([
#endif /* MARC_CONFIG_H */
// Local] [Variables:
// mode:C++
// End:
])
dnl Checks for libraries.
dnl We're of course going to need the C math library.
AC_SEARCH_LIBS([cos],[m])
MARC_SAVE_LIBS=$LIBS
ARGP_LIBS=
AC_SEARCH_LIBS([argp_parse],
[argp],
[AC_DEFINE([HAVE_ARGP], [1], [Define if you have Argp])
dnl Prevent the Argp library from being link to all
dnl MaRC binaries. It is only used by the MaRC
dnl program.
AS_IF([test "x$ac_cv_search_argp_parse" != "xno" \
-a "x$ac_cv_search_argp_parse" != "xnone required"],
[ARGP_LIBS="$ac_cv_search_argp_parse"
LIBS="$MARC_SAVE_LIBS"
AC_SUBST([ARGP_LIBS])
])
],
[dnl BSD-style EX_* exit codes.
AC_CHECK_HEADERS([sysexits.h])
])
PKG_CHECK_MODULES([CFITSIO], [cfitsio])
AC_SUBST([CFITSIO_LIBS])
AC_SUBST([CFITSIO_CFLAGS])
dnl spdlog requires POSIX threads support.
dnl AX_CXX_PTHREAD
dnl LIBS="$PTHREAD_LIBS $LIBS"
dnl CXXFLAGS="$CXXFLAGS $PTHREAD_CXXFLAGS"
dnl CXX="$PTHREAD_CXX"
dnl Workaround AX_CXX_PTHREAD's inability to detect the need for
dnl Clang's -Qunused-arguments command line option in some cases, such
dnl as when building a shared library through Libtool.
dnl AS_IF([test "x$ax_pthread_clang" = "xyes"],
dnl [MARC_UNUSED_ARGUMENT_LDFLAGS="-Xcompiler -Qunused-arguments"
dnl AC_SUBST([MARC_UNUSED_ARGUMENT_LDFLAGS])])
dnl @todo Switch to std::format once C++20 is supported by MaRC.
AC_CACHE_CHECK([for fmt library >= 7.1.3],
[marc_cv_lib_fmt],
[
MARC_SAVE_LIBS=$LIBS
LIBS="$LIBS -lfmt"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <fmt/core.h>
#if FMT_VERSION < 70103
# error "fmt >= 7.1.3 is required"
#endif
void vlog_info(char const * format, fmt::format_args args)
{
fmt::print("INFO: ");
fmt::vprint(format, args);
}
template <typename ... Args>
void log_info(char const * format, Args const & ... args)
{
vlog_info(format, fmt::make_format_args(args...));
}
]],
[[
log_info("{}", "foo");
]])
],
[
marc_cv_lib_fmt=yes
],
[
marc_cv_lib_fmt=no
LIBS=$MARC_SAVE_LIBS
])
])
dnl ])
AS_IF([test "x$marc_cv_lib_fmt" = "xyes"],
[],
[AC_MSG_WARN([fmt library not found, or it is old - using fallback])
AC_DEFINE([FMT_HEADER_ONLY],[1],[Use fmt library in header-only form])
dnl Do not add -DFMT_HEADER_ONLY to the CPPFLAGS so that we can
dnl catch potential issues with fmt library headers that are
dnl indirectly exposed through the public MaRC API.
FMTLIB_CPPFLAGS="-I\$(top_srcdir)/opt/fmt-8.0.1/include"
AC_SUBST([FMTLIB_CPPFLAGS])
])
dnl System specific configuration
AS_IF([test "x$ax_enable_debug" != "xyes"],
[
dnl Compile-time optimization
marc_optimization_flag="-O2"
AX_CHECK_COMPILE_FLAG([$marc_optimization_flag],
[AX_APPEND_FLAG([$marc_optimization_flag],
[XCXXFLAGS])])
dnl Link-time optimization
marc_lto_flag="-flto"
AX_CHECK_COMPILE_FLAG([$marc_lto_flag],
[AX_APPEND_FLAG([$marc_lto_flag],
[XCXXFLAGS])])
dnl NDEBUG is defined in <marc/config.h> but also define it on
dnl the command line to avoid having to include <marc/config.h>
dnl in MaRC headers or template code.
dnl AX_APPEND_FLAG([-DNDEBUG], [XCPPFLAGS])
])
AS_IF([test "x$enable_arch_detect" = "xyes"],
[AX_GCC_ARCHFLAG([yes],
[AX_APPEND_FLAG([$ax_cv_gcc_archflag],
[XCXXFLAGS])])
])
AX_CXXFLAGS_WARN_ALL([CXXFLAGS])
AS_IF([test "x$GXX" = "xyes"],
[XCXXFLAGS="$XCXXFLAGS -Wextra -Wformat=2 -pedantic"],
[])
AX_APPEND_COMPILE_FLAGS([-fvisibility=hidden -fvisibility-inlines-hidden])
dnl Export the public API from the MaRC shared library.
AM_CONDITIONAL([BUILDING_DLL], [test "x$enable_shared" = xyes])
dnl Combine package set flags with user's flags.
dnl User's flags go after package flags to allow user to override
dnl package defaults.
CXXFLAGS="$XCXXFLAGS $CXXFLAGS"
CPPFLAGS="$XCPPFLAGS $CPPFLAGS"
LDFLAGS="$XLDFLAGS $LDFLAGS"
AC_CONFIG_FILES([
Makefile
doc/Makefile
lib/Makefile
lib/marc/Makefile
lib/marc/marc.pc
src/Makefile
tests/Makefile
])
AC_OUTPUT