| 1 |
# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 |
|
| 4 |
ACLOCAL_AMFLAGS = -I m4 |
| 5 |
|
| 6 |
.DELETE_ON_ERROR: |
| 7 |
|
| 8 |
AM_CPPFLAGS = -I $(top_srcdir)/include -iquote $(dir $@) \ |
| 9 |
-iquote $(srcdir)/$(dir $@) -D_GNU_SOURCE |
| 10 |
AM_CFLAGS = $(WARN_CFLAGS) $(SANITIZER_CFLAGS) |
| 11 |
AM_LDFLAGS= $(SANITIZER_LDFLAGS) |
| 12 |
|
| 13 |
noinst_HEADERS = include/elf.h \ |
| 14 |
tests/test_util.h |
| 15 |
|
| 16 |
include_HEADERS = drgn.h |
| 17 |
|
| 18 |
ARCH_DEFS_PYS = arch_aarch64_defs.py \ |
| 19 |
arch_arm_defs.py \ |
| 20 |
arch_ppc64_defs.py \ |
| 21 |
arch_s390x_defs.py \ |
| 22 |
arch_x86_64_defs.py |
| 23 |
|
| 24 |
ARCH_DEFS_INCS = $(ARCH_DEFS_PYS:_defs.py=_defs.inc) |
| 25 |
|
| 26 |
STRSWITCH_INCS = drgn_program_parse_vmcoreinfo.inc \ |
| 27 |
linux_kernel_object_find.inc |
| 28 |
|
| 29 |
BUILT_SOURCES = $(ARCH_DEFS_INCS) \ |
| 30 |
$(STRSWITCH_INCS) \ |
| 31 |
c_keywords.inc \ |
| 32 |
drgn.h \ |
| 33 |
drgn_section_name_to_index.inc \ |
| 34 |
elf_sections.h |
| 35 |
|
| 36 |
if ENABLE_PYTHON |
| 37 |
BUILT_SOURCES += python/docstrings.h |
| 38 |
endif |
| 39 |
|
| 40 |
noinst_LTLIBRARIES = libdrgn_common.la |
| 41 |
|
| 42 |
libdrgn_common_la_SOURCES = $(ARCH_DEFS_PYS:_defs.py=.c) \ |
| 43 |
$(ARCH_DEFS_INCS) \ |
| 44 |
$(STRSWITCH_INCS) \ |
| 45 |
accessors.c \ |
| 46 |
arch_i386.c \ |
| 47 |
arch_riscv.c \ |
| 48 |
array.h \ |
| 49 |
binary_buffer.c \ |
| 50 |
binary_buffer.h \ |
| 51 |
binary_search.h \ |
| 52 |
binary_search_tree.h \ |
| 53 |
bitmap.h \ |
| 54 |
bitops.h \ |
| 55 |
c_keywords.inc \ |
| 56 |
c_lexer.h \ |
| 57 |
cfi.c \ |
| 58 |
cfi.h \ |
| 59 |
cityhash.h \ |
| 60 |
cleanup.h \ |
| 61 |
crc32.c \ |
| 62 |
crc32.h \ |
| 63 |
debug_info.c \ |
| 64 |
debug_info.h \ |
| 65 |
debug_info_options.c \ |
| 66 |
debug_info_options.h \ |
| 67 |
drgn_internal.h \ |
| 68 |
drgn_section_name_to_index.inc \ |
| 69 |
dwarf_constants.c \ |
| 70 |
dwarf_constants.h \ |
| 71 |
dwarf_info.c \ |
| 72 |
dwarf_info.h \ |
| 73 |
elf_file.c \ |
| 74 |
elf_file.h \ |
| 75 |
elf_notes.c \ |
| 76 |
elf_notes.h \ |
| 77 |
elf_symtab.c \ |
| 78 |
elf_symtab.h \ |
| 79 |
elf_sections.h \ |
| 80 |
error.c \ |
| 81 |
error.h \ |
| 82 |
generics.h \ |
| 83 |
handler.c \ |
| 84 |
handler.h \ |
| 85 |
hash_table.c \ |
| 86 |
hash_table.h \ |
| 87 |
helpers.h \ |
| 88 |
hexlify.c \ |
| 89 |
hexlify.h \ |
| 90 |
io.c \ |
| 91 |
io.h \ |
| 92 |
kallsyms.c \ |
| 93 |
kallsyms.h \ |
| 94 |
language.c \ |
| 95 |
language.h \ |
| 96 |
language_c.c \ |
| 97 |
lazy_object.c \ |
| 98 |
lazy_object.h \ |
| 99 |
lexer.c \ |
| 100 |
lexer.h \ |
| 101 |
linux_kernel.c \ |
| 102 |
linux_kernel.h \ |
| 103 |
linux_kernel_helpers.c \ |
| 104 |
log.c \ |
| 105 |
log.h \ |
| 106 |
memory_reader.c \ |
| 107 |
memory_reader.h \ |
| 108 |
minmax.h \ |
| 109 |
nstring.h \ |
| 110 |
object.c \ |
| 111 |
object.h \ |
| 112 |
openmp.c \ |
| 113 |
openmp.h \ |
| 114 |
orc.h \ |
| 115 |
orc_info.c \ |
| 116 |
orc_info.h \ |
| 117 |
path.c \ |
| 118 |
path.h \ |
| 119 |
platform.c \ |
| 120 |
platform.h \ |
| 121 |
plugins.h \ |
| 122 |
pp.h \ |
| 123 |
program.c \ |
| 124 |
program.h \ |
| 125 |
qemu_machine_protocol.h \ |
| 126 |
register_state.c \ |
| 127 |
register_state.h \ |
| 128 |
serialize.c \ |
| 129 |
serialize.h \ |
| 130 |
splay_tree.c \ |
| 131 |
stack_trace.c \ |
| 132 |
stack_trace.h \ |
| 133 |
string_builder.c \ |
| 134 |
string_builder.h \ |
| 135 |
symbol.c \ |
| 136 |
symbol.h \ |
| 137 |
type.c \ |
| 138 |
type.h \ |
| 139 |
util.c \ |
| 140 |
util.h \ |
| 141 |
vector.h |
| 142 |
|
| 143 |
libdrgn_common_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden $(OPENMP_CFLAGS) \ |
| 144 |
$(elfutils_CFLAGS) $(json_c_CFLAGS) $(pcre2_CFLAGS) |
| 145 |
libdrgn_common_la_LIBADD = $(OPENMP_LIBS) $(elfutils_LIBS) $(json_c_LIBS) \ |
| 146 |
$(lzma_LIBS) $(pcre2_LIBS) -lm |
| 147 |
|
| 148 |
if WITH_DEBUGINFOD |
| 149 |
if ENABLE_DLOPEN_DEBUGINFOD |
| 150 |
libdrgn_common_la_LIBADD += -ldl |
| 151 |
else |
| 152 |
libdrgn_common_la_CFLAGS += $(libdebuginfod_CFLAGS) |
| 153 |
libdrgn_common_la_LIBADD += $(libdebuginfod_LIBS) |
| 154 |
endif |
| 155 |
endif |
| 156 |
|
| 157 |
if WITH_JSON_C |
| 158 |
libdrgn_common_la_SOURCES += qemu_machine_protocol.c |
| 159 |
endif |
| 160 |
|
| 161 |
if WITH_LIBKDUMPFILE |
| 162 |
libdrgn_common_la_SOURCES += kdump.c |
| 163 |
libdrgn_common_la_CFLAGS += $(libkdumpfile_CFLAGS) |
| 164 |
libdrgn_common_la_LIBADD += $(libkdumpfile_LIBS) |
| 165 |
endif |
| 166 |
|
| 167 |
if ENABLE_PYTHON |
| 168 |
noinst_LTLIBRARIES += libdrgn_common_python.la |
| 169 |
|
| 170 |
libdrgn_common_python_la_SOURCES = python/constants.c \ |
| 171 |
python/debug_info_options.c \ |
| 172 |
python/docstrings.c \ |
| 173 |
python/docstrings.h \ |
| 174 |
python/drgnpy.h \ |
| 175 |
python/error.c \ |
| 176 |
python/helpers.c \ |
| 177 |
python/language.c \ |
| 178 |
python/main.c \ |
| 179 |
python/memory_search.c \ |
| 180 |
python/module.c \ |
| 181 |
python/module_section_addresses.c \ |
| 182 |
python/object.c \ |
| 183 |
python/platform.c \ |
| 184 |
python/plugins.c \ |
| 185 |
python/program.c \ |
| 186 |
python/source_location.c \ |
| 187 |
python/stack_trace.c \ |
| 188 |
python/symbol.c \ |
| 189 |
python/symbol_index.c \ |
| 190 |
python/test.c \ |
| 191 |
python/thread.c \ |
| 192 |
python/type.c \ |
| 193 |
python/type_kind_set.c \ |
| 194 |
python/util.c |
| 195 |
|
| 196 |
libdrgn_common_python_la_CFLAGS = $(libdrgn_common_la_CFLAGS) |
| 197 |
libdrgn_common_python_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_CPPFLAGS) |
| 198 |
libdrgn_common_python_la_LIBADD = libdrgn_common.la |
| 199 |
endif |
| 200 |
|
| 201 |
EXTRA_LTLIBRARIES = libdrgn_common_no_python.la |
| 202 |
|
| 203 |
libdrgn_common_no_python_la_SOURCES = no_python.c |
| 204 |
libdrgn_common_no_python_la_CFLAGS = $(libdrgn_common_la_CFLAGS) |
| 205 |
libdrgn_common_no_python_la_LIBADD = libdrgn_common.la |
| 206 |
|
| 207 |
%: %.strswitch build-aux/gen_strswitch.py build-aux/codegen_utils.py |
| 208 |
$(AM_V_GEN)$(PYTHON) $(word 2, $^) -o $@ $< |
| 209 |
|
| 210 |
arch_%_defs.inc: arch_%_defs.py build-aux/gen_arch_inc_strswitch.py build-aux/gen_strswitch.py build-aux/codegen_utils.py |
| 211 |
$(AM_V_GEN)$(PYTHON) $(word 2, $^) $< | $(PYTHON) $(word 3, $^) -o $@ - |
| 212 |
|
| 213 |
c_keywords.inc: build-aux/gen_c_keywords_inc_strswitch.py build-aux/gen_strswitch.py build-aux/codegen_utils.py |
| 214 |
$(AM_V_GEN)$(PYTHON) $< | $(PYTHON) $(word 2, $^) -o $@ - |
| 215 |
|
| 216 |
drgn_section_name_to_index.inc: build-aux/gen_elf_sections.py build-aux/gen_strswitch.py build-aux/codegen_utils.py |
| 217 |
$(AM_V_GEN)$(PYTHON) $< | $(PYTHON) $(word 2, $^) -o $@ - |
| 218 |
|
| 219 |
elf_sections.h: build-aux/gen_elf_sections.py build-aux/codegen_utils.py |
| 220 |
$(AM_V_GEN)$(PYTHON) $< -H > $@ |
| 221 |
|
| 222 |
python/constants.c: drgn.h build-aux/gen_constants.py |
| 223 |
$(AM_V_GEN)$(PYTHON) $(word 2, $^) < $< > $@ |
| 224 |
|
| 225 |
drgndoc_docstrings_deps = $(wildcard $(srcdir)/../docs/exts/drgndoc/*.py) |
| 226 |
drgndoc_docstrings = PYTHONPATH="$(srcdir)/../docs/exts:$$PYTHONPATH" $(PYTHON) -m drgndoc.docstrings |
| 227 |
|
| 228 |
python/docstrings.c: ../_drgn.pyi $(drgndoc_docstrings_deps) |
| 229 |
$(AM_V_GEN)$(drgndoc_docstrings) -m _drgn:drgn $< > $@ |
| 230 |
|
| 231 |
python/docstrings.h: ../_drgn.pyi $(drgndoc_docstrings_deps) |
| 232 |
$(AM_V_GEN)$(drgndoc_docstrings) -H -m _drgn:drgn $< > $@ |
| 233 |
|
| 234 |
if ENABLE_LIBDRGN |
| 235 |
if ENABLE_PYTHON |
| 236 |
libdrgn_libs = $(PYTHON_LIBS) libdrgn_common_python.la |
| 237 |
else |
| 238 |
libdrgn_libs = libdrgn_common_no_python.la |
| 239 |
endif |
| 240 |
else |
| 241 |
libdrgn_libs = libdrgn_common_no_python.la |
| 242 |
endif |
| 243 |
|
| 244 |
if ENABLE_LIBDRGN |
| 245 |
lib_LTLIBRARIES = libdrgn.la |
| 246 |
|
| 247 |
libdrgn_la_SOURCES = |
| 248 |
libdrgn_la_LDFLAGS = $(AM_LDFLAGS) -version-info 0:0:0 |
| 249 |
libdrgn_la_LIBADD = $(libdrgn_libs) |
| 250 |
endif |
| 251 |
|
| 252 |
if ENABLE_PYTHON_EXTENSION |
| 253 |
noinst_LTLIBRARIES += _drgn.la |
| 254 |
|
| 255 |
_drgn_la_SOURCES = |
| 256 |
_drgn_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version -module -shared -rpath $(pkgpyexecdir) |
| 257 |
_drgn_la_LIBADD = libdrgn_common_python.la |
| 258 |
endif |
| 259 |
|
| 260 |
EXTRA_DIST = $(ARCH_DEFS_PYS) \ |
| 261 |
$(STRSWITCH_INCS:.inc=.inc.strswitch) \ |
| 262 |
Doxyfile \ |
| 263 |
build-aux/checkmk \ |
| 264 |
build-aux/codegen_utils.py \ |
| 265 |
build-aux/gen_arch_inc_strswitch.py \ |
| 266 |
build-aux/gen_c_keywords_inc_strswitch.py \ |
| 267 |
build-aux/gen_constants.py \ |
| 268 |
build-aux/gen_elf_sections.py \ |
| 269 |
build-aux/gen_strswitch.py |
| 270 |
|
| 271 |
EXTRA_PROGRAMS = examples/load_debug_info |
| 272 |
|
| 273 |
examples_load_debug_info_SOURCES = examples/load_debug_info.c |
| 274 |
examples_load_debug_info_LDADD = $(libdrgn_libs) |
| 275 |
|
| 276 |
# Only test internals here. Anything exposed via Python should be tested in |
| 277 |
# Python unit tests instead. |
| 278 |
TESTS = $(check_PROGRAMS) |
| 279 |
|
| 280 |
check_PROGRAMS = tests/binary_search \ |
| 281 |
tests/bitmap \ |
| 282 |
tests/cityhash \ |
| 283 |
tests/crc32 \ |
| 284 |
tests/hexlify \ |
| 285 |
tests/language_c \ |
| 286 |
tests/lexer \ |
| 287 |
tests/parse_addr2line \ |
| 288 |
tests/path \ |
| 289 |
tests/recursion_guard \ |
| 290 |
tests/serialize |
| 291 |
|
| 292 |
EXTRA_DIST += $(addsuffix .c.in,$(check_PROGRAMS)) |
| 293 |
|
| 294 |
AM_TESTS_ENVIRONMENT = export CK_TAP_LOG_FILE_NAME=-; |
| 295 |
|
| 296 |
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \ |
| 297 |
$(top_srcdir)/build-aux/tap-driver.sh |
| 298 |
|
| 299 |
tests/%.c: build-aux/checkmk tests/%.c.in |
| 300 |
$(AWK) -f $^ > $@ |
| 301 |
|
| 302 |
test_cflags = $(AM_CFLAGS) $(check_CFLAGS) |
| 303 |
test_cppflags = $(AM_CPPFLAGS) -iquote $(srcdir)/tests |
| 304 |
test_ldadd = $(check_LIBS) $(libdrgn_libs) |
| 305 |
|
| 306 |
tests_binary_search_CFLAGS = $(test_cflags) |
| 307 |
tests_binary_search_CPPFLAGS = $(test_cppflags) |
| 308 |
tests_binary_search_LDADD = $(test_ldadd) |
| 309 |
tests_bitmap_CFLAGS = $(test_cflags) |
| 310 |
tests_bitmap_CPPFLAGS = $(test_cppflags) |
| 311 |
tests_bitmap_LDADD = $(test_ldadd) |
| 312 |
tests_cityhash_CFLAGS = $(test_cflags) |
| 313 |
tests_cityhash_CPPFLAGS = $(test_cppflags) |
| 314 |
tests_cityhash_LDADD = $(test_ldadd) |
| 315 |
tests_crc32_CFLAGS = $(test_cflags) |
| 316 |
tests_crc32_CPPFLAGS = $(test_cppflags) |
| 317 |
tests_crc32_LDADD = $(test_ldadd) |
| 318 |
tests_hexlify_CFLAGS = $(test_cflags) |
| 319 |
tests_hexlify_CPPFLAGS = $(test_cppflags) |
| 320 |
tests_hexlify_LDADD = $(test_ldadd) |
| 321 |
tests_language_c_CFLAGS = $(test_cflags) |
| 322 |
tests_language_c_CPPFLAGS = $(test_cppflags) |
| 323 |
tests_language_c_LDADD = $(test_ldadd) |
| 324 |
tests_lexer_CFLAGS = $(test_cflags) |
| 325 |
tests_lexer_CPPFLAGS = $(test_cppflags) |
| 326 |
tests_lexer_LDADD = $(test_ldadd) |
| 327 |
tests_parse_addr2line_CFLAGS = $(test_cflags) |
| 328 |
tests_parse_addr2line_CPPFLAGS = $(test_cppflags) |
| 329 |
tests_parse_addr2line_LDADD = $(test_ldadd) |
| 330 |
tests_path_CFLAGS = $(test_cflags) |
| 331 |
tests_path_CPPFLAGS = $(test_cppflags) |
| 332 |
tests_path_LDADD = $(test_ldadd) |
| 333 |
tests_recursion_guard_CFLAGS = $(test_cflags) |
| 334 |
tests_recursion_guard_CPPFLAGS = $(test_cppflags) |
| 335 |
tests_recursion_guard_LDADD = $(test_ldadd) |
| 336 |
tests_serialize_CFLAGS = $(test_cflags) |
| 337 |
tests_serialize_CPPFLAGS = $(test_cppflags) |
| 338 |
tests_serialize_LDADD = $(test_ldadd) |
| 339 |
|
| 340 |
# Don't delete test-suite.log on failure. |
| 341 |
.PRECIOUS: $(TEST_SUITE_LOG) |