diff mbox

[OpenWrt-Devel] Makefile: move cleaning of staging_dir/target* to clean instead of dirclean

Message ID 5560AD13.7050907@iki.fi
State Accepted
Headers show

Commit Message

Hannu Nyman May 23, 2015, 4:38 p.m. UTC
Makefile: move the cleaning of staging_dir/target* from dirclean to clean

Currently "make clean" only clears the build_dir/target*, but leaves 
staging_dir/target* intact. "make clean" should also clean the 
staging_dir/target* directories, as in the current situation some old 
packages or libraries may be linked into the firmware from staging_dir 
despite a "make clean".

The patch reorganises clean / dirclean functionality so that
* "make clean" also clears the staging_dir/target* in addition to 
build_dir/target*.
* "make dirclean" clears toolchain and host(=tools) directories from both 
build_dir and staging_dir

signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
---
This patch is continuation to r45736.  ( 
https://dev.openwrt.org/changeset/45736 )

The behaviour, where "make clean" does not clear staging_dir/target* can 
leave into problems when some package version gets bumped and some filenames 
change etc. It is possible that duplicated binaries can be found in 
staging_dir despite the user having run "make clean".

I have been burned by that in the past few months, but luckily both jow and 
arokh have pointed me to right direction.

Below are the directory definitions clarifying the variables and also an 
example that shows how staging_dir/target* contains quite many files after a 
make clean.

Directory definitions:
https://dev.openwrt.org/browser/trunk/rules.mk

BUILD_DIR_BASE:=$(TOPDIR)/build_dir

BUILD_DIR:=$(BUILD_DIR_BASE)/$(TARGET_DIR_NAME)
STAGING_DIR:=$(TOPDIR)/staging_dir/$(TARGET_DIR_NAME)

STAGING_DIR_HOST:=$(TOPDIR)/staging_dir/host
TOOLCHAIN_DIR:=$(TOPDIR)/staging_dir/$(TOOLCHAIN_DIR_NAME)
BUILD_DIR_HOST:=$(BUILD_DIR_BASE)/host
BUILD_DIR_TOOLCHAIN:=$(BUILD_DIR_BASE)/$(TOOLCHAIN_DIR_NAME)


Example:
********

perus@vb1504:/Openwrt/trunk$ make clean
  make[1] clean

perus@vb1504:/Openwrt/trunk$ ls build_dir/
host
toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2

perus@vb1504:/Openwrt/trunk$ ls staging_dir/
host
target-mips_34kc_uClibc-0.9.33.2
toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2

perus@vb1504:/Openwrt/trunk$ du -d1 staging_dir/target-mips_34kc_uClibc-0.9.33.2/
1604    staging_dir/target-mips_34kc_uClibc-0.9.33.2/pkginfo
26432    staging_dir/target-mips_34kc_uClibc-0.9.33.2/usr
4    staging_dir/target-mips_34kc_uClibc-0.9.33.2/include
180    staging_dir/target-mips_34kc_uClibc-0.9.33.2/packages
2396    staging_dir/target-mips_34kc_uClibc-0.9.33.2/host
4    staging_dir/target-mips_34kc_uClibc-0.9.33.2/bin
4    staging_dir/target-mips_34kc_uClibc-0.9.33.2/stamp
51688    staging_dir/target-mips_34kc_uClibc-0.9.33.2/root-ar71xx
4    staging_dir/target-mips_34kc_uClibc-0.9.33.2/lib
82320    staging_dir/target-mips_34kc_uClibc-0.9.33.2/
diff mbox

Patch

Index: Makefile
===================================================================
--- Makefile	(revision 45741)
+++ Makefile	(working copy)
@@ -50,10 +50,10 @@ 
 prepare: $(target/stamp-compile)
 
 clean: FORCE
-	rm -rf $(BUILD_DIR) $(BIN_DIR) $(BUILD_LOG_DIR)
+	rm -rf $(BUILD_DIR) $(STAGING_DIR) $(BIN_DIR) $(BUILD_LOG_DIR)
 
 dirclean: clean
-	rm -rf $(STAGING_DIR) $(STAGING_DIR_HOST) $(TOOLCHAIN_DIR) $(BUILD_DIR_HOST) $(BUILD_DIR_TOOLCHAIN)
+	rm -rf $(STAGING_DIR_HOST) $(TOOLCHAIN_DIR) $(BUILD_DIR_HOST) $(BUILD_DIR_TOOLCHAIN)
 	rm -rf $(TMP_DIR)
 
 ifndef DUMP_TARGET_DB