111
|
1 # Makefile.am -- Backtrace Makefile.
|
145
|
2 # Copyright (C) 2012-2020 Free Software Foundation, Inc.
|
111
|
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)
|
|
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 pecoff.c \
|
|
60 unknown.c \
|
|
61 xcoff.c
|
|
62
|
|
63 VIEW_FILES = \
|
|
64 read.c \
|
|
65 mmapio.c
|
|
66
|
|
67 ALLOC_FILES = \
|
|
68 alloc.c \
|
|
69 mmap.c
|
|
70
|
|
71 EXTRA_libbacktrace_la_SOURCES = \
|
|
72 $(BACKTRACE_FILES) \
|
|
73 $(FORMAT_FILES) \
|
|
74 $(VIEW_FILES) \
|
|
75 $(ALLOC_FILES)
|
|
76
|
|
77 libbacktrace_la_LIBADD = \
|
|
78 $(BACKTRACE_FILE) \
|
|
79 $(FORMAT_FILE) \
|
|
80 $(VIEW_FILE) \
|
|
81 $(ALLOC_FILE)
|
|
82
|
|
83 libbacktrace_la_DEPENDENCIES = $(libbacktrace_la_LIBADD)
|
|
84
|
|
85 # Testsuite.
|
|
86
|
145
|
87 # Add test to this variable, if you want it to be build.
|
111
|
88 check_PROGRAMS =
|
|
89
|
145
|
90 # Add test to this variable, if you want it to be run.
|
|
91 TESTS =
|
|
92
|
|
93 # Add test to this variable, if you want it to be build and run.
|
|
94 BUILDTESTS =
|
|
95
|
|
96 # Flags to use when compiling test programs.
|
|
97 libbacktrace_TEST_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) -g
|
111
|
98
|
|
99 if NATIVE
|
145
|
100 check_LTLIBRARIES = libbacktrace_alloc.la
|
|
101
|
|
102 libbacktrace_alloc_la_SOURCES = $(libbacktrace_la_SOURCES)
|
|
103 libbacktrace_alloc_la_LIBADD = $(BACKTRACE_FILE) $(FORMAT_FILE) read.lo alloc.lo
|
|
104
|
|
105 libbacktrace_alloc_la_DEPENDENCIES = $(libbacktrace_alloc_la_LIBADD)
|
|
106
|
|
107 check_LTLIBRARIES += libbacktrace_noformat.la
|
|
108
|
|
109 libbacktrace_noformat_la_SOURCES = $(libbacktrace_la_SOURCES)
|
|
110 libbacktrace_noformat_la_LIBADD = $(BACKTRACE_FILE) $(VIEW_FILE) $(ALLOC_FILE)
|
|
111
|
|
112 libbacktrace_noformat_la_DEPENDENCIES = $(libbacktrace_noformat_la_LIBADD)
|
|
113
|
|
114 if HAVE_ELF
|
|
115 if HAVE_OBJCOPY_DEBUGLINK
|
|
116
|
|
117 TEST_BUILD_ID_DIR=$(abs_builddir)/usr/lib/debug/.build-id/
|
|
118
|
|
119 check_LTLIBRARIES += libbacktrace_elf_for_test.la
|
|
120
|
|
121 libbacktrace_elf_for_test_la_SOURCES = $(libbacktrace_la_SOURCES)
|
|
122 libbacktrace_elf_for_test_la_LIBADD = $(BACKTRACE_FILE) elf_for_test.lo \
|
|
123 $(VIEW_FILE) $(ALLOC_FILE)
|
|
124
|
|
125 elf_for_test.c: elf.c
|
|
126 SEARCH='^#define SYSTEM_BUILD_ID_DIR.*$$'; \
|
|
127 REPLACE="#define SYSTEM_BUILD_ID_DIR \"$(TEST_BUILD_ID_DIR)\""; \
|
|
128 $(SED) "s%$$SEARCH%$$REPLACE%" \
|
|
129 $< \
|
|
130 > $@.tmp
|
|
131 mv $@.tmp $@
|
|
132
|
|
133 endif HAVE_OBJCOPY_DEBUGLINK
|
|
134 endif HAVE_ELF
|
|
135
|
|
136 elf_%.c: elf.c
|
|
137 SEARCH='#error "Unknown BACKTRACE_ELF_SIZE"'; \
|
|
138 REPLACE='#undef BACKTRACE_ELF_SIZE\
|
|
139 #define BACKTRACE_ELF_SIZE'; \
|
|
140 $(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
|
|
141 $< \
|
|
142 > $@.tmp
|
|
143 mv $@.tmp $@
|
|
144
|
|
145 xcoff_%.c: xcoff.c
|
|
146 SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \
|
|
147 REPLACE='#undef BACKTRACE_XCOFF_SIZE\
|
|
148 #define BACKTRACE_XCOFF_SIZE'; \
|
|
149 $(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
|
|
150 $< \
|
|
151 > $@.tmp
|
|
152 mv $@.tmp $@
|
|
153
|
|
154 test_elf_32_SOURCES = test_format.c testlib.c
|
|
155 test_elf_32_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
|
156 test_elf_32_LDADD = libbacktrace_noformat.la elf_32.lo
|
|
157
|
|
158 BUILDTESTS += test_elf_32
|
|
159
|
|
160 test_elf_64_SOURCES = test_format.c testlib.c
|
|
161 test_elf_64_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
|
162 test_elf_64_LDADD = libbacktrace_noformat.la elf_64.lo
|
|
163
|
|
164 BUILDTESTS += test_elf_64
|
|
165
|
|
166 test_xcoff_32_SOURCES = test_format.c testlib.c
|
|
167 test_xcoff_32_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
|
168 test_xcoff_32_LDADD = libbacktrace_noformat.la xcoff_32.lo
|
|
169
|
|
170 BUILDTESTS += test_xcoff_32
|
|
171
|
|
172 test_xcoff_64_SOURCES = test_format.c testlib.c
|
|
173 test_xcoff_64_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
|
174 test_xcoff_64_LDADD = libbacktrace_noformat.la xcoff_64.lo
|
|
175
|
|
176 BUILDTESTS += test_xcoff_64
|
|
177
|
|
178 test_pecoff_SOURCES = test_format.c testlib.c
|
|
179 test_pecoff_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
|
180 test_pecoff_LDADD = libbacktrace_noformat.la pecoff.lo
|
|
181
|
|
182 BUILDTESTS += test_pecoff
|
|
183
|
|
184 test_unknown_SOURCES = test_format.c testlib.c
|
|
185 test_unknown_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
|
186 test_unknown_LDADD = libbacktrace_noformat.la unknown.lo
|
|
187
|
|
188 BUILDTESTS += test_unknown
|
|
189
|
|
190 unittest_SOURCES = unittest.c testlib.c
|
|
191 unittest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
|
192 unittest_LDADD = libbacktrace.la
|
|
193
|
|
194 BUILDTESTS += unittest
|
|
195
|
|
196 unittest_alloc_SOURCES = $(unittest_SOURCES)
|
|
197 unittest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
|
198 unittest_alloc_LDADD = libbacktrace_alloc.la
|
|
199
|
|
200 BUILDTESTS += unittest_alloc
|
|
201
|
|
202 check_LTLIBRARIES += libbacktrace_instrumented_alloc.la
|
|
203
|
|
204 libbacktrace_instrumented_alloc_la_SOURCES = $(libbacktrace_la_SOURCES)
|
|
205 libbacktrace_instrumented_alloc_la_LIBADD = $(BACKTRACE_FILE) $(FORMAT_FILE) \
|
|
206 read.lo instrumented_alloc.lo
|
|
207
|
|
208 libbacktrace_instrumented_alloc_la_DEPENDENCIES = \
|
|
209 $(libbacktrace_instrumented_alloc_la_LIBADD)
|
|
210
|
|
211 instrumented_alloc.lo: alloc.c
|
|
212
|
|
213 allocfail_SOURCES = allocfail.c testlib.c
|
|
214 allocfail_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
|
215 allocfail_LDADD = libbacktrace_instrumented_alloc.la
|
|
216
|
|
217 check_PROGRAMS += allocfail
|
|
218
|
|
219 allocfail.sh: allocfail
|
|
220
|
|
221 TESTS += allocfail.sh
|
|
222
|
|
223 if HAVE_ELF
|
|
224 if HAVE_OBJCOPY_DEBUGLINK
|
|
225
|
|
226 b2test_SOURCES = $(btest_SOURCES)
|
|
227 b2test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
|
228 b2test_LDFLAGS = -Wl,--build-id
|
|
229 b2test_LDADD = libbacktrace_elf_for_test.la
|
|
230
|
|
231 check_PROGRAMS += b2test
|
|
232 TESTS += b2test_buildid
|
|
233
|
|
234 if HAVE_DWZ
|
|
235
|
|
236 b3test_SOURCES = $(btest_SOURCES)
|
|
237 b3test_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
|
238 b3test_LDFLAGS = -Wl,--build-id
|
|
239 b3test_LDADD = libbacktrace_elf_for_test.la
|
|
240
|
|
241 check_PROGRAMS += b3test
|
|
242 TESTS += b3test_dwz_buildid
|
|
243
|
|
244 endif HAVE_DWZ
|
|
245
|
|
246 endif HAVE_OBJCOPY_DEBUGLINK
|
|
247 endif HAVE_ELF
|
111
|
248
|
|
249 btest_SOURCES = btest.c testlib.c
|
145
|
250 btest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O
|
111
|
251 btest_LDADD = libbacktrace.la
|
|
252
|
145
|
253 BUILDTESTS += btest
|
|
254
|
|
255 if HAVE_ELF
|
|
256
|
|
257 btest_lto_SOURCES = btest.c testlib.c
|
|
258 btest_lto_CFLAGS = $(libbacktrace_TEST_CFLAGS) -O -flto
|
|
259 btest_lto_LDADD = libbacktrace.la
|
|
260
|
|
261 BUILDTESTS += btest_lto
|
|
262
|
|
263 endif HAVE_ELF
|
|
264
|
|
265 btest_alloc_SOURCES = $(btest_SOURCES)
|
|
266 btest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
|
267 btest_alloc_LDADD = libbacktrace_alloc.la
|
|
268
|
|
269 BUILDTESTS += btest_alloc
|
|
270
|
|
271 if HAVE_DWZ
|
|
272
|
|
273 %_dwz: %
|
|
274 rm -f $@ $@_common.debug
|
|
275 cp $< $@_1
|
|
276 cp $< $@_2
|
|
277 $(DWZ) -m $@_common.debug $@_1 $@_2
|
|
278 rm -f $@_2
|
|
279 mv $@_1 $@
|
|
280
|
|
281 TESTS += btest_dwz
|
|
282
|
|
283 if HAVE_OBJCOPY_DEBUGLINK
|
|
284
|
|
285 TESTS += btest_dwz_gnudebuglink
|
|
286
|
|
287 endif HAVE_OBJCOPY_DEBUGLINK
|
|
288
|
|
289 endif HAVE_DWZ
|
111
|
290
|
|
291 stest_SOURCES = stest.c
|
145
|
292 stest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
111
|
293 stest_LDADD = libbacktrace.la
|
|
294
|
145
|
295 BUILDTESTS += stest
|
|
296
|
|
297 stest_alloc_SOURCES = $(stest_SOURCES)
|
|
298 stest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
|
299 stest_alloc_LDADD = libbacktrace_alloc.la
|
|
300
|
|
301 BUILDTESTS += stest_alloc
|
|
302
|
|
303 if HAVE_ELF
|
111
|
304
|
|
305 ztest_SOURCES = ztest.c testlib.c
|
145
|
306 ztest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -DSRCDIR=\"$(srcdir)\"
|
111
|
307 ztest_LDADD = libbacktrace.la
|
145
|
308 ztest_alloc_LDADD = libbacktrace_alloc.la
|
111
|
309
|
|
310 if HAVE_ZLIB
|
|
311 ztest_LDADD += -lz
|
145
|
312 ztest_alloc_LDADD += -lz
|
111
|
313 endif
|
|
314 ztest_LDADD += $(CLOCK_GETTIME_LINK)
|
145
|
315 ztest_alloc_LDADD += $(CLOCK_GETTIME_LINK)
|
111
|
316
|
145
|
317 BUILDTESTS += ztest
|
|
318
|
|
319 ztest_alloc_SOURCES = $(ztest_SOURCES)
|
|
320 ztest_alloc_CFLAGS = $(ztest_CFLAGS)
|
|
321
|
|
322 BUILDTESTS += ztest_alloc
|
|
323
|
|
324 endif HAVE_ELF
|
111
|
325
|
|
326 edtest_SOURCES = edtest.c edtest2_build.c testlib.c
|
145
|
327 edtest_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
111
|
328 edtest_LDADD = libbacktrace.la
|
|
329
|
145
|
330 BUILDTESTS += edtest
|
|
331
|
|
332 edtest_alloc_SOURCES = $(edtest_SOURCES)
|
|
333 edtest_alloc_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
|
334 edtest_alloc_LDADD = libbacktrace_alloc.la
|
|
335
|
|
336 BUILDTESTS += edtest_alloc
|
111
|
337
|
|
338 edtest2_build.c: gen_edtest2_build; @true
|
|
339 gen_edtest2_build: $(srcdir)/edtest2.c
|
|
340 cat $(srcdir)/edtest2.c > tmp-edtest2_build.c
|
|
341 $(SHELL) $(srcdir)/../move-if-change tmp-edtest2_build.c edtest2_build.c
|
|
342 echo timestamp > $@
|
|
343
|
|
344 if HAVE_PTHREAD
|
|
345
|
145
|
346 BUILDTESTS += ttest
|
111
|
347
|
|
348 ttest_SOURCES = ttest.c testlib.c
|
145
|
349 ttest_CFLAGS = $(libbacktrace_TEST_CFLAGS) -pthread
|
111
|
350 ttest_LDADD = libbacktrace.la
|
|
351
|
145
|
352 BUILDTESTS += ttest_alloc
|
|
353
|
|
354 ttest_alloc_SOURCES = $(ttest_SOURCES)
|
|
355 ttest_alloc_CFLAGS = $(ttest_CFLAGS)
|
|
356 ttest_alloc_LDADD = libbacktrace_alloc.la
|
|
357
|
111
|
358 endif HAVE_PTHREAD
|
|
359
|
|
360 if HAVE_OBJCOPY_DEBUGLINK
|
|
361
|
145
|
362 TESTS += btest_gnudebuglink
|
111
|
363
|
145
|
364 %_gnudebuglink: %
|
|
365 $(OBJCOPY) --only-keep-debug $< $@.debug
|
|
366 $(OBJCOPY) --strip-debug --add-gnu-debuglink=$@.debug $< $@
|
111
|
367
|
|
368 endif HAVE_OBJCOPY_DEBUGLINK
|
|
369
|
145
|
370 %_buildid: %
|
|
371 ./install-debuginfo-for-buildid.sh \
|
|
372 "$(TEST_BUILD_ID_DIR)" \
|
|
373 $<
|
|
374 $(OBJCOPY) --strip-debug $< $@
|
|
375
|
111
|
376 if HAVE_COMPRESSED_DEBUG
|
|
377
|
|
378 ctestg_SOURCES = btest.c testlib.c
|
145
|
379 ctestg_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
111
|
380 ctestg_LDFLAGS = -Wl,--compress-debug-sections=zlib-gnu
|
|
381 ctestg_LDADD = libbacktrace.la
|
|
382
|
|
383 ctesta_SOURCES = btest.c testlib.c
|
145
|
384 ctesta_CFLAGS = $(libbacktrace_TEST_CFLAGS)
|
111
|
385 ctesta_LDFLAGS = -Wl,--compress-debug-sections=zlib-gabi
|
|
386 ctesta_LDADD = libbacktrace.la
|
|
387
|
145
|
388 BUILDTESTS += ctestg ctesta
|
|
389
|
|
390 ctestg_alloc_SOURCES = $(ctestg_SOURCES)
|
|
391 ctestg_alloc_CFLAGS = $(ctestg_CFLAGS)
|
|
392 ctestg_alloc_LDFLAGS = $(ctestg_LDFLAGS)
|
|
393 ctestg_alloc_LDADD = libbacktrace_alloc.la
|
|
394
|
|
395 ctesta_alloc_SOURCES = $(ctesta_SOURCES)
|
|
396 ctesta_alloc_CFLAGS = $(ctesta_CFLAGS)
|
|
397 ctesta_alloc_LDFLAGS = $(ctesta_LDFLAGS)
|
|
398 ctesta_alloc_LDADD = libbacktrace_alloc.la
|
|
399
|
|
400 BUILDTESTS += ctestg_alloc ctesta_alloc
|
|
401
|
|
402 endif
|
|
403
|
|
404 if HAVE_DWARF5
|
|
405
|
|
406 dwarf5_SOURCES = btest.c testlib.c
|
|
407 dwarf5_CFLAGS = $(libbacktrace_TEST_CFLAGS) -gdwarf-5
|
|
408 dwarf5_LDADD = libbacktrace.la
|
|
409
|
|
410 BUILDTESTS += dwarf5
|
|
411
|
|
412 dwarf5_alloc_SOURCES = $(dwarf5_SOURCES)
|
|
413 dwarf5_alloc_CFLAGS = $(dwarf5_CFLAGS)
|
|
414 dwarf5_alloc_LDADD = libbacktrace_alloc.la
|
|
415
|
|
416 BUILDTESTS += dwarf5_alloc
|
111
|
417
|
|
418 endif
|
|
419
|
|
420 endif NATIVE
|
|
421
|
145
|
422 check_PROGRAMS += $(BUILDTESTS)
|
|
423
|
|
424 TESTS += $(BUILDTESTS)
|
|
425
|
|
426 CLEANFILES = $(TESTS) *.debug elf_for_test.c edtest2_build.c gen_edtest2_build
|
|
427
|
|
428 clean-local:
|
|
429 -rm -rf usr
|
|
430
|
111
|
431 # We can't use automake's automatic dependency tracking, because it
|
|
432 # breaks when using bootstrap-lean. Automatic dependency tracking
|
|
433 # with GCC bootstrap will cause some of the objects to depend on
|
|
434 # header files in prev-gcc/include, e.g., stddef.h and stdarg.h. When
|
|
435 # using bootstrap-lean, prev-gcc is removed after each stage. When
|
|
436 # running "make install", those header files will be gone, causing the
|
|
437 # library to be rebuilt at install time. That may not succeed.
|
|
438
|
|
439 # These manual dependencies do not include dependencies on unwind.h,
|
|
440 # even though that is part of GCC, because where to find it depends on
|
|
441 # whether we are being built as a host library or a target library.
|
|
442
|
|
443 INCDIR = $(top_srcdir)/../include
|
|
444 alloc.lo: config.h backtrace.h internal.h
|
|
445 backtrace.lo: config.h backtrace.h internal.h
|
|
446 btest.lo: (INCDIR)/filenames.h backtrace.h backtrace-supported.h
|
|
447 dwarf.lo: config.h $(INCDIR)/dwarf2.h $(INCDIR)/dwarf2.def \
|
|
448 $(INCDIR)/filenames.h backtrace.h internal.h
|
|
449 elf.lo: config.h backtrace.h internal.h
|
|
450 fileline.lo: config.h backtrace.h internal.h
|
|
451 mmap.lo: config.h backtrace.h internal.h
|
|
452 mmapio.lo: config.h backtrace.h internal.h
|
|
453 nounwind.lo: config.h internal.h
|
|
454 pecoff.lo: config.h backtrace.h internal.h
|
|
455 posix.lo: config.h backtrace.h internal.h
|
|
456 print.lo: config.h backtrace.h internal.h
|
|
457 read.lo: config.h backtrace.h internal.h
|
|
458 simple.lo: config.h backtrace.h internal.h
|
|
459 sort.lo: config.h backtrace.h internal.h
|
|
460 stest.lo: config.h backtrace.h internal.h
|
|
461 state.lo: config.h backtrace.h backtrace-supported.h internal.h
|
|
462 unknown.lo: config.h backtrace.h internal.h
|
|
463 xcoff.lo: config.h backtrace.h internal.h
|
|
464
|
145
|
465 include $(top_srcdir)/../multilib.am
|