Skip to contentSkip to conversation

rt-tests: Makefile changes

PATCH New John Kacur 1 participant 4 messages Nov 16, 2009 Kbuild

lore
Share & tools
lore

John Kacur

author
#0 lore raw

cover rt-tests: Makefile changes

Here are a few simple Makefile changes to the rt-tests suite. The DEBUG option is especially useful for debugging problems. For example, it allows you to do:

make DEBUG=0 pi_stress

That will compile a version of pi_stress with -O0 -g

You can also pull
e2a22de97709513b3d541f65280db51e44431a3e 14806d13a0b84220fa17d38bdb32559610434794 7ea849f942f7e5b02d2be9ee50e2584635cd7be4
from git://git.kernel.org/pub/scm/linux/kernel/git/jkacur/rt-tests.git
(branch rt-tests-dev)

John Kacur (3):
rt-tests: Makefile - Change FLAGS to CFLAGS
rt-tests: Makefile - Specify when a target is a PHONY target.
rt-tests: Makefile - Add a DEBUG option to the Makefile

 Makefile |   31 +++++++++++++++++++++++++------
 1 files changed, 25 insertions(+), 6 deletions(-)
author
#1 lore raw

PATCH 1/3 rt-tests: Makefile - Change FLAGS to CFLAGS

Change FLAGS to CFLAGS as this is the standard

---
 Makefile |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
Makefile +6 -6
index 6a56a65..9685587 100644
@@ -2,7 +2,7 @@ VERSION_STRING = 0.53
 
 TARGETS	= cyclictest signaltest classic_pi pi_stress \
 	  hwlatdetect rt-migrate-test
-FLAGS	= -Wall -Wno-nonnull -O2
+CFLAGS	= -Wall -Wno-nonnull -O2
 LIBS 	= -lpthread -lrt
 DESTDIR	?=
 prefix  ?= /usr/local
@@ -12,23 +12,23 @@ mandir	?= $(prefix)/share/man/man8
 all: $(TARGETS)
 
 cyclictest: src/cyclictest/cyclictest.c
-	$(CC) $(FLAGS) -D VERSION_STRING=$(VERSION_STRING) $^ -o $@ $(LIBS)
+	$(CC) $(CFLAGS) -D VERSION_STRING=$(VERSION_STRING) $^ -o $@ $(LIBS)
 
 signaltest: src/signaltest/signaltest.c
-	$(CC) $(FLAGS) -D VERSION_STRING=$(VERSION_STRING) $^ -o $@ $(LIBS)
+	$(CC) $(CFLAGS) -D VERSION_STRING=$(VERSION_STRING) $^ -o $@ $(LIBS)
 
 classic_pi: src/pi_tests/classic_pi.c
-	$(CC) $(FLAGS) -D_GNU_SOURCE -D VERSION_STRING=\"$(VERSION_STRING)\" $^ -o $@ $(LIBS)
+	$(CC) $(CFLAGS) -D_GNU_SOURCE -D VERSION_STRING=\"$(VERSION_STRING)\" $^ -o $@ $(LIBS)
 
 pi_stress:  src/pi_tests/pi_stress.c
-	$(CC) $(FLAGS) -D_GNU_SOURCE -D VERSION_STRING=\"$(VERSION_STRING)\" $^ -o $@ $(LIBS)
+	$(CC) $(CFLAGS) -D_GNU_SOURCE -D VERSION_STRING=\"$(VERSION_STRING)\" $^ -o $@ $(LIBS)
 
 hwlatdetect:  src/hwlatdetect/hwlatdetect.py
 	chmod +x src/hwlatdetect/hwlatdetect.py
 	ln -s src/hwlatdetect/hwlatdetect.py hwlatdetect
 
 rt-migrate-test: src/rt-migrate-test/rt-migrate-test.c
