Debian Codegraph @

src/sord_config.h

raw
1 // Copyright 2021-2024 David Robillard <[email protected]>
2 // SPDX-License-Identifier: ISC
3
4 /*
5 Configuration header that defines reasonable defaults at compile time.
6
7 This allows compile-time configuration from the command line (typically via
8 the build system) while still allowing the source to be built without any
9 configuration. The build system can define SORD_NO_DEFAULT_CONFIG to disable
10 defaults, in which case it must define things like HAVE_FEATURE to enable
11 features. The design here ensures that compiler warnings or
12 include-what-you-use will catch any mistakes.
13 */
14
15 #ifndef SORD_CONFIG_H
16 #define SORD_CONFIG_H
17
18 // Define version unconditionally so a warning will catch a mismatch
19 #define SORD_VERSION "0.16.22"
20
21 #ifndef SORD_NO_DEFAULT_CONFIG
22
23 // The validator uses PCRE2 for literal pattern matching
24 # ifndef HAVE_PCRE2
25 # ifdef __has_include
26 # if __has_include(<pcre2.h>)
27 # define HAVE_PCRE2 1
28 # endif
29 # endif
30 # endif
31
32 #endif // !defined(SORD_NO_DEFAULT_CONFIG)
33
34 /*
35 Make corresponding USE_FEATURE defines based on the HAVE_FEATURE defines from
36 above or the command line. The code checks for these using #if (not #ifdef),
37 so there will be an undefined warning if it checks for an unknown feature,
38 and this header is always required by any code that checks for features, even
39 if the build system defines them all.
40 */
41
42 #ifdef HAVE_PCRE2
43 # define USE_PCRE2 1
44 #else
45 # define USE_PCRE2 0
46 #endif
47
48 #endif // SORD_CONFIG_H