diff --git a/Makefile b/Makefile index c4dc80c1f3..291197bc2a 100644 --- a/Makefile +++ b/Makefile @@ -187,7 +187,6 @@ uninstall-data: clean:: $(RM) $(ALLPROGS) $(RM) $(CLEANSUFFIXES) - $(RM) $(TOOLS) $(RM) $(CLEANSUFFIXES:%=tools/%) distclean:: diff --git a/common.mak b/common.mak index c4d299960e..5d80986aab 100644 --- a/common.mak +++ b/common.mak @@ -53,7 +53,13 @@ CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver DISTCLEANSUFFIXES = *.pc LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a +define RULES clean:: $(RM) $(OBJS) $(OBJS:.o=.d) + $(RM) $(HOSTPROGS) + $(RM) $(TOOLS) +endef + +$(eval $(RULES)) -include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d)) diff --git a/library.mak b/library.mak index 9309c42e5d..3b4bd2d161 100644 --- a/library.mak +++ b/library.mak @@ -58,7 +58,7 @@ $(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver $(DEP_LIBS) clean:: $(RM) $(addprefix $(SUBDIR),*-example$(EXESUF) *-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \ - $(CLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%) $(HOSTOBJS) $(HOSTPROGS) + $(CLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%) distclean:: clean $(RM) $(DISTCLEANSUFFIXES:%=$(SUBDIR)%) $(DISTCLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%)