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.
This commit is contained in:
parent
fb78e60d26
commit
6375307798
2 changed files with 6 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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 $<
|
||||
|
|
Loading…
Reference in a new issue