xref: /aosp_15_r20/external/elfutils/config/eu.am (revision 7304104da70ce23c86437a01be71edd1a2d7f37e)
1*7304104dSAndroid Build Coastguard Worker## Common automake fragments for elfutils subdirectory makefiles.
2*7304104dSAndroid Build Coastguard Worker##
3*7304104dSAndroid Build Coastguard Worker## Copyright (C) 2010, 2014, 2016 Red Hat, Inc.
4*7304104dSAndroid Build Coastguard Worker## Copyright (C) 2023, Mark J. Wielaard <[email protected]>
5*7304104dSAndroid Build Coastguard Worker##
6*7304104dSAndroid Build Coastguard Worker## This file is part of elfutils.
7*7304104dSAndroid Build Coastguard Worker##
8*7304104dSAndroid Build Coastguard Worker## This file is free software; you can redistribute it and/or modify
9*7304104dSAndroid Build Coastguard Worker## it under the terms of either
10*7304104dSAndroid Build Coastguard Worker##
11*7304104dSAndroid Build Coastguard Worker##   * the GNU Lesser General Public License as published by the Free
12*7304104dSAndroid Build Coastguard Worker##     Software Foundation; either version 3 of the License, or (at
13*7304104dSAndroid Build Coastguard Worker##     your option) any later version
14*7304104dSAndroid Build Coastguard Worker##
15*7304104dSAndroid Build Coastguard Worker## or
16*7304104dSAndroid Build Coastguard Worker##
17*7304104dSAndroid Build Coastguard Worker##   * the GNU General Public License as published by the Free
18*7304104dSAndroid Build Coastguard Worker##     Software Foundation; either version 2 of the License, or (at
19*7304104dSAndroid Build Coastguard Worker##     your option) any later version
20*7304104dSAndroid Build Coastguard Worker##
21*7304104dSAndroid Build Coastguard Worker## or both in parallel, as here.
22*7304104dSAndroid Build Coastguard Worker##
23*7304104dSAndroid Build Coastguard Worker## elfutils is distributed in the hope that it will be useful, but
24*7304104dSAndroid Build Coastguard Worker## WITHOUT ANY WARRANTY; without even the implied warranty of
25*7304104dSAndroid Build Coastguard Worker## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26*7304104dSAndroid Build Coastguard Worker## General Public License for more details.
27*7304104dSAndroid Build Coastguard Worker##
28*7304104dSAndroid Build Coastguard Worker## You should have received copies of the GNU General Public License and
29*7304104dSAndroid Build Coastguard Worker## the GNU Lesser General Public License along with this program.  If
30*7304104dSAndroid Build Coastguard Worker## not, see <http://www.gnu.org/licenses/>.
31*7304104dSAndroid Build Coastguard Worker##
32*7304104dSAndroid Build Coastguard Worker
33*7304104dSAndroid Build Coastguard WorkerDEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"${localedir}"'
34*7304104dSAndroid Build Coastguard WorkerAM_CPPFLAGS = -I. -I$(srcdir) -I$(top_srcdir)/lib -I..
35*7304104dSAndroid Build Coastguard Worker
36*7304104dSAndroid Build Coastguard Worker# Drop the 'u' flag that automake adds by default. It is incompatible
37*7304104dSAndroid Build Coastguard Worker# with deterministic archives.
38*7304104dSAndroid Build Coastguard WorkerARFLAGS = cr
39*7304104dSAndroid Build Coastguard Worker
40*7304104dSAndroid Build Coastguard Worker# Warn about stack usage of more than 256K = 262144 bytes.
41*7304104dSAndroid Build Coastguard Workerif ADD_STACK_USAGE_WARNING
42*7304104dSAndroid Build Coastguard WorkerSTACK_USAGE_WARNING=-Wstack-usage=262144
43*7304104dSAndroid Build Coastguard WorkerSTACK_USAGE_NO_ERROR=-Wno-error=stack-usage=
44*7304104dSAndroid Build Coastguard Workerelse
45*7304104dSAndroid Build Coastguard WorkerSTACK_USAGE_WARNING=
46*7304104dSAndroid Build Coastguard WorkerSTACK_USAGE_NO_ERROR=
47*7304104dSAndroid Build Coastguard Workerendif
48*7304104dSAndroid Build Coastguard Worker
49*7304104dSAndroid Build Coastguard Workerif SANE_LOGICAL_OP_WARNING
50*7304104dSAndroid Build Coastguard WorkerLOGICAL_OP_WARNING=-Wlogical-op
51*7304104dSAndroid Build Coastguard Workerelse
52*7304104dSAndroid Build Coastguard WorkerLOGICAL_OP_WARNING=
53*7304104dSAndroid Build Coastguard Workerendif
54*7304104dSAndroid Build Coastguard Worker
55*7304104dSAndroid Build Coastguard Workerif HAVE_DUPLICATED_COND_WARNING
56*7304104dSAndroid Build Coastguard WorkerDUPLICATED_COND_WARNING=-Wduplicated-cond
57*7304104dSAndroid Build Coastguard Workerelse
58*7304104dSAndroid Build Coastguard WorkerDUPLICATED_COND_WARNING=
59*7304104dSAndroid Build Coastguard Workerendif
60*7304104dSAndroid Build Coastguard Worker
61*7304104dSAndroid Build Coastguard Workerif HAVE_NULL_DEREFERENCE_WARNING
62*7304104dSAndroid Build Coastguard WorkerNULL_DEREFERENCE_WARNING=-Wnull-dereference
63*7304104dSAndroid Build Coastguard Workerelse
64*7304104dSAndroid Build Coastguard WorkerNULL_DEREFERENCE_WARNING=
65*7304104dSAndroid Build Coastguard Workerendif
66*7304104dSAndroid Build Coastguard Worker
67*7304104dSAndroid Build Coastguard Workerif HAVE_IMPLICIT_FALLTHROUGH_WARNING
68*7304104dSAndroid Build Coastguard Worker# Use strict fallthrough. Only __attribute__((fallthrough)) will prevent the
69*7304104dSAndroid Build Coastguard Worker# warning
70*7304104dSAndroid Build Coastguard Workerif HAVE_IMPLICIT_FALLTHROUGH_5_WARNING
71*7304104dSAndroid Build Coastguard WorkerIMPLICIT_FALLTHROUGH_WARNING=-Wimplicit-fallthrough=5
72*7304104dSAndroid Build Coastguard Workerelse
73*7304104dSAndroid Build Coastguard WorkerIMPLICIT_FALLTHROUGH_WARNING=-Wimplicit-fallthrough
74*7304104dSAndroid Build Coastguard Workerendif
75*7304104dSAndroid Build Coastguard Workerelse
76*7304104dSAndroid Build Coastguard WorkerIMPLICIT_FALLTHROUGH_WARNING=
77*7304104dSAndroid Build Coastguard Workerendif
78*7304104dSAndroid Build Coastguard Worker
79*7304104dSAndroid Build Coastguard Workerif HAVE_TRAMPOLINES_WARNING
80*7304104dSAndroid Build Coastguard WorkerTRAMPOLINES_WARNING=-Wtrampolines
81*7304104dSAndroid Build Coastguard Workerelse
82*7304104dSAndroid Build Coastguard WorkerTRAMPOLINES_WARNING=
83*7304104dSAndroid Build Coastguard Workerendif
84*7304104dSAndroid Build Coastguard Worker
85*7304104dSAndroid Build Coastguard Workerif HAVE_NO_PACKED_NOT_ALIGNED_WARNING
86*7304104dSAndroid Build Coastguard WorkerNO_PACKED_NOT_ALIGNED_WARNING=-Wno-packed-not-aligned
87*7304104dSAndroid Build Coastguard Workerelse
88*7304104dSAndroid Build Coastguard WorkerNO_PACKED_NOT_ALIGNED_WARNING=
89*7304104dSAndroid Build Coastguard Workerendif
90*7304104dSAndroid Build Coastguard Worker
91*7304104dSAndroid Build Coastguard Workerif HAVE_USE_AFTER_FREE3_WARNING
92*7304104dSAndroid Build Coastguard WorkerUSE_AFTER_FREE3_WARNING=-Wuse-after-free=3
93*7304104dSAndroid Build Coastguard Workerelse
94*7304104dSAndroid Build Coastguard WorkerUSE_AFTER_FREE3_WARNING=
95*7304104dSAndroid Build Coastguard Workerendif
96*7304104dSAndroid Build Coastguard Worker
97*7304104dSAndroid Build Coastguard WorkerAM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \
98*7304104dSAndroid Build Coastguard Worker	    -Wold-style-definition -Wstrict-prototypes $(TRAMPOLINES_WARNING) \
99*7304104dSAndroid Build Coastguard Worker	    $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \
100*7304104dSAndroid Build Coastguard Worker	    $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \
101*7304104dSAndroid Build Coastguard Worker	    $(USE_AFTER_FREE3_WARNING) \
102*7304104dSAndroid Build Coastguard Worker	    $(if $($(*F)_no_Werror),,-Werror) \
103*7304104dSAndroid Build Coastguard Worker	    $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
104*7304104dSAndroid Build Coastguard Worker	    $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \
105*7304104dSAndroid Build Coastguard Worker	    $(if $($(*F)_no_Wpacked_not_aligned),$(NO_PACKED_NOT_ALIGNED_WARNING),) \
106*7304104dSAndroid Build Coastguard Worker	    $($(*F)_CFLAGS)
107*7304104dSAndroid Build Coastguard Worker
108*7304104dSAndroid Build Coastguard WorkerAM_CXXFLAGS = -std=c++11 -Wall -Wshadow \
109*7304104dSAndroid Build Coastguard Worker	   $(TRAMPOLINES_WARNING) \
110*7304104dSAndroid Build Coastguard Worker	   $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \
111*7304104dSAndroid Build Coastguard Worker	   $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \
112*7304104dSAndroid Build Coastguard Worker	   $(if $($(*F)_no_Werror),,-Werror) \
113*7304104dSAndroid Build Coastguard Worker	   $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
114*7304104dSAndroid Build Coastguard Worker	   $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \
115*7304104dSAndroid Build Coastguard Worker	   $(if $($(*F)_no_Wpacked_not_aligned),$(NO_PACKED_NOT_ALIGNED_WARNING),) \
116*7304104dSAndroid Build Coastguard Worker	   $($(*F)_CXXFLAGS)
117*7304104dSAndroid Build Coastguard Worker
118*7304104dSAndroid Build Coastguard WorkerCOMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage, $(COMPILE))
119*7304104dSAndroid Build Coastguard Worker
120*7304104dSAndroid Build Coastguard WorkerDEFS.os = -DPIC -DSHARED
121*7304104dSAndroid Build Coastguard Workerif SYMBOL_VERSIONING
122*7304104dSAndroid Build Coastguard WorkerDEFS.os += -DSYMBOL_VERSIONING
123*7304104dSAndroid Build Coastguard Workerelse
124*7304104dSAndroid Build Coastguard Workerendif
125*7304104dSAndroid Build Coastguard Worker
126*7304104dSAndroid Build Coastguard Worker%.os: %.c %.o
127*7304104dSAndroid Build Coastguard Workerif AMDEP
128*7304104dSAndroid Build Coastguard Worker	$(AM_V_CC)if $(COMPILE.os) -c -o $@ $(fpic_CFLAGS) $(DEFS.os) -MT $@ -MD -MP \
129*7304104dSAndroid Build Coastguard Worker	  -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
130*7304104dSAndroid Build Coastguard Worker	then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
131*7304104dSAndroid Build Coastguard Worker	     rm -f "$(DEPDIR)/$*.Tpo"; \
132*7304104dSAndroid Build Coastguard Worker	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
133*7304104dSAndroid Build Coastguard Worker	fi
134*7304104dSAndroid Build Coastguard Workerelse
135*7304104dSAndroid Build Coastguard Worker	$(AM_V_CC)$(COMPILE.os) -c -o $@ $(fpic_CFLAGS) $(DEFS.os) $<
136*7304104dSAndroid Build Coastguard Workerendif
137*7304104dSAndroid Build Coastguard Worker
138*7304104dSAndroid Build Coastguard WorkerCLEANFILES = *.gcno *.gcda
139*7304104dSAndroid Build Coastguard Worker
140*7304104dSAndroid Build Coastguard Workertextrel_msg = echo "WARNING: TEXTREL found in '$@'"
141*7304104dSAndroid Build Coastguard Workerif FATAL_TEXTREL
142*7304104dSAndroid Build Coastguard Workertextrel_found = $(textrel_msg); exit 1
143*7304104dSAndroid Build Coastguard Workerelse
144*7304104dSAndroid Build Coastguard Workertextrel_found = $(textrel_msg)
145*7304104dSAndroid Build Coastguard Workerendif
146*7304104dSAndroid Build Coastguard Workertextrel_check = if $(READELF) -d $@ | grep -F -q TEXTREL; then $(textrel_found); fi
147*7304104dSAndroid Build Coastguard Worker
148*7304104dSAndroid Build Coastguard Workerprint-%:
149*7304104dSAndroid Build Coastguard Worker	@echo $*=$($*)
150