From: Miroslav Lichvar Date: Thu, 13 Sep 2018 07:48:15 +0000 (+0200) Subject: test: get list of objects from main Makefile X-Git-Tag: 3.4~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=637530779815cdf61a95e830abffbc116d91d1aa;p=thirdparty%2Fchrony.git 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. --- diff --git a/Makefile.in b/Makefile.in index cdf31e69..2d3e67df 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 bae0cb79..61ab7417 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 $<