Clean up and consolidate automake magic to reduce duplication and to work with --disable-dependency-tracking.
diff --git a/backends/ChangeLog b/backends/ChangeLog
index b52d75d..ff32f3c 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,7 @@
+2010-02-15  Roland McGrath  <roland@redhat.com>
+
+	* Makefile.am: Use config/eu.am for common stuff.
+
 2010-01-05  Roland McGrath  <roland@redhat.com>
 
 	* arm_retval.c (arm_return_value_location): Use dwarf_aggregate_size.
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 2aed621..d859cc9 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -1,6 +1,6 @@
 ## Process this file with automake to create Makefile.in
 ##
-## Copyright (C) 2000-2009 Red Hat, Inc.
+## Copyright (C) 2000-2010 Red Hat, Inc.
 ## This file is part of Red Hat elfutils.
 ##
 ## Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -24,17 +24,9 @@
 ## Network licensing program, please visit www.openinventionnetwork.com
 ## <http://www.openinventionnetwork.com>.
 ##
-DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DOBJDIR=\"$(shell pwd)\"
-if MUDFLAP
-AM_CFLAGS = -fmudflap
-else
-AM_CFLAGS =
-endif
-AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 \
-	     -std=gnu99
-INCLUDES = -I$(srcdir) -I$(top_srcdir)/libebl -I$(top_srcdir)/libasm \
-	   -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw \
-	   -I$(top_srcdir)/lib -I..
+include $(top_srcdir)/config/eu.am
+INCLUDES += -I$(top_srcdir)/libebl -I$(top_srcdir)/libasm \
+	   -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw
 
 
 modules = i386 sh x86_64 ia64 alpha arm sparc ppc ppc64 s390
@@ -49,17 +41,11 @@
 if MUDFLAP
 libelf = ../libelf/libelf.a
 libdw = ../libdw/libdw.a
-libmudflap = -lmudflap
 else
 libelf = ../libelf/libelf.so
 libdw = ../libdw/libdw.so
-libmudflap =
 endif
 
-
-textrel_check = if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi
-
-
 i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \
 	    i386_retval.c i386_regs.c i386_auxv.c i386_syscall.c
 cpu_i386 = ../libcpu/libcpu_i386.a
@@ -125,13 +111,6 @@
 libebl_%.map: Makefile
 	echo 'ELFUTILS_$(PACKAGE_VERSION) { global: $*_init; local: *; };' > $@
 
-%.os: %.c
-	if $(COMPILE) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
-	  -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
-	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
-	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
-	fi
-
 install: install-am install-ebl-modules
 install-ebl-modules:
 	$(mkinstalldirs) $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)
@@ -150,6 +129,5 @@
 noinst_HEADERS = libebl_CPU.h common-reloc.c linux-core-note.c x86_corenote.c
 EXTRA_DIST = $(foreach m,$(modules),$($(m)_SRCS)) $(modules:=_reloc.def)
 
-CLEANFILES = *.gcno *.gcda \
-	     $(foreach m,$(modules),\
-		       libebl_$(m).so $(am_libebl_$(m)_pic_a_OBJECTS))
+CLEANFILES += $(foreach m,$(modules),\
+			libebl_$(m).so $(am_libebl_$(m)_pic_a_OBJECTS))
diff --git a/config/ChangeLog b/config/ChangeLog
index 798a2f9..1e61047 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,7 @@
+2010-02-15  Roland McGrath  <roland@redhat.com>
+
+	* eu.am: New file.
+
 2009-04-19  Roland McGrath  <roland@redhat.com>
 
 	* version.h.in: Revert last change.
