From 637530779815cdf61a95e830abffbc116d91d1aa Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Thu, 13 Sep 2018 09:48:15 +0200 Subject: [PATCH] test: get list of objects from main Makefile Instead of linking unit tests with *.o in the root directory, which may include conflicting objects from a different configuration (e.g. hash), add a print target to the main Makefile and use it in the unit test Makefile to link only with objects that are relevant in the current configuration. --- Makefile.in | 3 +++ test/unit/Makefile.in | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile.in b/Makefile.in index cdf31e6..2d3e67d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -118,6 +118,9 @@ check : chronyd chronyc $(MAKE) -C test/unit check cd test/simulation && ./run -i 20 -m 2 +print-chronyd-objects : + @echo $(OBJS) $(EXTRA_OBJS) + Makefile : Makefile.in configure @echo @echo Makefile needs to be regenerated, run ./configure diff --git a/test/unit/Makefile.in b/test/unit/Makefile.in index bae0cb7..61ab741 100644 --- a/test/unit/Makefile.in +++ b/test/unit/Makefile.in @@ -11,13 +11,13 @@ SHARED_OBJS = test.o TEST_OBJS := $(sort $(patsubst %.c,%.o,$(wildcard *.c))) TESTS := $(patsubst %.o,%.test,$(filter-out $(SHARED_OBJS),$(TEST_OBJS))) -FILTER_OBJS = %/main.o %/client.o %/getdate.o -CHRONY_OBJS := $(filter-out $(FILTER_OBJS),$(wildcard $(CHRONY_SRCDIR)/*.o)) +CHRONYD_OBJS := $(patsubst %.o,$(CHRONY_SRCDIR)/%.o,$(filter-out main.o,\ + $(shell $(MAKE) -s -C $(CHRONY_SRCDIR) print-chronyd-objects))) all: $(TESTS) %.test: %.o $(SHARED_OBJS) - $(CC) $(CFLAGS) -o $@ $^ $(CHRONY_OBJS:%/$*.o=) $(LDFLAGS) + $(CC) $(CFLAGS) -o $@ $^ $(CHRONYD_OBJS:%/$*.o=) $(LDFLAGS) %.o: %.c $(CC) $(CPPFLAGS) $(CFLAGS) -c $<