Makefile: make it work for auto-completion
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Jun 04 17:43:49 2011 +0200 (2011-06-04)
changeset 2505f87f02b00cc7
parent 2504 3fc114996b20
child 2506 2ab553e37517
Makefile: make it work for auto-completion

The latest autocompletion calls 'make -qp' to get all the possible
targets. This currently fails, as our makefile is calling itself
again and again ad-libitum.

Fix it by detecting that the recursion level is not 0, and bail out
if so. It works so well that it has the side effect of showing only
the 'public' target, and hide our internal ones! :-)

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Makefile.in
     1.1 --- a/Makefile.in	Sat Jun 04 17:15:58 2011 +0200
     1.2 +++ b/Makefile.in	Sat Jun 04 17:43:49 2011 +0200
     1.3 @@ -88,6 +88,17 @@
     1.4  # See top of file for an explanation of why this is needed...
     1.5  ifneq ($(strip $(CT_MAKEFLAGS)),)
     1.6  
     1.7 +# Somehow, the new auto-completion for make in the recent distributions
     1.8 +# trigger a behavior where our Makefile calls itself recursively, in a
     1.9 +# never-ending loop (except on lack of ressources, swap, PIDs...)
    1.10 +# Avoid this situation by cutting the recursion short at the first
    1.11 +# level.
    1.12 +# This has the side effect of only showing the real targets, and hiding our
    1.13 +# internal ones. :-)
    1.14 +ifneq ($(MAKELEVEL),0)
    1.15 +$(error Recursion detected, bailing out...)
    1.16 +endif
    1.17 +
    1.18  MAKEFLAGS += $(CT_MAKEFLAGS)
    1.19  build install clean distclean uninstall:
    1.20  	@$(MAKE) $@