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 32DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"${localedir}"' 33AM_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. 37ARFLAGS = cr 38 39# Warn about stack usage of more than 256K = 262144 bytes. 40if ADD_STACK_USAGE_WARNING 41STACK_USAGE_WARNING=-Wstack-usage=262144 42STACK_USAGE_NO_ERROR=-Wno-error=stack-usage= 43else 44STACK_USAGE_WARNING= 45STACK_USAGE_NO_ERROR= 46endif 47 48if SANE_LOGICAL_OP_WARNING 49LOGICAL_OP_WARNING=-Wlogical-op 50else 51LOGICAL_OP_WARNING= 52endif 53 54if HAVE_DUPLICATED_COND_WARNING 55DUPLICATED_COND_WARNING=-Wduplicated-cond 56else 57DUPLICATED_COND_WARNING= 58endif 59 60if HAVE_NULL_DEREFERENCE_WARNING 61NULL_DEREFERENCE_WARNING=-Wnull-dereference 62else 63NULL_DEREFERENCE_WARNING= 64endif 65 66if HAVE_IMPLICIT_FALLTHROUGH_WARNING 67# Use strict fallthrough. Only __attribute__((fallthrough)) will prevent the 68# warning 69if HAVE_IMPLICIT_FALLTHROUGH_5_WARNING 70IMPLICIT_FALLTHROUGH_WARNING=-Wimplicit-fallthrough=5 71else 72IMPLICIT_FALLTHROUGH_WARNING=-Wimplicit-fallthrough 73endif 74else 75IMPLICIT_FALLTHROUGH_WARNING= 76endif 77 78if HAVE_TRAMPOLINES_WARNING 79TRAMPOLINES_WARNING=-Wtrampolines 80else 81TRAMPOLINES_WARNING= 82endif 83 84if HAVE_NO_PACKED_NOT_ALIGNED_WARNING 85NO_PACKED_NOT_ALIGNED_WARNING=-Wno-packed-not-aligned 86else 87NO_PACKED_NOT_ALIGNED_WARNING= 88endif 89 90AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \ 91 -Wold-style-definition -Wstrict-prototypes $(TRAMPOLINES_WARNING) \ 92 $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \ 93 $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \ 94 $(if $($(*F)_no_Werror),,-Werror) \ 95 $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \ 96 $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \ 97 $(if $($(*F)_no_Wpacked_not_aligned),$(NO_PACKED_NOT_ALIGNED_WARNING),) \ 98 $($(*F)_CFLAGS) 99 100AM_CXXFLAGS = -std=c++11 -Wall -Wshadow \ 101 $(TRAMPOLINES_WARNING) \ 102 $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \ 103 $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \ 104 $(if $($(*F)_no_Werror),,-Werror) \ 105 $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \ 106 $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \ 107 $(if $($(*F)_no_Wpacked_not_aligned),$(NO_PACKED_NOT_ALIGNED_WARNING),) \ 108 $($(*F)_CXXFLAGS) 109 110COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage, $(COMPILE)) 111 112DEFS.os = -DPIC -DSHARED 113if SYMBOL_VERSIONING 114DEFS.os += -DSYMBOL_VERSIONING 115else 116endif 117 118%.os: %.c %.o 119if AMDEP 120 $(AM_V_CC)if $(COMPILE.os) -c -o $@ $(fpic_CFLAGS) $(DEFS.os) -MT $@ -MD -MP \ 121 -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \ 122 then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \ 123 rm -f "$(DEPDIR)/$*.Tpo"; \ 124 else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ 125 fi 126else 127 $(AM_V_CC)$(COMPILE.os) -c -o $@ $(fpic_CFLAGS) $(DEFS.os) $< 128endif 129 130CLEANFILES = *.gcno *.gcda 131 132textrel_msg = echo "WARNING: TEXTREL found in '$@'" 133if FATAL_TEXTREL 134textrel_found = $(textrel_msg); exit 1 135else 136textrel_found = $(textrel_msg) 137endif 138textrel_check = if $(READELF) -d $@ | grep -F -q TEXTREL; then $(textrel_found); fi 139 140print-%: 141 @echo $*=$($*) 142