-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
207 lines (166 loc) · 6.2 KB
/
Makefile
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
VERSION_STRING = 0.87
sources = cyclictest.c signaltest.c pi_stress.c rt-migrate-test.c \
ptsematest.c sigwaittest.c svsematest.c pmqtest.c sendme.c \
pip_stress.c hackbench.c
TARGETS = $(sources:.c=)
LIBS = -lrt -lpthread -lrttest -L.
EXTRA_LIBS ?= -ldl # for get_cpu
DESTDIR ?=
prefix ?= /usr/local
bindir ?= $(prefix)/bin
mandir ?= $(prefix)/share/man
srcdir ?= $(prefix)/src
machinetype = $(shell $(CC) -dumpmachine | \
sed -e 's/-.*//' -e 's/i.86/i386/' -e 's/mips.*/mips/' -e 's/ppc.*/powerpc/')
ifneq ($(filter x86_64 i386 ia64 mips powerpc,$(machinetype)),)
NUMA := 1
endif
CFLAGS ?= -Wall -Wno-nonnull
CPPFLAGS += -D_GNU_SOURCE -Isrc/include
LDFLAGS ?=
PYLIB := $(shell python -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib()')
ifndef DEBUG
CFLAGS += -O2
else
CFLAGS += -O0 -g
endif
ifeq ($(NUMA),1)
CFLAGS += -DNUMA
NUMA_LIBS = -lnuma
endif
VPATH = src/cyclictest:
VPATH += src/signaltest:
VPATH += src/pi_tests:
VPATH += src/rt-migrate-test:
VPATH += src/ptsematest:
VPATH += src/sigwaittest:
VPATH += src/svsematest:
VPATH += src/pmqtest:
VPATH += src/backfire:
VPATH += src/lib
VPATH += src/hackbench
%.o: %.c
$(CC) -D VERSION_STRING=$(VERSION_STRING) -c $< $(CFLAGS) $(CPPFLAGS)
# Pattern rule to generate dependency files from .c files
%.d: %.c
@$(CC) -MM $(CFLAGS) $(CPPFLAGS) $< | 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 librttest.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(NUMA_LIBS)
signaltest: signaltest.o librttest.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
pi_stress: pi_stress.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
hwlatdetect: src/hwlatdetect/hwlatdetect.py
chmod +x src/hwlatdetect/hwlatdetect.py
ln -s src/hwlatdetect/hwlatdetect.py hwlatdetect
rt-migrate-test: rt-migrate-test.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
ptsematest: ptsematest.o librttest.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS)
sigwaittest: sigwaittest.o librttest.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS)
svsematest: svsematest.o librttest.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS)
pmqtest: pmqtest.o librttest.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS)
sendme: sendme.o librttest.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS)
pip_stress: pip_stress.o librttest.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
hackbench: hackbench.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
librttest.a: rt-utils.o error.o rt-get_cpu.o
$(AR) rcs librttest.a rt-utils.o error.o rt-get_cpu.o
CLEANUP = $(TARGETS) *.o .depend *.*~ *.orig *.rej rt-tests.spec *.d *.a
CLEANUP += $(if $(wildcard .git), ChangeLog)
.PHONY: clean
clean:
for F in $(CLEANUP); do find -type f -name $$F | xargs rm -f; done
rm -f hwlatdetect
rm -f tags
RPMDIRS = BUILD BUILDROOT RPMS SRPMS SPECS
.PHONY: distclean
distclean: clean
rm -rf $(RPMDIRS) releases *.tar.gz rt-tests.spec tmp
.PHONY: changelog
changelog:
git log >ChangeLog
.PHONY: install
install: all
mkdir -p "$(DESTDIR)$(bindir)" "$(DESTDIR)$(mandir)/man4"
mkdir -p "$(DESTDIR)$(srcdir)" "$(DESTDIR)$(mandir)/man8"
cp $(TARGETS) "$(DESTDIR)$(bindir)"
if test -n "$(PYLIB)" ; then \
install -D -m 755 src/hwlatdetect/hwlatdetect.py $(DESTDIR)$(PYLIB)/hwlatdetect.py ; \
rm -f "$(DESTDIR)$(bindir)/hwlatdetect" ; \
ln -s $(PYLIB)/hwlatdetect.py "$(DESTDIR)$(bindir)/hwlatdetect" ; \
fi
install -D -m 644 src/backfire/backfire.c "$(DESTDIR)$(srcdir)/backfire/backfire.c"
install -m 644 src/backfire/Makefile "$(DESTDIR)$(srcdir)/backfire/Makefile"
gzip src/backfire/backfire.4 -c >"$(DESTDIR)$(mandir)/man4/backfire.4.gz"
gzip src/cyclictest/cyclictest.8 -c >"$(DESTDIR)$(mandir)/man8/cyclictest.8.gz"
gzip src/pi_tests/pi_stress.8 -c >"$(DESTDIR)$(mandir)/man8/pi_stress.8.gz"
gzip src/hwlatdetect/hwlatdetect.8 -c >"$(DESTDIR)$(mandir)/man8/hwlatdetect.8.gz"
gzip src/ptsematest/ptsematest.8 -c >"$(DESTDIR)$(mandir)/man8/ptsematest.8.gz"
gzip src/sigwaittest/sigwaittest.8 -c >"$(DESTDIR)$(mandir)/man8/sigwaittest.8.gz"
gzip src/svsematest/svsematest.8 -c >"$(DESTDIR)$(mandir)/man8/svsematest.8.gz"
gzip src/pmqtest/pmqtest.8 -c >"$(DESTDIR)$(mandir)/man8/pmqtest.8.gz"
gzip src/backfire/sendme.8 -c >"$(DESTDIR)$(mandir)/man8/sendme.8.gz"
gzip src/hackbench/hackbench.8 -c >"$(DESTDIR)$(mandir)/man8/hackbench.8.gz"
.PHONY: release
release: distclean changelog
mkdir -p releases
mkdir -p tmp/rt-tests
cp -r Makefile COPYING ChangeLog src tmp/rt-tests
rm -f rt-tests-$(VERSION_STRING).tar rt-tests-$(VERSION_STRING).tar.asc
tar -C tmp -cf rt-tests-$(VERSION_STRING).tar rt-tests
gpg2 --default-key [email protected] --detach-sign --armor rt-tests-$(VERSION_STRING).tar
gzip rt-tests-$(VERSION_STRING).tar
rm -f ChangeLog
cp rt-tests-$(VERSION_STRING).tar.gz rt-tests-$(VERSION_STRING).tar.asc releases
.PHONY: push
push: release
scripts/do-git-push $(VERSION_STRING)
.PHONY: pushtest
pushtest: release
scripts/do-git-push --test $(VERSION_STRING)
rt-tests.spec: Makefile rt-tests.spec-in
sed s/__VERSION__/$(VERSION_STRING)/ <$@-in >$@
ifeq ($(NUMA),1)
sed -i -e 's/__MAKE_NUMA__/NUMA=1/' $@
sed -i -e 's/__BUILDREQUIRES_NUMA__/numactl-devel/' $@
else
sed -i -e 's/__MAKE_NUMA__//' $@
sed -i -e 's/__BUILDREQUIRES_NUMA__//' $@
endif
HERE := $(shell pwd)
RPMARGS := --define "_topdir $(HERE)" \
--define "_sourcedir $(HERE)/releases" \
--define "_builddir $(HERE)/BUILD" \
.PHONY: rpm
rpm: rpmdirs release rt-tests.spec
rpmbuild -ba $(RPMARGS) rt-tests.spec
.PHONY: rpmdirs
rpmdirs:
@[ -d BUILD ] || mkdir BUILD
@[ -d RPMS ] || mkdir RPMS
@[ -d SRPMS ] || mkdir SRPMS
.PHONY: help
help:
@echo ""
@echo " rt-tests useful Makefile targets:"
@echo ""
@echo " all : build all tests (default"
@echo " install : install tests to local filesystem"
@echo " release : build source tarfile"
@echo " rpm : build RPM package"
@echo " clean : remove object files"
@echo " distclean : remove all generated files"
@echo " help : print this message"
.PHONY: tags
tags:
ctags -R --extra=+f --c-kinds=+p --exclude=tmp --exclude=BUILD *