diff --git a/config/eu.am b/config/eu.am
new file mode 100644
index 0000000..7cbdd24
--- /dev/null
+++ b/config/eu.am
@@ -0,0 +1,60 @@
+## Common automake fragments for elfutils subdirectory makefiles.
+##
+## Copyright (C) 2010 Red Hat, Inc.
+## This file is part of Red Hat elfutils.
+##
+## Red Hat elfutils is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by the
+## Free Software Foundation; version 2 of the License.
+##
+## Red Hat elfutils is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License along
+## with Red Hat elfutils; if not, write to the Free Software Foundation,
+## Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+##
+## Red Hat elfutils is an included package of the Open Invention Network.
+## An included package of the Open Invention Network is a package for which
+## Open Invention Network licensees cross-license their patents.  No patent
+## license is granted, either expressly or impliedly, by designation as an
+## included package.  Should you wish to participate in the Open Invention
+## Network licensing program, please visit www.openinventionnetwork.com
+## <http://www.openinventionnetwork.com>.
+##
+
+DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
+INCLUDES = -I. -I$(srcdir) -I$(top_srcdir)/lib -I..
+AM_CFLAGS = -std=gnu99 -Wall -Wshadow \
+	    $(if $($(*F)_no_Werror),,-Werror) \
+	    $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
+	    $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) \
+	    $($(*F)_CFLAGS)
+
+if MUDFLAP
+AM_CFLAGS += -fmudflap
+libmudflap = -lmudflap
+else
+libmudflap =
+endif
+
+COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage $(no_mudflap.os),\
+	     		  $(COMPILE))
+
+%.os: %.c %.o
+if AMDEP
+	if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
+	  -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
+	then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
+	     rm -f "$(DEPDIR)/$*.Tpo"; \
+	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+	fi
+else
+	$(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED $<
+endif
+
+CLEANFILES = *.gcno *.gcda
+
+textrel_check = if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 73f8e73..089747a 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,7 @@
+2010-02-15  Roland McGrath  <roland@redhat.com>
+
+	* Makefile.am: Use config/eu.am for common stuff.
+
 2009-08-09  Roland McGrath  <roland@redhat.com>
 
 	* eu-config.h (OLD_VERSION, NEW_VERSION, COMPAT_VERSION): New macros.
diff --git a/lib/Makefile.am b/lib/Makefile.am
index b95d3e3..50d55c5 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,6 +1,6 @@
 ## Process this file with automake to create Makefile.in
 ##
-## Copyright (C) 1996-2001, 2002, 2004, 2005, 2008 Red Hat, Inc.
+## Copyright (C) 1996-2010 Red Hat, Inc.
 ## This file is part of Red Hat elfutils.
 ##
 ## Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -24,14 +24,9 @@
 ## Network licensing program, please visit www.openinventionnetwork.com
 ## <http://www.openinventionnetwork.com>.
 ##
-DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
-if MUDFLAP
-AM_CFLAGS = -fmudflap
-else
-AM_CFLAGS =
-endif
-AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused -Wextra $($(*F)_CFLAGS)
-INCLUDES = -I$(srcdir)/../libelf -I..
+include $(top_srcdir)/config/eu.am
+AM_CFLAGS += -fpic
+INCLUDES += -I$(srcdir)/../libelf
 
 noinst_LIBRARIES = libeu.a
 
diff --git a/libasm/ChangeLog b/libasm/ChangeLog
index d0d4039..ef31dbb 100644
--- a/libasm/ChangeLog
+++ b/libasm/ChangeLog
@@ -1,3 +1,7 @@
+2010-02-15  Roland McGrath  <roland@redhat.com>
+
+	* Makefile.am: Use config/eu.am for common stuff.
+
 2009-01-10  Ulrich Drepper  <drepper@redhat.com>
 
 	* Makefile.am: Use USE_LOCKS instead of USE_TLS.
diff --git a/libasm/Makefile.am b/libasm/Makefile.am
index 7d5e25d..52de7a3 100644
--- a/libasm/Makefile.am
+++ b/libasm/Makefile.am
@@ -1,6 +1,6 @@
 ## Process this file with automake to create Makefile.in
 ##
-## Copyright (C) 2002, 2004, 2005, 2006, 2008, 2009 Red Hat, Inc.
+## Copyright (C) 2002-2010 Red Hat, Inc.
 ## This file is part of Red Hat elfutils.
 ##
 ## Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -24,22 +24,12 @@
 ## Network licensing program, please visit www.openinventionnetwork.com
 ## <http://www.openinventionnetwork.com>.
 ##
-DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
-if MUDFLAP
-AM_CFLAGS = -fmudflap
-else
-AM_CFLAGS =
-endif
-AM_CFLAGS += -std=gnu99 -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2
-INCLUDES = -I. -I$(srcdir) -I.. \
-	   -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl -I$(top_srcdir)/libdw\
-	   -I$(top_srcdir)/lib
+include $(top_srcdir)/config/eu.am
+INCLUDES += -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl -I$(top_srcdir)/libdw
+
 GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include)
 VERSION = 1
 
