| 1 |
# Makefile.am -- Backtrace Makefile. |
| 2 |
# Copyright (C) 2012-2025 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
# Redistribution and use in source and binary forms, with or without |
| 5 |
# modification, are permitted provided that the following conditions are |
| 6 |
# met: |
| 7 |
|
| 8 |
# (1) Redistributions of source code must retain the above copyright |
| 9 |
# notice, this list of conditions and the following disclaimer. |
| 10 |
|
| 11 |
# (2) Redistributions in binary form must reproduce the above copyright |
| 12 |
# notice, this list of conditions and the following disclaimer in |
| 13 |
# the documentation and/or other materials provided with the |
| 14 |
# distribution. |
| 15 |
|
| 16 |
# (3) The name of the author may not be used to |
| 17 |
# endorse or promote products derived from this software without |
| 18 |
# specific prior written permission. |
| 19 |
|
| 20 |
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 21 |
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 22 |
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 23 |
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
| 24 |
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 25 |
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 26 |
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 27 |
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 28 |
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 29 |
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 30 |
# POSSIBILITY OF SUCH DAMAGE. |
| 31 |
|
| 32 |
ACLOCAL_AMFLAGS = -I .. -I ../config |
| 33 |
|
| 34 |
AM_CPPFLAGS = -I $(top_srcdir)/../include -I $(top_srcdir)/../libgcc \ |
| 35 |
-I ../libgcc |
| 36 |
|
| 37 |
AM_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) $(PIC_FLAG) $(CET_HOST_FLAGS) |
| 38 |
|
| 39 |
noinst_LTLIBRARIES = libbacktrace.la |
| 40 |
|
| 41 |
libbacktrace_la_SOURCES = \ |
| 42 |
backtrace.h \ |
| 43 |
atomic.c \ |
| 44 |
dwarf.c \ |
| 45 |
fileline.c \ |
| 46 |
internal.h \ |
| 47 |
posix.c \ |
| 48 |
print.c \ |
| 49 |
sort.c \ |
| 50 |
state.c |
| 51 |
|
| 52 |
BACKTRACE_FILES = \ |
| 53 |
backtrace.c \ |
| 54 |
simple.c \ |
| 55 |
nounwind.c |
| 56 |
|
| 57 |
FORMAT_FILES = \ |
| 58 |
elf.c \ |
| 59 |
macho.c \ |
| 60 |
pecoff.c \ |
| 61 |
unknown.c \ |
| 62 |
xcoff.c |
| 63 |
|
| 64 |
VIEW_FILES = \ |
| 65 |
read.c \ |
| 66 |
mmapio.c |
| 67 |
|
| 68 |
ALLOC_FILES = \ |
| 69 |
alloc.c \ |
| 70 |
mmap.c |
| 71 |
|
| 72 |
EXTRA_libbacktrace_la_SOURCES = \ |
| 73 |
$(BACKTRACE_FILES) \ |
| 74 |
$(FORMAT_FILES) \ |
| 75 |
$(VIEW_FILES) \ |
| 76 |
$(ALLOC_FILES) |
| 77 |
|
| 78 |
libbacktrace_la_LIBADD = \ |
| 79 |
$(BACKTRACE_FILE) \ |
| 80 |
$(FORMAT_FILE) \ |
| 81 |
$(VIEW_FILE) \ |
| 82 |
$(ALLOC_FILE) |
| 83 |
|
| 84 |
libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD) |
| 85 |
|
| 86 |
# Testsuite. |
| 87 |
|
| 88 |
# Add a test to this variable if you want it to be built as a program, |
| 89 |
# with SOURCES, etc. |
| 90 |
check_PROGRAMS = |
| 91 |
|
| 92 |
# Add a test to this variable if you want it to be run. |
| 93 |
TESTS = |
| 94 |
|
| 95 |
# Add a test to this variable if you want it to be built as a Makefile |
| 96 |
# target and run. |
| 97 |
MAKETESTS = |
| 98 |
|
| 99 |
# Add a test to this variable if you want it to be built as a program, |
| 100 |
# with SOURCES, etc., and run. |
| 101 |
BUILDTESTS = |
| 102 |
|
| 103 |
# Add a file to this variable if you want it to be built for testing. |
| 104 |
check_DATA = |
| 105 |
|
| 106 |
# Flags to use when compiling test programs. |
| 107 |
libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g |
| 108 |
|
| 109 |
# Flags to use when linking test programs. |
| 110 |
# This avoids generating a shell script when configured with --enable-shared. |
| 111 |
libbacktrace_testing_ldflags = -no-install |
| 112 |
|
| 113 |
if USE_DSYMUTIL |
| 114 |
|
| 115 |
%.dSYM: % |
| 116 |
$(DSYMUTIL) $< |
| 117 |
|
| 118 |
endif USE_DSYMUTIL |
| 119 |
|
| 120 |
if NATIVE |
| 121 |
check_LTLIBRARIES = libbacktrace_alloc.la |
| 122 |
|
| 123 |
libbacktrace_alloc_la_SOURCES = $(libbacktrace_la_SOURCES) |
| 124 |
libbacktrace_alloc_la_LIBADD = $(BACKTRACE_FILE) $(FORMAT_FILE) read.lo alloc.lo |
| 125 |
|
| 126 |
libbacktrace_alloc_la_DEPENDENCIES = $(libbacktrace_alloc_la_LIBADD) |
| 127 |
|
| 128 |
check_LTLIBRARIES += libbacktrace_noformat.la |
| 129 |
|
| 130 |
libbacktrace_noformat_la_SOURCES = $(libbacktrace_la_SOURCES) |
| 131 |
libbacktrace_noformat_la_LIBADD = $(BACKTRACE_FILE) $(VIEW_FILE) $(ALLOC_FILE) |
| 132 |
|
| 133 |
libbacktrace_noformat_la_DEPENDENCIES = $(libbacktrace_noformat_la_LIBADD) |
| 134 |
|
| 135 |
if HAVE_ELF |
| 136 |
if HAVE_OBJCOPY_DEBUGLINK |
| 137 |
|
| 138 |
TEST_BUILD_ID_DIR=$(abs_builddir)/usr/lib/debug/.build-id/ |
| 139 |
|
| 140 |
check_LTLIBRARIES += libbacktrace_elf_for_test.la |
| 141 |
|
| 142 |
libbacktrace_elf_for_test_la_SOURCES = $(libbacktrace_la_SOURCES) |
| 143 |
libbacktrace_elf_for_test_la_LIBADD = $(BACKTRACE_FILE) elf_for_test.lo \ |
| 144 |
$(VIEW_FILE) $(ALLOC_FILE) |
| 145 |
|
| 146 |
elf_for_test.c: elf.c |
| 147 |
SEARCH='^#define SYSTEM_BUILD_ID_DIR.*$$'; \ |
| 148 |
REPLACE="#define SYSTEM_BUILD_ID_DIR \"$(TEST_BUILD_ID_DIR)\""; \ |
| 149 |
$(SED) "s%$$SEARCH%$$REPLACE%" \ |
| 150 |
$< \ |
| 151 |
> [email protected] |
| 152 |
mv [email protected] $@ |
| 153 |
|
| 154 |
endif HAVE_OBJCOPY_DEBUGLINK |
| 155 |
endif HAVE_ELF |
| 156 |
|
| 157 |
elf_%.c: elf.c |
| 158 |
nlinit=`echo 'nl="'; echo '"'`; eval "$$nlinit"; \ |
| 159 |
SEARCH='#error "Unknown BACKTRACE_ELF_SIZE"'; \ |
| 160 |
REPLACE="#undef BACKTRACE_ELF_SIZE\\$${nl}#define BACKTRACE_ELF_SIZE"; \ |
| 161 |
$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \ |
| 162 |
$< \ |
| 163 |
> [email protected] |
| 164 |
mv [email protected] $@ |
| 165 |
|
| 166 |
xcoff_%.c: xcoff.c |
| 167 |
nlinit=`echo 'nl="'; echo '"'`; eval "$$nlinit"; \ |
| 168 |
SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \ |
| 169 |
REPLACE="#undef BACKTRACE_XCOFF_SIZE\\$${nl}#define BACKTRACE_XCOFF_SIZE"; \ |
| 170 |
$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \ |
| 171 |
$< \ |
| 172 |
> [email protected] |
| 173 |
mv [email protected] $@ |
| 174 |
|
| 175 |
test_elf_32_SOURCES = test_format.c testlib.c |
| 176 |
test_elf_32_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 177 |
test_elf_32_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 178 |
test_elf_32_LDADD = libbacktrace_noformat.la elf_32.lo |
| 179 |
|
| 180 |
BUILDTESTS += test_elf_32 |
| 181 |
|
| 182 |
test_elf_64_SOURCES = test_format.c testlib.c |
| 183 |
test_elf_64_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 184 |
test_elf_64_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 185 |
test_elf_64_LDADD = libbacktrace_noformat.la elf_64.lo |
| 186 |
|
| 187 |
BUILDTESTS += test_elf_64 |
| 188 |
|
| 189 |
test_macho_SOURCES = test_format.c testlib.c |
| 190 |
test_macho_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 191 |
test_macho_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 192 |
test_macho_LDADD = libbacktrace_noformat.la macho.lo |
| 193 |
|
| 194 |
BUILDTESTS += test_macho |
| 195 |
|
| 196 |
test_xcoff_32_SOURCES = test_format.c testlib.c |
| 197 |
test_xcoff_32_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 198 |
test_xcoff_32_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 199 |
test_xcoff_32_LDADD = libbacktrace_noformat.la xcoff_32.lo |
| 200 |
|
| 201 |
BUILDTESTS += test_xcoff_32 |
| 202 |
|
| 203 |
test_xcoff_64_SOURCES = test_format.c testlib.c |
| 204 |
test_xcoff_64_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 205 |
test_xcoff_64_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 206 |
test_xcoff_64_LDADD = libbacktrace_noformat.la xcoff_64.lo |
| 207 |
|
| 208 |
BUILDTESTS += test_xcoff_64 |
| 209 |
|
| 210 |
test_pecoff_SOURCES = test_format.c testlib.c |
| 211 |
test_pecoff_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 212 |
test_pecoff_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 213 |
test_pecoff_LDADD = libbacktrace_noformat.la pecoff.lo |
| 214 |
|
| 215 |
BUILDTESTS += test_pecoff |
| 216 |
|
| 217 |
test_unknown_SOURCES = test_format.c testlib.c |
| 218 |
test_unknown_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 219 |
test_unknown_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 220 |
test_unknown_LDADD = libbacktrace_noformat.la unknown.lo |
| 221 |
|
| 222 |
BUILDTESTS += test_unknown |
| 223 |
|
| 224 |
unittest_SOURCES = unittest.c testlib.c |
| 225 |
unittest_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 226 |
unittest_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 227 |
unittest_LDADD = libbacktrace.la |
| 228 |
|
| 229 |
BUILDTESTS += unittest |
| 230 |
|
| 231 |
unittest_alloc_SOURCES = $(unittest_SOURCES) |
| 232 |
unittest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 233 |
unittest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 234 |
unittest_alloc_LDADD = libbacktrace_alloc.la |
| 235 |
|
| 236 |
BUILDTESTS += unittest_alloc |
| 237 |
|
| 238 |
check_LTLIBRARIES += libbacktrace_instrumented_alloc.la |
| 239 |
|
| 240 |
libbacktrace_instrumented_alloc_la_SOURCES = $(libbacktrace_la_SOURCES) |
| 241 |
libbacktrace_instrumented_alloc_la_LIBADD = $(BACKTRACE_FILE) $(FORMAT_FILE) \ |
| 242 |
read.lo instrumented_alloc.lo |
| 243 |
|
| 244 |
libbacktrace_instrumented_alloc_la_DEPENDENCIES = \ |
| 245 |
$(libbacktrace_instrumented_alloc_la_LIBADD) |
| 246 |
|
| 247 |
instrumented_alloc.lo: alloc.c |
| 248 |
|
| 249 |
allocfail_SOURCES = allocfail.c testlib.c |
| 250 |
allocfail_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 251 |
allocfail_LDADD = libbacktrace_instrumented_alloc.la |
| 252 |
|
| 253 |
check_PROGRAMS += allocfail |
| 254 |
|
| 255 |
allocfail.sh: allocfail |
| 256 |
|
| 257 |
TESTS += allocfail.sh |
| 258 |
|
| 259 |
if USE_DSYMUTIL |
| 260 |
check_DATA += allocfail.dSYM |
| 261 |
endif USE_DSYMUTIL |
| 262 |
|
| 263 |
if HAVE_ELF |
| 264 |
if HAVE_BUILDID |
| 265 |
if HAVE_OBJCOPY_DEBUGLINK |
| 266 |
|
| 267 |
b2test_SOURCES = $(btest_SOURCES) |
| 268 |
b2test_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 269 |
b2test_LDFLAGS = -Wl,--build-id $(libbacktrace_testing_ldflags) |
| 270 |
b2test_LDADD = libbacktrace_elf_for_test.la |
| 271 |
|
| 272 |
check_PROGRAMS += b2test |
| 273 |
MAKETESTS += b2test_buildid b2test_buildidfull |
| 274 |
|
| 275 |
if HAVE_DWZ |
| 276 |
|
| 277 |
b3test_SOURCES = $(btest_SOURCES) |
| 278 |
b3test_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 279 |
b3test_LDFLAGS = -Wl,--build-id $(libbacktrace_testing_ldflags) |
| 280 |
b3test_LDADD = libbacktrace_elf_for_test.la |
| 281 |
|
| 282 |
check_PROGRAMS += b3test |
| 283 |
MAKETESTS += b3test_dwz_buildid b3test_dwz_buildidfull |
| 284 |
|
| 285 |
endif HAVE_DWZ |
| 286 |
|
| 287 |
endif HAVE_OBJCOPY_DEBUGLINK |
| 288 |
endif HAVE_BUILDID |
| 289 |
endif HAVE_ELF |
| 290 |
|
| 291 |
btest_SOURCES = btest.c testlib.c |
| 292 |
btest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O |
| 293 |
btest_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 294 |
btest_LDADD = libbacktrace.la |
| 295 |
|
| 296 |
BUILDTESTS += btest |
| 297 |
|
| 298 |
if USE_DSYMUTIL |
| 299 |
check_DATA += btest.dSYM |
| 300 |
endif USE_DSYMUTIL |
| 301 |
|
| 302 |
if HAVE_ELF |
| 303 |
|
| 304 |
btest_lto_SOURCES = btest.c testlib.c |
| 305 |
btest_lto_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O -flto |
| 306 |
btest_lto_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 307 |
btest_lto_LDADD = libbacktrace.la |
| 308 |
|
| 309 |
BUILDTESTS += btest_lto |
| 310 |
|
| 311 |
endif HAVE_ELF |
| 312 |
|
| 313 |
btest_alloc_SOURCES = $(btest_SOURCES) |
| 314 |
btest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 315 |
btest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 316 |
btest_alloc_LDADD = libbacktrace_alloc.la |
| 317 |
|
| 318 |
BUILDTESTS += btest_alloc |
| 319 |
|
| 320 |
if USE_DSYMUTIL |
| 321 |
check_DATA += btest_alloc.dSYM |
| 322 |
endif USE_DSYMUTIL |
| 323 |
|
| 324 |
if HAVE_DWZ |
| 325 |
|
| 326 |
%_dwz: % |
| 327 |
rm -f $@ $@_common.debug |
| 328 |
cp $< $@_1 |
| 329 |
cp $< $@_2 |
| 330 |
if $(DWZ) -m $@_common.debug $@_1 $@_2; then \ |
| 331 |
rm -f $@_2; \ |
| 332 |
mv $@_1 $@; \ |
| 333 |
else \ |
| 334 |
echo "Ignoring dwz errors, assuming that test passes"; \ |
| 335 |
cp $< $@; \ |
| 336 |
fi |
| 337 |
|
| 338 |
MAKETESTS += btest_dwz |
| 339 |
|
| 340 |
if HAVE_OBJCOPY_DEBUGLINK |
| 341 |
|
| 342 |
MAKETESTS += btest_dwz_gnudebuglink |
| 343 |
|
| 344 |
endif HAVE_OBJCOPY_DEBUGLINK |
| 345 |
|
| 346 |
endif HAVE_DWZ |
| 347 |
|
| 348 |
stest_SOURCES = stest.c |
| 349 |
stest_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 350 |
stest_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 351 |
stest_LDADD = libbacktrace.la |
| 352 |
|
| 353 |
BUILDTESTS += stest |
| 354 |
|
| 355 |
if USE_DSYMUTIL |
| 356 |
check_DATA += stest.dSYM |
| 357 |
endif USE_DSYMUTIL |
| 358 |
|
| 359 |
stest_alloc_SOURCES = $(stest_SOURCES) |
| 360 |
stest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 361 |
stest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 362 |
stest_alloc_LDADD = libbacktrace_alloc.la |
| 363 |
|
| 364 |
BUILDTESTS += stest_alloc |
| 365 |
|
| 366 |
if USE_DSYMUTIL |
| 367 |
check_DATA += stest_alloc.dSYM |
| 368 |
endif USE_DSYMUTIL |
| 369 |
|
| 370 |
if HAVE_ELF |
| 371 |
|
| 372 |
ztest_SOURCES = ztest.c testlib.c |
| 373 |
ztest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\" |
| 374 |
ztest_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 375 |
ztest_LDADD = libbacktrace.la |
| 376 |
ztest_alloc_LDADD = libbacktrace_alloc.la |
| 377 |
|
| 378 |
if HAVE_ZLIB |
| 379 |
ztest_LDADD += -lz |
| 380 |
ztest_alloc_LDADD += -lz |
| 381 |
endif |
| 382 |
ztest_LDADD += $(CLOCK_GETTIME_LINK) |
| 383 |
ztest_alloc_LDADD += $(CLOCK_GETTIME_LINK) |
| 384 |
|
| 385 |
BUILDTESTS += ztest |
| 386 |
|
| 387 |
ztest_alloc_SOURCES = $(ztest_SOURCES) |
| 388 |
ztest_alloc_CFLAGS = $(ztest_CFLAGS) |
| 389 |
ztest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 390 |
|
| 391 |
BUILDTESTS += ztest_alloc |
| 392 |
|
| 393 |
zstdtest_SOURCES = zstdtest.c testlib.c |
| 394 |
zstdtest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\" |
| 395 |
zstdtest_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 396 |
zstdtest_LDADD = libbacktrace.la |
| 397 |
zstdtest_alloc_LDADD = libbacktrace_alloc.la |
| 398 |
|
| 399 |
if HAVE_ZSTD |
| 400 |
zstdtest_LDADD += -lzstd |
| 401 |
zstdtest_alloc_LDADD += -lzstd |
| 402 |
endif |
| 403 |
zstdtest_LDADD += $(CLOCK_GETTIME_LINK) |
| 404 |
zstdtest_alloc_LDADD += $(CLOCK_GETTIME_LINK) |
| 405 |
|
| 406 |
BUILDTESTS += zstdtest |
| 407 |
|
| 408 |
zstdtest_alloc_SOURCES = $(zstdtest_SOURCES) |
| 409 |
zstdtest_alloc_CFLAGS = $(zstdtest_CFLAGS) |
| 410 |
zstdtest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 411 |
|
| 412 |
BUILDTESTS += zstdtest_alloc |
| 413 |
|
| 414 |
endif HAVE_ELF |
| 415 |
|
| 416 |
edtest_SOURCES = edtest.c edtest2_build.c testlib.c |
| 417 |
edtest_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 418 |
edtest_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 419 |
edtest_LDADD = libbacktrace.la |
| 420 |
|
| 421 |
BUILDTESTS += edtest |
| 422 |
|
| 423 |
if USE_DSYMUTIL |
| 424 |
check_DATA += edtest.dSYM |
| 425 |
endif USE_DSYMUTIL |
| 426 |
|
| 427 |
edtest_alloc_SOURCES = $(edtest_SOURCES) |
| 428 |
edtest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 429 |
edtest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 430 |
edtest_alloc_LDADD = libbacktrace_alloc.la |
| 431 |
|
| 432 |
if USE_DSYMUTIL |
| 433 |
check_DATA += edtest_alloc.dSYM |
| 434 |
endif USE_DSYMUTIL |
| 435 |
|
| 436 |
BUILDTESTS += edtest_alloc |
| 437 |
|
| 438 |
edtest2_build.c: gen_edtest2_build; @true |
| 439 |
gen_edtest2_build: $(srcdir)/edtest2.c |
| 440 |
cat $(srcdir)/edtest2.c > tmp-edtest2_build.c |
| 441 |
$(SHELL) $(srcdir)/../move-if-change tmp-edtest2_build.c edtest2_build.c |
| 442 |
echo timestamp > $@ |
| 443 |
|
| 444 |
if HAVE_PTHREAD |
| 445 |
|
| 446 |
BUILDTESTS += ttest |
| 447 |
|
| 448 |
ttest_SOURCES = ttest.c testlib.c |
| 449 |
ttest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -pthread |
| 450 |
ttest_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 451 |
ttest_LDADD = libbacktrace.la |
| 452 |
|
| 453 |
if USE_DSYMUTIL |
| 454 |
check_DATA += ttest.dSYM |
| 455 |
endif USE_DSYMUTIL |
| 456 |
|
| 457 |
BUILDTESTS += ttest_alloc |
| 458 |
|
| 459 |
ttest_alloc_SOURCES = $(ttest_SOURCES) |
| 460 |
ttest_alloc_CFLAGS = $(ttest_CFLAGS) |
| 461 |
ttest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 462 |
ttest_alloc_LDADD = libbacktrace_alloc.la |
| 463 |
|
| 464 |
if USE_DSYMUTIL |
| 465 |
check_DATA += ttest_alloc.dSYM |
| 466 |
endif USE_DSYMUTIL |
| 467 |
|
| 468 |
endif HAVE_PTHREAD |
| 469 |
|
| 470 |
if HAVE_OBJCOPY_DEBUGLINK |
| 471 |
|
| 472 |
MAKETESTS += btest_gnudebuglink btest_gnudebuglinkfull |
| 473 |
|
| 474 |
%_gnudebuglink: % |
| 475 |
$(OBJCOPY) --only-keep-debug $< [email protected] |
| 476 |
$(OBJCOPY) --strip-debug [email protected] $< $@ |
| 477 |
|
| 478 |
%_gnudebuglinkfull: % |
| 479 |
$(OBJCOPY) --only-keep-debug $< [email protected] |
| 480 |
$(OBJCOPY) --strip-all [email protected] $< $@ |
| 481 |
|
| 482 |
endif HAVE_OBJCOPY_DEBUGLINK |
| 483 |
|
| 484 |
%_buildid: % |
| 485 |
./install-debuginfo-for-buildid.sh \ |
| 486 |
"$(TEST_BUILD_ID_DIR)" \ |
| 487 |
$< |
| 488 |
$(OBJCOPY) --strip-debug $< $@ |
| 489 |
|
| 490 |
%_buildidfull: % |
| 491 |
./install-debuginfo-for-buildid.sh \ |
| 492 |
"$(TEST_BUILD_ID_DIR)" \ |
| 493 |
$< |
| 494 |
$(OBJCOPY) --strip-all $< $@ |
| 495 |
|
| 496 |
if HAVE_COMPRESSED_DEBUG_ZLIB_GNU |
| 497 |
|
| 498 |
ctestg_SOURCES = btest.c testlib.c |
| 499 |
ctestg_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 500 |
ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib-gnu $(libbacktrace_testing_ldflags) |
| 501 |
ctestg_LDADD = libbacktrace.la |
| 502 |
|
| 503 |
ctestg_alloc_SOURCES = $(ctestg_SOURCES) |
| 504 |
ctestg_alloc_CFLAGS = $(ctestg_CFLAGS) |
| 505 |
ctestg_alloc_LDFLAGS = $(ctestg_LDFLAGS) $(libbacktrace_testing_ldflags) |
| 506 |
ctestg_alloc_LDADD = libbacktrace_alloc.la |
| 507 |
|
| 508 |
BUILDTESTS += ctestg ctestg_alloc |
| 509 |
|
| 510 |
endif |
| 511 |
|
| 512 |
if HAVE_COMPRESSED_DEBUG_ZLIB_GABI |
| 513 |
|
| 514 |
ctesta_SOURCES = btest.c testlib.c |
| 515 |
ctesta_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 516 |
ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi $(libbacktrace_testing_ldflags) |
| 517 |
ctesta_LDADD = libbacktrace.la |
| 518 |
|
| 519 |
ctesta_alloc_SOURCES = $(ctesta_SOURCES) |
| 520 |
ctesta_alloc_CFLAGS = $(ctesta_CFLAGS) |
| 521 |
ctesta_alloc_LDFLAGS = $(ctesta_LDFLAGS) $(libbacktrace_testing_ldflags) |
| 522 |
ctesta_alloc_LDADD = libbacktrace_alloc.la |
| 523 |
|
| 524 |
BUILDTESTS += ctesta ctesta_alloc |
| 525 |
|
| 526 |
endif |
| 527 |
|
| 528 |
if HAVE_COMPRESSED_DEBUG_ZSTD |
| 529 |
|
| 530 |
ctestzstd_SOURCES = btest.c testlib.c |
| 531 |
ctestzstd_CFLAGS = $(libbacktrace_TEST_CFLAGS) |
| 532 |
ctestzstd_LDFLAGS = -Wl,--compress-debug-sections=zstd $(libbacktrace_testing_ldflags) |
| 533 |
ctestzstd_LDADD = libbacktrace.la |
| 534 |
|
| 535 |
ctestzstd_alloc_SOURCES = $(ctestzstd_SOURCES) |
| 536 |
ctestzstd_alloc_CFLAGS = $(ctestzstd_CFLAGS) |
| 537 |
ctestzstd_alloc_LDFLAGS = $(ctestzstd_LDFLAGS) $(libbacktrace_testing_ldflags) |
| 538 |
ctestzstd_alloc_LDADD = libbacktrace_alloc.la |
| 539 |
|
| 540 |
BUILDTESTS += ctestzstd ctestzstd_alloc |
| 541 |
|
| 542 |
endif |
| 543 |
|
| 544 |
if HAVE_DWARF5 |
| 545 |
|
| 546 |
dwarf5_SOURCES = btest.c testlib.c |
| 547 |
dwarf5_CFLAGS = $(libbacktrace_TEST_CFLAGS) -gdwarf-5 |
| 548 |
dwarf5_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 549 |
dwarf5_LDADD = libbacktrace.la |
| 550 |
|
| 551 |
BUILDTESTS += dwarf5 |
| 552 |
|
| 553 |
if USE_DSYMUTIL |
| 554 |
check_DATA += dwarf5.dSYM |
| 555 |
endif USE_DSYMUTIL |
| 556 |
|
| 557 |
dwarf5_alloc_SOURCES = $(dwarf5_SOURCES) |
| 558 |
dwarf5_alloc_CFLAGS = $(dwarf5_CFLAGS) |
| 559 |
dwarf5_alloc_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 560 |
dwarf5_alloc_LDADD = libbacktrace_alloc.la |
| 561 |
|
| 562 |
BUILDTESTS += dwarf5_alloc |
| 563 |
|
| 564 |
if USE_DSYMUTIL |
| 565 |
check_DATA += dwarf5_alloc.dSYM |
| 566 |
endif USE_DSYMUTIL |
| 567 |
|
| 568 |
endif |
| 569 |
|
| 570 |
mtest_SOURCES = mtest.c testlib.c |
| 571 |
mtest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O |
| 572 |
mtest_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 573 |
mtest_LDADD = libbacktrace.la |
| 574 |
|
| 575 |
BUILDTESTS += mtest |
| 576 |
|
| 577 |
if USE_DSYMUTIL |
| 578 |
check_DATA += mtest.dSYM |
| 579 |
endif USE_DSYMUTIL |
| 580 |
|
| 581 |
if HAVE_MINIDEBUG |
| 582 |
|
| 583 |
MAKETESTS += mtest_minidebug |
| 584 |
|
| 585 |
%_minidebug: % |
| 586 |
$(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms |
| 587 |
$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms |
| 588 |
$(COMM) -13 $<.dsyms $<.fsyms > $<.keepsyms |
| 589 |
$(OBJCOPY) --only-keep-debug $< $<.dbg |
| 590 |
$(OBJCOPY) -S --remove-section .gdb_index --remove-section .comment --keep-symbols=$<.keepsyms $<.dbg $<.mdbg |
| 591 |
$(OBJCOPY) --strip-all --remove-section ..comment $< $<.strip |
| 592 |
rm -f $<.mdbg.xz |
| 593 |
$(XZ) $<.mdbg |
| 594 |
$(OBJCOPY) --add-section .gnu_debugdata=$<.mdbg.xz $<.strip |
| 595 |
mv $<.strip $@ |
| 596 |
|
| 597 |
if HAVE_ELF |
| 598 |
if HAVE_BUILDID |
| 599 |
if HAVE_OBJCOPY_DEBUGLINK |
| 600 |
|
| 601 |
m2test_SOURCES = $(mtest_SOURCES) |
| 602 |
m2test_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O |
| 603 |
m2test_LDFLAGS = -Wl,--build-id $(libbacktrace_testing_ldflags) |
| 604 |
m2test_LDADD = libbacktrace_elf_for_test.la |
| 605 |
|
| 606 |
check_PROGRAMS += m2test |
| 607 |
MAKETESTS += m2test_minidebug2 |
| 608 |
|
| 609 |
# minidebug2 is like minidebug but also adds the gnu_debugdata section |
| 610 |
# to the debug file, and uses a build ID file. There is no reason to do |
| 611 |
# this but it was causing an infinite recursion. |
| 612 |
%_minidebug2: % |
| 613 |
$(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms2 |
| 614 |
$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms2 |
| 615 |
$(COMM) -13 $<.dsyms2 $<.fsyms2 > $<.keepsyms2 |
| 616 |
$(OBJCOPY) --only-keep-debug $< $<.dbg2 |
| 617 |
$(OBJCOPY) -S --remove-section .gdb_index --remove-section .comment --keep-symbols=$<.keepsyms2 $<.dbg2 $<.mdbg2 |
| 618 |
$(OBJCOPY) --strip-all --remove-section ..comment $< $<.strip2 |
| 619 |
rm -f $<.mdbg2.xz |
| 620 |
$(XZ) $<.mdbg2 |
| 621 |
$(OBJCOPY) --add-section .gnu_debugdata=$<.mdbg2.xz $<.dbg2 |
| 622 |
$(OBJCOPY) --add-section .gnu_debugdata=$<.mdbg2.xz $<.strip2 |
| 623 |
$(SHELL) ./install-debuginfo-for-buildid.sh $(TEST_BUILD_ID_DIR) $<.dbg2 |
| 624 |
mv $<.strip2 $@ |
| 625 |
|
| 626 |
endif HAVE_OBJCOPY_DEBUGLINK |
| 627 |
endif HAVE_BUILDID |
| 628 |
endif HAVE_ELF |
| 629 |
|
| 630 |
endif HAVE_MINIDEBUG |
| 631 |
|
| 632 |
endif NATIVE |
| 633 |
|
| 634 |
if HAVE_ELF |
| 635 |
|
| 636 |
xztest_SOURCES = xztest.c testlib.c |
| 637 |
xztest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\" |
| 638 |
xztest_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 639 |
xztest_LDADD = libbacktrace.la |
| 640 |
|
| 641 |
xztest_alloc_SOURCES = $(xztest_SOURCES) |
| 642 |
xztest_alloc_CFLAGS = $(xztest_CFLAGS) |
| 643 |
xztest_alloc_LDFLAGS = $(libbacktrace_testing_ldflags) |
| 644 |
xztest_alloc_LDADD = libbacktrace_alloc.la |
| 645 |
|
| 646 |
if HAVE_LIBLZMA |
| 647 |
xztest_LDADD += -llzma |
| 648 |
xztest_alloc_LDADD += -llzma |
| 649 |
endif |
| 650 |
|
| 651 |
xztest_LDADD += $(CLOCK_GETTIME_LINK) |
| 652 |
xztest_alloc_LDADD += $(CLOCK_GETTIME_LINK) |
| 653 |
|
| 654 |
BUILDTESTS += xztest xztest_alloc |
| 655 |
|
| 656 |
endif HAVE_ELF |
| 657 |
|
| 658 |
check_PROGRAMS += $(BUILDTESTS) |
| 659 |
|
| 660 |
TESTS += $(MAKETESTS) $(BUILDTESTS) |
| 661 |
|
| 662 |
CLEANFILES = \ |
| 663 |
$(MAKETESTS) $(BUILDTESTS) *.debug elf_for_test.c edtest2_build.c \ |
| 664 |
gen_edtest2_build \ |
| 665 |
*.dsyms *.fsyms *.keepsyms *.dbg *.mdbg *.mdbg.xz *.strip \ |
| 666 |
*.dsyms2 *.fsyms2 *.keepsyms2 *.dbg2 *.mdbg2 *.mdbg2.xz *.strip2 |
| 667 |
|
| 668 |
clean-local: |
| 669 |
-rm -rf usr |
| 670 |
|
| 671 |
# We can't use automake's automatic dependency tracking, because it |
| 672 |
# breaks when using bootstrap-lean. Automatic dependency tracking |
| 673 |
# with GCC bootstrap will cause some of the objects to depend on |
| 674 |
# header files in prev-gcc/include, e.g., stddef.h and stdarg.h. When |
| 675 |
# using bootstrap-lean, prev-gcc is removed after each stage. When |
| 676 |
# running "make install", those header files will be gone, causing the |
| 677 |
# library to be rebuilt at install time. That may not succeed. |
| 678 |
|
| 679 |
# These manual dependencies do not include dependencies on unwind.h, |
| 680 |
# even though that is part of GCC, because where to find it depends on |
| 681 |
# whether we are being built as a host library or a target library. |
| 682 |
|
| 683 |
INCDIR = $(top_srcdir)/../include |
| 684 |
alloc.lo: config.h backtrace.h internal.h |
| 685 |
backtrace.lo: config.h backtrace.h internal.h |
| 686 |
btest.lo: $(INCDIR)/filenames.h backtrace.h backtrace-supported.h |
| 687 |
dwarf.lo: config.h $(INCDIR)/dwarf2.h $(INCDIR)/dwarf2.def \ |
| 688 |
$(INCDIR)/filenames.h backtrace.h internal.h |
| 689 |
elf.lo: config.h backtrace.h internal.h |
| 690 |
fileline.lo: config.h backtrace.h internal.h |
| 691 |
macho.lo: config.h backtrace.h internal.h |
| 692 |
mmap.lo: config.h backtrace.h internal.h |
| 693 |
mmapio.lo: config.h backtrace.h internal.h |
| 694 |
mtest.lo: backtrace.h backtrace-supported.h |
| 695 |
nounwind.lo: config.h internal.h |
| 696 |
pecoff.lo: config.h backtrace.h internal.h |
| 697 |
posix.lo: config.h backtrace.h internal.h |
| 698 |
print.lo: config.h backtrace.h internal.h |
| 699 |
read.lo: config.h backtrace.h internal.h |
| 700 |
simple.lo: config.h backtrace.h internal.h |
| 701 |
sort.lo: config.h backtrace.h internal.h |
| 702 |
stest.lo: config.h backtrace.h internal.h |
| 703 |
state.lo: config.h backtrace.h backtrace-supported.h internal.h |
| 704 |
unknown.lo: config.h backtrace.h internal.h |
| 705 |
xcoff_32.lo: config.h backtrace.h internal.h |
| 706 |
xcoff_64.lo: config.h backtrace.h internal.h |
| 707 |
xztest.lo: config.h backtrace.h backtrace-supported.h internal.h testlib.h |
| 708 |
ztest.lo: config.h backtrace.h backtrace-supported.h internal.h testlib.h |
| 709 |
|
| 710 |
include $(top_srcdir)/../multilib.am |