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