[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Disabling a makefile template quickly

From: Johan Bezem
Subject: Re: Disabling a makefile template quickly
Date: Sun, 17 Oct 2004 14:51:49 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)

I have a similar structure, using recursive make-calls. In my structure, make 
finds all the directories it needs to traverse by scanning for a file called 
'Makefile' in all its subdirectories, like
# List_dirs will contain a space delimited list of all directories
# containing any makefile. $(sort is used to cover the
# case where multiple makefiles are present in one directory.
# Since $(sort removes duplicates...
list_dirs := $(sort $(dir $(wildcard $(YT_SRCVPATH)/*/Makefile 
$(YT_SRCVPATH)/*/makefile $(YT_SRCVPATH)/*/GNUmakefile)))
list_dirs := $(patsubst $(YT_SRCVPATH)/%,%,$(list_dirs))
(The second line removes all but the last path component)
Now, if this is the way the main makefile (MakeTemplate.exe in your case) 
discovers where to recurse to, the next step will filter-out any directories 
indicated in a special variable YT_EXCL_DIRS (the YT_ in my variable names is 
just to avoid any possible name clashes):
 # If YT_EXCL_DIRS contains any directory names (with an appended slash!),
 # these directories are excluded from the recursive make. The value can
 # be set in the immediate makefile of the parent directory (recommended),
 # or, if necessary, from the root. However, in the last situation, calling
 # make from a subdirectory will NOT exclude the directories!
 list_dirs := $(filter-out $(YT_EXCL_DIRS),$(list_dirs))
Next I call all directory names as well as the special target 'RECURSE' "PHONY":
 # We define RECURSE as PHONY here, so we don't need to specify it in
 # case we don't need recursion anymore (the else-clause for the following
 # ifneq). The directories are to be phony, in order to execute the
 # recursion commands for all directories in all cases.
 .PHONY: RECURSE $(list_dirs)
If list_dirss is not empty...
 ifneq ($(strip $(list_dirs)),)
   # If list_dirs is not empty, we define everything necessary for
   # recursively going through the subdirs. RECURSE and the directories
   # are PHONY, in order to execute all rules in any case.

   # The RECURSE target can be used as a dependency for all targets
   # that need to be made recursively. Put it as the first dependency
   # for a depth-first usage.
   RECURSE: $(list_dirs)

\t # Call make recursively for each directory \t address@hidden(MAKE) --directory=$@ -f $@/Makefile --no-print-directory $(MAKECMDGOALS)

BEWARE: I have removed several commands and make-options not relevant to the 
issues discussed here, and not tested the above commands. Use it as indication, 
but verify for your case.

Now, you just define the variable YT_EXCL_DIRS to contain a list with 
directories to be skipped (attach the trailing slash for each), and the 
recursion mechanism will skip those directories.

I'm not quite sure that this solution will work for you as is, but maybe you 
can adapt it to your needs.



Alexander Farber wrote:
Sometimes I have to disable some of the MakeTemplates,
for example don't build the .exe type above. I wonder, if there is a nice way to do that?
So I wonder if there is some nice trick, some variable or
special rule, which I could set or uncomment in the MakeTemplate?
JB Enterprises - Johan Bezem         Tel:   +49 172 5463210
Software Architect - Project Manager Fax:   +49 172 50 5463210
Realtime / Embedded Consultant       Email: address@hidden
Design - Development - Test - QA     Web:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]