makefile: Clean up compiler flags
diff --git a/Makefile.am b/Makefile.am
index 9bddc5e..26cc8db 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,13 @@
ACLOCAL_AMFLAGS = -I m4
+export AM_CPPFLAGS = -I$(abs_builddir)/src -I$(abs_srcdir)/src \
+ $(SYSTEMD_CFLAGS) $(CODE_COVERAGE_CPPFLAGS)
+export AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
+export AM_CXXFLAGS = $(CODE_COVERAGE_CXXFLAGS)
+
+export COMMON_LIBS = $(SYSTEMD_LIBS) $(CODE_COVERAGE_LIBS)
+export SDEVENTPLUS_LIBS = $(abs_builddir)/src/libsdeventplus.la $(COMMON_LIBS)
+
+
EXTRA_DIST = LICENSE MAINTAINERS README.md
SUBDIRS = src example test
diff --git a/example/Makefile.am b/example/Makefile.am
index 3fad73a..3d8e3cf 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -1,11 +1,5 @@
-AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src \
- $(SYSTEMD_CFLAGS) $(CODE_COVERAGE_CPPFLAGS)
-AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
-AM_CXXFLAGS = $(CODE_COVERAGE_CXXFLAGS)
-common_ldadd = $(top_builddir)/src/libsdeventplus.la
-
noinst_PROGRAMS =
noinst_PROGRAMS += follow
follow_SOURCES = follow.cpp
-follow_LDADD = $(common_ldadd)
+follow_LDADD = $(SDEVENTPLUS_LIBS)
diff --git a/src/Makefile.am b/src/Makefile.am
index 8c48eeb..f006891 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,12 +1,8 @@
-AM_CPPFLAGS = $(SYSTEMD_CFLAGS) $(CODE_COVERAGE_CPPFLAGS)
-AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
-AM_CXXFLAGS = $(CODE_COVERAGE_CXXFLAGS)
-
nobase_include_HEADERS =
pkgconfig_DATA = sdeventplus.pc
lib_LTLIBRARIES = libsdeventplus.la
libsdeventplus_la_SOURCES =
-libsdeventplus_la_LIBADD = $(SYSTEMD_LIBS) $(CODE_COVERAGE_LIBS)
+libsdeventplus_la_LIBADD = $(COMMON_LIBS)
nobase_include_HEADERS += sdeventplus/event.hpp
libsdeventplus_la_SOURCES += sdeventplus/event.cpp
diff --git a/test/Makefile.am b/test/Makefile.am
index 7534c42..e899539 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,30 +1,28 @@
@VALGRIND_CHECK_RULES@
@CODE_COVERAGE_RULES@
-AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src \
- $(GTEST_CFLAGS) $(GMOCK_CFLAGS) $(SYSTEMD_CFLAGS) \
- $(CODE_COVERAGE_CPPFLAGS)
-AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
-AM_CXXFLAGS = $(CODE_COVERAGE_CXXFLAGS)
-test_ldadd = $(top_builddir)/src/libsdeventplus.la $(SYSTEMD_LIBS) \
- $(CODE_COVERAGE_LIBS)
-gtest_ldadd = $(test_ldadd) $(GTEST_LIBS) $(GMOCK_LIBS) -lgmock_main
+gtest_cppflags = $(AM_CPPFLAGS) $(GTEST_CFLAGS) $(GMOCK_CFLAGS)
+gtest_ldadd = $(SDEVENTPLUS_LIBS) $(GTEST_LIBS) $(GMOCK_LIBS) -lgmock_main
check_PROGRAMS =
TESTS = $(check_PROGRAMS)
check_PROGRAMS += event
event_SOURCES = event.cpp
+event_CPPFLAGS = $(gtest_cppflags)
event_LDADD = $(gtest_ldadd)
check_PROGRAMS += exception
exception_SOURCES = exception.cpp
+exception_CPPFLAGS = $(gtest_cppflags)
exception_LDADD = $(gtest_ldadd)
check_PROGRAMS += sdref
sdref_SOURCES = sdref.cpp
+sdref_CPPFLAGS = $(gtest_cppflags)
sdref_LDADD = $(gtest_ldadd)
check_PROGRAMS += source
source_SOURCES = source.cpp
+source_CPPFLAGS = $(gtest_cppflags)
source_LDADD = $(gtest_ldadd)