Permalink
Browse files

build-system/make:

 * introduce new function sorted-wildcard to overcome one deficiency of $(sort $(wildcard ...))
 * use it in makefiles


git-svn-id: file:///var/svn/freetz/trunk@10069 149334a1-2f27-0410-a3b9-fc62619ac1e6
  • Loading branch information...
1 parent b222b21 commit 510506cdd866312f9b6b07f648e7010c78c97f66 er13 committed Feb 9, 2013
View
@@ -54,6 +54,7 @@ CHECK_PREREQ_TOOL:=$(TOOLS_DIR)/check_prerequisites
CHECK_BUILD_DIR_VERSION:=
CHECK_UCLIBC_VERSION:=$(TOOLS_DIR)/check_uclibc
+# do not use sorted-wildcard here, it's first defined in files included here
include $(sort $(wildcard include/make/*.mk))
# Use echo -e "$(_Y)message$(_N)" if you want to print a yellow message
@@ -177,7 +178,7 @@ TOOLS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TOOLS))
TOOLS_DISTCLEAN:=$(patsubst %,%-distclean,$(TOOLS))
TOOLS_SOURCE:=$(patsubst %,%-source,$(TOOLS))
-include $(sort $(wildcard $(TOOLS_DIR)/make/*.mk))
+include $(call sorted-wildcard,$(TOOLS_DIR)/make/*.mk)
$(DL_DIR) \
$(DL_FW_DIR) \
@@ -198,13 +199,13 @@ step: image world tools firmware
include $(TOOLCHAIN_DIR)/make/Makefile.in
include $(MAKE_DIR)/Makefile.in
-include $(sort $(wildcard $(MAKE_DIR)/libs/*/Makefile.in))
-include $(sort $(wildcard $(MAKE_DIR)/*/Makefile.in))
+include $(call sorted-wildcard,$(MAKE_DIR)/libs/*/Makefile.in)
+include $(call sorted-wildcard,$(MAKE_DIR)/*/Makefile.in)
ALL_PACKAGES:=
LOCALSOURCE_PACKAGES:=
-include $(sort $(wildcard $(MAKE_DIR)/libs/*/*.mk))
-include $(sort $(wildcard $(MAKE_DIR)/*/*.mk))
+include $(call sorted-wildcard,$(MAKE_DIR)/libs/*/*.mk)
+include $(call sorted-wildcard,$(MAKE_DIR)/*/*.mk)
NON_LOCALSOURCE_PACKAGES:=$(filter-out $(LOCALSOURCE_PACKAGES),$(ALL_PACKAGES))
PACKAGES_CHECK_DOWNLOADS:=$(patsubst %,%-check-download,$(NON_LOCALSOURCE_PACKAGES))
PACKAGES_MIRROR:=$(patsubst %,%-download-mirror,$(NON_LOCALSOURCE_PACKAGES))
@@ -2,6 +2,7 @@ _comma:=,
_empty:=
_space:=$(empty) $(empty)
_hash:=\#
+_bang:=!
define _newline
@@ -8,6 +8,23 @@ define qstrip
$(strip $(subst ",,$(1)))
endef
+#
+# $1 - pattern (regular wildcard parameter)
+#
+# Overcomes the following deficiency of $(sort $(wildcard ...))
+#
+# $(sort xyz-suffix xyz):
+# returns (as expected) "xyz xyz-suffix"
+# $(sort xyz-suffix/... xyz/...):
+# however returns "xyz-suffix/... xyz/..."
+# which is actually correct (ASCII code of "-" is smaller than that of "/")
+# but not what one would expect when sorting is applied to filepaths.
+#
+# sorted-wildcard returns "xyz/... xyz-suffix/..." for "xyz-suffix/... xyz/..."
+#
+define sorted-wildcard
+$(strip $(subst $(_bang),/,$(sort $(subst /,$(_bang),$(wildcard $(1))))))
+endef
#
# $1 - some string representing a version of some package
@@ -1,5 +1,5 @@
--include $(sort $(wildcard $(TOOLCHAIN_DIR)/make/kernel/*/Makefile.in))
--include $(sort $(wildcard $(TOOLCHAIN_DIR)/make/target/*/Makefile.in))
+-include $(call sorted-wildcard,$(TOOLCHAIN_DIR)/make/kernel/*/Makefile.in)
+-include $(call sorted-wildcard,$(TOOLCHAIN_DIR)/make/target/*/Makefile.in)
TARGET_ARCH:=$(call qstrip,$(FREETZ_TARGET_ARCH))

0 comments on commit 510506c

Please sign in to comment.