Skip to content

Commit

Permalink
add 'distclean' target and add uniq to all foreach
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilal Hatipoglu committed Feb 3, 2020
1 parent 0e01c4e commit 4540019
Showing 1 changed file with 42 additions and 36 deletions.
78 changes: 42 additions & 36 deletions Makefile.lib
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Makefile.lib
#
# version : 3.2.2
# version : 3.2.3
# copyright : 2002 - 2020 by Alper Akcan
# email : [email protected]
#
Expand Down Expand Up @@ -51,6 +51,7 @@
# 20190702 - fix depends-y for subdirs
# 20190806 - fix parallel compilation of ${target}_depends-y
# 20200130 - adding install rule
# 20200203 - add 'distclean' target and add uniq to all foreach

#
# Example
Expand Down Expand Up @@ -272,8 +273,10 @@ else
MAKE += --no-print-directory
endif

pur_objects = $(CURDIR)/$$@
pur_objects = $$(subst __UPDIR__/,../,$(CURDIR)/$$@)
uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))

pur_objects := $$(subst __UPDIR__/,../,$$@)
pur_objects := $$(if $$(patsubst /%,,$(pur_objects)),$(CURDIR)/$(pur_objects),$(pur_objects))
#pur_objects = $$(subst $(TOPDIR)/,,$$(subst /.$1,/$1,$(CURDIR)/$$@))
#pur_objects = $$(subst .$1/,,$$@)

Expand Down Expand Up @@ -950,53 +953,53 @@ endef

# generate target variables

$(eval $(foreach T,$(target-y), $(eval $(call target-variables,$T,$($T_files-y)))))
$(eval $(foreach T,$(target-n), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(target-), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(call uniq,$(target-y)), $(eval $(call target-variables,$T,$($T_files-y)))))
$(eval $(foreach T,$(call uniq,$(target-n)), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(call uniq,$(target-)), $(eval $(call target_empty-defaults,$T))))

$(eval $(foreach T,$(target.o-y), $(eval $(call target.o-variables,$T,$($T_files-y)))))
$(eval $(foreach T,$(target.o-n), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(target.o-), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(call uniq,$(target.o-y)), $(eval $(call target.o-variables,$T,$($T_files-y)))))
$(eval $(foreach T,$(call uniq,$(target.o-n)), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(call uniq,$(target.o-)), $(eval $(call target_empty-defaults,$T))))

$(eval $(foreach T,$(target.a-y), $(eval $(call target.a-variables,$T,$($T_files-y)))))
$(eval $(foreach T,$(target.a-n), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(target.a-), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(call uniq,$(target.a-y)), $(eval $(call target.a-variables,$T,$($T_files-y)))))
$(eval $(foreach T,$(call uniq,$(target.a-n)), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(call uniq,$(target.a-)), $(eval $(call target_empty-defaults,$T))))

$(eval $(foreach T,$(target.so-y), $(eval $(call target.so-variables,$T,$($T_files-y)))))
$(eval $(foreach T,$(target.so-n), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(target.so-), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(call uniq,$(target.so-y)), $(eval $(call target.so-variables,$T,$($T_files-y)))))
$(eval $(foreach T,$(call uniq,$(target.so-n)), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(call uniq,$(target.so-)), $(eval $(call target_empty-defaults,$T))))

$(eval $(foreach T,$(target.host-y), $(eval $(call target.host-variables,$T,$($T_files-y)))))
$(eval $(foreach T,$(target.host-n), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(target.host-), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(call uniq,$(target.host-y)), $(eval $(call target.host-variables,$T,$($T_files-y)))))
$(eval $(foreach T,$(call uniq,$(target.host-n)), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(call uniq,$(target.host-)), $(eval $(call target_empty-defaults,$T))))

