From: Tom Hughes Date: Tue, 17 May 2005 16:11:40 +0000 (+0000) Subject: Get rid of all the duplicated settings of AM_CFLAGS in the makefiles X-Git-Tag: svn/VALGRIND_3_0_0~558 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ccae44d3174a86b348363e1ec685b2cdee31f79e;p=thirdparty%2Fvalgrind.git 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 --- diff --git a/Makefile.core-AM_CPPFLAGS.am b/Makefile.core-AM_CPPFLAGS.am index fe9d406311..5055b2162b 100644 --- a/Makefile.core-AM_CPPFLAGS.am +++ b/Makefile.core-AM_CPPFLAGS.am @@ -12,6 +12,11 @@ add_includes = -I$(top_srcdir)/coregrind \ -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 1e31292cab..1c7ab40d58 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 f7db9808df..11f2073f12 100644 --- a/configure.in +++ b/configure.in @@ -335,6 +335,7 @@ AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables]) 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 @@ AC_CACHE_CHECK([for PIE support], vg_cv_pie, 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 ed1a206edc..6c8430945b 100644 --- a/coregrind/Makefile.am +++ b/coregrind/Makefile.am @@ -23,9 +23,6 @@ DIST_SUBDIRS = \ 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 @@ stage2_extra= \ ## 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 @@ st2_LDFLAGS_common = \ -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 a4daba551e..58b3a7328b 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 @@ noinst_LIBRARIES = libplatform.a 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 35729bb48f..5248b709f2 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 @@ libarch_a_SOURCES = \ 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 0e434f3fa7..cb4cb1f896 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 @@ noinst_LIBRARIES = libplatform.a 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 c4a81e84ee..99b3d44419 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 @@ CLEANFILES = stage2.lds 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 871f9b2581..33da84fcfa 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 @@ noinst_LIBRARIES = libos.a 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 d8a6626420..30d62d2910 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 @@ noinst_LIBRARIES = libaspacemgr.a 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 3625614526..fa521bfb33 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 d9b5cf6c8f..79abd355b3 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 096492c966..4e1942d1b7 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 @@ noinst_LIBRARIES = \ 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 610ffba898..a7b1017baa 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 @@ noinst_LIBRARIES = libsigframe.a 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 ff7ee9668c..796a082231 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 @@ noinst_HEADERS = \ 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 @@ libsyscalls_a_SOURCES = \ 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 ca6ac2e4cd..58b3a7328b 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 @@ noinst_LIBRARIES = libplatform.a 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 03d41694b7..a3e429618a 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 @@ libarch_a_SOURCES = \ 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 $@