]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
test: get list of objects from main Makefile
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 13 Sep 2018 07:48:15 +0000 (09:48 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 13 Sep 2018 09:23:16 +0000 (11:23 +0200)
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
test/unit/Makefile.in

index cdf31e69d44114a9e3612f8693e7ce1109cb11a8..2d3e67dfdb3b23eb523411cc54ffb407203aacfb 100644 (file)
@@ -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
index bae0cb7984f627d85cd7665d3fa6760eee61e0e8..61ab7417813d2a3b1b198211a2f4ffb83d714234 100644 (file)
@@ -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 $<