diff mbox series

[v3,5/6] build: add a common-clean target

Message ID 1592813672-If0b4368e847a16595115731f5341cfd34714b387@changeid
State Superseded
Headers show
Series [v3,1/6] hs20: server: add a .gitignore file | expand

Commit Message

Johannes Berg June 22, 2020, 8:14 a.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

Clean up in a more common fashion as well, initially for ../src/.

Also add $(Q) to the clean target in src/

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 eap_example/Makefile    | 5 ++---
 hostapd/Makefile        | 5 ++---
 hs20/client/Makefile    | 4 ++--
 hs20/server/Makefile    | 4 ++--
 radius_example/Makefile | 5 ++---
 src/Makefile            | 4 ++--
 src/build.rules         | 8 ++++++++
 tests/Makefile          | 5 ++---
 wlantest/Makefile       | 5 ++---
 wpa_supplicant/Makefile | 4 ++--
 10 files changed, 26 insertions(+), 23 deletions(-)
diff mbox series

Patch

diff --git a/eap_example/Makefile b/eap_example/Makefile
index e5f3b3471035..ecef3c97662b 100644
--- a/eap_example/Makefile
+++ b/eap_example/Makefile
@@ -116,8 +116,7 @@  endif
 eap_example: $(OBJS_ex) $(LIBEAP)
 	$(LDO) $(LDFLAGS) -o eap_example $(OBJS_ex) -L. -leap $(LIBS)
 
-clean:
-	$(MAKE) -C ../src clean
-	rm -f core *~ *.o *.d libeap.a libeap.so $(ALL)
+clean: common-clean
+	rm -f core *~ *.o *.d libeap.a libeap.so
 
 -include $(OBJS:%.o=%.d)
diff --git a/hostapd/Makefile b/hostapd/Makefile
index 5c830fb448b1..2e15c8911483 100644
--- a/hostapd/Makefile
+++ b/hostapd/Makefile
@@ -1362,9 +1362,8 @@  lcov-html:
 	lcov -c -d .. > lcov.info
 	genhtml lcov.info --output-directory lcov-html
 
-clean:
-	$(MAKE) -C ../src clean
-	rm -f core *~ *.o hostapd hostapd_cli nt_password_hash hlr_auc_gw
+clean: common-clean
+	rm -f core *~ *.o nt_password_hash hlr_auc_gw
 	rm -f sae_pk_gen
 	rm -f *.d *.gcno *.gcda *.gcov
 	rm -f lcov.info
diff --git a/hs20/client/Makefile b/hs20/client/Makefile
index 70fb73598dfe..cbb1105e186b 100644
--- a/hs20/client/Makefile
+++ b/hs20/client/Makefile
@@ -75,8 +75,8 @@  hs20-osu-client: $(OBJS)
 	$(Q)$(LDO) $(LDFLAGS) -o hs20-osu-client $(OBJS) $(LIBS)
 	@$(E) "  LD " $@
 
