summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Kacur <jkacur@redhat.com>2010-01-27 21:12:06 +0100
committerJohn Kacur <jkacur@redhat.com>2010-01-27 21:12:06 +0100
commit88449adc30a86e3d2fb8afe2b4d4b49590b89276 (patch)
tree414ec818451e939e8dfff926396bce75a295ff5b
parentdb54b6152ac64f4ae220bb7eda78a29c2049b7c8 (diff)
downloadrt-tests-88449adc30a86e3d2fb8afe2b4d4b49590b89276.tar.gz
rt-tests: Automatically generate dependencies.
Automatically generate dependencies. This will tell the make file that cyclictest is dependent on rt_numa.h for example, and that if a change is made there, then cyclictest needs to be remade. Signed-off-by: John Kacur <jkacur@redhat.com>
-rw-r--r--Makefile20
1 files changed, 16 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 6156c03..4be0838 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,10 @@
VERSION_STRING = 0.63
-TARGETS = cyclictest signaltest pi_stress \
- rt-migrate-test ptsematest sigwaittest svsematest \
- sendme pip
+sources = cyclictest.c signaltest.c pi_stress.c rt-migrate-test.c \
+ ptsematest.c sigwaittest.c svsematest.c sendme.c pip.c
+
+TARGETS = $(sources:.c=)
+
LIBS = -lrt -lpthread
EXTRA_LIBS ?= -ldl # for get_cpu
DESTDIR ?=
@@ -39,9 +41,19 @@ VPATH += src/lib
%.o: %.c
$(CC) -D VERSION_STRING=$(VERSION_STRING) -c $< $(CFLAGS)
+# Pattern rule to generate dependency files from .c files
+%.d: %.c
+ @set -e; rm -f $@; \
+ $(CC) -MM $(CFLAGS) $< > $@.$$$$; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+ rm -f $@.$$$$
+
.PHONY: all
all: $(TARGETS) hwlatdetect
+# Include dependency files, automatically generate them if needed.
+-include $(sources:.c=.d)
+
cyclictest: cyclictest.o rt-utils.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(NUMA_LIBS)
@@ -73,7 +85,7 @@ sendme: sendme.o rt-utils.o rt-get_cpu.o
pip: pip.o error.o rt-utils.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
-CLEANUP = $(TARGETS) *.o .depend *.*~ *.orig *.rej rt-tests.spec
+CLEANUP = $(TARGETS) *.o .depend *.*~ *.orig *.rej rt-tests.spec *.d
CLEANUP += $(if $(wildcard .git), ChangeLog)
.PHONY: clean