1## Common automake fragments for elfutils subdirectory makefiles.
2##
3## Copyright (C) 2010, 2014 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
42else
43STACK_USAGE_WARNING=
44endif
45AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \
46	    -Wold-style-definition -Wstrict-prototypes \
47	    $(if $($(*F)_no_Werror),,-Werror) \
48	    $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
49	    $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \
50	    $($(*F)_CFLAGS)
51
52COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage, $(COMPILE))
53
54DEFS.os = -DPIC -DSHARED
55if SYMBOL_VERSIONING
56DEFS.os += -DSYMBOL_VERSIONING
57else
58endif
59
60%.os: %.c %.o
61if AMDEP
62	$(AM_V_CC)if $(COMPILE.os) -c -o $@ -fPIC $(DEFS.os) -MT $@ -MD -MP \
63	  -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
64	then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
65	     rm -f "$(DEPDIR)/$*.Tpo"; \
66	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
67	fi
68else
69	$(AM_V_CC)$(COMPILE.os) -c -o $@ -fPIC $(DEFS.os) $<
70endif
71
72CLEANFILES = *.gcno *.gcda
73
74textrel_msg = echo "WARNING: TEXTREL found in '$@'"
75if FATAL_TEXTREL
76textrel_found = $(textrel_msg); exit 1
77else
78textrel_found = $(textrel_msg)
79endif
80textrel_check = if $(READELF) -d $@ | fgrep -q TEXTREL; then $(textrel_found); fi
81
82print-%:
83	@echo $*=$($*)
84