-COMPILE.os = $(filter-out -fprofile-arcs, $(filter-out -ftest-coverage, \
-						       $(COMPILE)))
-
 lib_LIBRARIES = libasm.a
 if !MUDFLAP
 noinst_LIBRARIES = libasm_pic.a
@@ -79,15 +69,6 @@
 	if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi
 	ln -fs $@ $@.$(VERSION)
 
-
-%.os: %.c %.o
-	if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
-	  -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
-	then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
-	     rm -f "$(DEPDIR)/$*.Tpo"; \
-	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
-	fi
-
 install: install-am libasm.so
 	$(mkinstalldirs) $(DESTDIR)$(libdir)
 	$(INSTALL_PROGRAM) libasm.so $(DESTDIR)$(libdir)/libasm-$(PACKAGE_VERSION).so
@@ -104,4 +85,4 @@
 noinst_HEADERS = libasmP.h symbolhash.h
 EXTRA_DIST = libasm.map
 
-CLEANFILES = $(am_libasm_pic_a_OBJECTS) *.gcno *.gcda libasm.so.$(VERSION)
+CLEANFILES += $(am_libasm_pic_a_OBJECTS) libasm.so.$(VERSION)
diff --git a/libcpu/ChangeLog b/libcpu/ChangeLog
index 738af57..9d517fc 100644
--- a/libcpu/ChangeLog
+++ b/libcpu/ChangeLog
@@ -1,3 +1,7 @@
+2010-02-15  Roland McGrath  <roland@redhat.com>
+
+	* Makefile.am: Use config/eu.am for common stuff.
+
 2009-04-14  Roland McGrath  <roland@redhat.com>
 
 	* Makefile.am (AM_CFLAGS): Add -fdollars-in-identifiers; it is not the
diff --git a/libcpu/Makefile.am b/libcpu/Makefile.am
index 923556f..ca334bb 100644
--- a/libcpu/Makefile.am
+++ b/libcpu/Makefile.am
@@ -1,6 +1,6 @@
 ## Process this file with automake to create Makefile.in
 ##
-## Copyright (C) 2002, 2004, 2005, 2007, 2008, 2009 Red Hat, Inc.
+## Copyright (C) 2002-2010 Red Hat, Inc.
 ## This file is part of Red Hat elfutils.
 ##
 ## Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -24,26 +24,14 @@
 ## Network licensing program, please visit www.openinventionnetwork.com
 ## <http://www.openinventionnetwork.com>.
 ##
-DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
-if MUDFLAP
-AM_CFLAGS = -fmudflap
-else
-AM_CFLAGS =
-endif
-AM_CFLAGS += -Wall -Wshadow -Wunused -Wextra -std=gnu99 -fpic \
-	     -fdollars-in-identifiers \
-	     $($(*F)_CFLAGS) \
-	     $(if $($(*F)_no_Werror),,-Werror)
-INCLUDES = -I$(srcdir) -I$(srcdir)/../lib -I$(srcdir)/../libelf \
-	   -I$(srcdir)/../libebl -I$(srcdir)/../libdw -I$(srcdir)/../libasm
+include $(top_srcdir)/config/eu.am
+INCLUDES += -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
+	    -I$(srcdir)/../libdw -I$(srcdir)/../libasm
+AM_CFLAGS += -fpic -fdollars-in-identifiers
 LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS) -P$(<F:lex.l=)
 LEX_OUTPUT_ROOT = lex.$(<F:lex.l=)
 AM_YFLAGS = -p$(<F:parse.y=)
 
-if MUDFLAP
-libmudflap = -lmudflap
-endif
-
 noinst_LIBRARIES = libcpu_i386.a libcpu_x86_64.a
 noinst_PROGRAMS = i386_gendis
 
@@ -81,4 +69,4 @@
 
 EXTRA_DIST = defs/i386
 
