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