From f884dd858c283cbb9388795e45cecf6bc7970b8c Mon Sep 17 00:00:00 2001 From: albfan Date: Sun, 8 Mar 2015 12:22:05 +0100 Subject: [PATCH] split monolithic Makefile.am to follow autotools standards --- Makefile.am | 278 +---------------------------------------- autogen.sh | 17 +-- common.am | 20 +++ configure.ac | 44 +++++-- m4/.gitkeep | 0 res/Makefile.am | 2 + src/Makefile.am | 15 +++ src/ctl/Makefile.am | 31 +++++ src/dhcp/Makefile.am | 24 ++++ src/shared/Makefile.am | 23 ++++ src/wifi/Makefile.am | 17 +++ test/Makefile.am | 58 +++++++++ 12 files changed, 230 insertions(+), 299 deletions(-) create mode 100644 common.am create mode 100644 m4/.gitkeep create mode 100644 res/Makefile.am create mode 100644 src/Makefile.am create mode 100644 src/ctl/Makefile.am create mode 100644 src/dhcp/Makefile.am create mode 100644 src/shared/Makefile.am create mode 100644 src/wifi/Makefile.am create mode 100644 test/Makefile.am diff --git a/Makefile.am b/Makefile.am index d251817..ef42db4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,276 +1,6 @@ -# -# MiracleCast - Global Makefile -# Copyright (c) 2013-2014 David Herrmann -# - -# -# Global Configurations and Initializations -# - -ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} -AM_MAKEFLAGS = --no-print-directory -AUTOMAKE_OPTIONS = color-tests - -SUBDIRS = . - -.DELETE_ON_ERROR: - -include_HEADERS = -EXTRA_DIST = \ - README \ +SUBDIRS = src res test +EXTRA_DIST = README.md \ COPYING \ - NEWS \ - res/wpa.conf -CLEANFILES = -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = -TPHONY = + NEWS -TESTS = -MEMTESTS = -bin_PROGRAMS = -check_PROGRAMS = -lib_LTLIBRARIES = -noinst_LTLIBRARIES = - -# -# Default CFlags -# Make all files include "config.h" by default. This shouldn't cause any -# problems and we cannot forget to include it anymore. -# Also make the linker discard all unused symbols. -# - -AM_CFLAGS = \ - -Wall \ - -pipe \ - -fno-common \ - -ffast-math \ - -fdiagnostics-show-option \ - -fno-strict-aliasing \ - -fvisibility=hidden \ - -ffunction-sections \ - -fdata-sections -AM_CPPFLAGS = \ - -include $(top_builddir)/config.h \ - -I $(srcdir)/src \ - -I $(srcdir)/src/shared \ - -DBUILD_ENABLE_DEBUG \ - '-DBUILD_BINDIR="$(bindir)"' -AM_LDFLAGS = \ - -Wl,--as-needed \ - -Wl,--gc-sections \ - -Wl,-z,relro \ - -Wl,-z,now -AM_LIBADD = \ - -lsystemd - -# -# Shared Helpers -# - -noinst_LTLIBRARIES += libmiracle-shared.la - -libmiracle_shared_la_SOURCES = \ - src/shared/rtsp.h \ - src/shared/rtsp.c \ - src/shared/shl_dlist.h \ - src/shared/shl_htable.h \ - src/shared/shl_htable.c \ - src/shared/shl_log.h \ - src/shared/shl_log.c \ - src/shared/shl_macro.h \ - src/shared/shl_ring.h \ - src/shared/shl_ring.c \ - src/shared/shl_util.h \ - src/shared/shl_util.c \ - src/shared/util.h \ - src/shared/wpas.h \ - src/shared/wpas.c -libmiracle_shared_la_CPPFLAGS = $(AM_CPPFLAGS) -libmiracle_shared_la_LDFLAGS = $(AM_LDFLAGS) -libmiracle_shared_la_LIBADD = $(AM_LIBADD) - -# -# miracle-wifid -# - -bin_PROGRAMS += miracle-wifid - -miracle_wifid_SOURCES = \ - src/wifi/wifid.h \ - src/wifi/wifid.c \ - src/wifi/wifid-dbus.c \ - src/wifi/wifid-link.c \ - src/wifi/wifid-peer.c \ - src/wifi/wifid-supplicant.c -miracle_wifid_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - $(DEPS_CFLAGS) -miracle_wifid_LDADD = \ - libmiracle-shared.la \ - $(DEPS_LIBS) -miracle_wifid_LDFLAGS = $(AM_LDFLAGS) - -# -# miracle-wifictl -# - -bin_PROGRAMS += miracle-wifictl - -miracle_wifictl_SOURCES = \ - src/ctl/ctl.h \ - src/ctl/ctl-cli.c \ - src/ctl/ctl-wifi.c \ - src/ctl/wifictl.c -miracle_wifictl_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - $(DEPS_CFLAGS) -miracle_wifictl_LDADD = \ - libmiracle-shared.la \ - -lreadline \ - $(DEPS_LIBS) -miracle_wifictl_LDFLAGS = $(AM_LDFLAGS) - -# -# miracle-sinkctl -# - -bin_PROGRAMS += miracle-sinkctl - -miracle_sinkctl_SOURCES = \ - src/ctl/ctl.h \ - src/ctl/ctl-cli.c \ - src/ctl/ctl-sink.c \ - src/ctl/ctl-wifi.c \ - src/ctl/sinkctl.c -miracle_sinkctl_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - $(DEPS_CFLAGS) -miracle_sinkctl_LDADD = \ - libmiracle-shared.la \ - -lreadline \ - $(DEPS_LIBS) -miracle_sinkctl_LDFLAGS = $(AM_LDFLAGS) - -# -# miracle-dhcp -# - -bin_PROGRAMS += miracle-dhcp - -miracle_dhcp_SOURCES = \ - src/dhcp/dhcp.c \ - src/dhcp/gdhcp.h \ - src/dhcp/unaligned.h \ - src/dhcp/common.h \ - src/dhcp/common.c \ - src/dhcp/ipv4ll.h \ - src/dhcp/ipv4ll.c \ - src/dhcp/client.c \ - src/dhcp/server.c -miracle_dhcp_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - $(DEPS_CFLAGS) \ - $(GDHCP_CFLAGS) -miracle_dhcp_LDADD = \ - libmiracle-shared.la \ - $(DEPS_LIBS) \ - $(GDHCP_LIBS) -miracle_dhcp_LDFLAGS = $(AM_LDFLAGS) - -# -# miracled -# - -bin_PROGRAMS += miracled - -miracled_SOURCES = \ - src/miracled.h \ - src/miracled.c -miracled_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - $(DEPS_CFLAGS) -miracled_LDADD = \ - libmiracle-shared.la \ - $(DEPS_LIBS) -miracled_LDFLAGS = $(AM_LDFLAGS) - -# -# miracle-gst.sh -# - -bin_SCRIPTS = res/miracle-gst.sh - -# -# Tests -# - -tests = \ - test_rtsp \ - test_wpas - -if BUILD_HAVE_CHECK -check_PROGRAMS += $(tests) test_valgrind -TESTS += $(tests) test_valgrind -MEMTESTS += $(tests) -endif - -test_sources = \ - test/test_common.h -test_libs = \ - libmiracle-shared.la \ - $(DEPS_LIBS) \ - $(CHECK_LIBS) -test_cflags = \ - $(AM_CPPFLAGS) \ - $(DEPS_CFLAGS) \ - $(CHECK_CFLAGS) -test_lflags = \ - $(AM_LDFLAGS) - -test_rtsp_SOURCES = test/test_rtsp.c $(test_sources) -test_rtsp_CPPFLAGS = $(test_cflags) -test_rtsp_LDADD = $(test_libs) -test_rtsp_LDFLAGS = $(test_lflags) - -test_valgrind_SOURCES = test/test_valgrind.c $(test_sources) -test_valgrind_CPPFLAGS = $(test_cflags) -test_valgrind_LDADD = $(test_libs) -test_valgrind_LDFLAGS = $(test_lflags) - -test_wpas_SOURCES = test/test_wpas.c $(test_sources) -test_wpas_CPPFLAGS = $(test_cflags) -test_wpas_LDADD = $(test_libs) -test_wpas_LDFLAGS = $(test_lflags) - -VALGRIND = CK_FORK=no valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --leak-resolution=high --error-exitcode=1 --suppressions=$(top_builddir)/test.supp - -# verify that test_valgrind actually leaks data -memcheck-verify: check - $(AM_V_GEN)$(VALGRIND) --log-file=/dev/null ./test_valgrind >/dev/null ; test 1 = $$? - -TPHONY += memcheck-verify - -# run memcheck tests via valgrind -memcheck: memcheck-verify - $(AM_V_GEN)for i in $(MEMTESTS) ; do \ - $(VALGRIND) --log-file=$(top_builddir)/$$i.memlog \ - $(top_builddir)/$$i >/dev/null || (echo "memcheck failed on: $$i" ; exit 1) ; \ - done - -TPHONY += memcheck - -distcheck-hook: memcheck - -# -# Phony targets -# - -.PHONY: $(TPHONY) - -# -# Empty .SECONDARY target causes alle intermediate files to be treated as -# secondary files. That is, they don't get deleted after make finished. -# - -.SECONDARY: +ACLOCAL_AMFLAGS = -I m4 diff --git a/autogen.sh b/autogen.sh index 65a6fe1..0fb6c4f 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,17 +1,2 @@ #!/bin/sh -set -e - -srcdir=`dirname $0` -test -z "$srcdir" && srcdir=. - -origdir=`pwd` -cd $srcdir - -mkdir -p m4 -autoreconf -is --force - -cd $origdir - -if test -z "$NOCONFIGURE" ; then - exec $srcdir/configure "$@" -fi +autoreconf --install diff --git a/common.am b/common.am new file mode 100644 index 0000000..36fe4ef --- /dev/null +++ b/common.am @@ -0,0 +1,20 @@ +AM_CFLAGS = -Wall \ + -pipe \ + -fno-common \ + -ffast-math \ + -fdiagnostics-show-option \ + -fno-strict-aliasing \ + -fvisibility=hidden \ + -ffunction-sections \ + -fdata-sections + +AM_CPPFLAGS = -include $(top_builddir)/config.h \ + -I $(top_srcdir)/src \ + -I $(top_srcdir)/src/shared \ + -DBUILD_ENABLE_DEBUG \ + '-DBUILD_BINDIR="$(bindir)"' + +AM_LDFLAGS = -Wl,--as-needed \ + -Wl,--gc-sections \ + -Wl,-z,relro \ + -Wl,-z,now diff --git a/configure.ac b/configure.ac index 2daf24d..baf9dc5 100644 --- a/configure.ac +++ b/configure.ac @@ -59,7 +59,14 @@ AM_CONDITIONAL([BUILD_HAVE_CHECK], [test "x$have_check" = "xyes"]) # After everything is configured, we create all makefiles. # -AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([Makefile + res/Makefile + src/Makefile + src/ctl/Makefile + src/dhcp/Makefile + src/shared/Makefile + src/wifi/Makefile + test/Makefile]) AC_OUTPUT # @@ -68,15 +75,34 @@ AC_OUTPUT # configured as expected. # +if test "x$have_check" = "xyes" +then AC_MSG_NOTICE([Build configuration: + prefix: $prefix + exec-prefix: $exec_prefix + bindir: $bindir + libdir: $libdir + includedir: $includedir - prefix: $prefix - exec-prefix: $exec_prefix - bindir: $bindir - libdir: $libdir - includedir: $includedir - - Miscellaneous Options: +Miscellaneous Options: building tests: $have_check - Run "${MAKE-make}" to start compilation process]) +Compilation + mkdir build && cd build + "${MAKE-make}" to start compilation process + "${MAKE-make}" check to pass test]) +else +AC_MSG_NOTICE([Build configuration: + prefix: $prefix + exec-prefix: $exec_prefix + bindir: $bindir + libdir: $libdir + includedir: $includedir + +Miscellaneous Options: + building tests: $have_check + +Compilation + mkdir build && cd build + "${MAKE-make}" to start compilation process]) +fi diff --git a/m4/.gitkeep b/m4/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/res/Makefile.am b/res/Makefile.am new file mode 100644 index 0000000..51f71fb --- /dev/null +++ b/res/Makefile.am @@ -0,0 +1,2 @@ +bin_SCRIPTS = miracle-gst.sh +EXTRA_DIST = wpa.conf diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..f10e22b --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,15 @@ +include $(top_srcdir)/common.am +SUBDIRS = shared wifi dhcp ctl + +bin_PROGRAMS = miracled + +miracled_SOURCES = \ + miracled.h \ + miracled.c +miracled_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + $(DEPS_CFLAGS) +miracled_LDADD = \ + shared/libmiracle-shared.la \ + $(DEPS_LIBS) + diff --git a/src/ctl/Makefile.am b/src/ctl/Makefile.am new file mode 100644 index 0000000..f7c144d --- /dev/null +++ b/src/ctl/Makefile.am @@ -0,0 +1,31 @@ +include $(top_srcdir)/common.am +bin_PROGRAMS = miracle-wifictl miracle-sinkctl + +miracle_wifictl_SOURCES = \ + ctl.h \ + ctl-cli.c \ + ctl-wifi.c \ + wifictl.c +miracle_wifictl_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + $(DEPS_CFLAGS) +miracle_wifictl_LDADD = \ + ../shared/libmiracle-shared.la \ + -lreadline \ + $(DEPS_LIBS) + +miracle_sinkctl_SOURCES = \ + ctl.h \ + ctl-cli.c \ + ctl-sink.c \ + ctl-wifi.c \ + sinkctl.c +miracle_sinkctl_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + $(DEPS_CFLAGS) +miracle_sinkctl_LDADD = \ + ../shared/libmiracle-shared.la \ + -lreadline \ + $(DEPS_LIBS) + + diff --git a/src/dhcp/Makefile.am b/src/dhcp/Makefile.am new file mode 100644 index 0000000..2703f48 --- /dev/null +++ b/src/dhcp/Makefile.am @@ -0,0 +1,24 @@ +include $(top_srcdir)/common.am +bin_PROGRAMS = miracle-dhcp + +miracle_dhcp_SOURCES = \ + dhcp.c \ + gdhcp.h \ + unaligned.h \ + common.h \ + common.c \ + ipv4ll.h \ + ipv4ll.c \ + client.c \ + server.c +miracle_dhcp_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + $(DEPS_CFLAGS) \ + $(GDHCP_CFLAGS) +miracle_dhcp_LDADD = \ + ../shared/libmiracle-shared.la \ + $(DEPS_LIBS) \ + $(GDHCP_LIBS) + + + diff --git a/src/shared/Makefile.am b/src/shared/Makefile.am new file mode 100644 index 0000000..e79c8ff --- /dev/null +++ b/src/shared/Makefile.am @@ -0,0 +1,23 @@ +include $(top_srcdir)/common.am +noinst_LTLIBRARIES = libmiracle-shared.la + +libmiracle_shared_la_SOURCES = \ + rtsp.h \ + rtsp.c \ + shl_dlist.h \ + shl_htable.h \ + shl_htable.c \ + shl_log.h \ + shl_log.c \ + shl_macro.h \ + shl_ring.h \ + shl_ring.c \ + shl_util.h \ + shl_util.c \ + util.h \ + wpas.h \ + wpas.c +libmiracle_shared_la_LIBADD = -lsystemd + + + diff --git a/src/wifi/Makefile.am b/src/wifi/Makefile.am new file mode 100644 index 0000000..179d4cc --- /dev/null +++ b/src/wifi/Makefile.am @@ -0,0 +1,17 @@ +include $(top_srcdir)/common.am +bin_PROGRAMS = miracle-wifid + +miracle_wifid_SOURCES = \ + wifid.h \ + wifid.c \ + wifid-dbus.c \ + wifid-link.c \ + wifid-peer.c \ + wifid-supplicant.c +miracle_wifid_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + $(DEPS_CFLAGS) +miracle_wifid_LDADD = \ + ../shared/libmiracle-shared.la \ + $(DEPS_LIBS) + diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 0000000..c27342c --- /dev/null +++ b/test/Makefile.am @@ -0,0 +1,58 @@ +include $(top_srcdir)/common.am +tests = \ + test_rtsp \ + test_wpas + +if BUILD_HAVE_CHECK +check_PROGRAMS = $(tests) test_valgrind +TESTS = $(tests) test_valgrind +MEMTESTS = $(tests) +endif + +test_sources = \ + test_common.h +test_libs = \ + ../src/shared/libmiracle-shared.la \ + $(DEPS_LIBS) \ + $(CHECK_LIBS) +test_cflags = \ + $(AM_CPPFLAGS) \ + $(DEPS_CFLAGS) \ + $(CHECK_CFLAGS) + +test_rtsp_SOURCES = test_rtsp.c $(test_sources) +test_rtsp_CPPFLAGS = $(test_cflags) +test_rtsp_LDADD = $(test_libs) + +test_valgrind_SOURCES = test_valgrind.c $(test_sources) +test_valgrind_CPPFLAGS = $(test_cflags) +test_valgrind_LDADD = $(test_libs) + +test_wpas_SOURCES = test_wpas.c $(test_sources) +test_wpas_CPPFLAGS = $(test_cflags) +test_wpas_LDADD = $(test_libs) + +## custom recipes + +VALGRIND = CK_FORK=no valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --leak-resolution=high --error-exitcode=1 --suppressions=$(top_builddir)/test.supp + +# verify that test_valgrind actually leaks data +memcheck-verify: check + $(AM_V_GEN)$(VALGRIND) --log-file=/dev/null ./test_valgrind >/dev/null ; test 1 = $$? + +# run memcheck tests via valgrind +memcheck: memcheck-verify + $(AM_V_GEN)for i in $(MEMTESTS) ; do \ + $(VALGRIND) --log-file=$(top_builddir)/$$i.memlog \ + $(top_builddir)/$$i >/dev/null || (echo "memcheck failed on: $$i" ; exit 1) ; \ + done + +distcheck-hook: memcheck +AM_MAKEFLAGS = --no-print-directory +AUTOMAKE_OPTIONS = color-tests + +# +# Phony targets +# + +.PHONY: memcheck-verify