summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2007-08-30 21:12:39 +0000
committernbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2007-08-30 21:12:39 +0000
commit40aa2d8b06a03e4779cf728c4575c301f389eb72 (patch)
tree36c08c3a3571e181641a7399e73eea11e4b1352d
parent3a065a453ff58430b6915b58cf542e81d143ae3e (diff)
clean up recursive dependency handling, use timestamp.pl again, because it saves memory and execution time
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@8558 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--Makefile2
-rw-r--r--include/debug.mk15
-rw-r--r--include/depends.mk46
-rw-r--r--include/host-build.mk5
-rw-r--r--include/package.mk13
-rw-r--r--rules.mk2
-rwxr-xr-xscripts/timestamp.pl4
7 files changed, 54 insertions, 33 deletions
diff --git a/Makefile b/Makefile
index 840c28ff6..a5e03d1cb 100644
--- a/Makefile
+++ b/Makefile
@@ -14,12 +14,12 @@ export TOPDIR LC_ALL LANG IS_TTY
world:
-include $(TOPDIR)/include/debug.mk
include $(TOPDIR)/include/host.mk
ifneq ($(OPENWRT_BUILD),1)
override OPENWRT_BUILD=1
export OPENWRT_BUILD
+ include $(TOPDIR)/include/debug.mk
include $(TOPDIR)/include/toplevel.mk
else
include rules.mk
diff --git a/include/debug.mk b/include/debug.mk
index 73e617906..68d70ba09 100644
--- a/include/debug.mk
+++ b/include/debug.mk
@@ -10,12 +10,15 @@
# d: show subdirectory tree
# t: show added targets
# l: show legacy targets
+# r: show autorebuild messages
# v: verbose (no .SILENCE for common targets)
-ifeq ($(DEBUG),all)
- build_debug:=dltv
-else
- build_debug:=$(DEBUG)
+ifeq ($(DUMP),)
+ ifeq ($(DEBUG),all)
+ build_debug:=dltvr
+ else
+ build_debug:=$(DEBUG)
+ endif
endif
define debug
@@ -26,6 +29,10 @@ define warn
$$(if $(call debug,$(1),$(2)),$$(warning $(3)))
endef
+define debug_eval
+$$(if $(call debug,$(1),$(2)),$(3))
+endef
+
define warn_eval
$(call warn,$(1),$(2),$(3) $(4))
$(4)
diff --git a/include/depends.mk b/include/depends.mk
index 4819d6dfc..b488af927 100644
--- a/include/depends.mk
+++ b/include/depends.mk
@@ -6,26 +6,42 @@
#
# define a dependency on a subtree
# parameters:
-# 1: directory
+# 1: directories/files
# 2: directory dependency
# 3: tempfile for file listings
# 4: find options
-DEP_FINDPARAMS := -type f -not -name ".*" -and -not -path "*.svn*" -type f -not -name ".*" -and -not -path "*.svn*" -and -not -path "*:*" -and -not -path "*!*" -and -not -path "* *" -and -not -path "*\\\#*"
+DEP_FINDPARAMS := -x "*.svn*" -x ".*" -x "*.svn*" -x "*:*" -x "*\!*" -x "* *" -x "*\\\#*" -x "*/.*_check"
+
+find_md5=find $(1) -type f $(patsubst -x,-and -not -path,$(DEP_FINDPARAMS) $(2)) | md5s
+
define rdep
- $(foreach file,$(shell find $(1) $(DEP_FINDPARAMS) $(4)),
- $(2): $(file)
- $(file): ;
- )
+ .PRECIOUS: $(2)
+ .SILENT: $(2)_check
- ifneq ($(3),)
- ifneq ($$(shell find $(1) $(DEP_FINDPARAMS) $(4) 2>/dev/null | md5s),$(if $(3),$(shell cat $(3) || touch $(3) 2>/dev/null)))
- $(2): $(3)
- endif
-
- endif
+ $(2): $(2)_check
+ $(2)_check::
+ if [ -f "$(2)" ]; then \
+ $(if $(3), \
+ $(call find_md5,$(1),$(4)) > $(3).1; \
+ { [ \! -f "$(3)" ] || diff $(3) $(3).1 >/dev/null; } && \
+ ) \
+ { \
+ [ -f "$(2)_check.1" ] && mv "$(2)_check.1"; \
+ $(SCRIPT_DIR)/timestamp.pl $(DEP_FINDPARAMS) $(4) -n $(2) $(1) && { \
+ $(call debug_eval,$(SUBDIR),r,echo "No need to rebuild $(2)";) \
+ touch -r "$(2)" "$(2)_check"; \
+ } \
+ } || { \
+ $(call debug_eval,$(SUBDIR),r,echo "Need to rebuild $(2)";) \
+ touch "$(2)_check"; \
+ }; \
+ $(if $(3), mv $(3).1 $(3);) \
+ else \
+ $(if $(3), rm -f $(3) $(3).1;) \
+ $(call debug_eval,$(SUBDIR),r,echo "Target $(2) not built";) \
+ true; \
+ fi
- $(3): FORCE
- @-find $(1) $(DEP_FINDPARAMS) $(4) 2>/dev/null | md5s > $$@
- .PRECIOUS: $(3)
endef
+
diff --git a/include/host-build.mk b/include/host-build.mk
index 47ec9b0d3..581c2cfd4 100644
--- a/include/host-build.mk
+++ b/include/host-build.mk
@@ -12,7 +12,7 @@ include $(INCLUDE_DIR)/host.mk
include $(INCLUDE_DIR)/unpack.mk
include $(INCLUDE_DIR)/depends.mk
-STAMP_PREPARED:=$(PKG_BUILD_DIR)/.prepared_$(shell find ${CURDIR} $(PKG_FILE_DEPEND) $(DEP_FINDPARAMS) | md5s)
+STAMP_PREPARED:=$(PKG_BUILD_DIR)/.prepared_$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPEND),))
STAMP_CONFIGURED:=$(PKG_BUILD_DIR)/.configured
STAMP_BUILT:=$(PKG_BUILD_DIR)/.built
STAMP_INSTALLED:=$(STAGING_DIR_HOST)/stamp/.$(PKG_NAME)_installed
@@ -82,9 +82,8 @@ endif
ifneq ($(if $(QUILT),,$(CONFIG_AUTOREBUILD)),)
define HostBuild/Autoclean
- $(PKG_BUILD_DIR)/.dep_files: $(STAMP_PREPARED)
$(call rdep,${CURDIR} $(PKG_FILE_DEPEND),$(STAMP_PREPARED))
- $(if $(if $(Build/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(PKG_BUILD_DIR),$(STAMP_BUILT),$(PKG_BUILD_DIR)/.dep_files, -and -not -path "/.*" -and -not -path "*/ipkg*"))
+ $(if $(if $(Build/Compile),$(filter prepare,$(MAKECMDGOALS)),1),,$(call rdep,$(PKG_BUILD_DIR),$(STAMP_BUILT)))
endef
endif
diff --git a/include/package.mk b/include/package.mk
index 4b811f8af..0b3335294 100644
--- a/include/package.mk
+++ b/include/package.mk
@@ -16,7 +16,7 @@ include $(INCLUDE_DIR)/host.mk
include $(INCLUDE_DIR)/unpack.mk
include $(INCLUDE_DIR)/depends.mk
-STAMP_PREPARED:=$(PKG_BUILD_DIR)/.prepared$(if $(DUMP),,_$(shell find ${CURDIR} $(PKG_FILE_DEPEND) $(DEP_FINDPARAMS) | md5s))
+STAMP_PREPARED:=$(PKG_BUILD_DIR)/.prepared$(if $(DUMP),,_$(shell $(call find_md5,${CURDIR} $(PKG_FILE_DEPEND),)))
STAMP_CONFIGURED:=$(PKG_BUILD_DIR)/.configured
STAMP_BUILT:=$(PKG_BUILD_DIR)/.built
@@ -32,8 +32,8 @@ ifeq ($(DUMP)$(filter prereq clean refresh update,$(MAKECMDGOALS)),)
ifneq ($(if $(QUILT),,$(CONFIG_AUTOREBUILD)),)
define Build/Autoclean
$(PKG_BUILD_DIR)/.dep_files: $(STAMP_PREPARED)
- $(call rdep,${CURDIR} $(PKG_FILE_DEPEND),$(STAMP_PREPARED))
- $(if $(filter prepare,$(MAKECMDGOALS)),,$(call rdep,$(PKG_BUILD_DIR),$(STAMP_BUILT),$(PKG_BUILD_DIR)/.dep_files, -and -not -path "/.*" -and -not -path "*/ipkg*"))
+ $(call rdep,${CURDIR} $(PKG_FILE_DEPEND),$(STAMP_PREPARED),$(PKG_BUILD_DIR)/.dep_files,-x "/.dep_*")
+ $(if $(filter prepare,$(MAKECMDGOALS)),,$(call rdep,$(PKG_BUILD_DIR),$(STAMP_BUILT),,-x "/.dep_*" -x "*/ipkg*"))
endef
endif
endif
@@ -64,14 +64,11 @@ define Build/DefaultTargets
$(STAMP_BUILT): $(STAMP_CONFIGURED)
$(Build/Compile)
+ $(Build/InstallDev)
touch $$@
ifdef Build/InstallDev
- compile: $(STAGING_DIR)/stamp/.$(PKG_NAME)-installed
- $(STAGING_DIR)/stamp/.$(PKG_NAME)-installed: $(STAMP_BUILT)
- mkdir -p $(STAGING_DIR)/stamp
- $(Build/InstallDev)
- touch $$@
+ compile: $(STAMP_BUILT)
endif
define Build/DefaultTargets
diff --git a/rules.mk b/rules.mk
index e76c75d04..3885a8695 100644
--- a/rules.mk
+++ b/rules.mk
@@ -8,6 +8,7 @@
ifeq ($(DUMP),)
-include $(TOPDIR)/.config
endif
+include $(TOPDIR)/include/debug.mk
include $(TOPDIR)/include/verbose.mk
TMP_DIR:=$(TOPDIR)/tmp
@@ -25,6 +26,7 @@ ARCH:=$(call qstrip,$(CONFIG_ARCH))
TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION))
BUILD_SUFFIX:=$(call qstrip,$(CONFIG_BUILD_SUFFIX))
GCCV:=$(call qstrip,$(CONFIG_GCC_VERSION))
+SUBDIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR})
OPTIMIZE_FOR_CPU:=$(ARCH)
diff --git a/scripts/timestamp.pl b/scripts/timestamp.pl
index 89ec4e70c..6bfa3ea1f 100755
--- a/scripts/timestamp.pl
+++ b/scripts/timestamp.pl
@@ -13,7 +13,7 @@ sub get_ts($$) {
my $options = shift;
my $ts = 0;
my $fn = "";
- open FIND, "find $path -not -path \\*.svn\\* -and -not -path \\*CVS\\* $options 2>/dev/null |";
+ open FIND, "find $path -type f -and -not -path \\*.svn\\* -and -not -path \\*CVS\\* $options 2>/dev/null |";
while (<FIND>) {
chomp;
my $file = $_;
@@ -36,7 +36,7 @@ while (@ARGV > 0) {
my $path = shift @ARGV;
if ($path =~ /^-x/) {
my $str = shift @ARGV;
- $options{"findopts"} .= " -and -not -path \\*".$str."\\*"
+ $options{"findopts"} .= " -and -not -path '".$str."'"
} elsif ($path =~ /^-f/) {
$options{"findopts"} .= " -follow";
} elsif ($path =~ /^-n/) {