Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -526,17 +526,31 @@ endif

# These rules clean things up. 'modclean' cleans files generated by 'modules'
# (except that it doesn't remove the modules that were copied to rtlib)
# 'clean' cleans everything but dependency files, and 'depclean' cleans them
# too.
# 'clean' removes the build products (including, via 'objects', the
# dependency files), and 'depclean' removes the dependency files alone.
modclean:
find -name '.*.cmd' -or -name '*.ko' -or -name '*.mod.c' -or -name '*.mod.o' | xargs rm -f
-rm -rf .tmp_versions
find . -name .tmp_versions |xargs rm -rf
-rm -f ../rtlib/*.ko
-rm -f ../rtlib/*.so

# Dependency files land in two places: 'depends' for realtime under
# BUILD_SYS=normal, and beside their objects as objects/**/*.d for
# everything else, realtime included under BUILD_SYS=uspace, where
# 'depends' is never created at all. Both have to go. Dropping them
# forces no recompilation (nothing depends on a .d existing), but it does
# clear stale prerequisites -- a dependency file naming a source that has
# since been renamed or moved otherwise aborts the build with "No rule to
# make target", and there is no way out of that short of a full
# 'make clean'.
# This is a find rather than '$(RM) $(DEPS) $(RTDEPS)' because the files
# that break the build are precisely the ones whose source no longer
# exists, so they are absent from $(DEPS); and $(DEPS) is only defined
# when TRIVIAL_BUILD=no. The pure-make form would not fix the bug.
depclean:
-rm -rf depends
-find objects -name '*.d' -print0 2>/dev/null | xargs -0 -r rm -f

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth saying in the comment why this is a find and not $(RM) $(DEPS) $(RTDEPS), because the pure-make form is the obvious suggestion and it would not fix the bug: the files that break the build are exactly the ones whose source no longer exists, so they are absent from $(DEPS). DEPS is also only defined when TRIVIAL_BUILD=no. One clause here saves a review round.


clean: genclean depclean modclean
genclean:
Expand Down