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