aostruszka / nonrec-make

Non-recursive make template for GNU make

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

make dist_clean and custom OBJDIRs

xulfir opened this issue · comments

Hi Andrzej,
I've noticed that if I specialize OBJDIR by adding another sub directory, the obj directory will no longer be removed when I run make dist_clean. I've got a proposed solution below, if you are interested.

Other than that, this project has been working very nicely for me. Thanks, again for sharing!
Xulfir

diff --git a/mk/footer.mk b/mk/footer.mk
index ec25b8a..f95a1b8 100644
--- a/mk/footer.mk
+++ b/mk/footer.mk
@@ -38,7 +38,7 @@ dist_clean :: $(OBJPATH)/.fake_file
 else
 dist_clean :: $(OBJPATH)/.fake_file clean_extra_$(d)
 endif
-       rm -rf $(<D)
+       rm -rf $(subst $(OBJDIR),$(OBJBASE),$(<D))

 #### Per directory targets ####

diff --git a/mk/skel.mk b/mk/skel.mk
index f7305c2..900533b 100644
--- a/mk/skel.mk
+++ b/mk/skel.mk
@@ -93,8 +93,10 @@ AUTO_TGTS := %.o

 # Where to put the compiled objects.  You can e.g. make it different
 # depending on the target platform (e.g. for cross-compilation a good
-# choice would be OBJDIR := obj/$(HOST_ARCH)) or debugging being on/off.
-OBJDIR := obj
+# choice would be OBJDIR := $(OBJBASE)/$(HOST_ARCH)) or debugging being
+# on/off.
+OBJBASE := obj
+OBJDIR := $(OBJBASE)
 OBJPATH = $(d)/$(OBJDIR)

Xulfir

Thanks for pointing to this. Right now I'm not able to look at it closer but I'll take care of this when I'll get back home (I'm having week off :D)

Best regards
Andrzej

Xulfir

Thanks again for pointing to this (and providing proposal). However your proposal has some drawbacks:

  1. It relies on the unnecessary dependency on .fake_file - this was causing creation of OBJDIR with .fake_file (if it was not present) in order to just moment later to remove it :). Now that I've realized this I want to remove this dependency.
  2. It introduces another user parameter - and I'd like to minimize them as much as I can without limiting functionality in order to simplify usage.

So I've fixed this in a bit different way under c323b16 and I'm closing this issue.

Best regards
Andrzej

Interesting solution. Thanks, Andrzej!