-CLEANFILES = i386.mnemonics i386_dis.h x86_64.mnemonics x86_64_dis.h
+CLEANFILES += i386.mnemonics i386_dis.h x86_64.mnemonics x86_64_dis.h
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index a348b7e..c21b912 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,7 @@
+2010-02-15  Roland McGrath  <roland@redhat.com>
+
+	* Makefile.am: Use config/eu.am for common stuff.
+
 2010-02-02  Mark Wielaard  <mjw@redhat.com>
 
 	* fde.c (intern_fde): Fix length check for sized_augmentation_data.
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 23896fa..4bd0f2a 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -24,22 +24,14 @@
 ## Network licensing program, please visit www.openinventionnetwork.com
 ## <http://www.openinventionnetwork.com>.
 ##
-DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DIS_LIBDW
-if MUDFLAP
-AM_CFLAGS = -fmudflap
-else
-AM_CFLAGS =
-endif
+include $(top_srcdir)/config/eu.am
+DEFS += -DIS_LIBDW
 if BUILD_STATIC
 AM_CFLAGS += -fpic
 endif
-AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 -Wextra -std=gnu99
-INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I.. -I$(srcdir)/../lib
+INCLUDES += -I$(srcdir)/../libelf
 VERSION = 1
 
-COMPILE.os = $(filter-out -fprofile-arcs, $(filter-out -ftest-coverage, \
-						       $(COMPILE)))
-
 lib_LIBRARIES = libdw.a
 if !MUDFLAP
 noinst_LIBRARIES = libdw_pic.a
@@ -117,14 +109,6 @@
 	if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi
 	ln -fs $@ $@.$(VERSION)
 
-%.os: %.c %.o
-	if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
-	   -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
-	then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
-	     rm -f "$(DEPDIR)/$*.Tpo"; \
-	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
-	fi
-
 install: install-am libdw.so
 	$(mkinstalldirs) $(DESTDIR)$(libdir)
 	$(INSTALL_PROGRAM) libdw.so $(DESTDIR)$(libdir)/libdw-$(PACKAGE_VERSION).so
@@ -145,4 +129,4 @@
 
 EXTRA_DIST = libdw.map
 
-MOSTLYCLEANFILES = $(am_libdw_pic_a_OBJECTS) *.gcno *.gcda libdw.so.$(VERSION)
+MOSTLYCLEANFILES = $(am_libdw_pic_a_OBJECTS) libdw.so.$(VERSION)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index f6d3eaf..833c2a5 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,5 +1,7 @@
 2010-02-15  Roland McGrath  <roland@redhat.com>
 
+	* Makefile.am: Use config/eu.am for common stuff.
+
 	* find-debuginfo.c (find_debuginfo_in_path): Fix uninitialized
 	variable in failure path.
 
diff --git a/libdwfl/Makefile.am b/libdwfl/Makefile.am
index 69bef7d..8ec1f4f 100644
--- a/libdwfl/Makefile.am
+++ b/libdwfl/Makefile.am
@@ -2,7 +2,7 @@
 ##
 ## Process this file with automake to create Makefile.in
 ##
-## Copyright (C) 2005, 2006, 2007, 2008, 2009 Red Hat, Inc.
+## Copyright (C) 2005-2010 Red Hat, Inc.
 ## This file is part of Red Hat elfutils.
 ##
 ## Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -26,20 +26,11 @@
 ## Network licensing program, please visit www.openinventionnetwork.com
 ## <http://www.openinventionnetwork.com>.
 ##
-DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
-if MUDFLAP
-AM_CFLAGS = -fmudflap
-else
-AM_CFLAGS =
-endif
-AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 -Wextra -std=gnu99
-INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
-	   -I$(srcdir)/../libdw -I.. -I$(srcdir)/../lib
+include $(top_srcdir)/config/eu.am
+INCLUDES += -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
+	   -I$(srcdir)/../libdw
 VERSION = 1
 
-COMPILE.os = $(filter-out -fprofile-arcs, $(filter-out -ftest-coverage, \
-						       $(COMPILE)))
-
 noinst_LIBRARIES = libdwfl.a
 if !MUDFLAP
 noinst_LIBRARIES += libdwfl_pic.a
@@ -90,7 +81,6 @@
 libdwfl = libdwfl.a $(libdw) $(libebl) $(libelf) $(libeu)
 libdw = ../libdw/libdw.a
 libelf = ../libelf/libelf.a