-	$(CC) $(FLAGS) -D_GNU_SOURCE -D VERSION_STRING=\"$(VERSION_STRING)\" $^ -o $@ $(LIBS)
+	$(CC) $(CFLAGS) -D_GNU_SOURCE -D VERSION_STRING=\"$(VERSION_STRING)\" $^ -o $@ $(LIBS)
 
 CLEANUP  = $(TARGETS) *.o .depend *.*~ *.orig *.rej rt-tests.spec
 CLEANUP += $(if $(wildcard .git), ChangeLog)
Signature · 1 line
1.6.2.5
author
#2 lore raw

PATCH 2/3 rt-tests: Makefile - Specify when a target is a PHONY target.

---
 Makefile |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
Makefile +13 -0
index 9685587..96c7bca 100644
@@ -9,6 +9,7 @@ prefix  ?= /usr/local
 bindir  ?= $(prefix)/bin
 mandir	?= $(prefix)/share/man/man8
 
+.PHONY: all
 all: $(TARGETS)
 
 cyclictest: src/cyclictest/cyclictest.c
@@ -33,16 +34,20 @@ rt-migrate-test: src/rt-migrate-test/rt-migrate-test.c
 CLEANUP  = $(TARGETS) *.o .depend *.*~ *.orig *.rej rt-tests.spec
 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
 
+.PHONY: distclean
 distclean: clean
 	rm -rf BUILD RPMS SRPMS releases *.tar.gz rt-tests.spec
 
+.PHONY: changelog
 changelog:
 	git log >ChangeLog
 
+.PHONY: all
 install: all
 	mkdir -p "$(DESTDIR)$(bindir)" "$(DESTDIR)$(mandir)"
 	cp $(TARGETS) "$(DESTDIR)$(bindir)"
@@ -50,6 +55,7 @@ install: all
 	gzip src/pi_tests/pi_stress.8 -c >"$(DESTDIR)$(mandir)/pi_stress.8.gz"
 	gzip src/hwlatdetect/hwlatdetect.8 -c >"$(DESTDIR)$(mandir)/hwlatdetect.8.gz"
 
+.PHONY: release
 release: clean changelog
 	mkdir -p releases
 	rm -rf tmp && mkdir -p tmp/rt-tests
@@ -58,12 +64,16 @@ release: clean changelog
 	rm -f ChangeLog
 	cp rt-tests-$(VERSION_STRING).tar.gz releases
 
+.PHONY: push
 push:	release
 	scripts/do-git-push $(VERSION_STRING)
 
+.PHONY: pushtest
 pushtest: release
 	scripts/do-git-push --test $(VERSION_STRING)
 
+# Note although rt-tests.spec is a file, it is okay to remake it every time.
+.PHONY: rt-tests.spec
 rt-tests.spec: Makefile rt-tests.spec-in
 	sed s/__VERSION__/$(VERSION_STRING)/ <$@-in >$@
 
@@ -72,14 +82,17 @@ 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:"
Signature · 1 line
1.6.2.5
author
#3 lore raw

PATCH 3/3 rt-tests: Makefile - Add a DEBUG option to the Makefile

This allows you to do
make DEBUG=0
which changes CFLAGS from -Wall -Wno-nonnull -O2
to -Wall -Wno-nonnull -O0 -g

---
 Makefile |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
Makefile +7 -1
index 96c7bca..7414a68 100644
@@ -2,13 +2,19 @@ VERSION_STRING = 0.53
 
 TARGETS	= cyclictest signaltest classic_pi pi_stress \
 	  hwlatdetect rt-migrate-test
-CFLAGS	= -Wall -Wno-nonnull -O2
 LIBS 	= -lpthread -lrt
 DESTDIR	?=
 prefix  ?= /usr/local
 bindir  ?= $(prefix)/bin
 mandir	?= $(prefix)/share/man/man8
 
+CFLAGS = -Wall -Wno-nonnull
+ifndef DEBUG
+	CFLAGS	+= -O2
+else
+	CFLAGS	+= -O0 -g
+endif
+
 .PHONY: all
 all: $(TARGETS)
 
Signature · 1 line
1.6.2.5