From e4fae829bc0ef8a080c1b58e82e1b3d182a2a65c Mon Sep 17 00:00:00 2001 From: Damien Stuart Date: Tue, 17 Feb 2015 14:37:20 -0500 Subject: [PATCH] Refactor of Makefile.am files to fix issues caused by referencing source files in other directories - which broke make dist and make distclean targets. --- Makefile.am | 2 +- client/Makefile.am | 14 +- {test/c-unit-tests => client}/fwknop_utests.c | 0 common/Makefile.am | 6 +- {lib => common}/fko_util.c | 0 {lib => common}/fko_util.h | 0 {lib => common}/strlcat.c | 0 {lib => common}/strlcpy.c | 0 lib/Makefile.am | 8 +- {test/c-unit-tests => lib}/fko_utests.c | 0 server/Makefile.am | 43 +++-- .../c-unit-tests => server}/fwknopd_utests.c | 0 test/c-unit-tests/Makefile.am | 148 +++++++++--------- 13 files changed, 124 insertions(+), 97 deletions(-) rename {test/c-unit-tests => client}/fwknop_utests.c (100%) rename {lib => common}/fko_util.c (100%) rename {lib => common}/fko_util.h (100%) rename {lib => common}/strlcat.c (100%) rename {lib => common}/strlcpy.c (100%) rename {test/c-unit-tests => lib}/fko_utests.c (100%) rename {test/c-unit-tests => server}/fwknopd_utests.c (100%) diff --git a/Makefile.am b/Makefile.am index ee125ebe..c9ddb5d5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,8 +13,8 @@ if WANT_C_UNIT_TESTS endif SUBDIRS = \ - lib \ common \ + lib \ $(CLIENT_DIR) \ $(SERVER_DIR) \ $(C_UNIT_TESTS_DIR) \ diff --git a/client/Makefile.am b/client/Makefile.am index 9637a8a8..a9cc9776 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -1,17 +1,27 @@ bin_PROGRAMS = fwknop -fwknop_SOURCES = fwknop.c fwknop.h config_init.c config_init.h \ +BASE_SOURCE_FILES = fwknop.h config_init.c config_init.h \ fwknop_common.h spa_comm.c spa_comm.h utils.c utils.h \ http_resolve_host.c getpasswd.c getpasswd.h cmd_opts.h \ log_msg.c log_msg.h +fwknop_SOURCES = fwknop.c $(BASE_SOURCE_FILES) + +if WANT_C_UNIT_TESTS + noinst_PROGRAMS = fwknop_utests + fwknop_utests_SOURCES = fwknop_utests.c $(BASE_SOURCE_FILES) + fwknop_utests_CPPFLAGS = -I $(top_builddir)/lib -I $(top_builddir)/common $(GPGME_CFLAGS) + fwknop_utests_LDADD = $(top_builddir)/lib/libfko.la $(top_builddir)/common/libfko_util.a + fwknop_utests_LDFLAGS = -lcunit $(GPGME_LIBS) +endif + fwknop_CPPFLAGS = -I $(top_srcdir)/lib -I $(top_srcdir)/common fwknop_LDADD = $(top_builddir)/lib/libfko.la $(top_builddir)/common/libfko_util.a dist_man_MANS = fwknop.8 -EXTRA_DIST = fwknop.8.in +EXTRA_DIST = fwknop.8.in fwknop_utests.c fwknop.8: $(top_srcdir)/client/fwknop.8.in $(SED) \ diff --git a/test/c-unit-tests/fwknop_utests.c b/client/fwknop_utests.c similarity index 100% rename from test/c-unit-tests/fwknop_utests.c rename to client/fwknop_utests.c diff --git a/common/Makefile.am b/common/Makefile.am index 7000b851..ae19e244 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -2,9 +2,7 @@ AUTOMAKE_OPTIONS = subdir-objects noinst_LIBRARIES = libfko_util.a -libfko_util_source_files = \ - ../lib/strlcpy.c ../lib/strlcat.c ../lib/fko_util.c \ - ../lib/fko_util.h +libfko_util_source_files = strlcpy.c strlcat.c fko_util.c fko_util.h if WANT_C_UNIT_TESTS libfko_util_source_files += cunit_common.c cunit_common.h @@ -12,6 +10,6 @@ endif libfko_util_a_SOURCES = $(libfko_util_source_files) -AM_CPPFLAGS = $(GPGME_CFLAGS) -I $(top_srcdir)/common +AM_CPPFLAGS = $(GPGME_CFLAGS) -I $(top_srcdir)/common -I $(top_srcdir)/lib EXTRA_DIST = common.h netinet_common.h cunit_common.h cunit_common.c diff --git a/lib/fko_util.c b/common/fko_util.c similarity index 100% rename from lib/fko_util.c rename to common/fko_util.c diff --git a/lib/fko_util.h b/common/fko_util.h similarity index 100% rename from lib/fko_util.h rename to common/fko_util.h diff --git a/lib/strlcat.c b/common/strlcat.c similarity index 100% rename from lib/strlcat.c rename to common/strlcat.c diff --git a/lib/strlcpy.c b/common/strlcpy.c similarity index 100% rename from lib/strlcpy.c rename to common/strlcpy.c diff --git a/lib/Makefile.am b/lib/Makefile.am index d75140d1..9a21d649 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -8,11 +8,15 @@ libfko_source_files = \ fko.h fko_limits.h fko_timestamp.c fko_hmac.c hmac.c hmac.h \ fko_user.c fko_user.h md5.c md5.h rijndael.c rijndael.h sha1.c \ sha1.h sha2.c sha2.h fko_context.h fko_state.h \ - gpgme_funcs.c gpgme_funcs.h strlcpy.c strlcat.c fko_util.c fko_util.h + gpgme_funcs.c gpgme_funcs.h if WANT_C_UNIT_TESTS -libfko_la_LIBADD = $(top_builddir)/common/cunit_common.o + libfko_la_LIBADD = $(top_builddir)/common/cunit_common.o + noinst_PROGRAMS = fko_utests + fko_utests_SOURCES = fko_utests.c + fko_utests_CPPFLAGS = -I ../lib -I ../common $(GPGME_CFLAGS) + fko_utests_LDFLAGS = -lcunit $(GPGME_LIBS) endif libfko_la_SOURCES = $(libfko_source_files) diff --git a/test/c-unit-tests/fko_utests.c b/lib/fko_utests.c similarity index 100% rename from test/c-unit-tests/fko_utests.c rename to lib/fko_utests.c diff --git a/server/Makefile.am b/server/Makefile.am index fbea5842..99b8bc15 100644 --- a/server/Makefile.am +++ b/server/Makefile.am @@ -1,21 +1,36 @@ -sbin_PROGRAMS = fwknopd +sbin_PROGRAMS = fwknopd -fwknopd_SOURCES = fwknopd.c fwknopd.h config_init.c config_init.h \ - fwknopd_common.h incoming_spa.c incoming_spa.h \ - pcap_capture.c pcap_capture.h process_packet.c \ - process_packet.h log_msg.c log_msg.h utils.c utils.h \ - sig_handler.c sig_handler.h replay_cache.c replay_cache.h \ - access.c access.h fwknopd_errors.c fwknopd_errors.h \ - tcp_server.c tcp_server.h udp_server.c udp_server.h \ - fw_util.c fw_util.h fw_util_ipf.c fw_util_ipf.h \ - fw_util_firewalld.c fw_util_firewalld.h \ - fw_util_iptables.c fw_util_iptables.h \ - fw_util_ipfw.c fw_util_ipfw.h \ - fw_util_pf.c fw_util_pf.h cmd_opts.h \ - extcmd.c extcmd.h +BASE_SOURCE_FILES = fwknopd.h config_init.c config_init.h \ + fwknopd_common.h incoming_spa.c incoming_spa.h \ + pcap_capture.c pcap_capture.h process_packet.c \ + process_packet.h log_msg.c log_msg.h utils.c utils.h \ + sig_handler.c sig_handler.h replay_cache.c replay_cache.h \ + access.c access.h fwknopd_errors.c fwknopd_errors.h \ + tcp_server.c tcp_server.h udp_server.c udp_server.h \ + fw_util.c fw_util.h fw_util_ipf.c fw_util_ipf.h \ + fw_util_firewalld.c fw_util_firewalld.h \ + fw_util_iptables.c fw_util_iptables.h \ + fw_util_ipfw.c fw_util_ipfw.h \ + fw_util_pf.c fw_util_pf.h cmd_opts.h \ + extcmd.c extcmd.h + +fwknopd_SOURCES = fwknopd.c $(BASE_SOURCE_FILES) fwknopd_LDADD = $(top_builddir)/lib/libfko.la $(top_builddir)/common/libfko_util.a +if WANT_C_UNIT_TESTS + noinst_PROGRAMS = fwknopd_utests + fwknopd_utests_SOURCES = fwknopd_utests.c $(BASE_SOURCE_FILES) + fwknopd_utests_CPPFLAGS = -I $(top_builddir)/lib -I $(top_builddir)/common $(GPGME_CFLAGS) -DSYSCONFDIR=\"$(sysconfdir)\" -DSYSRUNDIR=\"$(localstatedir)\" + fwknopd_utests_LDADD = $(top_builddir)/lib/libfko.la $(top_builddir)/common/libfko_util.a + fwknopd_utests_LDFLAGS = -lcunit $(GPGME_LIBS) + +if !UDP_SERVER + fwknopd_utests_LDFLAGS += -lpcap +endif + +endif + if !UDP_SERVER fwknopd_LDADD += -lpcap endif diff --git a/test/c-unit-tests/fwknopd_utests.c b/server/fwknopd_utests.c similarity index 100% rename from test/c-unit-tests/fwknopd_utests.c rename to server/fwknopd_utests.c diff --git a/test/c-unit-tests/Makefile.am b/test/c-unit-tests/Makefile.am index 79d4546e..23d010d1 100755 --- a/test/c-unit-tests/Makefile.am +++ b/test/c-unit-tests/Makefile.am @@ -1,74 +1,74 @@ -bin_PROGRAMS = fwknop_utests fwknopd_utests fko_utests - -fwknop_utests_SOURCES = fwknop_utests.c \ - ../../client/config_init.c \ - ../../client/spa_comm.c \ - ../../client/utils.c \ - ../../client/http_resolve_host.c \ - ../../client/getpasswd.c \ - ../../client/log_msg.c - -fwknop_utests_CPPFLAGS = -I ../../lib -I ../../common -I ../../client - -fwknop_utests_LDADD = ../../lib/libfko.la ../../common/libfko_util.a - -fwknop_utests_LDFLAGS = -lcunit - -fwknopd_utests_SOURCES = fwknopd_utests.c \ - ../../server/config_init.c \ - ../../server/incoming_spa.c \ - ../../server/pcap_capture.c \ - ../../server/process_packet.c \ - ../../server/log_msg.c \ - ../../server/utils.c \ - ../../server/sig_handler.c \ - ../../server/replay_cache.c \ - ../../server/access.c\ - ../../server/fwknopd_errors.c \ - ../../server/tcp_server.c \ - ../../server/extcmd.c \ - ../../server/fw_util.c \ - ../../server/fw_util_ipf.c \ - ../../server/fw_util_ipfw.c \ - ../../server/fw_util_pf.c \ - ../../server/fw_util_iptables.c \ - ../../server/fw_util_firewalld.c - -fwknopd_utests_CPPFLAGS = -I ../../lib -I ../../common -I ../../server -DSYSCONFDIR=\"$(sysconfdir)\" -DSYSRUNDIR=\"$(localstatedir)\" - -fwknopd_utests_LDADD = $(top_builddir)/lib/libfko.la $(top_builddir)/common/libfko_util.a - -fwknopd_utests_LDFLAGS = -lcunit -lpcap - -fko_utests_SOURCES = fko_utests.c \ - ../../lib/base64.c \ - ../../lib/cipher_funcs.c \ - ../../lib/digest.c \ - ../../lib/fko_client_timeout.c \ - ../../lib/fko_digest.c \ - ../../lib/fko_encode.c \ - ../../lib/fko_decode.c \ - ../../lib/fko_encryption.c \ - ../../lib/fko_error.c \ - ../../lib/fko_funcs.c \ - ../../lib/fko_message.c \ - ../../lib/fko_nat_access.c \ - ../../lib/fko_rand_value.c \ - ../../lib/fko_server_auth.c \ - ../../lib/fko_timestamp.c \ - ../../lib/fko_hmac.c \ - ../../lib/hmac.c \ - ../../lib/fko_user.c \ - ../../lib/md5.c \ - ../../lib/rijndael.c \ - ../../lib/sha1.c \ - ../../lib/sha2.c \ - ../../lib/strlcpy.c \ - ../../lib/strlcat.c \ - ../../lib/fko_util.c \ - ../../lib/gpgme_funcs.c \ - ../../common/cunit_common.c - -fko_utests_CPPFLAGS = -I ../../lib -I ../../common $(GPGME_CFLAGS) - -fko_utests_LDFLAGS = -lcunit $(GPGME_LIBS) +#bin_PROGRAMS = fwknop_utests fwknopd_utests fko_utests +# +#fwknop_utests_SOURCES = fwknop_utests.c \ +# ../../client/config_init.c \ +# ../../client/spa_comm.c \ +# ../../client/utils.c \ +# ../../client/http_resolve_host.c \ +# ../../client/getpasswd.c \ +# ../../client/log_msg.c +# +#fwknop_utests_CPPFLAGS = -I ../../lib -I ../../common -I ../../client +# +#fwknop_utests_LDADD = ../../lib/libfko.la ../../common/libfko_util.a +# +#fwknop_utests_LDFLAGS = -lcunit +# +#fwknopd_utests_SOURCES = fwknopd_utests.c \ +# ../../server/config_init.c \ +# ../../server/incoming_spa.c \ +# ../../server/pcap_capture.c \ +# ../../server/process_packet.c \ +# ../../server/log_msg.c \ +# ../../server/utils.c \ +# ../../server/sig_handler.c \ +# ../../server/replay_cache.c \ +# ../../server/access.c\ +# ../../server/fwknopd_errors.c \ +# ../../server/tcp_server.c \ +# ../../server/extcmd.c \ +# ../../server/fw_util.c \ +# ../../server/fw_util_ipf.c \ +# ../../server/fw_util_ipfw.c \ +# ../../server/fw_util_pf.c \ +# ../../server/fw_util_iptables.c \ +# ../../server/fw_util_firewalld.c +# +#fwknopd_utests_CPPFLAGS = -I ../../lib -I ../../common -I ../../server -DSYSCONFDIR=\"$(sysconfdir)\" -DSYSRUNDIR=\"$(localstatedir)\" +# +#fwknopd_utests_LDADD = $(top_builddir)/lib/libfko.la $(top_builddir)/common/libfko_util.a +# +#fwknopd_utests_LDFLAGS = -lcunit -lpcap +# +#fko_utests_SOURCES = fko_utests.c \ +# ../../lib/base64.c \ +# ../../lib/cipher_funcs.c \ +# ../../lib/digest.c \ +# ../../lib/fko_client_timeout.c \ +# ../../lib/fko_digest.c \ +# ../../lib/fko_encode.c \ +# ../../lib/fko_decode.c \ +# ../../lib/fko_encryption.c \ +# ../../lib/fko_error.c \ +# ../../lib/fko_funcs.c \ +# ../../lib/fko_message.c \ +# ../../lib/fko_nat_access.c \ +# ../../lib/fko_rand_value.c \ +# ../../lib/fko_server_auth.c \ +# ../../lib/fko_timestamp.c \ +# ../../lib/fko_hmac.c \ +# ../../lib/hmac.c \ +# ../../lib/fko_user.c \ +# ../../lib/md5.c \ +# ../../lib/rijndael.c \ +# ../../lib/sha1.c \ +# ../../lib/sha2.c \ +# ../../lib/strlcpy.c \ +# ../../lib/strlcat.c \ +# ../../lib/fko_util.c \ +# ../../lib/gpgme_funcs.c \ +# ../../common/cunit_common.c +# +#fko_utests_CPPFLAGS = -I ../../lib -I ../../common $(GPGME_CFLAGS) +# +#fko_utests_LDFLAGS = -lcunit $(GPGME_LIBS)