From 924ecd85c70ec4f5496068209f7a1b74cc25b0e7 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Fri, 20 Jul 2012 17:37:36 +0200
Subject: [PATCH] Change how we create the 'ganeti' symlink

Currently, if one runs 'make' in an already fully-built tree, this is
the result:

  cd . && test -h "ganeti" || { rm -f ganeti && ln -s lib ganeti; }
  make  all-am
  make[1]: Entering directory `/tmp/test'
  cd . && test -h "ganeti" || { rm -f ganeti && ln -s lib ganeti; }
  make[1]: Leaving directory `/tmp/test'

This is because commit dc7d2c49 added 'ganeti' (which is a PHONY
target) to BUILT_SOURCES, and since that is a dependency of other,
real targets, it means the ganeti target is always remade.

To fix this, we keep ganeti as a PHONY target, but we remove it from
the 'built_base_sources' target, and instead we only remake it
manually in the stamp-directories target. A make run now is just:

  make  all-am
  make[1]: Entering directory `/tmp/test'
  make[1]: Nothing to be done for `all-am'.
  make[1]: Leaving directory `/tmp/test'

Note that we can't get rid of the all-am since we use BUILT_SOURCES.

We also remove the comment of BUILT_SOURCES since it no longer depends
on PHONY targets.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 Makefile.am | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 3c95893f3..3d4c03653 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -158,15 +158,12 @@ CLEANFILES = \
 	.hpc/*.mix htools/*.tix \
 	doc/hs-lint.html
 
-# BUILT_SOURCES should only be used as a dependency on phony
-# targets. Otherwise it'll cause the target to rebuild every time.
 BUILT_SOURCES = \
 	$(built_base_sources) \
 	$(BUILT_PYTHON_SOURCES) \
 	$(PYTHON_BOOTSTRAP)
 
 built_base_sources = \
-	ganeti \
 	stamp-directories \
 	stamp-srclinks
 
@@ -1250,6 +1247,7 @@ $(HS_BUILT_TEST_HELPERS): Makefile
 	chmod u+x $@
 
 stamp-directories: Makefile
+	$(MAKE) $(AM_MAKEFLAGS) ganeti
 	@mkdir_p@ $(DIRS) $(BUILDTIME_DIR_AUTOCREATE)
 	touch $@
 
-- 
GitLab