aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2007-08-30 21:12:39 +0000
committerFelix Fietkau <nbd@openwrt.org>2007-08-30 21:12:39 +0000
commit5f748a6c24863b08652d835c2858acfd83a84238 (patch)
tree7492870ce899ef7791c89ecb4a2b570f9d637be5
parent9566fb1f0701759d499e1579a340943ff5a7422d (diff)
downloadupstream-5f748a6c24863b08652d835c2858acfd83a84238.tar.gz
upstream-5f748a6c24863b08652d835c2858acfd83a84238.tar.bz2
upstream-5f748a6c24863b08652d835c2858acfd83a84238.zip
clean up recursive dependency handling, use timestamp.pl again, because it saves memory and execution time
SVN-Revision: 8558
-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 840c28ff61..a5e03d1cb3 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 73e6179060..68d70ba093 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 4819d6dfc1..b488af9271 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 47ec9b0d3a..581c2cfd4e 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 4b811f8af6..0b33352941 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 e76c75d04b..3885a86953 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 89ec4e70c3..6bfa3ea1f0 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/) {