[PATCH 4/4] tools: Connect to the kernel build system

From: Borislav Petkov
Date: Thu Mar 29 2012 - 08:26:40 EST


From: Borislav Petkov <borislav.petkov@xxxxxxx>

Now you can do

$ make tools/<toolname>

from the toplevel kernel directory and have the respective tool built.

If you want to build and install it, do

$ make tools/<toolname> tinstall

The install target is called "tinstall" so that there's no conflict with
the main kernel install target and should mean "tool install".

$ make tools/ <toolname>_clean

should clean the respective tool directories.

If you want to clean all in tools, simply do

$ make tools/ cleanall

Also, if you want to get what the possible targets are, simply calling

$ make tools/

should give you the short help.

Signed-off-by: Borislav Petkov <borislav.petkov@xxxxxxx>
---
Makefile | 11 +++++++++++
tools/Makefile | 31 +++++++++++++++++++++++++++----
2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 1932984478c1..9e85648dd745 100644
--- a/Makefile
+++ b/Makefile
@@ -1468,6 +1468,17 @@ kernelrelease:
kernelversion:
@echo $(KERNELVERSION)

+# empty targets used in tools/Makefile, defined here to suppress error message
+tinstall:
+cleanall:
+
+# Clear a bunch of variables before executing the submake
+tools/: FORCE
+ $(Q)$(MAKE) LDFLAGS= TOOL=help -C tools/ $(patsubst tools/%,%,$(MAKECMDGOALS))
+
+tools/%: FORCE
+ $(Q)$(MAKE) LDFLAGS= MAKEFLAGS= TOOL=$* -C $(src)/tools/ $(patsubst tools/%,%,$(MAKECMDGOALS))
+
# Single targets
# ---------------------------------------------------------------------------
# Single targets are compatible with:
diff --git a/tools/Makefile b/tools/Makefile
index 25566cd74937..dcc86b42021b 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -1,5 +1,7 @@
include scripts/Makefile.include

+default: $(TOOL)
+
help:
@echo 'Possible targets:'
@echo ''
@@ -13,13 +15,19 @@ 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> tinstall'
+ @echo ''
+ @echo ' from the kernel command line to build and install one of'
+ @echo ' 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 mytest: FORCE
$(QUIET_SUBDIR0)$@/ $(QUIET_SUBDIR1)

cpupower: FORCE
@@ -28,16 +36,31 @@ cpupower: FORCE
turbostat x86_energy_perf_policy: FORCE
$(QUIET_SUBDIR0)power/x86/$@/ $(QUIET_SUBDIR1)

+tinstall: $(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
--
1.7.9.3.362.g71319

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/