summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2007-07-30 18:22:01 +0000
committernbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2007-07-30 18:22:01 +0000
commitaf927159a9e65228875999840012a1cde1c36b6a (patch)
tree5569019c40b6d11d6ded7321899f99020a2ec4eb
parent3cd9eea04e166dc36dd0ecd4c1ebdf92ed76f8f2 (diff)
next round of build system cleanup - convert package/ to new structure
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@8236 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--Makefile35
-rw-r--r--include/debug.mk34
-rw-r--r--include/host.mk5
-rw-r--r--include/quilt.mk4
-rw-r--r--include/subdir.mk56
-rw-r--r--include/toplevel.mk42
-rw-r--r--include/verbose.mk2
-rw-r--r--package/Makefile73
-rwxr-xr-xscripts/metadata.pl6
-rw-r--r--toolchain/Makefile4
-rw-r--r--tools/Makefile4
11 files changed, 127 insertions, 138 deletions
diff --git a/Makefile b/Makefile
index be53622cc1..fbed1297a1 100644
--- a/Makefile
+++ b/Makefile
@@ -6,23 +6,26 @@
# See /LICENSE for more information.
#
-all: world
-
TOPDIR:=${CURDIR}
LC_ALL:=C
LANG:=C
IS_TTY:=${shell tty -s && echo 1 || echo 0}
export TOPDIR LC_ALL LANG IS_TTY
+world:
+
+include $(TOPDIR)/include/debug.mk
+include $(TOPDIR)/include/host.mk
+
ifneq ($(OPENWRT_BUILD),1)
- export OPENWRT_BUILD:=1
+ override OPENWRT_BUILD=1
+ export OPENWRT_BUILD
include $(TOPDIR)/include/toplevel.mk
else
- include $(TOPDIR)/include/host.mk
-
include rules.mk
include $(INCLUDE_DIR)/depends.mk
include $(INCLUDE_DIR)/subdir.mk
+ include package/Makefile
include tools/Makefile
include toolchain/Makefile
@@ -35,14 +38,32 @@ dirclean: clean
distclean: dirclean config-clean symlinkclean docs/clean
rm -rf dl
-package/% target/%: FORCE
+target/%: FORCE
$(MAKE) -C $(patsubst %/$*,%,$@) $*
-world: .config $(tools/stamp) $(toolchain/stamp) FORCE
+# check prerequisites before starting to build
+prereq: tmp/.prereq-target $(package/stamp-prereq) ;
+
+world: .config $(tools/stamp-install) $(toolchain/stamp-install) FORCE
$(MAKE) target/compile
$(MAKE) package/compile
$(MAKE) package/install
$(MAKE) target/install
$(MAKE) package/index
+package/symlinks:
+ $(SCRIPT_DIR)/feeds.sh $(CONFIG_SOURCE_FEEDS) $(CONFIG_SOURCE_FEEDS_REV)
+
+# FIXME: remove after converting target/ to new structure
+tmp/.prereq-target: tmp/.targetinfo .config
+tmp/.prereq-target: include/prereq.mk
+ mkdir -p tmp
+ rm -f tmp/.host.mk
+ @+$(NO_TRACE_MAKE) -s -C target prereq 2>/dev/null || { \
+ echo "Prerequisite check failed. Use FORCE=1 to override."; \
+ false; \
+ }
+ touch $@
+.SILENT: tmp/.prereq-target
+
endif
diff --git a/include/debug.mk b/include/debug.mk
new file mode 100644
index 0000000000..73e6179060
--- /dev/null
+++ b/include/debug.mk
@@ -0,0 +1,34 @@
+#
+# Copyright (C) 2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+# debug flags:
+#
+# d: show subdirectory tree
+# t: show added targets
+# l: show legacy targets
+# v: verbose (no .SILENCE for common targets)
+
+ifeq ($(DEBUG),all)
+ build_debug:=dltv
+else
+ build_debug:=$(DEBUG)
+endif
+
+define debug
+$$(findstring $(2),$$(if $$(DEBUG_DIR),$$(if $$(filter $$(DEBUG_DIR)%,$(1)),$(build_debug)),$(build_debug)))
+endef
+
+define warn
+$$(if $(call debug,$(1),$(2)),$$(warning $(3)))
+endef
+
+define warn_eval
+$(call warn,$(1),$(2),$(3) $(4))
+$(4)
+endef
+
+
diff --git a/include/host.mk b/include/host.mk
index 8b2e56ce51..d163c997dd 100644
--- a/include/host.mk
+++ b/include/host.mk
@@ -1,17 +1,18 @@
#
-# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2007 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
+TMP_DIR ?= $(TOPDIR)/tmp
-include $(TMP_DIR)/.host.mk
export TAR
-TMP_DIR ?= $(TOPDIR)/tmp
ifneq ($(__host_inc),1)
__host_inc:=1
+.PRECIOUS: $(TMP_DIR)/.host.mk
$(TMP_DIR)/.host.mk: $(TOPDIR)/include/host.mk
@mkdir -p $(TMP_DIR)
@( \
diff --git a/include/quilt.mk b/include/quilt.mk
index 7714f29119..dc5a9d2b69 100644
--- a/include/quilt.mk
+++ b/include/quilt.mk
@@ -10,6 +10,10 @@ ifeq ($(KERNEL_BUILD),1)
endif
PATCH_DIR?=./patches
+ifeq ($(MAKECMDGOALS),refresh)
+ override QUILT=1
+endif
+
define Quilt/Patch
@for patch in $$$$( (cd $(1) && ls) 2>/dev/null ); do ( \
cp "$(1)/$$$$patch" $(PKG_BUILD_DIR); \
diff --git a/include/subdir.mk b/include/subdir.mk
index 16e4f4b6c4..a27333d9e6 100644
--- a/include/subdir.mk
+++ b/include/subdir.mk
@@ -1,32 +1,14 @@
-# debug flags:
+#
+# Copyright (C) 2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
#
-# d: show subdirectory tree
-# t: show added targets
-# l: show legacy targets
-
-ifeq ($(DEBUG),all)
- build_debug:=dlt
-else
- build_debug:=$(DEBUG)
-endif
-
-define debug
-$$(findstring $(2),$$(if $$(DEBUG_DIR),$$(if $$(filter $$(DEBUG_DIR)%,$(1)),$(build_debug)),$(build_debug)))
-endef
-
-define warn
-$$(if $(call debug,$(1),$(2)),$$(warning $(3)))
-endef
-
-define warn_eval
-$(call warn,$(1),$(2),$(3) $(4))
-$(4)
-endef
SUBTARGETS:=clean download prepare compile install update refresh prereq
define subtarget
- $(call warn_eval,$(1),t,T,$(1)/$(2): $($(1)/) $(foreach bd,$(if $($(1)/builddirs-$(2)),$($(1)/builddirs-$(2)),$($(1)/builddirs)),$(1)/$(bd)/$(2)))
+ $(call warn_eval,$(1),t,T,$(1)/$(2): $($(1)/) $(foreach bd,$(if $($(1)/builddirs-$(2)),$(filter-out .,$($(1)/builddirs-$(2))),$($(1)/builddirs)),$(1)/$(bd)/$(2)))
endef
@@ -46,19 +28,19 @@ define subdir
$(foreach target,$(SUBTARGETS),$(call subtarget,$(1),$(target)))
endef
-# Parameters: <subdir> <name>
+# Parameters: <subdir> <name> <target>
define stampfile
- $(1)/stamp:=$(STAGING_DIR)/stampfiles/.$(2)_installed
- $(call rdep,$(1),$$($(1)/stamp))
-
- $$($(1)/stamp):
- @+$(MAKE) $(1)/install
- @mkdir -p $$$$(dirname $$($(1)/stamp))
- @touch $$($(1)/stamp)
- .PRECIOUS: $$($(1)/stamp) # work around a make bug
-
- $(1)//clean:=$(1)/stamp/clean
- $(1)/stamp/clean: FORCE
- @rm -f $$($(1)/stamp)
+ $(1)/stamp-$(3):=$(STAGING_DIR)/stampfiles/.$(2)_$(3)
+ $(call rdep,$(1),$$($(1)/stamp-$(3)),)
+
+ $$($(1)/stamp-$(3)):
+ @+$(MAKE) $(1)/$(3)
+ @mkdir -p $$$$(dirname $$($(1)/stamp-$(3)))
+ @touch $$($(1)/stamp-$(3))
+ .PRECIOUS: $$($(1)/stamp-$(3)) # work around a make bug
+
+ $(1)//clean:=$(1)/stamp-$(3)/clean
+ $(1)/stamp-$(3)/clean: FORCE
+ @rm -f $$($(1)/stamp-$(3))
endef
diff --git a/include/toplevel.mk b/include/toplevel.mk
index 05839832d2..33b318abb7 100644
--- a/include/toplevel.mk
+++ b/include/toplevel.mk
@@ -9,10 +9,9 @@
RELEASE:=Kamikaze
#VERSION:=2.0 # uncomment for final release
-all: world
-
SHELL:=/usr/bin/env bash
OPENWRTVERSION:=$(RELEASE)
+PREP_MK= OPENWRT_BUILD= QUIET=0
include $(TOPDIR)/include/verbose.mk
ifneq ($(VERSION),)
OPENWRTVERSION:=$(VERSION) ($(OPENWRTVERSION))
@@ -26,27 +25,26 @@ export OPENWRTVERSION
ifeq ($(FORCE),)
.config scripts/config/conf scripts/config/mconf: tmp/.prereq-build
- world: prereq
endif
SCAN_COOKIE?=$(shell echo $$$$)
export SCAN_COOKIE
-tmp/.packageinfo tmp/.targetinfo prepare-tmpinfo:
- @mkdir -p tmp/info
- @+$(NO_TRACE_MAKE) -s -f include/scan.mk SCAN_TARGET="packageinfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPS="$(TOPDIR)/include/package*.mk" SCAN_DEPTH=4 SCAN_EXTRA=""
- @+$(NO_TRACE_MAKE) -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPS="profiles/*.mk $(TOPDIR)/include/kernel*.mk" SCAN_DEPTH=2 SCAN_EXTRA=""
- @for type in package target; do \
+tmp/.packageinfo tmp/.targetinfo prepare-tmpinfo: FORCE
+ mkdir -p tmp/info
+ +$(NO_TRACE_MAKE) -s -f include/scan.mk SCAN_TARGET="packageinfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPS="$(TOPDIR)/include/package*.mk" SCAN_DEPTH=4 SCAN_EXTRA=""
+ +$(NO_TRACE_MAKE) -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPS="profiles/*.mk $(TOPDIR)/include/kernel*.mk" SCAN_DEPTH=2 SCAN_EXTRA=""
+ for type in package target; do \
f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \
[ "$$t" -nt "$$f" ] || ./scripts/metadata.pl $${type}_config < "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \
done
+ ./scripts/metadata.pl package_mk < tmp/.packageinfo > tmp/.packagedeps || { rm -f tmp/.packagedeps; false; }
.config: ./scripts/config/conf prepare-tmpinfo
@+if [ \! -f .config ]; then \
[ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \
- $(NO_TRACE_MAKE) menuconfig QUIET=0 OPENWRT_BUILD=; \
+ $(NO_TRACE_MAKE) menuconfig $(PREP_MK); \
fi
- $< -D .config Config.in &> /dev/null
scripts/config/mconf:
@+$(MAKE) -C scripts/config all
@@ -88,20 +86,6 @@ tmp/.prereq-build: include/prereq-build.mk
}
touch $@
-tmp/.prereq-package: tmp/.packageinfo .config
-tmp/.prereq-target: tmp/.targetinfo .config
-tmp/.prereq-package tmp/.prereq-target: include/prereq.mk
- mkdir -p tmp
- rm -f tmp/.host.mk
- @+$(NO_TRACE_MAKE) -s -C $(patsubst tmp/.prereq-%,%,$@) prereq 2>/dev/null || { \
- echo "Prerequisite check failed. Use FORCE=1 to override."; \
- false; \
- }
- touch $@
-
-prereq: tmp/.prereq-build tmp/.prereq-package tmp/.prereq-target .config FORCE
- @true
-
download: .config FORCE
$(MAKE) -j1 tools/download
$(MAKE) -j1 toolchain/download
@@ -111,8 +95,12 @@ download: .config FORCE
clean dirclean distclean:
@$(MAKE) $@
+prereq:: .config
+ @+$(SUBMAKE) -s tmp/.prereq-build $(PREP_MK)
+ @$(NO_TRACE_MAKE) -s $@
+
%::
- @$(SUBMAKE) -s prereq QUIET=0 OPENWRT_BUILD=
+ @+$(PREP_MK) $(NO_TRACE_MAKE) -s prereq
@+$(MAKE) $@
help:
@@ -128,7 +116,9 @@ symlinkclean:
-find package -type l | xargs rm -f
rm -rf tmp
-.SILENT: symlinkclean clean dirclean distclean config-clean download help tmpinfo-clean .config scripts/config/mconf scripts/config/conf menuconfig tmp/.prereq-build tmp/.prereq-package tmp/.prereq-target
+ifeq ($(findstring v,$(DEBUG)),)
+ .SILENT: symlinkclean clean dirclean distclean config-clean download help tmpinfo-clean .config scripts/config/mconf scripts/config/conf menuconfig tmp/.prereq-build tmp/.prereq-package tmp/.prereq-target tmp/.packageinfo tmp/.targetinfo prepare-tmpinfo
+endif
.PHONY: help FORCE
.NOTPARALLEL:
diff --git a/include/verbose.mk b/include/verbose.mk
index 5ceaf9999c..4abdf8d661 100644
--- a/include/verbose.mk
+++ b/include/verbose.mk
@@ -44,7 +44,7 @@ ifneq ($(KBUILD_VERBOSE),99)
MAKE:=&>/dev/null $(MAKE)
endif
export QUIET:=1
- MAKE:=cmd() { $(MAKE) $$* || { echo "make $$*: build failed. Please re-run make with V=99 to see what's going on"; false; } } 3>&1 4>&2; cmd
+ MAKE:=cmd() { $(MAKE) -s $$* || { echo "make $$*: build failed. Please re-run make with V=99 to see what's going on"; false; } } 3>&1 4>&2; cmd
endif
.SILENT: $(MAKECMDGOALS)
diff --git a/package/Makefile b/package/Makefile
index 501b158e4f..31f03c01bb 100644
--- a/package/Makefile
+++ b/package/Makefile
@@ -6,53 +6,18 @@
#
# $Id$
-include $(TOPDIR)/rules.mk
-include $(TOPDIR)/.config
-include $(INCLUDE_DIR)/host.mk
-
-all: compile
-
-include $(TMP_DIR)/.packagedeps
-
-PREREQ_PACKAGES:=$(patsubst %,%-prereq,$(prereq-y) $(prereq-m))
-DOWNLOAD_PACKAGES:=$(patsubst %,%-download,$(package-y) $(package-m))
-COMPILE_PACKAGES:=$(patsubst %,%-compile,$(package-y) $(package-m))
-INSTALL_PACKAGES:=$(patsubst %,%-install,$(package-y))
-
-$(STAMP_DIR) $(TARGET_DIR):
- mkdir -p $@
-
-ifeq ($(QUIET),1)
-%-compile %-install: FORCE
- $(MAKE) -j1 -C $* $(patsubst $*-%,%,$@) || { $(call MESSAGE, "*** $* $(patsubst $*-%,%,$@) failed"); false; }
-
-%-prepare %-prereq %-download %-clean: FORCE
-else
-%-prepare %-prereq %-download %-clean %-compile %-install: FORCE
-endif
- $(MAKE) -j1 -C $* $(patsubst $*-%,%,$@)
-
-%-refresh %-update:
- -$(MAKE) -C $* $(patsubst $*-%,%,$@)
-
-%-autorefresh:
- -$(MAKE) -C $* clean refresh QUILT=1
-
-
-# .IGNORE: $(COMPILE_PACKAGES)
-
-$(TMP_DIR)/.packagedeps: $(TMP_DIR)/.packageinfo
- @$(TOPDIR)/scripts/metadata.pl package_mk < $< > $@ || rm -f $@
-
-preconfig:
-clean: $(patsubst %,%-clean,$(package-) $(package-y) $(package-m))
-prereq: $(PREREQ_PACKAGES)
-download: $(DOWNLOAD_PACKAGES)
-compile: $(COMPILE_PACKAGES)
-refresh: $(patsubst %,%-autorefresh,$(package-y) $(package-m) $(package-))
-
-install-targets: $(INSTALL_PACKAGES)
-install:
+curdir:=package
+
+include .config
+-include $(TMP_DIR)/.packagedeps
+$(curdir)/builddirs:=$(sort $(package-) $(package-y) $(package-m))
+$(curdir)/builddirs-compile:=$(sort $(package-y) $(package-m))
+$(curdir)/builddirs-install:=. $(sort $(package-y))
+$(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m))
+
+$(curdir)//compile:=.config prereq
+$(curdir)/install:=$(curdir)/install-cleanup
+$(curdir)/install-cleanup:
rm -rf $(BUILD_DIR)/root
$(MAKE) install-targets
$(MAKE) preconfig
@@ -71,16 +36,8 @@ install:
@-find $(BUILD_DIR)/root -name .svn | $(XARGS) rm -rf
@-find $(BUILD_DIR)/root -name '.#*' | $(XARGS) rm -f
-index: $(PACKAGE_DIR)/Packages
-
-$(PACKAGE_DIR)/Packages: $(PACKAGE_DIR)/*.ipk
+$(curdir)/index: FORCE
(cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages)
-symlinks:
- ../scripts/feeds.sh $(CONFIG_SOURCE_FEEDS) $(CONFIG_SOURCE_FEEDS_REV)
-
-ifeq ($(MAKECMDGOALS),compile)
-MAKEFLAGS:=$(MAKEFLAGS) -j$(CONFIG_JLEVEL)
-else
-.NOTPARALLEL:
-endif
+$(eval $(call stampfile,$(curdir),package,prereq))
+$(eval $(call subdir,$(curdir)))
diff --git a/scripts/metadata.pl b/scripts/metadata.pl
index 6ed128aae2..16a120a7ae 100755
--- a/scripts/metadata.pl
+++ b/scripts/metadata.pl
@@ -576,12 +576,12 @@ sub gen_package_mk() {
undef $idx if $idx =~ /^(kernel)|(base-files)$/;
if ($idx) {
next if $dep{$pkg->{src}."->".$idx};
- $depline .= " $idx\-compile";
+ $depline .= " \$(curdir)/$idx/compile";
$dep{$pkg->{src}."->".$idx} = 1;
}
}
if ($depline) {
- $line .= $pkg->{subdir}."$pkg->{src}-compile: $depline\n";
+ $line .= "\$(curdir)/".$pkg->{subdir}."$pkg->{src}/compile := $depline\n";
}
}
@@ -604,7 +604,7 @@ $cmds \\
) > \$@
ifneq (\$(UCI_PRECONFIG)\$(CONFIG_UCI_PRECONFIG),)
- preconfig: \$(TARGET_DIR)/etc/uci-defaults/$preconfig
+ package/preconfig: \$(TARGET_DIR)/etc/uci-defaults/$preconfig
endif
EOF
}
diff --git a/toolchain/Makefile b/toolchain/Makefile
index 3e1b3b4a2d..b7a45047ae 100644
--- a/toolchain/Makefile
+++ b/toolchain/Makefile
@@ -21,11 +21,11 @@ endif
$(curdir)/gcc/install:=$(curdir)/uClibc/install
# prerequisites for the individual targets
-$(curdir)/ := .config $(tools/stamp)
+$(curdir)/ := .config $(tools/stamp-install) prereq
$(curdir)//prepare = $(STAGING_DIR)/include-host/.done
$(curdir)//compile = $(1)/prepare
$(curdir)//install = $(1)/compile
-$(eval $(call stampfile,$(curdir),toolchain))
+$(eval $(call stampfile,$(curdir),toolchain,install))
$(eval $(call subdir,$(curdir)))
diff --git a/tools/Makefile b/tools/Makefile
index 2b0143e6b3..5ad4bfd723 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -25,9 +25,9 @@ endef
$(eval $(call copy_include,$(curdir)))
# prerequisites for the individual targets
-$(curdir)/ := .config
+$(curdir)/ := .config prereq
$(curdir)//compile = $(1)/prepare
$(curdir)//install = $(1)/compile
-$(eval $(call stampfile,$(curdir),tools))
+$(eval $(call stampfile,$(curdir),tools,install))
$(eval $(call subdir,$(curdir)))