-clean:
-	rm -f core *~ *.o *.d hs20-osu-client
+clean: common-clean
+	rm -f core *~ *.o *.d
 	rm -f ../../src/utils/*.o
 	rm -f ../../src/utils/*.d
 	rm -f ../../src/common/*.o
diff --git a/hs20/server/Makefile b/hs20/server/Makefile
index 9ec7e4491ad4..24b81cd8a28a 100644
--- a/hs20/server/Makefile
+++ b/hs20/server/Makefile
@@ -36,8 +36,8 @@  OBJS += ../../src/utils/xml_libxml2.o
 hs20_spp_server: $(OBJS)
 	$(LDO) $(LDFLAGS) -o hs20_spp_server $(OBJS) $(LIBS)
 
-clean:
-	rm -f core *~ *.o *.d hs20_spp_server
+clean: common-clean
+	rm -f core *~ *.o *.d
 	rm -f ../../src/utils/*.o
 	rm -f ../../src/utils/*.d
 	rm -f ../../src/crypto/*.o
diff --git a/radius_example/Makefile b/radius_example/Makefile
index 75cb3caeb3dd..3492ac70fc49 100644
--- a/radius_example/Makefile
+++ b/radius_example/Makefile
@@ -27,8 +27,7 @@  OBJS_ex = radius_example.o
 radius_example: $(OBJS_ex) $(LIBS)
 	$(LDO) $(LDFLAGS) -o radius_example $(OBJS_ex) $(LIBS) $(LLIBS)
 
-clean:
-	$(MAKE) -C ../src clean
-	rm -f core *~ *.o *.d $(ALL)
+clean: common-clean
+	rm -f core *~ *.o *.d
 
 -include $(OBJS:%.o=%.d)
diff --git a/src/Makefile b/src/Makefile
index c9e84c11de7a..6eb7f2acb5a1 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -5,8 +5,8 @@  all:
 	for d in $(SUBDIRS); do [ -d $$d ] && $(MAKE) -C $$d; done
 
 clean:
-	for d in $(SUBDIRS); do [ -d $$d ] && $(MAKE) -C $$d clean; done
-	rm -f *~
+	$(Q)for d in $(SUBDIRS); do [ -d $$d ] && $(MAKE) -C $$d clean; done
+	$(Q)rm -f *~
 
 install:
 	for d in $(SUBDIRS); do [ -d $$d ] && $(MAKE) -C $$d install; done
diff --git a/src/build.rules b/src/build.rules
index d6861a671306..e70a0aa2cda7 100644
--- a/src/build.rules
+++ b/src/build.rules
@@ -3,6 +3,9 @@  all: $(VERIFY) $(ALL) $(EXTRA_TARGETS)
 # disable built-in rules
 .SUFFIXES:
 
+ROOTDIR := $(dir $(lastword $(MAKEFILE_LIST)))
+ROOTDIR := $(dir $(ROOTDIR:%/=%))
+
 ifndef CC
 CC=gcc
 endif
@@ -43,3 +46,8 @@  else
 	$(Q)$(CC) -c -o $@ $(CFLAGS) $<
 	@$(E) "  CC " $<
 endif
+
+.PHONY: common-clean
+common-clean:
+	$(Q)$(MAKE) -C $(ROOTDIR)/src clean
+	$(Q)rm -f $(ALL)
diff --git a/tests/Makefile b/tests/Makefile
index 119ed7a2ae90..4d9f2e0ab8c1 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -151,9 +151,8 @@  run-tests: $(ALL)
 	@echo
 	@echo All tests completed successfully.
 
-clean:
-	$(MAKE) -C ../src clean
-	rm -f $(ALL) *~ *.o *.d
+clean: common-clean
+	rm -f *~ *.o *.d
 	rm -f test-eapol
 	rm -f test-https
 	rm -f test-json
diff --git a/wlantest/Makefile b/wlantest/Makefile
index 0324fa54855e..fee80f6f4e2c 100644
--- a/wlantest/Makefile
+++ b/wlantest/Makefile
@@ -81,8 +81,7 @@  wlantest_cli: $(OBJS_cli) $(OWN_LIBS)
 test_vectors: $(TOBJS) $(OWN_LIBS)
 	$(LDO) $(LDFLAGS) -o test_vectors $(TOBJS) $(OWN_LIBS) $(LIBS)
 
-clean:
-	$(MAKE) -C ../src clean
-	rm -f core *~ *.o *.d $(ALL)
+clean: common-clean
+	rm -f core *~ *.o *.d
 
 -include $(OBJS:%.o=%.d)
diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile
index be3dad3c8a9c..f34379c5e2f6 100644
--- a/wpa_supplicant/Makefile
+++ b/wpa_supplicant/Makefile
@@ -2003,11 +2003,11 @@  lcov-html: wpa_supplicant.gcda
 	lcov -c -d .. > lcov.info
 	genhtml lcov.info --output-directory lcov-html
 
-clean:
+clean: common-clean
 	$(MAKE) -C ../src clean
 	$(MAKE) -C dbus clean
 	rm -f core *~ *.o *.d *.gcno *.gcda *.gcov
-	rm -f eap_*.so $(ALL) $(WINALL) eapol_test preauth_test
+	rm -f eap_*.so $(WINALL) eapol_test preauth_test
 	rm -f wpa_priv
 	rm -f nfc_pw_token
 	rm -f lcov.info