Changeset a748603 in rtems for c/src/automake


Ignore:
Timestamp:
May 14, 2017, 1:52:52 AM (4 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
5, master
Children:
ff781cc
Parents:
86ae03c
git-author:
Chris Johns <chrisj@…> (05/14/17 01:52:52)
git-committer:
Chris Johns <chrisj@…> (05/24/17 09:59:22)
Message:

build-system: Parallel build all subdirs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/automake/subdirs.am

    r86ae03c ra748603  
    1 ## Borrowed from automake-1.4 and adapted to RTEMS
     1## Copyright 2017 Chris Johns <chrisj@rtems.org>
    22
    3 ## NOTE: This is a temporary work-around to keep
    4 ## RTEMS's non automake standard make targets working.
    5 ## Once automake is fully integrated these make targets
    6 ## and this file will probably be removed
     3##
     4## The following builds in parallel. The subdirectories are
     5## expanded into separate rules and all the targets are listed
     6## and make runs as many as it can.
     7##
     8## A macro is defined and evaluated once for each directory. This
     9## creates the instance of the rule. Use $(info ...) to print them.
     10##
    711
    8 preinstall-recursive:
    9         @set fnord $(MAKEFLAGS); amf=$$2; \
    10         dot_seen=no; \
    11         target=`echo $@ | sed s/-recursive//`; \
    12         list='$(SUBDIRS)'; for subdir in $$list; do \
    13           echo "Making $$target in $$subdir"; \
    14           if test "$$subdir" = "."; then \
    15             dot_seen=yes; \
    16             local_target="$$target-am"; \
    17           else \
    18             local_target="$$target"; \
    19           fi; \
    20           (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
    21 ## This trick allows "-k" to keep its natural meaning when running a
    22 ## recursive rule.
    23            || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
    24         done; \
    25         if test "$$dot_seen" = "no"; then \
    26           $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
    27         fi; test -z "$$fail"
     12SUBDIRS_dot                            = $(filter     .,$(_SUBDIRS))
     13SUBDIRS_no_dot                         = $(filter-out .,$(_SUBDIRS))
     14SUBDIRS_no_dot_no_wrapup               = $(filter-out wrapup,$(SUBDIRS_no_dot))
     15SUBDIRS_no_dot_no_testsuites           = $(filter-out testsuites,$(SUBDIRS_no_dot))
     16SUBDIRS_no_dot_no_wrapup_no_testsuites = $(filter-out testsuites,$(SUBDIRS_no_dot_no_wrapup))
     17SUBDIRS_wrapup                         = $(filter     wrapup,$(SUBDIRS_no_dot))
     18SUBDIRS_testsuites                     = $(filter     testsuites,$(SUBDIRS_no_dot))
    2819
    29 preinstall: preinstall-recursive
    30 .PHONY: preinstall-recursive
     20SUBDIR_TARGET     = $(subst /,-,$1)
     21PREINSTALL_TARGET = preinstall-$(call SUBDIR_TARGET,$(1))
     22
     23preintstall_targets  = $(if "$(SUBDIRS_dot)" ".",preinstall-dot) $(foreach D,$(SUBDIRS_no_dot),$(call PREINSTALL_TARGET,$(D)))
     24
     25define PREINSTALL_DIR
     26.PHONY: $1
     27$1:
     28        @+set fnord $(MAKEFLAGS); amf=$$$$2; \
     29        subdir=$(2); \
     30        subdir_label=`echo $(1) | sed -e 's/preinstall-//'`; \
     31        target=`echo $$@ | sed -e 's/-recursive//' -e "s/-$$$${subdir_label}//"`$(3); \
     32        echo "Making $$$$target in $$$$subdir"; \
     33        (cd $$$$subdir && $(MAKE) $(AM_MAKEFLAGS) $$$$target) \
     34         || case "$$$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac;
     35endef
     36
     37$(if "$(SUBDIRS_dot)" ".",$(eval $(call PREINSTALL_DIR,preinstall-dot,.,-am)))
     38
     39$(foreach D,$(SUBDIRS_no_dot),$(eval $(call PREINSTALL_DIR,$(call PREINSTALL_TARGET,$(D)),$(D))))
     40
     41preinstall: $(preintstall_targets)
     42.PHONY: preinstall
     43
     44define CPUKITDIR
     45.PHONY: $1
     46$1: $(preintstall_targets)
     47        @+set fnord $(MAKEFLAGS); amf=$$$$2; \
     48        subdir=$(2); \
     49        target=`echo $(MAKECMDGOALS) | sed s/-recursive//`; \
     50        if test "$$$$target" = "all-local-am"; then \
     51          target="all-am"; \
     52        fi; \
     53        if test "$$$$target" = "all-local"; then \
     54          target="all"; \
     55        fi; \
     56        echo "Making $$$$target in $$$$subdir"; \
     57        if test "$$$$subdir" != "."; then \
     58          cd $$$$subdir; \
     59          $(MAKE) $(AM_MAKEFLAGS) $$$$local_target; \
     60        fi;
     61endef
     62
     63#
     64# This GNU make syntax is being used to stop automake thinking the code is for
     65# it.
     66#
     67$(if "$(SUBDIRS_dot)" ".",$(eval $(call CPUKITDIR,dot,.)))
     68
     69$(foreach D,$(SUBDIRS_no_dot),$(eval $(call CPUKITDIR,$(D),$(D))))
     70
     71#
     72# If there is a wrapup make it depend on all other directories except the
     73# testsuite so it is not entered until everything but the testsuite has
     74# finished.
     75#
     76$(if "$(SUBDIRS_wrapup)" "wrapup",wrapup: dot $(SUBDIRS_no_dot_no_wrapup_no_testsuites))
     77
     78#
     79# If there is a testsuite make it depend on all other directories so it is not
     80# entered until everything else has finished.
     81#
     82$(if "$(SUBDIRS_testsuites)" "testsuites",testsuites: dot $(SUBDIRS_no_dot_no_testsuites))
     83
     84#
     85# The general build all rule for automake.
     86#
     87all-local: preinstall $(if "$(SUBDIRS_dot)" ".",dot) $(SUBDIRS_no_dot)
Note: See TracChangeset for help on using the changeset viewer.