Add a Xen build target to count the lines of code of the source files built. Uses `cloc' to do the job.
Generate the list of source files from the %.o targets, append output to "sourcelist". Remove sourcelist on clean, and also at the beginning of the build target to avoid appending to sourcelist on consequence builds. Otherwise one could imagine sourcelist could become large if the user builds Xen repeatedly without calling clean. For the cloc target, first clean, then build to make sure all files are properly accounted (no partial builds). Signed-off-by: Stefano Stabellini <[email protected]> CC: [email protected] CC: [email protected] --- xen/Makefile | 14 ++++++++++++-- xen/Rules.mk | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/xen/Makefile b/xen/Makefile index 62d479c..f53fd22 100644 --- a/xen/Makefile +++ b/xen/Makefile @@ -48,7 +48,7 @@ else endif .PHONY: _build -_build: $(TARGET)$(CONFIG_XEN_INSTALL_SUFFIX) +_build: clean-sourcelist $(TARGET)$(CONFIG_XEN_INSTALL_SUFFIX) .PHONY: _install _install: D=$(DESTDIR) @@ -108,7 +108,7 @@ _debug: $(OBJDUMP) -D -S $(TARGET)-syms > $(TARGET).s .PHONY: _clean -_clean: delete-unfresh-files +_clean: delete-unfresh-files clean-sourcelist $(MAKE) -C tools clean $(MAKE) -f $(BASEDIR)/Rules.mk -C include clean $(MAKE) -f $(BASEDIR)/Rules.mk -C common clean @@ -267,3 +267,13 @@ $(KCONFIG_CONFIG): include/config/auto.conf.cmd: ; -include $(BASEDIR)/include/config/auto.conf.cmd + +.PHONY: cloc +cloc: $(BASEDIR)/sourcelist + cloc --list-file=$(BASEDIR)/sourcelist + +$(BASEDIR)/sourcelist: clean build + +.PHONY: clean-sourcelist +clean-sourcelist: + rm -f $(BASEDIR)/sourcelist diff --git a/xen/Rules.mk b/xen/Rules.mk index 5337e20..cb48aa7 100644 --- a/xen/Rules.mk +++ b/xen/Rules.mk @@ -190,9 +190,11 @@ _clean_%/: FORCE $(MAKE) -f $(BASEDIR)/Rules.mk -C $* clean %.o: %.c Makefile + echo `pwd`/$< >> $(BASEDIR)/sourcelist $(CC) $(CFLAGS) -c $< -o $@ %.o: %.S Makefile + echo `pwd`/$< >> $(BASEDIR)/sourcelist $(CC) $(AFLAGS) -c $< -o $@ SPECIAL_DATA_SECTIONS := rodata $(foreach a,1 2 4 8 16, \ -- 1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
