Get rid of all the duplicated settings of AM_CFLAGS in the makefiles
for the various core modules and use a single global setting so that
the flags are actually consistent everywhere.
Also get rid of most the USE_PIE blocks in the makefiles by having
configure pass expand a variable in the new global AM_CFLAGS to one
of "-fpie" or "" depending on whether PIE is in use.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3760 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/Makefile.core-AM_CPPFLAGS.am b/Makefile.core-AM_CPPFLAGS.am
index fe9d406..5055b21 100644
--- a/Makefile.core-AM_CPPFLAGS.am
+++ b/Makefile.core-AM_CPPFLAGS.am
@@ -12,6 +12,11 @@
-DVGO_$(VG_OS)=1 \
-DVGP_$(VG_ARCH)_$(VG_OS)=1
+BASE_AM_CFLAGS = @ARCH_CORE_AM_CFLAGS@ -Wmissing-prototypes -Winline -Wall -Wshadow -O -g
+
+PIC_AM_CFLAGS = $(BASE_AM_CFLAGS) -fpic -fno-omit-frame-pointer
+
AM_CPPFLAGS = $(add_includes)
+AM_CFLAGS = $(WERROR) @PIE_AM_CFLAGS@ $(BASE_AM_CFLAGS)
AM_CCASFLAGS = $(add_includes) @ARCH_CORE_AM_CCASFLAGS@ -Wa,-gstabs
diff --git a/auxprogs/Makefile.am b/auxprogs/Makefile.am
index 1e31292..1c7ab40 100644
--- a/auxprogs/Makefile.am
+++ b/auxprogs/Makefile.am
@@ -1,8 +1,6 @@
include $(top_srcdir)/Makefile.all.am
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
-AM_CFLAGS = $(WERROR) -Winline -Wall -O -g
-
bin_PROGRAMS = valgrind-listener
valgrind_listener_SOURCES = valgrind-listener.c
diff --git a/configure.in b/configure.in
index f7db980..11f2073 100644
--- a/configure.in
+++ b/configure.in
@@ -335,6 +335,7 @@
fi
# Check for PIE support in the compiler and linker
+AC_SUBST(PIE_AM_CFLAGS)
AC_CACHE_CHECK([for PIE support], vg_cv_pie,
[AC_ARG_ENABLE(pie, [ --enable-pie platform supports PIE linking],
[vg_cv_pie=$enableval],
@@ -350,6 +351,7 @@
LDFLAGS=$safe_LDFLAGS])])
if test "$vg_cv_pie" = yes; then
AC_DEFINE([HAVE_PIE], 1, [can create position-independent executables])
+PIE_AM_CFLAGS="-fpie"
fi
AM_CONDITIONAL(USE_PIE, test "$vg_cv_pie" = "yes")
diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am
index ed1a206..6c84309 100644
--- a/coregrind/Makefile.am
+++ b/coregrind/Makefile.am
@@ -23,9 +23,6 @@
AM_CPPFLAGS += -DVG_LIBDIR="\"$(valdir)"\" \
-DKICKSTART_BASE=@KICKSTART_BASE@
-AM_CFLAGS = $(WERROR) -Wmissing-prototypes -Winline -Wall -Wshadow -O -g @ARCH_CORE_AM_CFLAGS@
-AM_CFLAGS += -fno-omit-frame-pointer
-
default.supp: $(SUPP_FILES)
bin_PROGRAMS = \
@@ -120,7 +117,7 @@
## only referred to by tool shared objects).
stage2_extra2 = \
m_replacemalloc/libreplacemalloc_core.a
-
+
## Nb: older versions of automake don't seem to like having += within an
## if-then-else, so we have to use these variables for the common parts.
st2_DEPS_common = \
@@ -133,14 +130,12 @@
-Wl,-version-script $(srcdir)/valgrind.vs
if USE_PIE
-stage2_CFLAGS = $(AM_CFLAGS) -fpie
stage2_DEPENDENCIES = $(st2_DEPS_common)
stage2_LDFLAGS = \
$(st2_LDFLAGS_common) \
-Wl,--whole-archive $(stage2_extra2) -Wl,--no-whole-archive \
-pie
else
-stage2_CFLAGS = $(AM_CFLAGS)
stage2_DEPENDENCIES = $(st2_DEPS_common) ${VG_ARCH}/stage2.lds
stage2_LDFLAGS = \
$(st2_LDFLAGS_common) \
diff --git a/coregrind/amd64-linux/Makefile.am b/coregrind/amd64-linux/Makefile.am
index a4daba5..58b3a73 100644
--- a/coregrind/amd64-linux/Makefile.am
+++ b/coregrind/amd64-linux/Makefile.am
@@ -1,8 +1,6 @@
include $(top_srcdir)/Makefile.all.am
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
-AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O -fomit-frame-pointer -g
-
noinst_HEADERS = \
core_platform.h \
vki_unistd.h
@@ -12,9 +10,3 @@
libplatform_a_SOURCES = \
core_platform.c
-
-if USE_PIE
-libplatform_a_CFLAGS = $(AM_CFLAGS) -fpie
-else
-libplatform_a_CFLAGS = $(AM_CFLAGS)
-endif
diff --git a/coregrind/amd64/Makefile.am b/coregrind/amd64/Makefile.am
index 35729bb..5248b70 100644
--- a/coregrind/amd64/Makefile.am
+++ b/coregrind/amd64/Makefile.am
@@ -1,8 +1,6 @@
include $(top_srcdir)/Makefile.all.am
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
-AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O -fomit-frame-pointer -g
-
noinst_HEADERS = \
core_arch.h
@@ -20,12 +18,6 @@
jmp_with_stack.c \
state.c
-if USE_PIE
-libarch_a_CFLAGS = $(AM_CFLAGS) -fpie
-else
-libarch_a_CFLAGS = $(AM_CFLAGS)
-endif
-
# Extract ld's default linker script and hack it to our needs
stage2.lds: Makefile
$(CC) -Wl,--verbose -nostdlib 2>&1 | sed \
diff --git a/coregrind/arm-linux/Makefile.am b/coregrind/arm-linux/Makefile.am
index 0e434f3..cb4cb1f 100644
--- a/coregrind/arm-linux/Makefile.am
+++ b/coregrind/arm-linux/Makefile.am
@@ -1,8 +1,6 @@
include $(top_srcdir)/Makefile.all.am
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
-AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O -fomit-frame-pointer -g
-
noinst_HEADERS = \
core_platform.h \
vki_unistd.h
@@ -11,8 +9,3 @@
libplatform_a_SOURCES =
-if USE_PIE
-libplatform_a_CFLAGS = $(AM_CFLAGS) -fpie
-else
-libplatform_a_CFLAGS = $(AM_CFLAGS)
-endif
diff --git a/coregrind/arm/Makefile.am b/coregrind/arm/Makefile.am
index c4a81e8..99b3d44 100644
--- a/coregrind/arm/Makefile.am
+++ b/coregrind/arm/Makefile.am
@@ -1,8 +1,6 @@
include $(top_srcdir)/Makefile.all.am
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
-AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O -fomit-frame-pointer -g
-
noinst_HEADERS = \
core_arch.h
@@ -18,12 +16,6 @@
libarch_a_SOURCES = \
state.c
-if USE_PIE
-libarch_a_CFLAGS = $(AM_CFLAGS) -fpie
-else
-libarch_a_CFLAGS = $(AM_CFLAGS)
-endif
-
# Extract ld's default linker script and hack it to our needs
stage2.lds: Makefile
$(CC) -Wl,--verbose -nostdlib 2>&1 | sed \
diff --git a/coregrind/linux/Makefile.am b/coregrind/linux/Makefile.am
index 871f9b2..33da84f 100644
--- a/coregrind/linux/Makefile.am
+++ b/coregrind/linux/Makefile.am
@@ -1,8 +1,6 @@
include $(top_srcdir)/Makefile.all.am
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
-AM_CFLAGS = $(WERROR) -Wmissing-prototypes -Winline -Wall -Wshadow -O -g
-
noinst_HEADERS = \
core_os.h
@@ -11,9 +9,3 @@
libos_a_SOURCES = \
core_os.c \
sema.c
-
-if USE_PIE
-libos_a_CFLAGS = $(AM_CFLAGS) -fpie
-else
-libos_a_CFLAGS = $(AM_CFLAGS)
-endif
diff --git a/coregrind/m_aspacemgr/Makefile.am b/coregrind/m_aspacemgr/Makefile.am
index d8a6626..30d62d2 100644
--- a/coregrind/m_aspacemgr/Makefile.am
+++ b/coregrind/m_aspacemgr/Makefile.am
@@ -1,8 +1,6 @@
include $(top_srcdir)/Makefile.all.am
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
-AM_CFLAGS = $(WERROR) -Wmissing-prototypes -Winline -Wall -Wshadow -O -g
-
EXTRA_DIST = \
README_ASPACEMGR.txt
@@ -11,9 +9,3 @@
libaspacemgr_a_SOURCES = \
read_procselfmaps.c \
aspacemgr.c
-
-if USE_PIE
-libaspacemgr_a_CFLAGS = $(AM_CFLAGS) -fpie
-else
-libaspacemgr_a_CFLAGS = $(AM_CFLAGS)
-endif
diff --git a/coregrind/m_demangle/Makefile.am b/coregrind/m_demangle/Makefile.am
index 3625614..fa521bf 100644
--- a/coregrind/m_demangle/Makefile.am
+++ b/coregrind/m_demangle/Makefile.am
@@ -1,14 +1,6 @@
include $(top_srcdir)/Makefile.all.am
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
-## Test repeated in both arms of the if-then-else because older versions of
-## automake don't seem to like having += within an if-then-else.
-if USE_PIE
-AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O -g -fpie
-else
-AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -O -g
-endif
-
noinst_HEADERS = \
ansidecl.h \
dyn-string.h \
diff --git a/coregrind/m_dispatch/Makefile.am b/coregrind/m_dispatch/Makefile.am
index d9b5cf6..79abd35 100644
--- a/coregrind/m_dispatch/Makefile.am
+++ b/coregrind/m_dispatch/Makefile.am
@@ -1,17 +1,9 @@
include $(top_srcdir)/Makefile.all.am
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
-AM_CFLAGS = $(WERROR) -Wmissing-prototypes -Winline -Wall -Wshadow -O -g
-
noinst_LIBRARIES = libdispatch.a
## XXX: this won't work with "make dist" -- only one dispatch-XXX.S file
## will be put in the tarball. Problem exists in various other Makefiles.
libdispatch_a_SOURCES = \
dispatch-@VG_ARCH@.S
-
-if USE_PIE
-libdispatch_a_CFLAGS = $(AM_CFLAGS) -fpie
-else
-libdispatch_a_CFLAGS = $(AM_CFLAGS)
-endif
diff --git a/coregrind/m_replacemalloc/Makefile.am b/coregrind/m_replacemalloc/Makefile.am
index 096492c..4e1942d 100644
--- a/coregrind/m_replacemalloc/Makefile.am
+++ b/coregrind/m_replacemalloc/Makefile.am
@@ -1,8 +1,6 @@
include $(top_srcdir)/Makefile.all.am
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
-AM_CFLAGS = $(WERROR) -Wmissing-prototypes -Winline -Wall -Wshadow -O -g
-
EXTRA_DIST = \
README_REPLACEMALLOC.txt
@@ -13,15 +11,9 @@
libreplacemalloc_core_a_SOURCES = \
replacemalloc_core.c
-if USE_PIE
-libreplacemalloc_core_a_CFLAGS = $(AM_CFLAGS) -fpie
-else
-libreplacemalloc_core_a_CFLAGS = $(AM_CFLAGS)
-endif
-
libreplacemalloc_toolpreload_a_SOURCES = \
vg_replace_malloc.c
libreplacemalloc_toolpreload_a_CFLAGS = \
- $(AM_CFLAGS) -fpic -fno-omit-frame-pointer
+ $(PIC_AM_CFLAGS)
diff --git a/coregrind/m_sigframe/Makefile.am b/coregrind/m_sigframe/Makefile.am
index 610ffba..a7b1017 100644
--- a/coregrind/m_sigframe/Makefile.am
+++ b/coregrind/m_sigframe/Makefile.am
@@ -1,8 +1,6 @@
include $(top_srcdir)/Makefile.all.am
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
-AM_CFLAGS = $(WERROR) -Wmissing-prototypes -Winline -Wall -Wshadow -O -g
-
EXTRA_DIST = \
README_SIGFRAME.txt
@@ -10,9 +8,3 @@
libsigframe_a_SOURCES = \
sigframe-@VG_PLATFORM@.c
-
-if USE_PIE
-libsigframe_a_CFLAGS = $(AM_CFLAGS) -fpie
-else
-libsigframe_a_CFLAGS = $(AM_CFLAGS)
-endif
diff --git a/coregrind/m_syscalls/Makefile.am b/coregrind/m_syscalls/Makefile.am
index ff7ee96..796a082 100644
--- a/coregrind/m_syscalls/Makefile.am
+++ b/coregrind/m_syscalls/Makefile.am
@@ -1,8 +1,6 @@
include $(top_srcdir)/Makefile.all.am
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
-AM_CFLAGS = $(WERROR) -Wmissing-prototypes -Winline -Wall -Wshadow -O -g
-
EXTRA_DIST = \
README_SYSCALLS.txt
@@ -12,7 +10,7 @@
priv_syscalls-amd64-linux.h \
priv_syscalls-arm-linux.h \
priv_syscalls-x86-linux.h
-
+
noinst_LIBRARIES = libsyscalls.a
libsyscalls_a_SOURCES = \
@@ -20,9 +18,3 @@
syscalls.c \
syscalls-@VG_OS@.c \
syscalls-@VG_PLATFORM@.c
-
-if USE_PIE
-libsyscalls_a_CFLAGS = $(AM_CFLAGS) -fpie
-else
-libsyscalls_a_CFLAGS = $(AM_CFLAGS)
-endif
diff --git a/coregrind/x86-linux/Makefile.am b/coregrind/x86-linux/Makefile.am
index ca6ac2e..58b3a73 100644
--- a/coregrind/x86-linux/Makefile.am
+++ b/coregrind/x86-linux/Makefile.am
@@ -1,8 +1,6 @@
include $(top_srcdir)/Makefile.all.am
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
-AM_CFLAGS = $(WERROR) -Wmissing-prototypes -Winline -Wall -Wshadow -O -g
-
noinst_HEADERS = \
core_platform.h \
vki_unistd.h
@@ -12,9 +10,3 @@
libplatform_a_SOURCES = \
core_platform.c
-
-if USE_PIE
-libplatform_a_CFLAGS = $(AM_CFLAGS) -fpie
-else
-libplatform_a_CFLAGS = $(AM_CFLAGS)
-endif
diff --git a/coregrind/x86/Makefile.am b/coregrind/x86/Makefile.am
index 03d4169..a3e4296 100644
--- a/coregrind/x86/Makefile.am
+++ b/coregrind/x86/Makefile.am
@@ -1,8 +1,6 @@
include $(top_srcdir)/Makefile.all.am
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
-AM_CFLAGS = $(WERROR) -Wmissing-prototypes -Winline -Wall -Wshadow -O -g
-
noinst_HEADERS = \
core_arch.h
@@ -20,15 +18,9 @@
jmp_with_stack.c \
state.c
-if USE_PIE
-libarch_a_CFLAGS = $(AM_CFLAGS) -fpie
-else
-libarch_a_CFLAGS = $(AM_CFLAGS)
-endif
-
# Extract ld's default linker script and hack it to our needs
stage2.lds: Makefile
- $(CC) -Wl,--verbose -nostdlib 2>&1 | sed \
+ $(CC) $(AM_CFLAGS) -Wl,--verbose -nostdlib 2>&1 | sed \
-e '1,/^=====\+$$/d' \
-e '/^=====\+$$/d' \
-e 's/0x08048000/kickstart_base/g' > $@ || rm -f $@