File:  [EPICS Repository] / base / configure / RULES_DIRS
Revision 1.19: download - view: text, annotated - select for diffs
Fri Apr 24 09:01:02 2009 UTC (8 years, 7 months ago) by lange
Branches: MAIN
CVS tags: HEAD
3.14 synch (changed comment on GNU make version)

#*************************************************************************
# Copyright (c) 2006 UChicago Argonne LLC, as Operator of Argonne
#     National Laboratory.
# Copyright (c) 2002 The Regents of the University of California, as
#     Operator of Los Alamos National Laboratory.
# EPICS BASE is distributed subject to a Software License Agreement found
# in the file LICENSE that is included with this distribution. 
#*************************************************************************
#
#  $Id: RULES_DIRS,v 1.19 2009/04/24 09:01:02 lange Exp $
#


ARCHS += $(BUILD_ARCHS)
ACTIONS += inc build install buildInstall clean realclean archclean runtests

dirPart = $(join $(dir $@), $(word 1, $(subst $(DIVIDER), ,$(notdir $@))))

actionArchPart = $(join $(word 2, $(subst $(DIVIDER), ,$(notdir $@))), \
 $(addprefix $(DIVIDER),$(word 3, $(subst $(DIVIDER), ,$(notdir $@))))) 

dirActionArchTargets = $(foreach dir, $(DIRS), \
                       $(foreach action, $(ACTIONS),\
                       $(foreach arch, $(ARCHS), \
                       $(dir)$(DIVIDER)$(action)$(DIVIDER)$(arch))))
dirArchTargets += $(foreach dir, $(DIRS), \
                  $(foreach arch, $(ARCHS),\
                  $(dir)$(DIVIDER)$(arch)))
dirActionTargets += $(foreach dir, $(DIRS), \
                    $(foreach action, $(ACTIONS),\
                    $(dir)$(DIVIDER)$(action)))
actionArchTargets = $(foreach action, $(ACTIONS),\
                    $(foreach arch, $(ARCHS), \
                    $(action)$(DIVIDER)$(arch)))

all : install

rebuild : clean install

# Create directory dependancies lines for GNU make -j option
# Only works with GNU make 3.81 or later (uses eval function)
define DEP_template1
$(1): $$($(1)_DEPEND_DIRS)
endef
$(foreach dir, $(DIRS),$(eval $(call DEP_template1,$(dir))))

define DEP_template2
$(1)$$(DIVIDER)$(2) : $$(foreach ddir, $$($(1)_DEPEND_DIRS),$$(addsuffix $$(DIVIDER)$(2),$$(ddir)))
endef
$(foreach action, $(ACTIONS), $(foreach dir, $(DIRS),$(eval $(call DEP_template2,$(dir),$(action)))))

define DEP_template3
$(1)$$(DIVIDER)$(2) : $$(foreach ddir, $$($(1)_DEPEND_DIRS),$$(addsuffix $$(DIVIDER)$(2),$$(ddir)))
endef
$(foreach arch, $(ARCHS), $(foreach dir, $(DIRS),$(eval $(call DEP_template3,$(dir),$(arch)))))

define DEP_template4
$(1)$$(DIVIDER)$(2)$$(DIVIDER)$(3) : $$(foreach ddir, $$($(1)_DEPEND_DIRS),$$(addsuffix $$(DIVIDER)$(2)$$(DIVIDER)$(3),$$(ddir)))
endef
$(foreach arch, $(ARCHS), $(foreach action, $(ACTIONS), $(foreach dir, $(DIRS), \
              $(eval $(call DEP_template4,$(dir),$(action),$(arch))))))


$(DIRS) $(dirActionTargets) $(dirArchTargets) $(dirActionArchTargets) :
	$(MAKE) -C $(dirPart) $(actionArchPart)

$(ARCHS) $(ACTIONS) $(actionArchTargets) :%: \
	$(foreach dir, $(DIRS), $(dir)$(DIVIDER)%)

.PHONY : $(DIRS) all rebuild
.PHONY : $(ARCHS) $(ACTIONS)
.PHONY : $(dirActionTargets) $(dirArchTargets)
.PHONY : $(dirActionArchTargets)
.PHONY : $(actionArchTargets)


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>