-libmudflap = -lmudflap
 else
 libdwfl = $(libdw)
 libdw = ../libdw/libdw.so
@@ -99,20 +89,11 @@
 libebl = ../libebl/libebl.a
 libeu = ../lib/libeu.a
 
-
 if !MUDFLAP
 libdwfl_pic_a_SOURCES =
 am_libdwfl_pic_a_OBJECTS = $(libdwfl_a_SOURCES:.c=.os)
-
-%.os: %.c %.o
-	if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
-	   -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
-	then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
-	     rm -f "$(DEPDIR)/$*.Tpo"; \
-	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
-	fi
 endif
 
 noinst_HEADERS = libdwflP.h
 
-CLEANFILES = $(am_libdwfl_pic_a_OBJECTS)
+CLEANFILES += $(am_libdwfl_pic_a_OBJECTS)
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index aaa1c86..ed9361c 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,7 @@
+2010-02-15  Roland McGrath  <roland@redhat.com>
+
+	* Makefile.am: Use config/eu.am for common stuff.
+
 2010-01-04  Roland McGrath  <roland@redhat.com>
 
 	* eblcorenote.c (ebl_core_note): Take GElf_Nhdr * and name data
diff --git a/libebl/Makefile.am b/libebl/Makefile.am
index a95e66d..d157195 100644
--- a/libebl/Makefile.am
+++ b/libebl/Makefile.am
@@ -1,6 +1,6 @@
 ## Process this file with automake to create Makefile.in
 ##
-## Copyright (C) 2000-2009 Red Hat, Inc.
+## Copyright (C) 2000-2010 Red Hat, Inc.
 ## This file is part of Red Hat elfutils.
 ##
 ## Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -24,19 +24,10 @@
 ## Network licensing program, please visit www.openinventionnetwork.com
 ## <http://www.openinventionnetwork.com>.
 ##
-DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DOBJDIR=\"$(shell pwd)\"
-if MUDFLAP
-AM_CFLAGS = -fmudflap
-else
-AM_CFLAGS =
-endif
-AM_CFLAGS += -fpic -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 \
-	     -std=gnu99
-
-INCLUDES = -I$(srcdir) -I$(top_srcdir)/libelf -I$(top_srcdir)/libdw \
-	   -I$(top_srcdir)/lib -I.. -I$(srcdir)/../libasm
+include $(top_srcdir)/config/eu.am
+AM_CFLAGS += -fpic
+INCLUDES += -I$(srcdir)/../libelf -I$(srcdir)/../libdw -I$(srcdir)/../libasm
 VERSION = 1
-PACKAGE_VERSION = @PACKAGE_VERSION@
 LIBEBL_SUBDIR = @LIBEBL_SUBDIR@
 
 lib_LIBRARIES = libebl.a
@@ -63,15 +54,6 @@
 
 libebl_a_SOURCES = $(gen_SOURCES)
 
-
-%.os: %.c %.o
-	if $(COMPILE) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
-	  -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
-	then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
-	     rm -f "$(DEPDIR)/$*.Tpo"; \
-	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
-	fi
-
 noinst_HEADERS = libeblP.h ebl-hooks.h
 
-CLEANFILES = $(am_libebl_pic_a_OBJECTS) *.gcno *.gcda
+CLEANFILES += $(am_libebl_pic_a_OBJECTS)
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index c71c563..303975b 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,7 @@
+2010-02-15  Roland McGrath  <roland@redhat.com>
+
+	* Makefile.am: Use config/eu.am for common stuff.
+
 2010-01-07  Roland McGrath  <roland@redhat.com>
 
 	* elf32_getphdr.c: Use __elf_getphdrnum_rdlock.
diff --git a/libelf/Makefile.am b/libelf/Makefile.am
index b277e94..c7c83f3 100644
--- a/libelf/Makefile.am
+++ b/libelf/Makefile.am
@@ -24,24 +24,12 @@
 ## Network licensing program, please visit www.openinventionnetwork.com
 ## <http://www.openinventionnetwork.com>.
 ##
-DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H
-if MUDFLAP
-AM_CFLAGS = -fmudflap
-else
-AM_CFLAGS =
-endif
+include $(top_srcdir)/config/eu.am
 if BUILD_STATIC
 AM_CFLAGS += -fpic
 endif
