blob: 99798405ac6285a3de95df11ae4447545e24dba8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
TEST_WRAPPER =
CHRONY_SRCDIR = ../..
CC = @CC@
CFLAGS = @CFLAGS@
CPPFLAGS = -I$(CHRONY_SRCDIR) @CPPFLAGS@
LDFLAGS = @LDFLAGS@ @LIBS@ @EXTRA_LIBS@
SHARED_OBJS = test.o
TEST_OBJS := $(sort $(patsubst %.c,%.o,$(wildcard *.c)))
TESTS := $(patsubst %.o,%.test,$(filter-out $(SHARED_OBJS),$(TEST_OBJS)))
CHRONYD_OBJS := $(patsubst %.o,$(CHRONY_SRCDIR)/%.o,$(filter-out main.o,\
$(filter %.o,$(shell $(MAKE) -f $(CHRONY_SRCDIR)/Makefile \
print-chronyd-objects NODEPS=1))))
all: $(TESTS)
$(CHRONYD_OBJS): ;
%.test: %.o $(SHARED_OBJS) $(CHRONYD_OBJS)
$(CC) $(CFLAGS) -o $@ $(filter-out $(CHRONY_SRCDIR)/$<,$^) $(LDFLAGS)
%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c $<
check: $(TESTS)
@ret=0; \
for t in $^; do \
$(TEST_WRAPPER) ./$$t || ret=1; \
done; \
exit $$ret
clean:
rm -f *.o *.gcda *.gcno core.* $(TESTS)
rm -rf .deps
distclean: clean
rm -f Makefile
.deps:
@mkdir .deps
.deps/%.d: %.c | .deps
@$(CC) -MM $(CPPFLAGS) -MT '$(<:%.c=%.o) $@' $< -o $@
-include $(TEST_OBJS:%.o=.deps/%.d)
|