tools: Add a toplevel Makefile
cover tools: Add a toplevel Makefile
From: Borislav Petkov <[email protected]>
Hi all,
here's a refreshed version from yesterday incorporating all comments and suggestions along with a third patch that adds a 'help' target as the default one causing the following below. Btw, Arnaldo, could you please pick those up if there are no complaints since the first patch touches perf and I don't have a clear idea who else to send it to anyway :).
Thanks.
$ make Possible targets:
cpupower - a tool for all things x86 CPU power firewire - the userspace part of nosy, an IEEE-1394 traffic sniffer lguest - a minimal 32-bit x86 hypervisor perf - Linux performance measurements tool slub - slabs reporting tool turbostat - Intel CPU idle stats and freq reporting tool usb - USB testing tools virtio - vhost test module
x86_energy_perf_policy - Intel energy policy tool
Cleaning targets:
all of the above with the "_clean" string appended cleans
the respective build directory.
clean: a summary clean target to clean _all_ folders
Changelog:
* v1:
this is a refresh and carve-out of an old patchset. It adds a toplevel Makefile to tools/ so that one can build the tool of her/his liking by simply doing
$ cd tools/ $ make <toolname>
By default, we build perf. There's also a scripts/Makefile.lib now which should contain all make-related generic stuff which can be used by all tools' build process after including this file.
</Changelog>
Any comments/suggestions are welcome,
thanks.
PATCH 1/3 tools: Add Makefile.include
From: Borislav Petkov <[email protected]>
Put generic enough build settings which could be reused by other tools into a common Makefile.include file.
--- tools/perf/Makefile | 45 +------------------------------- tools/scripts/Makefile.include | 55 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 44 deletions(-) create mode 100644 tools/scripts/Makefile.include
tools/perf/Makefile +1 -44
@@ -1,18 +1,10 @@ -ifeq ("$(origin O)", "command line") - OUTPUT := $(O)/ -endif +include ../scripts/Makefile.include # The default target of this Makefile is... all: include config/utilities.mak -ifneq ($(OUTPUT),) -# check that the output directory actually exists -OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd) -$(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist)) -endif - # Define V to have a more verbose compile. # # Define PYTHON to point to the python binary if the default
@@ -70,31 +62,6 @@ ifneq ($(WERROR),0) CFLAGS_WERROR := -Werror endif -# -# Include saner warnings here, which can catch bugs: -# - -EXTRA_WARNINGS := -Wformat -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-security -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-y2k -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Winit-self -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wpacked -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-aliasing=3 -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-default -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-enum -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wno-system-headers -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wundef -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wwrite-strings -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wbad-function-cast -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-declarations -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-prototypes -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wnested-externs -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement - ifeq ("$(origin DEBUG)", "command line") PERF_DEBUG = $(DEBUG) endif
@@ -619,16 +586,6 @@ else endif endif -ifneq ($(findstring $(MAKEFLAGS),s),s) -ifndef V - QUIET_CC = @echo ' ' CC $@; - QUIET_AR = @echo ' ' AR $@; - QUIET_LINK = @echo ' ' LINK $@; - QUIET_MKDIR = @echo ' ' MKDIR $@; - QUIET_GEN = @echo ' ' GEN $@; -endif -endif - ifdef ASCIIDOC8 export ASCIIDOC8 endif
tools/scripts/Makefile.include new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
1.7.9.3.362.g71319
PATCH 2/3 tools: Add a toplevel Makefile
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Add a Makefile with all the targets under tools/. Also, and add a minimalistic Makefile to slub/ for completeness.
--- tools/Makefile | 24 ++++++++++++++++++++++++ tools/slub/Makefile | 4 ++++ 2 files changed, 28 insertions(+) create mode 100644 tools/Makefile create mode 100644 tools/slub/Makefile
tools/Makefile new file +24 -0
@@ -0,0 +1,24 @@ +include scripts/Makefile.include + +perf firewire lguest slub usb virtio: FORCE + $(QUIET_SUBDIR0)$@/ $(QUIET_SUBDIR1) + +cpupower: FORCE + $(QUIET_SUBDIR0)power/$@/ $(QUIET_SUBDIR1) + +turbostat x86_energy_perf_policy: FORCE + $(QUIET_SUBDIR0)power/x86/$@/ $(QUIET_SUBDIR1) + +firewire_clean lguest_clean perf_clean slub_clean usb_clean virtio_clean: + $(QUIET_SUBDIR0)$(@:_clean=)/ $(QUIET_SUBDIR1) clean + +cp_clean: + $(QUIET_SUBDIR0)power/cpupower/ $(QUIET_SUBDIR1) clean + +turbostat_clean x86_energy_perf_policy_clean: + $(QUIET_SUBDIR0)power/x86/$(@:_clean=)/ $(QUIET_SUBDIR1) clean + +clean: cp_clean firewire_clean lguest_clean perf_clean slub_clean turbostat_clean \ + usb_clean virtio_clean x86_energy_perf_policy_clean + +.PHONY: FORCE
tools/slub/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +slabinfo: slabinfo.c + +clean: + rm -rf slabinfo
Signature · 1 line
1.7.9.3.362.g71319
PATCH 3/3 tools: Add a help target
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
... and make it the default one so that calling 'make' without arguments in the tools/ directory gives you the possible targets to build along with a short description of what they are.
--- tools/Makefile | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
tools/Makefile +19 -0
@@ -1,5 +1,24 @@ include scripts/Makefile.include +help: + @echo 'Possible targets:' + @echo '' + @echo ' cpupower - a tool for all things x86 CPU power' + @echo ' firewire - the userspace part of nosy, an IEEE-1394 traffic sniffer' + @echo ' lguest - a minimal 32-bit x86 hypervisor' + @echo ' perf - Linux performance measurements tool' + @echo ' slub - slabs reporting tool' + @echo ' turbostat - Intel CPU idle stats and freq reporting tool' + @echo ' usb - USB testing tools' + @echo ' virtio - vhost test module' + @echo ' x86_energy_perf_policy - Intel energy policy tool' + @echo '' + @echo 'Cleaning targets:' + @echo '' + @echo ' all of the above with the "_clean" string appended cleans' + @echo ' the respective build directory.' + @echo ' clean: a summary clean target to clean _all_ folders' + perf firewire lguest slub usb virtio: FORCE $(QUIET_SUBDIR0)$@/ $(QUIET_SUBDIR1)
Signature · 1 line
1.7.9.3.362.g71319
Quoted 10 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Hi all,
here's a refreshed version from yesterday incorporating all comments and suggestions along with a third patch that adds a 'help' target as the default one causing the following below. Btw, Arnaldo, could you please pick those up if there are no complaints since the first patch touches perf and I don't have a clear idea who else to send it to anyway :).
Quoted 3 lines
Thanks.
$ make
Could this also be accessible via 'make tools' in the toplevel Makefile?
I'd love to be able to type:
make -j tools perf install
But ... your current patches are an improvement as well, this list alone:
Quoted 11 lines
$ make Possible targets:cpupower - a tool for all things x86 CPU power firewire - the userspace part of nosy, an IEEE-1394 traffic sniffer lguest - a minimal 32-bit x86 hypervisor perf - Linux performance measurements tool slub - slabs reporting tool turbostat - Intel CPU idle stats and freq reporting tool usb - USB testing tools virtio - vhost test module
Quoted 1 line
x86_energy_perf_policy- Intel energy policy tool
is already pretty useful.
Btw., please fix the perf line to say:
s/performance measurements tool/performance measurement and analysis tool
Thanks,
Ingo
Quoted 6 lines · Ingo Molnar
Could this also be accessible via 'make tools' in the toplevel
Makefile?I'd love to be able to type:
make -j tools perf install
Well,
you could do
$ make -j -C tools perf
which builds perf. I'd need to make it work with the install target too so that when you do
$ make -j -C tools perf install
it knows that you mean the install target of perf. Let me play with it a bit ...
[..]
Quoted 3 lines
Btw., please fix the perf line to say:
s/performance measurements tool/performance measurement and analysis tool
Done,
thanks.
Signature · 8 lines
Regards/Gruss, Boris. Advanced Micro Devices GmbH Einsteinring 24, 85609 Dornach GM: Alberto Bozzo Reg: Dornach, Landkreis Muenchen HRB Nr. 43632 WEEE Registernr: 129 19551
Quoted 14 lines · Borislav Petkov
Quoted 6 lines · Ingo Molnar
Could this also be accessible via 'make tools' in the toplevel
Makefile?I'd love to be able to type:
make -j tools perf install
Well,
you could do
$ make -j -C tools perf
Quoted 7 lines
which builds perf. I'd need to make it work with the install target too so that when you do
$ make -j -C tools perf installit knows that you mean the install target of perf. Let me play with it a bit ...
Yep, we can do that, below is a possible version:
This way you can do
$ make -j -C tools <tool> install
for example. It cannot handle multiple tools yet, i.e.
$ make -j -C tools <tool1> <tool2> install
because it doesn't seem make a whole lot of sense to me right now (besides, make is really clumsy for such stuff :)
help is still the default target when you do
$ make -C tools
with no explicit build target.
Hmm...
--
tools/Makefile +30 -4
@@ -1,5 +1,11 @@ include scripts/Makefile.include +TOOL:=perf + +ifeq ($(findstring install,$(MAKECMDGOALS)), install) + TOOL:=$(filter-out install, $(MAKECMDGOALS)) +endif + help: @echo 'Possible targets:' @echo ''
@@ -13,13 +19,18 @@ help: @echo ' virtio - vhost test module' @echo ' x86_energy_perf_policy - Intel energy policy tool' @echo '' + @echo 'You can do:' + @echo ' $$ make -C tools/ <tool> install' + @echo '' + @echo ' from the kernel command line to build and install one of the tools above' + @echo '' @echo 'Cleaning targets:' @echo '' @echo ' all of the above with the "_clean" string appended cleans' @echo ' the respective build directory.' - @echo ' clean: a summary clean target to clean _all_ folders' + @echo ' cleanall: a summary clean target to clean _all_ folders' -perf firewire lguest slub usb virtio: FORCE +firewire lguest perf slub usb virtio: FORCE $(QUIET_SUBDIR0)$@/ $(QUIET_SUBDIR1) cpupower: FORCE
@@ -28,16 +39,31 @@ cpupower: FORCE turbostat x86_energy_perf_policy: FORCE $(QUIET_SUBDIR0)power/x86/$@/ $(QUIET_SUBDIR1) +install: $(TOOL) +ifeq ($(TOOL),cpupower) + $(MAKE) -C power/$(TOOL) install +else + ifeq ($(TOOL),turbostat) + $(MAKE) -C power/x86/$(TOOL) install + else + ifeq ($(TOOL),x86_energy_perf_policy) + $(MAKE) -C power/x86/$(TOOL) install + else + $(MAKE) -C $(TOOL)/ install + endif + endif +endif + firewire_clean lguest_clean perf_clean slub_clean usb_clean virtio_clean: $(QUIET_SUBDIR0)$(@:_clean=)/ $(QUIET_SUBDIR1) clean -cp_clean: +cpupower_clean: $(QUIET_SUBDIR0)power/cpupower/ $(QUIET_SUBDIR1) clean turbostat_clean x86_energy_perf_policy_clean: $(QUIET_SUBDIR0)power/x86/$(@:_clean=)/ $(QUIET_SUBDIR1) clean -clean: cp_clean firewire_clean lguest_clean perf_clean slub_clean turbostat_clean \ +cleanall: cpupower_clean firewire_clean lguest_clean perf_clean slub_clean turbostat_clean \ usb_clean virtio_clean x86_energy_perf_policy_clean .PHONY: FORCE
Signature · 8 lines
Regards/Gruss, Boris. Advanced Micro Devices GmbH Einsteinring 24, 85609 Dornach GM: Alberto Bozzo Reg: Dornach, Landkreis Muenchen HRB Nr. 43632 WEEE Registernr: 129 19551
Quoted 6 lines · Borislav Petkov
Quoted 5 lines · Ingo Molnar
Could this also be accessible via 'make tools' in the toplevel
Makefile?I'd love to be able to type:
Quoted 7 lines
Quoted 1 line
make -j tools perf install
Well,
you could do
$ make -j -C tools perf
Arguably I could also type:
cd tools/perf; make -j install
:-)
So I just wanted to bring this up, that integrating it into the top level Makefile might make sense. Or not.
Thanks,
Ingo
Quoted 17 lines · Ingo Molnar
Quoted 6 lines · Borislav Petkov
Quoted 5 lines · Ingo Molnar
Could this also be accessible via 'make tools' in the toplevel
Makefile?I'd love to be able to type:
Quoted 7 lines
Quoted 1 line
make -j tools perf install
Well,
you could do
$ make -j -C tools perf
Quoted 8 lines
Arguably I could also type:
cd
tools/perf; make -j install:-)
So I just wanted to bring this up, that integrating it into the top level
Makefilemight make sense. Or not.
Right,
so from dealing with make in the last days, I can say that it's not a fun walk in the park :). The problem is having multiple targets like the following:
$ make -j tools perf install
I have to be able to differentiate in the Makefile which of the targets is a directory ("tools"), which is the actual tool name to build ("perf") and which is a special target ("install") which relates to the tool name coming before it on the command line and is not the "install" target of the main Makefile.
And it becomes nasty very fast if you reorder them
$ make -j install perf tools
where all that sequential info doesn't mean anything anymore.
So, the question is, what we actually want?
$ make -j tools perf install
is pretty cryptic wrt to which target we're actually building and having the -C switch makes stuff a bit clearer IMHO:
$ make -j -C tools perf install
Also, having "install" as the last target means IMO to build the tool before it and then install it.
In the end of the day, probably the most important thing is what is the use case for tools/ which makes most sense. I definitely think the 'help' target is a step in that direction. Being able to do
$ make -C tools
and it give you a short description is pretty helpful.
How about we have:
make tools-<toolname> install
or
make tools/perf install
from the toplevel kernel directory? Would that make more sense from a usability perspective?
Signature · 8 lines
Regards/Gruss, Boris. Advanced Micro Devices GmbH Einsteinring 24, 85609 Dornach GM: Alberto Bozzo Reg: Dornach, Landkreis Muenchen HRB Nr. 43632 WEEE Registernr: 129 19551
Quoted 69 lines · Borislav Petkov
Quoted 17 lines · Ingo Molnar
Quoted 6 lines · Borislav Petkov
Quoted 5 lines · Ingo Molnar
Could this also be accessible via 'make tools' in the toplevel
Makefile?I'd love to be able to type:
Quoted 7 lines
Quoted 1 line
make -j tools perf install
Well,
you could do
$ make -j -C tools perfQuoted 8 lines
Arguably I could also type:
cd
tools/perf; make -j install:-)
So I just wanted to bring this up, that integrating it into the top level
Makefilemight make sense. Or not.Right,
so from dealing with make in the last days, I can say that it's not a fun walk in the park :). The problem is having multiple targets like the following:
$ make -j tools perf installI have to be able to differentiate in the
Makefilewhich of the targets is a directory ("tools"), which is the actual tool name to build ("perf") and which is a special target ("install") which relates to the tool name coming before it on the command line and is not the "install" target of the mainMakefile.And it becomes nasty very fast if you reorder them
$ make -j install perf toolswhere all that sequential info doesn't mean anything anymore.
So, the question is, what we actually want?
$ make -j tools perf installis pretty cryptic wrt to which target we're actually building and having the -C switch makes stuff a bit clearer IMHO:
$ make -j -C tools perf installAlso, having "install" as the last target means IMO to build the tool before it and then install it.
In the end of the day, probably the most important thing is what is the use case for
tools/which makes most sense. I definitely think the 'help' target is a step in that direction. Being able to do$ make -C toolsand it give you a short description is pretty helpful.
How about we have:
Quoted 8 lines
make tools-<toolname> install
or
make
tools/perfinstallfrom the toplevel kernel directory? Would that make more sense from a usability perspective?
I have no strong preference currently. I think since it affects kbuild it would be nice to know the opinion of the kbuild folks (Cc:-ed): how should the integration of tools/ proceed?
Thanks,
Ingo
Quoted 76 lines · Ingo Molnar
Quoted 73 lines · Borislav Petkov
Quoted 17 lines · Ingo Molnar
Quoted 6 lines · Borislav Petkov
Quoted 5 lines · Ingo Molnar
Could this also be accessible via 'make tools' in the toplevel
Makefile?I'd love to be able to type:
Quoted 7 lines
Quoted 1 line
make -j tools perf install
Well,
you could do
$ make -j -C tools perfQuoted 8 lines
Arguably I could also type:
cd
tools/perf; make -j install:-)
So I just wanted to bring this up, that integrating it into the top level
Makefilemight make sense. Or not.Right,
so from dealing with make in the last days, I can say that it's not a fun walk in the park :). The problem is having multiple targets like the following:
$ make -j tools perf installI have to be able to differentiate in the
Makefilewhich of the targets is a directory ("tools"), which is the actual tool name to build ("perf") and which is a special target ("install") which relates to the tool name coming before it on the command line and is not the "install" target of the mainMakefile.And it becomes nasty very fast if you reorder them
$ make -j install perf toolswhere all that sequential info doesn't mean anything anymore.
So, the question is, what we actually want?
$ make -j tools perf installis pretty cryptic wrt to which target we're actually building and having the -C switch makes stuff a bit clearer IMHO:
$ make -j -C tools perf installAlso, having "install" as the last target means IMO to build the tool before it and then install it.
In the end of the day, probably the most important thing is what is the use case for
tools/which makes most sense. I definitely think the 'help' target is a step in that direction. Being able to do$ make -C toolsand it give you a short description is pretty helpful.
How about we have:
make tools-<toolname> install
or
Quoted 8 lines
Quoted 4 lines
make
tools/perfinstallfrom the toplevel kernel directory? Would that make more sense from a usability perspective?
I have no strong preference currently. I think since it affects kbuild it would be nice to know the opinion of the kbuild folks (Cc:-ed): how should the integration of
tools/proceed?
Btw,
I'm currently thinking I want to give the make tools/{perf,help,...} approach a try because it is clear that it is a subdir of the kernel src tree and it probably could support all the targets we thought about.
Let me play around with it a bit...
Signature · 8 lines
Regards/Gruss, Boris. Advanced Micro Devices GmbH Einsteinring 24, 85609 Dornach GM: Alberto Bozzo Reg: Dornach, Landkreis Muenchen HRB Nr. 43632 WEEE Registernr: 129 19551
Quoted 5 lines · Borislav Petkov
I'm currently thinking I want to give the make
tools/{perf,help,...}approach a try because it is clear that it is a subdir of the kernel src tree and it probably could support all the targets we thought about.Let me play around with it a bit...
Yeah, nasty. I've almost got it to build a tool when doing
$ make tools/<toolname>
but it fails on all the targets which have implicit build rules. (It seems to build perf fine though because perf Makefile doesn't have implicit rules for %.c -> %.o etc). And I can see that implicit rules are being cleared in the toplevel kernel Makefile so that they don't kick in.
At this moment, I'm open for hints from the kbuild people, if we use the toplevel Makefile to build tools/, should all the tools' Makefiles have explicit rules or ...? Any suggestions are appreciated.
Thanks.
Signature · 8 lines
Regards/Gruss, Boris. Advanced Micro Devices GmbH Einsteinring 24, 85609 Dornach GM: Alberto Bozzo Reg: Dornach, Landkreis Muenchen HRB Nr. 43632 WEEE Registernr: 129 19551
Quoted 17 lines · Borislav Petkov
Quoted 5 lines · Borislav Petkov
I'm currently thinking I want to give the make
tools/{perf,help,...}approach a try because it is clear that it is a subdir of the kernel src tree and it probably could support all the targets we thought about.Let me play around with it a bit...
Yeah, nasty. I've almost got it to build a tool when doing
$ make tools/<toolname>but it fails on all the targets which have implicit build rules. (It seems to build perf fine though because perf
Makefiledoesn't have implicit rules for %.c -> %.o etc). And I can see that implicit rules are being cleared in the toplevel kernelMakefileso that they don't kick in.
Quoted 3 lines
At this moment, I'm open for hints from the kbuild people, if we use the toplevel
Makefileto buildtools/, should all the tools' Makefiles have explicit rules or ...? Any suggestions are appreciated.
Ok, I got it:
when make is run from the toplevel kernel Makefile, MAKEFLAGS contains '--no-print-directory -RrI /home/boris/kernel/linux-2.6' which is passed down to the sub-make and the '-r' especially turns off the use of built-in implicit rules, thus the problem. Clearing MAKEFLAGS in the sub-make fixes the issue, sorry for the noise.
Signature · 8 lines
Regards/Gruss, Boris. Advanced Micro Devices GmbH Einsteinring 24, 85609 Dornach GM: Alberto Bozzo Reg: Dornach, Landkreis Muenchen HRB Nr. 43632 WEEE Registernr: 129 19551