$(eval $(foreach T,$(target.o.host-y), $(eval $(call target.o.host-variables,$T,$($T_files-y)))))
$(eval $(foreach T,$(target.o.host-n), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(target.o.host-), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(call uniq,$(target.o.host-y)), $(eval $(call target.o.host-variables,$T,$($T_files-y)))))
$(eval $(foreach T,$(call uniq,$(target.o.host-n)), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(call uniq,$(target.o.host-)), $(eval $(call target_empty-defaults,$T))))

$(eval $(foreach T,$(target.so.host-y), $(eval $(call target.so.host-variables,$T,$($T_files-y)))))
$(eval $(foreach T,$(target.so.host-n), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(target.so.host-), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(call uniq,$(target.so.host-y)), $(eval $(call target.so.host-variables,$T,$($T_files-y)))))
$(eval $(foreach T,$(call uniq,$(target.so.host-n)), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(call uniq,$(target.so.host-)), $(eval $(call target_empty-defaults,$T))))

$(eval $(foreach T,$(target.a.host-y), $(eval $(call target.a.host-variables,$T,$($T_files-y)))))
$(eval $(foreach T,$(target.a.host-n), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(target.a.host-), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(call uniq,$(target.a.host-y)), $(eval $(call target.a.host-variables,$T,$($T_files-y)))))
$(eval $(foreach T,$(call uniq,$(target.a.host-n)), $(eval $(call target_empty-defaults,$T))))
$(eval $(foreach T,$(call uniq,$(target.a.host-)), $(eval $(call target_empty-defaults,$T))))

# generate subdir targets

$(eval $(foreach S,$(subdir-y),$(eval $(call subdir-defaults,$S))))
$(eval $(foreach S,$(subdir-n),$(eval $(call subdir_empty-defaults,$S,clean))))
$(eval $(foreach S,$(subdir-),$(eval $(call subdir_empty-defaults,$S,clean))))
$(eval $(foreach S,$(call uniq,$(subdir-y)),$(eval $(call subdir-defaults,$S))))
$(eval $(foreach S,$(call uniq,$(subdir-n)),$(eval $(call subdir_empty-defaults,$S,clean))))
$(eval $(foreach S,$(call uniq,$(subdir-)),$(eval $(call subdir_empty-defaults,$S,clean))))

# distributin tags

ifneq ($(dist.dir),)
$(eval $(foreach D,$(dist.bin-y), $(eval $(call dist.bin-variables,$D))))
$(eval $(foreach D,$(dist.lib-y), $(eval $(call dist.lib-variables,$D))))
$(eval $(foreach D,$(dist.obj-y), $(eval $(call dist.obj-variables,$D))))
$(eval $(foreach D,$(dist.src-y), $(eval $(call dist.src-variables,$D))))
$(eval $(foreach D,$(dist.include-y), $(eval $(call dist.include-variables,$D))))
$(eval $(foreach D,$(dist.share-y), $(eval $(call dist.share-variables,$D))))
$(eval $(foreach D,$(call uniq,$(dist.bin-y)), $(eval $(call dist.bin-variables,$D))))
$(eval $(foreach D,$(call uniq,$(dist.lib-y)), $(eval $(call dist.lib-variables,$D))))
$(eval $(foreach D,$(call uniq,$(dist.obj-y)), $(eval $(call dist.obj-variables,$D))))
$(eval $(foreach D,$(call uniq,$(dist.src-y)), $(eval $(call dist.src-variables,$D))))
$(eval $(foreach D,$(call uniq,$(dist.include-y)), $(eval $(call dist.include-variables,$D))))
$(eval $(foreach D,$(call uniq,$(dist.share-y)), $(eval $(call dist.share-variables,$D))))
endif

# generic tags
Expand All @@ -1017,6 +1020,9 @@ clean: $(target-cleans)
clean: $(addsuffix _clean, $(targets-empty))
clean: __FORCE

distclean: clean
distclean: __FORCE

__FORCE:
@true

Expand Down

0 comments on commit 4540019

Please sign in to comment.