-AM_CFLAGS += -Wall -Wshadow -Werror -Wunused -Wextra -Wformat=2 -std=gnu99 \
-	     $($(*F)_CFLAGS)
-INCLUDES = -I$(srcdir) -I$(top_srcdir)/lib -I..
 GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include)
 VERSION = 1
-PACKAGE_VERSION = @PACKAGE_VERSION@
-
-COMPILE.os = $(filter-out -fprofile-arcs, $(filter-out -ftest-coverage, \
-						       $(COMPILE)))
 
 lib_LIBRARIES = libelf.a
 if !MUDFLAP
@@ -118,14 +106,6 @@
 	if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi
 	ln -fs $@ $@.$(VERSION)
 
-%.os: %.c %.o
-	if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
-	  -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
-	then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
-	     rm -f "$(DEPDIR)/$*.Tpo"; \
-	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
-	fi
-
 install: install-am libelf.so
 	$(mkinstalldirs) $(DESTDIR)$(libdir)
 	$(INSTALL_PROGRAM) libelf.so $(DESTDIR)$(libdir)/libelf-$(PACKAGE_VERSION).so
@@ -142,4 +122,4 @@
 		 version_xlate.h gnuhash_xlate.h note_xlate.h dl-hash.h
 EXTRA_DIST = libelf.map
 
-CLEANFILES = $(am_libelf_pic_a_OBJECTS) *.gcno *.gcda libelf.so.$(VERSION)
+CLEANFILES += $(am_libelf_pic_a_OBJECTS) libelf.so.$(VERSION)
diff --git a/src/ChangeLog b/src/ChangeLog
index f9f98ac..0b7c51a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,7 @@
 2010-02-15  Roland McGrath  <roland@redhat.com>
 
+	* Makefile.am: Use config/eu.am for common stuff.
+
 	* readelf.c (print_debug_frame_section): Add a cast to avoid sign
 	mismatch in comparison.
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 9b7d7f0..afd3bd3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,6 @@
 ## Process this file with automake to create Makefile.in
 ##
-## Copyright (C) 1996-2002, 2003, 2004, 2005, 2006, 2007, 2009 Red Hat, Inc.
+## Copyright (C) 1996-2010 Red Hat, Inc.
 ## This file is part of Red Hat elfutils.
 ##
 ## Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -24,24 +24,17 @@
 ## Network licensing program, please visit www.openinventionnetwork.com
 ## <http://www.openinventionnetwork.com>.
 ##
-DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H $(YYDEBUG) -DDEBUGPRED=@DEBUGPRED@ \
-       -DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\"
-if MUDFLAP
-AM_CFLAGS = -fmudflap
-else
-AM_CFLAGS =
-endif
-AM_CFLAGS += -Wall -Wshadow -std=gnu99 $(native_ld_cflags) \
-	     $(if $($(*F)_no_Werror),,-Werror) \
-	     $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
-	     $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2) $(CFLAGS_$(*F))
-
-INCLUDES = -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
-	   -I$(srcdir)/../libdw -I$(srcdir)/../libdwfl \
-	   -I$(srcdir)/../libasm -I$(srcdir)/../lib -I..
+include $(top_srcdir)/config/eu.am
+DEFS += $(YYDEBUG) -DDEBUGPRED=@DEBUGPRED@ \
+	-DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\"
+INCLUDES += -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
+	    -I$(srcdir)/../libdw -I$(srcdir)/../libdwfl \
+	    -I$(srcdir)/../libasm
 
 AM_LDFLAGS = -Wl,-rpath-link,../libelf:../libdw
 
+no_mudflap.os = -fmudflap
+
 YACC = @YACC@ -d
 AM_YFLAGS = -pld
 AM_LFLAGS = -Pld -olex.yy.c
@@ -70,8 +63,6 @@
 libdummy_a_SOURCES = i386_ld.c
 endif
 
-textrel_check = if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi
-
 
 ld_SOURCES = ld.c ldgeneric.c ldlex.l ldscript.y symbolhash.c sectionhash.c \
 	     versionhash.c
@@ -87,11 +78,7 @@
 
 bin_SCRIPTS = make-debug-archive
 EXTRA_DIST += make-debug-archive.in
