Debian Codegraph @

libdrgn/configure.ac

raw
1 dnl Copyright (c) Meta Platforms, Inc. and affiliates.
2 dnl SPDX-License-Identifier: LGPL-2.1-or-later
3
4 AC_INIT([libdrgn], [0.2.0],
5 [https://github.com/osandov/drgn/issues],,
6 [https://github.com/osandov/drgn])
7
8 AC_CONFIG_AUX_DIR([build-aux])
9 AC_CONFIG_MACRO_DIR([m4])
10 AC_PROG_CC
11
12 AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign nostdinc subdir-objects])
13 AM_SILENT_RULES([yes])
14 AM_PROG_AR
15
16 LT_INIT
17
18 AC_SYS_LARGEFILE
19
20 AC_REQUIRE_AUX_FILE([tap-driver.sh])
21
22 MY_C_AUTO
23 MY_C_SWITCH_ENUM
24 MY_CHECK_VA_ARGS_COMMA_DELETION
25
26 AC_ARG_ENABLE([openmp],
27 [AS_HELP_STRING([--enable-openmp@<:@=ARG@:>@],
28 [use OpenMP. ARG may be yes, no, or the name of
29 the OpenMP runtime library to use (e.g., gomp or
30 omp)
31 @<:@default=yes@:>@])],
32 [], [enable_openmp=yes])
33
34 OPENMP_CFLAGS=
35 OPENMP_LIBS=
36 AS_CASE(["x$enable_openmp"],
37 [xyes], [OPENMP_CFLAGS=-fopenmp],
38 [xno], [],
39 dnl Use -Wc so that -fopenmp only gets passed when compiling, not
40 dnl linking, otherwise the linker will add the default runtime library.
41 [OPENMP_CFLAGS=-Wc,-fopenmp
42 OPENMP_LIBS=-l$enable_openmp])
43 AC_SUBST(OPENMP_CFLAGS)
44 AC_SUBST(OPENMP_LIBS)
45
46 dnl We need Python for code generation even if we're not building the bindings.
47 AM_PATH_PYTHON([3.8])
48
49 AC_ARG_ENABLE([libdrgn],
50 [AS_HELP_STRING([--disable-libdrgn],
51 [don't build the libdrgn C library. Note that
52 libdrgn's API and ABI are unstable])],
53 [], [enable_libdrgn=yes])
54
55 AC_ARG_ENABLE([python],
56 [AS_HELP_STRING([--enable-python],
57 [enable Python support in libdrgn, which allows
58 it to use Python plugins and double as the
59 Python extension module])],
60 [], [enable_python=no])
61
62 AC_ARG_ENABLE([python-extension],
63 [AS_HELP_STRING([--enable-python-extension],
64 [build the drgn Python extension module separate
65 from libdrgn])],
66 [], [enable_python_extension=no])
67
68 AM_CONDITIONAL([ENABLE_LIBDRGN], [test "x$enable_libdrgn" != xno])
69 AM_CONDITIONAL([ENABLE_PYTHON],
70 [test "x$enable_python" != xno || test "x$enable_python_extension" != xno])
71 AM_CONDITIONAL([ENABLE_PYTHON_EXTENSION],
72 [test "x$enable_python_extension" != xno])
73
74 AM_COND_IF([ENABLE_PYTHON],
75 [AS_IF([test "x$enable_libdrgn" != xno],
76 [find_libpython=yes], [find_libpython=no])
77 MY_PYTHON_DEVEL([$find_libpython])])
78
79 PKG_PROG_PKG_CONFIG
80
81 PKG_CHECK_MODULES(elfutils, [libelf >= 0.165 libdw >= 0.165])
82
83 AC_ARG_WITH([debuginfod],
84 [AS_HELP_STRING([--with-debuginfod],
85 [build with support for debuginfod
86 @<:@default=auto@:>@])],
87 [], [with_debuginfod=auto])
88 AS_CASE(["x$with_debuginfod"],
89 [xyes], [PKG_CHECK_MODULES(libdebuginfod, [libdebuginfod])],
90 [xauto], [PKG_CHECK_MODULES(libdebuginfod, [libdebuginfod],
91 [with_debuginfod=yes],
92 [with_debuginfod=no])])
93 AM_CONDITIONAL([WITH_DEBUGINFOD], [test "x$with_debuginfod" != xno])
94 AM_COND_IF([WITH_DEBUGINFOD], [AC_DEFINE(WITH_DEBUGINFOD)])
95
96 AC_ARG_ENABLE([dlopen-debuginfod],
97 [AS_HELP_STRING([--disable-dlopen-debuginfod],
98 [if building with support for debuginfod, link
99 against libdebuginfod instead of loading it with
100 dlopen(3)])],
101 [], [enable_dlopen_debuginfod=yes])
102 AM_CONDITIONAL([ENABLE_DLOPEN_DEBUGINFOD],
103 [test "x$enable_dlopen_debuginfod" != xno])
104 AM_COND_IF([ENABLE_DLOPEN_DEBUGINFOD], [AC_DEFINE(ENABLE_DLOPEN_DEBUGINFOD)])
105
106 AC_ARG_WITH([libkdumpfile],
107 [AS_HELP_STRING([--with-libkdumpfile],
108 [build with support for the makedumpfile kernel
109 core dump format using libkdumpfile
110 @<:@default=auto@:>@])],
111 [], [with_libkdumpfile=auto])
112 AS_CASE(["x$with_libkdumpfile"],
113 [xyes], [PKG_CHECK_MODULES(libkdumpfile, [libkdumpfile])],
114 [xauto], [PKG_CHECK_MODULES(libkdumpfile, [libkdumpfile],
115 [with_libkdumpfile=yes],
116 [with_libkdumpfile=no])])
117 AM_CONDITIONAL([WITH_LIBKDUMPFILE], [test "x$with_libkdumpfile" = xyes])
118 AM_COND_IF([WITH_LIBKDUMPFILE], [AC_DEFINE(WITH_LIBKDUMPFILE)])
119
120 AC_ARG_WITH([lzma],
121 [AS_HELP_STRING([--with-lzma],
122 [build with support for lzma decompression of ELF sections
123 @<:@default=auto@:>@])],
124 [], [with_lzma=auto])
125 AS_CASE(["x$with_lzma"],
126 [xyes], [PKG_CHECK_MODULES(lzma, [liblzma])],
127 [xauto], [PKG_CHECK_MODULES(lzma, [liblzma],
128 [with_lzma=yes],
129 [with_lzma=no])])
130 AM_CONDITIONAL([WITH_LZMA], [test "x$with_lzma" != xno])
131 AM_COND_IF([WITH_LZMA], [AC_DEFINE(WITH_LZMA)])
132
133 AC_ARG_WITH([pcre2],
134 [AS_HELP_STRING([--with-pcre2],
135 [build with support for searching memory with
136 regular expressions using PCRE2
137 @<:@default=auto@:>@])],
138 [], [with_pcre2=auto])
139 AS_CASE(["x$with_pcre2"],
140 [xyes], [PKG_CHECK_MODULES(pcre2, [libpcre2-8])],
141 [xauto], [PKG_CHECK_MODULES(pcre2, [libpcre2-8],
142 [with_pcre2=yes],
143 [with_pcre2=no])])
144 AM_CONDITIONAL([WITH_PCRE2], [test "x$with_pcre2" = xyes])
145 AM_COND_IF([WITH_PCRE2], [AC_DEFINE(WITH_PCRE2)])
146
147 AC_ARG_WITH([json_c],
148 [AS_HELP_STRING([--with-json-c],
149 [build with support for JSON (needed for QEMU
150 Machine Protocol support)
151 @<:@default=auto@:>@])],
152 [], [with_json_c=auto])
153 AS_CASE(["x$with_json_c"],
154 [xyes], [PKG_CHECK_MODULES(json_c, [json-c])],
155 [xauto], [PKG_CHECK_MODULES(json_c, [json-c],
156 [with_json_c=yes],
157 [with_json_c=no])])
158 AM_CONDITIONAL([WITH_JSON_C], [test "x$with_json_c" = xyes])
159 AM_COND_IF([WITH_JSON_C], [AC_DEFINE(WITH_JSON_C)])
160
161 dnl We need check for running tests, but we don't want to fail the build over
162 dnl it. Instead, if it's not found, set variables so that only `make check`
163 dnl fails.
164 PKG_CHECK_MODULES(check, [check >= 0.10.0],,
165 [check_CFLAGS="\$(error Test requires 'check' ('check-devel') >= 0.10.0)"
166 check_LIBS="\$(error Test requires 'check' ('check-devel') >= 0.10.0)"])
167
168 AC_ARG_ENABLE([compiler-warnings],
169 [AS_HELP_STRING([--enable-compiler-warnings@<:@=no|yes|error@:>@],
170 [enable compiler warnings. If no, then only the
171 default compiler warnings are enabled. If yes,
172 then additional warnings required by the package
173 are enabled. If error, then warnings are treated
174 as errors (this is only intended for
175 developers). @<:@default=yes@:>@])],
176 [], [enable_compiler_warnings=no])
177
178 dnl Make Clang error instead of warn for unknown warning options.
179 AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],
180 [compiler_flags_test="-Werror=unknown-warning-option"],
181 [compiler_flags_test=""])
182 AS_IF([test "x$enable_compiler_warnings" != xno],
183 [AX_APPEND_COMPILE_FLAGS([ dnl
184 -Wall dnl
185 -Wformat-overflow=2 dnl
186 -Wformat-security dnl
187 -Wformat-truncation=2 dnl
188 -Wimplicit-fallthrough dnl
189 -Wmissing-prototypes dnl
190 -Wpointer-arith dnl
191 -Wshadow dnl
192 -Wvla dnl
193 -Wno-format-zero-length dnl
194 ], [WARN_CFLAGS], [$compiler_flags_test])])
195 AS_IF([test "x$enable_compiler_warnings" = xerror],
196 [AX_APPEND_FLAG([-Werror], [WARN_CFLAGS])])
197 AC_SUBST(WARN_CFLAGS)
198
199 AC_ARG_ENABLE([asan],
200 [AS_HELP_STRING([--enable-asan], [enable AddressSanitizer])],
201 [], [enable_asan=no])
202
203 AS_IF([test "x$enable_asan" != xno],
204 [AX_APPEND_FLAG([-fsanitize=address], [SANITIZER_CFLAGS])
205 AX_APPEND_FLAG([-fno-omit-frame-pointer], [SANITIZER_CFLAGS])
206 AX_APPEND_FLAG([-fsanitize=address], [SANITIZER_LDFLAGS])])
207
208 AC_ARG_ENABLE([ubsan],
209 [AS_HELP_STRING([--enable-ubsan],
210 [enable UndefinedBehaviorSanitizer])],
211 [], [enable_ubsan=no])
212
213 AS_IF([test "x$enable_ubsan" != xno],
214 [AX_APPEND_FLAG([-fsanitize=undefined], [SANITIZER_CFLAGS])
215 AX_APPEND_FLAG([-fno-omit-frame-pointer], [SANITIZER_CFLAGS])
216 AX_APPEND_FLAG([-fsanitize=undefined], [SANITIZER_LDFLAGS])])
217
218 AC_SUBST(SANITIZER_CFLAGS)
219 AC_SUBST(SANITIZER_LDFLAGS)
220
221 AC_CONFIG_FILES([Makefile])
222 AC_OUTPUT