[RS6000] No inline PLT for V4 bss-plt, implement -mno-pltseq
[official-gcc.git] / libbacktrace / Makefile.am
blob3b5f6e374d81c2106320ccc35b813d1ac71b5cdd
1 # Makefile.am -- Backtrace Makefile.
2 # Copyright (C) 2012-2019 Free Software Foundation, Inc.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
8 #     (1) Redistributions of source code must retain the above copyright
9 #     notice, this list of conditions and the following disclaimer.
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.
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.
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.
32 ACLOCAL_AMFLAGS = -I .. -I ../config
34 AM_CPPFLAGS = -I $(top_srcdir)/../include -I $(top_srcdir)/../libgcc \
35         -I ../libgcc
37 AM_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) $(PIC_FLAG)
39 noinst_LTLIBRARIES = libbacktrace.la
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
52 BACKTRACE_FILES = \
53         backtrace.c \
54         simple.c \
55         nounwind.c
57 FORMAT_FILES = \
58         elf.c \
59         pecoff.c \
60         unknown.c \
61         xcoff.c
63 VIEW_FILES = \
64         read.c \
65         mmapio.c
67 ALLOC_FILES = \
68         alloc.c \
69         mmap.c
71 EXTRA_libbacktrace_la_SOURCES = \
72         $(BACKTRACE_FILES) \
73         $(FORMAT_FILES) \
74         $(VIEW_FILES) \
75         $(ALLOC_FILES)
77 libbacktrace_la_LIBADD = \
78         $(BACKTRACE_FILE) \
79         $(FORMAT_FILE) \
80         $(VIEW_FILE) \
81         $(ALLOC_FILE)
83 libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD)
85 # Testsuite.
87 # Add test to this variable, if you want it to be build.
88 check_PROGRAMS =
90 # Add test to this variable, if you want it to be run.
91 TESTS =
93 # Add test to this variable, if you want it to be build and run.
94 BUILDTESTS =
96 if NATIVE
97 check_LTLIBRARIES = libbacktrace_alloc.la
99 libbacktrace_alloc_la_SOURCES = $(libbacktrace_la_SOURCES)
100 libbacktrace_alloc_la_LIBADD = $(BACKTRACE_FILE) $(FORMAT_FILE) read.lo alloc.lo
102 libbacktrace_alloc_la_DEPENDENCIES = $(libbacktrace_alloc_la_LIBADD)
104 check_LTLIBRARIES += libbacktrace_noformat.la
106 libbacktrace_noformat_la_SOURCES = $(libbacktrace_la_SOURCES)
107 libbacktrace_noformat_la_LIBADD = $(BACKTRACE_FILE) $(VIEW_FILE) $(ALLOC_FILE)
109 libbacktrace_noformat_la_DEPENDENCIES = $(libbacktrace_noformat_la_LIBADD)
111 if HAVE_ELF
112 if HAVE_OBJCOPY_DEBUGLINK
114 TEST_BUILD_ID_DIR=$(abs_builddir)/usr/lib/debug/.build-id/
116 check_LTLIBRARIES += libbacktrace_elf_for_test.la
118 libbacktrace_elf_for_test_la_SOURCES = $(libbacktrace_la_SOURCES)
119 libbacktrace_elf_for_test_la_LIBADD = $(BACKTRACE_FILE) elf_for_test.lo \
120         $(VIEW_FILE) $(ALLOC_FILE)
122 elf_for_test.c: elf.c
123         SEARCH='^#define SYSTEM_BUILD_ID_DIR.*$$'; \
124         REPLACE="#define SYSTEM_BUILD_ID_DIR \"$(TEST_BUILD_ID_DIR)\""; \
125         $(SED) "s%$$SEARCH%$$REPLACE%" \
126                 $< \
127                 > $@.tmp
128         mv $@.tmp $@
130 endif HAVE_OBJCOPY_DEBUGLINK
131 endif HAVE_ELF
133 xcoff_%.c: xcoff.c
134         SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \
135         REPLACE='#undef BACKTRACE_XCOFF_SIZE\
136         #define BACKTRACE_XCOFF_SIZE'; \
137         $(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
138                 $< \
139                 > $@.tmp
140         mv $@.tmp $@
142 test_elf_SOURCES = test_format.c testlib.c
143 test_elf_LDADD = libbacktrace_noformat.la elf.lo
145 BUILDTESTS += test_elf
147 test_xcoff_32_SOURCES = test_format.c testlib.c
148 test_xcoff_32_LDADD = libbacktrace_noformat.la xcoff_32.lo
150 BUILDTESTS += test_xcoff_32
152 test_xcoff_64_SOURCES = test_format.c testlib.c
153 test_xcoff_64_LDADD = libbacktrace_noformat.la xcoff_64.lo
155 BUILDTESTS += test_xcoff_64
157 test_pecoff_SOURCES = test_format.c testlib.c
158 test_pecoff_LDADD = libbacktrace_noformat.la pecoff.lo
160 BUILDTESTS += test_pecoff
162 test_unknown_SOURCES = test_format.c testlib.c
163 test_unknown_LDADD = libbacktrace_noformat.la unknown.lo
165 BUILDTESTS += test_unknown
167 unittest_SOURCES = unittest.c testlib.c
168 unittest_LDADD = libbacktrace.la
170 BUILDTESTS += unittest
172 unittest_alloc_SOURCES = $(unittest_SOURCES)
173 unittest_alloc_LDADD = libbacktrace_alloc.la
175 BUILDTESTS += unittest_alloc
177 check_LTLIBRARIES += libbacktrace_instrumented_alloc.la
179 libbacktrace_instrumented_alloc_la_SOURCES = $(libbacktrace_la_SOURCES)
180 libbacktrace_instrumented_alloc_la_LIBADD = $(BACKTRACE_FILE) $(FORMAT_FILE) \
181         read.lo instrumented_alloc.lo
183 libbacktrace_instrumented_alloc_la_DEPENDENCIES = \
184         $(libbacktrace_instrumented_alloc_la_LIBADD)
186 instrumented_alloc.lo: alloc.c
188 allocfail_SOURCES = allocfail.c testlib.c
189 allocfail_LDADD = libbacktrace_instrumented_alloc.la
191 check_PROGRAMS += allocfail
193 allocfail.sh: allocfail
195 TESTS += allocfail.sh
197 if HAVE_ELF
198 if HAVE_OBJCOPY_DEBUGLINK
200 b2test_SOURCES = $(btest_SOURCES)
201 b2test_CFLAGS = $(btest_CFLAGS)
202 b2test_LDFLAGS = -Wl,--build-id
203 b2test_LDADD = libbacktrace_elf_for_test.la
205 check_PROGRAMS += b2test
206 TESTS += b2test_buildid
208 b3test_SOURCES = $(btest_SOURCES)
209 b3test_CFLAGS = $(btest_CFLAGS)
210 b3test_LDFLAGS = -Wl,--build-id
211 b3test_LDADD = libbacktrace_elf_for_test.la
213 check_PROGRAMS += b3test
214 TESTS += b3test_dwz_buildid
216 endif HAVE_OBJCOPY_DEBUGLINK
217 endif HAVE_ELF
219 btest_SOURCES = btest.c testlib.c
220 btest_CFLAGS = $(AM_CFLAGS) -g -O
221 btest_LDADD = libbacktrace.la
223 BUILDTESTS += btest
225 if HAVE_ELF
227 btest_lto_SOURCES = btest.c testlib.c
228 btest_lto_CFLAGS = $(AM_CFLAGS) -g -O -flto
229 btest_lto_LDADD = libbacktrace.la
231 BUILDTESTS += btest_lto
233 endif HAVE_ELF
235 btest_alloc_SOURCES = $(btest_SOURCES)
236 btest_alloc_CFLAGS = $(btest_CFLAGS)
237 btest_alloc_LDADD = libbacktrace_alloc.la
239 BUILDTESTS += btest_alloc
241 if HAVE_DWZ
243 %_dwz: %
244         rm -f $@ $@_common.debug
245         cp $< $@_1
246         cp $< $@_2
247         $(DWZ) -m $@_common.debug $@_1 $@_2
248         rm -f $@_2
249         mv $@_1 $@
251 TESTS += btest_dwz
253 if HAVE_OBJCOPY_DEBUGLINK
255 TESTS += btest_dwz_gnudebuglink
257 endif HAVE_OBJCOPY_DEBUGLINK
259 endif HAVE_DWZ
261 stest_SOURCES = stest.c
262 stest_LDADD = libbacktrace.la
264 BUILDTESTS += stest
266 stest_alloc_SOURCES = $(stest_SOURCES)
267 stest_alloc_LDADD = libbacktrace_alloc.la
269 BUILDTESTS += stest_alloc
271 ztest_SOURCES = ztest.c testlib.c
272 ztest_CFLAGS = -DSRCDIR=\"$(srcdir)\"
273 ztest_LDADD = libbacktrace.la
274 ztest_alloc_LDADD = libbacktrace_alloc.la
276 if HAVE_ZLIB
277 ztest_LDADD += -lz
278 ztest_alloc_LDADD += -lz
279 endif
280 ztest_LDADD += $(CLOCK_GETTIME_LINK)
281 ztest_alloc_LDADD += $(CLOCK_GETTIME_LINK)
283 BUILDTESTS += ztest
285 ztest_alloc_SOURCES = $(ztest_SOURCES)
286 ztest_alloc_CFLAGS = $(ztest_CFLAGS)
288 BUILDTESTS += ztest_alloc
290 edtest_SOURCES = edtest.c edtest2_build.c testlib.c
291 edtest_LDADD = libbacktrace.la
293 BUILDTESTS += edtest
295 edtest_alloc_SOURCES = $(edtest_SOURCES)
296 edtest_alloc_LDADD = libbacktrace_alloc.la
298 BUILDTESTS += edtest_alloc
300 edtest2_build.c: gen_edtest2_build; @true
301 gen_edtest2_build: $(srcdir)/edtest2.c
302         cat $(srcdir)/edtest2.c > tmp-edtest2_build.c
303         $(SHELL) $(srcdir)/../move-if-change tmp-edtest2_build.c edtest2_build.c
304         echo timestamp > $@
306 if HAVE_PTHREAD
308 BUILDTESTS += ttest
310 ttest_SOURCES = ttest.c testlib.c
311 ttest_CFLAGS = $(AM_CFLAGS) -pthread
312 ttest_LDADD = libbacktrace.la
314 BUILDTESTS += ttest_alloc
316 ttest_alloc_SOURCES = $(ttest_SOURCES)
317 ttest_alloc_CFLAGS = $(ttest_CFLAGS)
318 ttest_alloc_LDADD = libbacktrace_alloc.la
320 endif HAVE_PTHREAD
322 if HAVE_OBJCOPY_DEBUGLINK
324 TESTS += btest_gnudebuglink
326 %_gnudebuglink: %
327         $(OBJCOPY) --only-keep-debug $< $@.debug
328         $(OBJCOPY) --strip-debug --add-gnu-debuglink=$@.debug $< $@
330 endif HAVE_OBJCOPY_DEBUGLINK
332 %_buildid: %
333         ./install-debuginfo-for-buildid.sh \
334           "$(TEST_BUILD_ID_DIR)" \
335           $<
336         $(OBJCOPY) --strip-debug $< $@
338 if HAVE_COMPRESSED_DEBUG
340 ctestg_SOURCES = btest.c testlib.c
341 ctestg_CFLAGS = $(AM_CFLAGS) -g
342 ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib-gnu
343 ctestg_LDADD = libbacktrace.la
345 ctesta_SOURCES = btest.c testlib.c
346 ctesta_CFLAGS = $(AM_CFLAGS) -g
347 ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi
348 ctesta_LDADD = libbacktrace.la
350 BUILDTESTS += ctestg ctesta
352 ctestg_alloc_SOURCES = $(ctestg_SOURCES)
353 ctestg_alloc_CFLAGS = $(ctestg_CFLAGS)
354 ctestg_alloc_LDFLAGS = $(ctestg_LDFLAGS)
355 ctestg_alloc_LDADD = libbacktrace_alloc.la
357 ctesta_alloc_SOURCES = $(ctesta_SOURCES)
358 ctesta_alloc_CFLAGS = $(ctesta_CFLAGS)
359 ctesta_alloc_LDFLAGS = $(ctesta_LDFLAGS)
360 ctesta_alloc_LDADD = libbacktrace_alloc.la
362 BUILDTESTS += ctestg_alloc ctesta_alloc
364 endif
366 endif NATIVE
368 check_PROGRAMS += $(BUILDTESTS)
370 TESTS += $(BUILDTESTS)
372 # We can't use automake's automatic dependency tracking, because it
373 # breaks when using bootstrap-lean.  Automatic dependency tracking
374 # with GCC bootstrap will cause some of the objects to depend on
375 # header files in prev-gcc/include, e.g., stddef.h and stdarg.h.  When
376 # using bootstrap-lean, prev-gcc is removed after each stage.  When
377 # running "make install", those header files will be gone, causing the
378 # library to be rebuilt at install time.  That may not succeed.
380 # These manual dependencies do not include dependencies on unwind.h,
381 # even though that is part of GCC, because where to find it depends on
382 # whether we are being built as a host library or a target library.
384 INCDIR = $(top_srcdir)/../include
385 alloc.lo: config.h backtrace.h internal.h
386 backtrace.lo: config.h backtrace.h internal.h
387 btest.lo: (INCDIR)/filenames.h backtrace.h backtrace-supported.h
388 dwarf.lo: config.h $(INCDIR)/dwarf2.h $(INCDIR)/dwarf2.def \
389         $(INCDIR)/filenames.h backtrace.h internal.h
390 elf.lo: config.h backtrace.h internal.h
391 fileline.lo: config.h backtrace.h internal.h
392 mmap.lo: config.h backtrace.h internal.h
393 mmapio.lo: config.h backtrace.h internal.h
394 nounwind.lo: config.h internal.h
395 pecoff.lo: config.h backtrace.h internal.h
396 posix.lo: config.h backtrace.h internal.h
397 print.lo: config.h backtrace.h internal.h
398 read.lo: config.h backtrace.h internal.h
399 simple.lo: config.h backtrace.h internal.h
400 sort.lo: config.h backtrace.h internal.h
401 stest.lo: config.h backtrace.h internal.h
402 state.lo: config.h backtrace.h backtrace-supported.h internal.h
403 unknown.lo: config.h backtrace.h internal.h
404 xcoff.lo: config.h backtrace.h internal.h
406 include $(top_srcdir)/../multilib.am