-CLEANFILES = make-debug-archive
-
-if MUDFLAP
-libmudflap = -lmudflap
-endif
+CLEANFILES += make-debug-archive
 
 if BUILD_STATIC
 libasm = ../libasm/libasm.a
@@ -151,16 +138,6 @@
 	$(textrel_check)
 endif
 
-
-%.os: %.c %.o
-	if $(filter-out -fmudflap,$(COMPILE)) -c -o $@ -fpic -DPIC -DSHARED \
-	  -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
-	  `test -f '$<' || echo '$(srcdir)/'`$<; \
-	then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
-	     rm -f "$(DEPDIR)/$*.Tpo"; \
-	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
-	fi
-
 # Special rule to make it possible to define libld_elf_a_SOURCES as we do.
 # Otherwise make would complain.
 .deps/none_ld.Po: none_ld.os
@@ -183,7 +160,7 @@
 	  done; \
 	done; rm -f c$${pid}_.???; exit $$bad
 
-CLEANFILES += none_ld.os $(ld_modules:.c=.os) *.gcno *.gcda *.gconv
+CLEANFILES += none_ld.os $(ld_modules:.c=.os) *.gconv
 
 MAINTAINERCLEANFILES = ldlex.c ldscript.c ldscript.h
 
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 29789e2..c871baa 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,5 +1,7 @@
 2010-02-15  Roland McGrath  <roland@redhat.com>
 
+	* Makefile.am: Use config/eu.am for common stuff.
+
 	* asm-tst9.c (main): Rename local to avoid shadowing another local.
 
 2009-07-22  Roland McGrath  <roland@redhat.com>
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 54d2c61..1b9bc73 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,6 @@
 ## Process this file with automake to create Makefile.in
 ##
-## Copyright (C) 1996-2009 Red Hat, Inc.
+## Copyright (C) 1996-2010 Red Hat, Inc.
 ## This file is part of Red Hat elfutils.
 ##
 ## Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -24,26 +24,22 @@
 ## Network licensing program, please visit www.openinventionnetwork.com
 ## <http://www.openinventionnetwork.com>.
 ##
-DEFS = -DHAVE_CONFIG_H -D_GNU_SOURCE
+include $(top_srcdir)/config/eu.am
 if MUDFLAP
-AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 -fmudflap\
-	    $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2)
 BUILD_RPATH = \$$ORIGIN/../backends
 else
-AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 \
-	    $(if $($(*F)_no_Wformat),-Wno-format,-Wformat=2)
 BUILT_RPATH = \$$ORIGIN/../libasm:\$$ORIGIN/../libdw:\$$ORIGIN/../backends:\$$ORIGIN/../libelf
 endif
 
 AM_LDFLAGS =
 
 if !STANDALONE
-INCLUDES = -I$(top_srcdir)/libasm -I$(top_srcdir)/libdw \
-	   -I$(top_srcdir)/libdwfl \
-	   -I$(top_srcdir)/libebl -I$(top_srcdir)/libelf \
-	   -I$(top_srcdir)/lib -I..
+INCLUDES += -I$(top_srcdir)/libasm -I$(top_srcdir)/libdw \
+	    -I$(top_srcdir)/libdwfl \
+	    -I$(top_srcdir)/libebl -I$(top_srcdir)/libelf \
+	    -I$(top_srcdir)/lib -I..
 AM_LDFLAGS += -Wl,-rpath-link,../libasm:../libdw:../libelf
-endif !STANDALONE
+endif
 
 if TESTS_RPATH
 AM_LDFLAGS += -Wl,-rpath,$(BUILT_RPATH)
@@ -161,7 +157,6 @@
 
 if MUDFLAP
 static_build = yes
-libmudflap = -lmudflap
 endif
 
 if STANDALONE
@@ -233,11 +228,9 @@
 dwfl_bug_getmodules_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
 dwfl_addr_sect_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
 sha1_tst_LDADD = $(libeu) $(libmudflap)
-dwarf_getmacros_LDADD = $(libdw)
+dwarf_getmacros_LDADD = $(libdw) $(libmudflap)
 addrcfi_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
 
-CLEANFILES = xxx *.gcno *.gcda *gconv
-
 if GCOV
 check: check-am coverage
 .PHONY: coverage