kbuild: better cleaning Let make clean delete generated dot-files and .o files. Introduce distclean/mrproper that deletes .config, linux symlink and all files left behind by editors and patch. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- Hi Peter In following patch I did not make a difference between mrproper and distclean. I only added mrproper because I'm used to it from the kernel. Also I did not put in .hg directory, SCCS and others. I doubt people use it for klibc anyway, but it easy to ignore these too. I recall I tested make clean and I cannot see how I have missed all the *.o files. Maybe cogito played me a trick? Anyway I learned to use git ls-files --others Sam diff --git a/Makefile b/Makefile index 8c500e3..db9b8ac 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ export KLIBCSRC := klibc export KLIBCINC := include export KLIBCOBJ := klibc export KLIBCKERNELSRC := linux/ +include scripts/Kbuild.include export CC := gcc NOSTDINC_FLAGS := -nostdlib -nostdinc -isystem $(shell $(CC) -print-file-name=include) @@ -89,8 +90,29 @@ klibc: test: klibc $(Q)$(MAKE) $(klibc)=klibc/tests +### +# clean: remove generated files +# mrproper does a full cleaning including .config and linux symlink +FIND_IGNORE := \( -name .git \) -prune -o +quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),RM $(wildcard $(rm-files))) + cmd_rmfiles = rm -f $(rm-files) clean: $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.clean obj=. + $(Q)find . $(FIND_IGNORE) \ + \( -name *.o -o -name *.a -o -name '.*.cmd' -o \ + -name '.*.d' -o -name '.*.tmp' \) \ + -type f -print | xargs rm -f + +rm-files := .config linux +distclean mrproper: clean + $(Q)find . $(FIND_IGNORE) \ + \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ + -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ + -o -name '.*.rej' -o -size 0 \ + -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \ + -type f -print | xargs rm -f + $(call cmd,rmfiles) + install: all $(Q)$(MAKE) -f $(srctree)/scripts/Kbuild.install obj=. diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean