Brian Silverman | 8649792 | 2018-02-10 19:28:39 -0500 | [diff] [blame] | 1 | ## Common automake fragments for elfutils subdirectory makefiles. |
| 2 | ## |
| 3 | ## Copyright (C) 2010, 2014, 2016 Red Hat, Inc. |
| 4 | ## |
| 5 | ## This file is part of elfutils. |
| 6 | ## |
| 7 | ## This file is free software; you can redistribute it and/or modify |
| 8 | ## it under the terms of either |
| 9 | ## |
| 10 | ## * the GNU Lesser General Public License as published by the Free |
| 11 | ## Software Foundation; either version 3 of the License, or (at |
| 12 | ## your option) any later version |
| 13 | ## |
| 14 | ## or |
| 15 | ## |
| 16 | ## * the GNU General Public License as published by the Free |
| 17 | ## Software Foundation; either version 2 of the License, or (at |
| 18 | ## your option) any later version |
| 19 | ## |
| 20 | ## or both in parallel, as here. |
| 21 | ## |
| 22 | ## elfutils is distributed in the hope that it will be useful, but |
| 23 | ## WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 25 | ## General Public License for more details. |
| 26 | ## |
| 27 | ## You should have received copies of the GNU General Public License and |
| 28 | ## the GNU Lesser General Public License along with this program. If |
| 29 | ## not, see <http://www.gnu.org/licenses/>. |
| 30 | ## |
| 31 | |
| 32 | DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"${localedir}"' |
| 33 | AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_srcdir)/lib -I.. |
| 34 | |
| 35 | # Drop the 'u' flag that automake adds by default. It is incompatible |
| 36 | # with deterministic archives. |
| 37 | ARFLAGS = cr |
| 38 | |
| 39 | # Warn about stack usage of more than 256K = 262144 bytes. |
| 40 | if ADD_STACK_USAGE_WARNING |
| 41 | STACK_USAGE_WARNING=-Wstack-usage=262144 |
| 42 | else |
| 43 | STACK_USAGE_WARNING= |
| 44 | endif |
| 45 | |
| 46 | if SANE_LOGICAL_OP_WARNING |
| 47 | LOGICAL_OP_WARNING=-Wlogical-op |
| 48 | else |
| 49 | LOGICAL_OP_WARNING= |
| 50 | endif |
| 51 | |
| 52 | if HAVE_DUPLICATED_COND_WARNING |
| 53 | DUPLICATED_COND_WARNING=-Wduplicated-cond |
| 54 | else |
| 55 | DUPLICATED_COND_WARNING= |
| 56 | endif |
| 57 | |
| 58 | if HAVE_NULL_DEREFERENCE_WARNING |
| 59 | NULL_DEREFERENCE_WARNING=-Wnull-dereference |
| 60 | else |
| 61 | NULL_DEREFERENCE_WARNING= |
| 62 | endif |
| 63 | |
| 64 | if HAVE_IMPLICIT_FALLTHROUGH_WARNING |
| 65 | # Use strict fallthrough. Only __attribute__((fallthrough)) will prevent the |
| 66 | # warning |
| 67 | IMPLICIT_FALLTHROUGH_WARNING=-Wimplicit-fallthrough=5 |
| 68 | else |
| 69 | IMPLICIT_FALLTHROUGH_WARNING= |
| 70 | endif |
| 71 | |
| 72 | AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \ |
| 73 | -Wold-style-definition -Wstrict-prototypes \ |
| 74 | $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \ |
| 75 | $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \ |
| 76 | $(if $($(*F)_no_Werror),,-Werror) \ |
| 77 | $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \ |
| 78 | $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \ |
| 79 | $(if $($(*F)_no_Wpacked_not_aligned),-Wno-packed-not-aligned,) \ |
| 80 | $($(*F)_CFLAGS) |
| 81 | |
| 82 | COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage, $(COMPILE)) |
| 83 | |
| 84 | DEFS.os = -DPIC -DSHARED |
| 85 | if SYMBOL_VERSIONING |
| 86 | DEFS.os += -DSYMBOL_VERSIONING |
| 87 | else |
| 88 | endif |
| 89 | |
| 90 | %.os: %.c %.o |
| 91 | if AMDEP |
| 92 | $(AM_V_CC)if $(COMPILE.os) -c -o $@ $(fpic_CFLAGS) $(DEFS.os) -MT $@ -MD -MP \ |
| 93 | -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \ |
| 94 | then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \ |
| 95 | rm -f "$(DEPDIR)/$*.Tpo"; \ |
| 96 | else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ |
| 97 | fi |
| 98 | else |
| 99 | $(AM_V_CC)$(COMPILE.os) -c -o $@ $(fpic_CFLAGS) $(DEFS.os) $< |
| 100 | endif |
| 101 | |
| 102 | CLEANFILES = *.gcno *.gcda |
| 103 | |
| 104 | textrel_msg = echo "WARNING: TEXTREL found in '$@'" |
| 105 | if FATAL_TEXTREL |
| 106 | textrel_found = $(textrel_msg); exit 1 |
| 107 | else |
| 108 | textrel_found = $(textrel_msg) |
| 109 | endif |
| 110 | textrel_check = if $(READELF) -d $@ | fgrep -q TEXTREL; then $(textrel_found); fi |
| 111 | |
| 112 | print-%: |
| 113 | @echo $*=$($*) |