Changeset 5195


Ignore:
Timestamp:
Mar 6, 2010, 9:18:43 PM (5 years ago)
Author:
oxygene
Message:

More readable recursive descent macro in Makefile

Signed-off-by: Patrick Georgi <patrick.georgi@…>
Acked-by: Stefan Reinauer <stepan@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile

    r5186 r5195  
    120120ldscripts:=
    121121types:=obj initobj driver smmobj
    122 includemakefiles=$(foreach type,$(2), $(eval $(type)-y:=)) $(eval subdirs-y:=) $(eval -include $(1)) $(if $(strip $(3)),$(foreach type,$(2),$(eval $(type)s+=$$(patsubst util/%,$(obj)/util/%,$$(patsubst src/%,$(obj)/%,$$(addprefix $(dir $(1)),$$($(type)-y))))))) $(eval subdirs+=$$(subst $(PWD)/,,$$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y)))))
    123 evaluate_subdirs=$(eval cursubdirs:=$(subdirs)) $(eval subdirs:=) $(foreach dir,$(cursubdirs),$(eval $(call includemakefiles,$(dir)/Makefile.inc,$(types),$(1)))) $(if $(subdirs),$(eval $(call evaluate_subdirs, $(1))))
     122
     123# Clean -y variables, include Makefile.inc
     124# If $(3) is non-empty, add paths to files in X-y, and add them to Xs
     125# Add subdirs-y to subdirs
     126includemakefiles= \
     127        $(foreach type,$(2), $(eval $(type)-y:=)) \
     128        $(eval subdirs-y:=) \
     129        $(eval -include $(1)) \
     130        $(if $(strip $(3)), \
     131                $(foreach type,$(2), \
     132                        $(eval $(type)s+= \
     133                                $$(patsubst util/%, \
     134                                        $(obj)/util/%, \
     135                                        $$(patsubst src/%, \
     136                                                $(obj)/%, \
     137                                                $$(addprefix $(dir $(1)),$$($(type)-y))))))) \
     138        $(eval subdirs+=$$(subst $(PWD)/,,$$(abspath $$(addprefix $(dir $(1)),$$(subdirs-y)))))
     139
     140# For each path in $(subdirs) call includemakefiles, passing $(1) as $(3)
     141# Repeat until subdirs is empty
     142evaluate_subdirs= \
     143        $(eval cursubdirs:=$(subdirs)) \
     144        $(eval subdirs:=) \
     145        $(foreach dir,$(cursubdirs), \
     146                $(eval $(call includemakefiles,$(dir)/Makefile.inc,$(types),$(1)))) \
     147        $(if $(subdirs),$(eval $(call evaluate_subdirs, $(1))))
    124148
    125149# collect all object files eligible for building
Note: See TracChangeset for help on using the changeset viewer.