From 35d1297447cc2d8cf4c1037079beafe876094b87 Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@openwrt.org>
Date: Sat, 22 Oct 2005 00:06:20 +0000
Subject: [PATCH] large build system cleanup. added some stuff to control the
 verbosity level, but not complete, yet.

SVN-Revision: 2221
---
 openwrt/Config.in                          |  4 --
 openwrt/Makefile                           | 41 +++++++++-----------
 openwrt/package/Config.in                  |  1 +
 openwrt/package/Makefile                   | 29 ++++++++------
 openwrt/package/nvram/Config.in            |  7 ++++
 openwrt/package/nvram/Makefile             |  7 ----
 openwrt/package/rules.mk                   |  2 -
 openwrt/rules.mk                           | 45 +++++++++++++++-------
 openwrt/target/Makefile                    |  6 +++
 openwrt/target/linux/Config.in             | 45 ++++++----------------
 openwrt/target/linux/Makefile              |  3 ++
 openwrt/target/linux/image/Makefile        |  5 +++
 openwrt/target/linux/image/jffs2.mk        |  4 +-
 openwrt/target/linux/image/squashfs.mk     |  3 +-
 openwrt/target/linux/linux-2.4/Makefile    |  9 ++---
 openwrt/target/linux/linux-2.6/Makefile    | 13 ++-----
 openwrt/target/linux/linux-2.6/broadcom.mk |  3 --
 openwrt/target/linux/package/Makefile      |  4 ++
 openwrt/toolchain/Makefile                 | 16 ++++++--
 openwrt/toolchain/kernel-headers/Makefile  |  9 +++--
 20 files changed, 135 insertions(+), 121 deletions(-)
 create mode 100644 openwrt/package/nvram/Config.in
 delete mode 100644 openwrt/target/linux/linux-2.6/broadcom.mk

diff --git a/openwrt/Config.in b/openwrt/Config.in
index 6d636d1a72..3f5cb29c59 100644
--- a/openwrt/Config.in
+++ b/openwrt/Config.in
@@ -84,10 +84,6 @@ config BR2_TAR_VERBOSITY
 	bool 
 	default n
 
-config BR2_STAGING_DIR
-	string
-	default "$(BASE_DIR)/staging_dir_$(ARCH)$(ARCH_FPU_SUFFIX)"
-
 config BR2_JLEVEL
 	int
 	default "1"
diff --git a/openwrt/Makefile b/openwrt/Makefile
index d478227523..86367fefad 100644
--- a/openwrt/Makefile
+++ b/openwrt/Makefile
@@ -1,4 +1,4 @@
-# Makefile for OpenWRT
+# Makefile for OpenWrt
 #
 # Copyright (C) 2005 by Felix Fietkau <openwrt@nbd.name>
 # Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
@@ -24,6 +24,7 @@
 #--------------------------------------------------------------
 TOPDIR=${shell pwd}
 export TOPDIR
+
 ifneq ($(DEVELOPER),)
 CONFIG_CONFIG_IN = Config.in.devel
 else
@@ -57,7 +58,8 @@ all: world
 # In this section, we need .config
 include .config.cmd
 
-world: $(DL_DIR) $(BUILD_DIR) configtest toolchain/install target/compile package/compile target/install package_index
+world: $(DL_DIR) $(BUILD_DIR) configtest 
+	$(MAKE) toolchain/install target/compile package/compile root_clean package/install target/install package_index
 
 .PHONY: all world clean dirclean distclean image_clean target_clean source configtest
 
@@ -66,9 +68,7 @@ configtest:
 	-scripts/configtest.pl
 
 package_index:
-	(cd $(PACKAGE_DIR); \
-		$(STAGING_DIR)/usr/bin/ipkg-make-index . > Packages \
-	)
+	(cd $(PACKAGE_DIR); $(STAGING_DIR)/usr/bin/ipkg-make-index . > Packages)
 
 $(DL_DIR):
 	@mkdir -p $(DL_DIR)
@@ -76,16 +76,18 @@ $(DL_DIR):
 $(BUILD_DIR):
 	@mkdir -p $(BUILD_DIR)
 
-source: $(TARGETS_SOURCE)
-
+source: toolchain/source package/source target/source
 
 package/%:
+	@$(TRACE) $@
 	$(MAKE) -C package $(patsubst package/%,%,$@)
 
 target/%:
+	@$(TRACE) $@
 	$(MAKE) -C target $(patsubst target/%,%,$@)
 
 toolchain/%:
+	@$(TRACE) $@
 	$(MAKE) -C toolchain $(patsubst toolchain/%,%,$@)
 
 #############################################################
@@ -93,31 +95,24 @@ toolchain/%:
 # Cleanup and misc junk
 #
 #############################################################
-image_clean:
+root_clean:
+	rm -rf $(BUILD_DIR)/linux-*/root $(BUILD_DIR)/root
+
+target_clean: root_clean
 	rm -f $(STAMP_DIR)/.*-compile
 	rm -f $(STAMP_DIR)/.*-install
 	rm -rf $(BIN_DIR)
-	
-target_clean: image_clean
-	rm -rf $(BUILD_DIR)/linux-*/root
 
-clean: target_clean
-	@$(MAKE) -C $(CONFIG) clean
+clean: dirclean
 
-dirclean: clean
+dirclean:
+	@$(MAKE) -C $(CONFIG) clean
 	rm -rf $(BUILD_DIR)
 
-distclean: clean
-	rm -rf $(STAMP_DIR) $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR)
+distclean: dirclean
+	rm -rf $(STAMP_DIR) $(DL_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR)
 	rm -f .config* .tmpconfig.h
 
-sourceball: distclean
-	set -e; \
-	cd ..; \
-	rm -f buildroot.tar.bz2; \
-	tar -cvf buildroot.tar buildroot; \
-	bzip2 -9 buildroot.tar; \
-
 else # ifeq ($(strip $(BR2_HAVE_DOT_CONFIG)),y)
 
 all: menuconfig
diff --git a/openwrt/package/Config.in b/openwrt/package/Config.in
index b5a8e49ebb..75955fbadf 100644
--- a/openwrt/package/Config.in
+++ b/openwrt/package/Config.in
@@ -9,6 +9,7 @@ source "package/dnsmasq/Config.in"
 source "package/ipkg/Config.in"
 source "package/iptables/Config.in"
 source "package/mtd/Config.in"
+source "package/nvram/Config.in"
 
 comment "Applications"
 source "package/deco/Config.in"
diff --git a/openwrt/package/Makefile b/openwrt/package/Makefile
index 55fb1e1077..91307cd6c3 100644
--- a/openwrt/package/Makefile
+++ b/openwrt/package/Makefile
@@ -2,7 +2,6 @@
 include $(TOPDIR)/rules.mk
 
 package-:=tcp_wrappers
-package-y:=nvram
 package-$(BR2_PACKAGE_6TUNNEL) += 6tunnel
 package-$(BR2_PACKAGE_AICCU) += aiccu
 package-$(BR2_PACKAGE_AIRCRACK) += aircrack
@@ -125,6 +124,7 @@ package-$(BR2_PACKAGE_NFS_SERVER) += nfs-server
 package-$(BR2_PACKAGE_NMAP) += nmap
 package-$(BR2_PACKAGE_NOCATSPLASH) += nocatsplash
 package-$(BR2_PACKAGE_NTPCLIENT) += ntpclient
+package-$(BR2_PACKAGE_NVRAM) += nvram
 package-$(BR2_PACKAGE_OLSRD) += olsrd
 package-$(BR2_PACKAGE_OPENCDK) += opencdk
 package-$(BR2_PACKAGE_OPENLDAP) += openldap
@@ -206,7 +206,7 @@ package-$(BR2_PACKAGE_XINETD) += xinetd
 package-$(BR2_PACKAGE_XSUPPLICANT) += xsupplicant
 package-$(BR2_PACKAGE_ZLIB) += zlib
 
-DEV_LIBS:=tcp_wrappers glib ncurses openssl pcre popt zlib libnet libpcap mysql postgresql iptables matrixssl lzo gmp fuse portmap libelf uclibc++ speex libpng libgd wireless-tools nvram linux-atm
+DEV_LIBS:=tcp_wrappers glib ncurses openssl pcre popt zlib libnet libpcap mysql postgresql iptables matrixssl lzo gmp fuse portmap libelf uclibc++ speex libpng libgd wireless-tools nvram linux-atm libamsel libao libart libdaemon libdb libdnet libevent libffi-sable libgcrypt libgdbm libgpg-error libid3tag libmad libnet libnids libogg libosip2 libpcap libtasn1 libupnp libusb libvorbis libvorbisidec libxml2 libxslt
 DEV_LIBS_COMPILE:=$(patsubst %,%-compile,$(DEV_LIBS))
 SDK_DEFAULT_PACKAGES:=busybox dnsmasq iptables wireless-tools dropbear bridge ipkg ppp
 SDK_DEFAULT_COMPILE:=$(patsubst %,%-compile,$(SDK_DEFAULT_PACKAGES))
@@ -437,27 +437,34 @@ sdk-compile: $(DEV_LIBS_COMPILE) $(SDK_DEFAULT_COMPILE)
 $(STAMP_DIR):
 	mkdir -p $@
 
-%-prepare: $(STAMP_DIR)
-	@[ -f $(STAMP_DIR)/.$@ ] || $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
+$(TARGET_DIR):
+	mkdir -p $(TARGET_DIR)
+
+%-prepare: $(STAMP_DIR) $(TARGET_DIR)
+	@[ -f $(STAMP_DIR)/.$@ ] || { \
+		$(TRACE) package/$(patsubst %-prepare,%,$@)/prepare; \
+		$(MAKE) -C $(patsubst %-prepare,%,$@) prepare; \
+	}
 	@touch $(STAMP_DIR)/.$@
 
 %-compile: %-prepare 
-	@[ -f $(STAMP_DIR)/.$@ ] || $(MAKE) -C $(patsubst %-compile,%,$@) compile
+	@[ -f $(STAMP_DIR)/.$@ ] || { \
+		$(TRACE) package/$(patsubst %-compile,%,$@)/compile; \
+		$(MAKE) -C $(patsubst %-compile,%,$@) compile; \
+	}
 	@touch $(STAMP_DIR)/.$@
 
 %-install: %-compile
-	@$(MAKE) -C $(patsubst %-install,%,$@) \
-		TARGET_DIR="$(TARGET_DIR)" \
-		IPKG_CONF="$(IPKG_CONF)" \
-		BOARD="$(BOARD)" \
-		KERNEL="$(KERNEL)" \
-		install
+	@$(TRACE) package/$(patsubst %-install,%,$@)/install
+	@$(MAKE) -C $(patsubst %-install,%,$@) install
 
 %-rebuild: 
+	@$(TRACE) package/$(patsubst %-rebuild,%,$@)/rebuild
 	@rm -f $(STAMP_DIR)/.$(patsubst %-rebuild,%,$@)-*
 	$(MAKE) -C $(patsubst %-rebuild,%,$@) rebuild
 
 %-clean:
+	@$(TRACE) package/$(patsubst %-clean,%,$@)/clean
 	@$(MAKE) -C $(patsubst %-clean,%,$@) clean
 	@rm -f $(STAMP_DIR)/.$(patsubst %-clean,%,$@)-*
 
diff --git a/openwrt/package/nvram/Config.in b/openwrt/package/nvram/Config.in
new file mode 100644
index 0000000000..968a23fdbb
--- /dev/null
+++ b/openwrt/package/nvram/Config.in
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_NVRAM
+	tristate "nvram - broadcom config utility"
+	default y 
+	depends BR2_LINUX_2_4_BRCM
+	help
+	  control utility for broadcom's 'nvram' config area
+
diff --git a/openwrt/package/nvram/Makefile b/openwrt/package/nvram/Makefile
index b1b87fd15b..eea5a3aa09 100644
--- a/openwrt/package/nvram/Makefile
+++ b/openwrt/package/nvram/Makefile
@@ -9,13 +9,6 @@ PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
 
 include $(TOPDIR)/package/rules.mk
 
-# does not depend on menuconfig
-ifneq ($(BOARD)-$(KERNEL),brcm-2.4)
-BR2_PACKAGE_NVRAM:=m
-else
-BR2_PACKAGE_NVRAM:=y
-endif
-
 $(eval $(call PKG_template,NVRAM,nvram,$(PKG_RELEASE),$(ARCH)))
 
 $(PKG_BUILD_DIR)/.prepared:
diff --git a/openwrt/package/rules.mk b/openwrt/package/rules.mk
index f7b81c62af..67fad9ae32 100644
--- a/openwrt/package/rules.mk
+++ b/openwrt/package/rules.mk
@@ -1,6 +1,4 @@
 # invoke ipkg with configuration in $(STAGING_DIR)/etc/ipkg.conf 
-IPKG := IPKG_INSTROOT=$(TARGET_DIR) IPKG_CONF_DIR=$(IPKG_CONF) $(SCRIPT_DIR)/ipkg -force-defaults -force-depends
-IPKG_STATE_DIR := $(TARGET_DIR)/usr/lib/ipkg
 
 define PKG_template
 IPKG_$(1):=$(PACKAGE_DIR)/$(2)_$(3)_$(4).ipk
diff --git a/openwrt/rules.mk b/openwrt/rules.mk
index 2759941e2f..e6118bfb64 100644
--- a/openwrt/rules.mk
+++ b/openwrt/rules.mk
@@ -2,21 +2,41 @@ include $(TOPDIR)/.config
 SHELL=/bin/bash
 export SHELL
 
-MAKE1=make
-MAKEFLAGS=-j$(BR2_JLEVEL)
+ifeq ($(V),)
+V=99
+endif
+
+ifneq ($(V),0)
+TRACE:=echo "---> "
+else
+TRACE:=:
+endif
+
+ifeq (${shell [ "$(V)" -ge 5 ] && echo 1},)
+PKG_TRACE:=:
+else
+PKG_TRACE:=echo "------> "
+endif
 
+ifeq (${shell [ "$(V)" -ge 10 ] && echo 1},)
+EXTRA_MAKEFLAGS:=-s
+MAKE_TRACE:=>&/dev/null
+else
+MAKE_TRACE:=
+EXTRA_MAKEFLAGS:=
+TRACE:=:
+PKG_TRACE:=:
+endif
+
+MAKE1=make
+MAKEFLAGS=-j$(BR2_JLEVEL) V=$(V) $(EXTRA_MAKEFLAGS)
 # Strip off the annoying quoting
 ARCH:=$(strip $(subst ",, $(BR2_ARCH)))
-#"
 WGET:=$(strip $(subst ",, $(BR2_WGET)))
-#"
-
 GCC_VERSION:=$(strip $(subst ",, $(BR2_GCC_VERSION)))
-#"
 GCC_USE_SJLJ_EXCEPTIONS:=$(strip $(subst ",, $(BR2_GCC_USE_SJLJ_EXCEPTIONS)))
-#"
 TARGET_OPTIMIZATION:=$(strip $(subst ",, $(BR2_TARGET_OPTIMIZATION)))
-#""
+#"))"))"))"))")) # for vim's broken syntax highlighting :)
 
 
 ifeq ($(BR2_SOFT_FLOAT),y)
@@ -51,15 +71,14 @@ HOSTCC:=gcc
 BASE_DIR:=$(TOPDIR)
 DL_DIR:=$(BASE_DIR)/dl
 BUILD_DIR:=$(BASE_DIR)/build_$(ARCH)$(ARCH_FPU_SUFFIX)
+STAGING_DIR:=$(BASE_DIR)/staging_dir_$(ARCH)$(ARCH_FPU_SUFFIX)
 SCRIPT_DIR:=$(BASE_DIR)/scripts
 BIN_DIR:=$(BASE_DIR)/bin
 STAMP_DIR:=$(BUILD_DIR)/stamp
 PACKAGE_DIR:=$(BIN_DIR)/packages
 STAMP_DIR:=$(BUILD_DIR)/stamp
+TARGET_DIR:=$(BUILD_DIR)/root
 TOOL_BUILD_DIR=$(BASE_DIR)/toolchain_build_$(ARCH)$(ARCH_FPU_SUFFIX)
-# Strip off the annoying quoting
-STAGING_DIR:=$(strip $(subst ",, $(BR2_STAGING_DIR)))
-#"
 TARGET_PATH=$(STAGING_DIR)/usr/bin:$(STAGING_DIR)/bin:/bin:/sbin:/usr/bin:/usr/sbin
 IMAGE:=$(BUILD_DIR)/root_fs_$(ARCH)$(ARCH_FPU_SUFFIX)
 REAL_GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux-uclibc
@@ -67,7 +86,6 @@ GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux
 KERNEL_CROSS:=$(STAGING_DIR)/bin/$(OPTIMIZE_FOR_CPU)-linux-uclibc-
 TARGET_CROSS:=$(STAGING_DIR)/bin/$(OPTIMIZE_FOR_CPU)-linux-uclibc-
 TARGET_CC:=$(TARGET_CROSS)gcc
-#STRIP:=$(TARGET_CROSS)strip --remove-section=.comment --remove-section=.note
 STRIP:=$(STAGING_DIR)/bin/sstrip
 PATCH=$(SCRIPT_DIR)/patch-kernel.sh
 SED:=$(STAGING_DIR)/bin/sed -i -e
@@ -110,9 +128,10 @@ endif
 
 # invoke ipkg-build with some default options
 IPKG_BUILD := PATH="$(TARGET_PATH)" ipkg-build -c -o root -g root
-
 # where to build (and put) .ipk packages
 IPKG_TARGET_DIR := $(PACKAGE_DIR)
+IPKG:=IPKG_TMP=$(BUILD_DIR)/tmp IPKG_INSTROOT=$(TARGET_DIR) IPKG_CONF_DIR=$(STAGING_DIR)/etc $(SCRIPT_DIR)/ipkg -force-defaults -force-depends
+IPKG_STATE_DIR := $(TARGET_DIR)/usr/lib/ipkg
 
 RSTRIP:=STRIP="$(STRIP)" $(SCRIPT_DIR)/rstrip.sh
 RSTRIP_KMOD:=STRIP="$(TARGET_CROSS)strip --strip-unneeded --remove-section=.comment" $(SCRIPT_DIR)/rstrip.sh
diff --git a/openwrt/target/Makefile b/openwrt/target/Makefile
index e6156b48bf..a14749fcae 100644
--- a/openwrt/target/Makefile
+++ b/openwrt/target/Makefile
@@ -17,15 +17,21 @@ image_clean:
 	rm -f $(BIN_DIR)/openwrt-*
 
 %-clean:
+	@$(TRACE) target/$(patsubst %-clean,%,$@)/clean
 	$(MAKE) -C $(patsubst %-clean,%,$@) clean
 %-prepare:
+	@$(TRACE) target/$(patsubst %-prepare,%,$@)/prepare
 	$(MAKE) -C $(patsubst %-prepare,%,$@) prepare
 %-compile: %-prepare
+	@$(TRACE) target/$(patsubst %-compile,%,$@)/compile
 	$(MAKE) -C $(patsubst %-compile,%,$@) compile
 %-rebuild: 
+	@$(TRACE) target/$(patsubst %-rebuild,%,$@)/rebuild
 	$(MAKE) -C $(patsubst %-rebuild,%,$@) rebuild
 %-install: %-compile
+	@$(TRACE) target/$(patsubst %-install,%,$@)/install
 	$(MAKE) -C $(patsubst %-install,%,$@) install
 linux-imagebuilder:
+	@$(TRACE) target/linux/imagebuilder
 	$(MAKE) -C linux imagebuilder
 
diff --git a/openwrt/target/linux/Config.in b/openwrt/target/linux/Config.in
index 69f96c48d1..4c1b5ee1bb 100644
--- a/openwrt/target/linux/Config.in
+++ b/openwrt/target/linux/Config.in
@@ -1,13 +1,10 @@
-
-config BR2_LINUX_2_4
-	bool "Linux 2.4 (choose only one target board)"
-	default y
-
+choice
+	prompt "Target system"
+	
 config BR2_LINUX_2_4_BRCM
-	bool "Support for Broadcom based routers"
+	bool "Support for Broadcom based routers [2.4]"
 	default y
 	depends BR2_mipsel
-	depends BR2_LINUX_2_4
 	help
 	  Build firmware images for Broadcom based routers
 	  (e.g. Linksys WRT54G(S), Asus WL-500g, Motorola WR850G)
@@ -17,48 +14,30 @@ config BR2_LINUX_2_4_BRCM
 	  with TFTP client too. 
 
 config BR2_LINUX_2_4_AR7
-	bool "Support for TI AR7 based devices"
+	bool "Support for TI AR7 based devices [2.4]"
 	default n
 	depends BR2_mipsel
-	depends BR2_LINUX_2_4
 	help
 	  Build firmware images for TI AR7 based routers (w.g. Linksys WAG54G v2)
 
 config BR2_LINUX_2_4_SOEKRIS
-	bool "Support for Soekris boards"
+	bool "Support for Soekris boards [2.4]"
 	default n
 	depends BR2_i386
-	depends BR2_LINUX_2_4
 	help
 	  Build firmware images for Soekris based boards
 	  (e.g. net4521, net4801)
-	  
-	config BR2_TARGET_NET4521
-		default y
-		depends BR2_LINUX_2_4_SOEKRIS
-		bool "Soekris net4521"
-
-	config BR2_TARGET_NET4801
-		default y
-		depends BR2_LINUX_2_4_SOEKRIS
-		bool "Soekris net4801"
-
-config BR2_LINUX_2_6
-	bool "Linux 2.6"
-	default n
-
+	 
 config BR2_LINUX_2_6_BRCM
-	bool "Support for Broadcom based routers"
+	bool "Support for Broadcom based routers [2.6]"
 	default n
 	depends BR2_mipsel
-	depends BR2_LINUX_2_6
-	select BR2_PACKAGE_KMOD_B44
-	select BR2_PACKAGE_KMOD_MADWIFI
-	select BR2_PACKAGE_ROBOCFG
 	help
 	  Build firmware images for Broadcom based routers
 	  (e.g. Netgear WGT634u)
-	  
+	
+endchoice
+	
 comment "Kernel Modules"
 
 config BR2_PACKAGE_KMOD_SANGAM_ATM_A
@@ -103,6 +82,7 @@ config BR2_PACKAGE_KMOD_BRCM_ET
 config BR2_PACKAGE_KMOD_B44
 	tristate "Broadcom 44XX, 47XX ethernet driver"
 	default m
+	default y if BR2_LINUX_2_6_BRCM
 	help
 	  Free driver for Broadcom Ethernet chipsets (without switch support)
 
@@ -347,7 +327,6 @@ config BR2_PACKAGE_KMOD_PPPOATM
 
 config BR2_PACKAGE_KMOD_ATM
 	tristate "ATM support"
-	default m
 	default y if BR2_LINUX_2_4_AR7
 	help
 	  ATM support
diff --git a/openwrt/target/linux/Makefile b/openwrt/target/linux/Makefile
index 6fec977d65..2362ad6dd2 100644
--- a/openwrt/target/linux/Makefile
+++ b/openwrt/target/linux/Makefile
@@ -58,6 +58,7 @@ $(BIN_DIR)/$(IB_NAME).tar.bz2:
 	cp $(TOPDIR)/rules.mk $(IB_DIR)
 	cp -fpR ./image $(IB_DIR)/
 	cp $(TOPDIR)/.config $(IB_DIR)/
+	find $(IB_DIR) -name .svn | xargs rm -rf
 	find $(IB_DIR) -name CVS | xargs rm -rf
 	(cd $(BUILD_DIR); tar c $(IB_NAME) | bzip2 -c > $(BIN_DIR)/$(IB_NAME).tar.bz2)
 
@@ -66,8 +67,10 @@ install: $(BIN_DIR)/$(IB_NAME).tar.bz2
 endif
 
 prepare:
+	@$(TRACE) target/linux/image/prepare
 	$(MAKE) -C image prepare
 compile:
+	@$(TRACE) target/linux/image/compile
 	$(MAKE) -C image compile
 install:
 rebuild:
diff --git a/openwrt/target/linux/image/Makefile b/openwrt/target/linux/image/Makefile
index 1e3e22f15c..1dd48c7528 100644
--- a/openwrt/target/linux/image/Makefile
+++ b/openwrt/target/linux/image/Makefile
@@ -17,10 +17,15 @@ endif
 prepare:
 compile:
 install:
+
+$(BOARD)-compile:
+	@$(TRACE) target/linux/image/$(BOARD)/prepare
 	$(MAKE) -C $(BOARD) prepare
+	@$(TRACE) target/linux/image/$(BOARD)/compile
 	$(MAKE) -C $(BOARD) compile
 
 install-ib:
+	@$(TRACE) target/linux/image/$(BOARD)/install-ib
 	-$(MAKE) -C $(BOARD) IB_DIR="$(IB_DIR)" install-ib
 	mkdir -p $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)
 	cp $(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)/kernel[-_]*.ipk $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)/	
diff --git a/openwrt/target/linux/image/jffs2.mk b/openwrt/target/linux/image/jffs2.mk
index 2a169ab320..ab8cfbef33 100644
--- a/openwrt/target/linux/image/jffs2.mk
+++ b/openwrt/target/linux/image/jffs2.mk
@@ -19,8 +19,10 @@ $(KDIR)/root.jffs2-8MB: install-prepare
 	@rm -rf $(KDIR)/root/jffs
 	$(STAGING_DIR)/bin/mkfs.jffs2 $(JFFS2OPTS) -e 0x20000 -o $@ -d $(KDIR)/root
 
-jffs2-install: $(KDIR)/root.jffs2-4MB $(KDIR)/root.jffs2-8MB
+jffs2-install: $(KDIR)/root.jffs2-4MB $(KDIR)/root.jffs2-8MB $(BOARD)-compile
+	$(TRACE) target/linux/image/$(BOARD)/install
 	$(MAKE) -C $(BOARD) install KERNEL="$(KERNEL)" FS="jffs2-4MB"
+	$(TRACE) target/linux/image/$(BOARD)/install
 	$(MAKE) -C $(BOARD) install KERNEL="$(KERNEL)" FS="jffs2-8MB"
 
 jffs2-install-ib:
diff --git a/openwrt/target/linux/image/squashfs.mk b/openwrt/target/linux/image/squashfs.mk
index 3811567a09..00411c05e4 100644
--- a/openwrt/target/linux/image/squashfs.mk
+++ b/openwrt/target/linux/image/squashfs.mk
@@ -12,7 +12,8 @@ $(KDIR)/root.squashfs: install-prepare
 	@mkdir -p $(KDIR)/root/jffs
 	$(STAGING_DIR)/bin/mksquashfs-lzma $(KDIR)/root $@ -nopad -noappend -root-owned -le
 
-squashfs-install: $(KDIR)/root.squashfs
+squashfs-install: $(KDIR)/root.squashfs $(BOARD)-compile
+	$(TRACE) target/linux/image/$(BOARD)/install
 	$(MAKE) -C $(BOARD) install KERNEL="$(KERNEL)" FS="squashfs"
 
 squashfs-install-ib:
diff --git a/openwrt/target/linux/linux-2.4/Makefile b/openwrt/target/linux/linux-2.4/Makefile
index ede1e7a985..2754c42306 100644
--- a/openwrt/target/linux/linux-2.4/Makefile
+++ b/openwrt/target/linux/linux-2.4/Makefile
@@ -16,7 +16,7 @@ LINUX_BINARY_DRIVER_SITE := http://openwrt.org/downloads/sources/
 LINUX_SOURCE := linux-$(LINUX_VERSION).tar.bz2
 LINUX_SOURCE_DIR := $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)
 MODULES_DIR := $(LINUX_BUILD_DIR)/modules/$(MODULES_SUBDIR)
-TARGET_MODULES_DIR := $(TARGET_DIR)/lib/modules/$(LINUX_VERSION)
+TARGET_MODULES_DIR := $(LINUX_TARGET_DIR)/lib/modules/$(LINUX_VERSION)
 IPKG_KERNEL:=IPKG_TMP=$(BUILD_DIR)/tmp IPKG_INSTROOT=$(LINUX_TARGET_DIR) IPKG_CONF_DIR=$(LINUX_BUILD_DIR) $(SCRIPT_DIR)/ipkg -force-defaults -force-depends
 
 PKG_BUILD_DIR := $(LINUX_BUILD_DIR)/linux-modules
@@ -250,6 +250,7 @@ $(STAMP_DIR)/.linux-compile: $(LINUX_DIR)/.modules_done
 	@mkdir -p $(STAMP_DIR)
 	@$(MAKE) $(TARGETS)
 	ln -sf $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(LINUX_DIR)
+	@$(TRACE) target/linux/package
 	$(MAKE) -C $(TOPDIR)/target/linux/package \
 		$(KPKG_MAKEOPTS) \
 		compile
@@ -274,12 +275,8 @@ compile: $(STAMP_DIR)/.linux-compile
 
 install: compile $(TARGET_MODULES_DIR) $(KERNEL_IPKG)
 	rm -rf $(LINUX_BUILD_DIR)/root*
+	cp -fpR $(BUILD_DIR)/root $(LINUX_BUILD_DIR)/
 	echo -e 'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR)/ipkg.conf
-	$(MAKE) -C $(TOPDIR)/package \
-		TARGET_DIR="$(LINUX_TARGET_DIR)" \
-		IPKG_CONF="$(LINUX_BUILD_DIR)" \
-		BOARD="$(BOARD)" \
-		install
 	$(MAKE) -C $(TOPDIR)/target/linux/package \
 		$(KPKG_MAKEOPTS) \
 		install
diff --git a/openwrt/target/linux/linux-2.6/Makefile b/openwrt/target/linux/linux-2.6/Makefile
index 544b5c5c73..b61adf6255 100644
--- a/openwrt/target/linux/linux-2.6/Makefile
+++ b/openwrt/target/linux/linux-2.6/Makefile
@@ -25,7 +25,7 @@ LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
 LINUX_SOURCE := linux-$(LINUX_VERSION).tar.bz2
 LINUX_SOURCE_DIR := $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)
 MODULES_DIR := $(LINUX_BUILD_DIR)/modules/$(MODULES_SUBDIR)
-TARGET_MODULES_DIR := $(TARGET_DIR)/lib/modules/$(LINUX_VERSION)
+TARGET_MODULES_DIR := $(LINUX_TARGET_DIR)/lib/modules/$(LINUX_VERSION)
 IPKG_KERNEL:=IPKG_TMP=$(BUILD_DIR)/tmp IPKG_INSTROOT=$(LINUX_TARGET_DIR) IPKG_CONF_DIR=$(LINUX_BUILD_DIR) $(SCRIPT_DIR)/ipkg -force-defaults -force-depends
 
 PKG_BUILD_DIR := $(LINUX_BUILD_DIR)/linux-modules
@@ -47,10 +47,6 @@ include $(LINUX_KCONFIG)
 INSTALL_TARGETS := $(KERNEL_IPKG)
 TARGETS := 
 
-ifeq ($(BOARD),brcm)
-include ./broadcom.mk
-endif
-
 $(eval $(call KMOD_template,ATM,atm,\
 	$(MODULES_DIR)/kernel/net/atm/atm.ko \
 	$(MODULES_DIR)/kernel/net/atm/br2684.ko \
@@ -238,18 +234,15 @@ source: $(DL_DIR)/$(LINUX_SOURCE)
 prepare: $(LINUX_DIR)/.configured
 compile: $(LINUX_DIR)/.modules_done $(TARGETS)
 	ln -sf $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(LINUX_DIR)
+	@$(TRACE) target/linux/package
 	$(MAKE) -C $(TOPDIR)/target/linux/package \
 		$(KPKG_MAKEOPTS) \
 		compile
 
 install: compile $(TARGET_MODULES_DIR) $(KERNEL_IPKG)
 	rm -rf $(LINUX_BUILD_DIR)/root*
+	cp -fpR $(BUILD_DIR)/root $(LINUX_BUILD_DIR)/
 	echo -e 'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR)/ipkg.conf
-	$(MAKE) -C $(TOPDIR)/package \
-		TARGET_DIR="$(LINUX_TARGET_DIR)" \
-		IPKG_CONF="$(LINUX_BUILD_DIR)" \
-		BOARD="$(BOARD)" \
-		install
 	$(MAKE) -C $(TOPDIR)/target/linux/package \
 		$(KPKG_MAKEOPTS) \
 		install
diff --git a/openwrt/target/linux/linux-2.6/broadcom.mk b/openwrt/target/linux/linux-2.6/broadcom.mk
deleted file mode 100644
index f34fe6ac6a..0000000000
--- a/openwrt/target/linux/linux-2.6/broadcom.mk
+++ /dev/null
@@ -1,3 +0,0 @@
-# $Id$
-#
-# broadcom specific kmod packages
diff --git a/openwrt/target/linux/package/Makefile b/openwrt/target/linux/package/Makefile
index 7e8588d99a..6b7a85816c 100644
--- a/openwrt/target/linux/package/Makefile
+++ b/openwrt/target/linux/package/Makefile
@@ -34,20 +34,24 @@ MAKEOPTS:=	BOARD="$(BOARD)" \
 
 
 %-prepare:
+	@$(TRACE) target/linux/package/$(patsubst %-prepare,%,$@)-prepare
 	$(MAKE) -C $(patsubst %-prepare,%,$@) \
 		$(MAKEOPTS) \
 		prepare
 
 %-compile: %-prepare 
+	@$(TRACE) target/linux/package/$(patsubst %-compile,%,$@)-compile
 	$(MAKE) -C $(patsubst %-compile,%,$@) \
 		$(MAKEOPTS) \
 		compile
 
 %-install: %-compile
+	@$(TRACE) target/linux/package/$(patsubst %-install,%,$@)-install
 	$(MAKE) -C $(patsubst %-install,%,$@) \
 		$(MAKEOPTS) \
 		install
 
 %-clean:
+	@$(TRACE) target/linux/package/$(patsubst %-clean,%,$@)-clean
 	@$(MAKE) -C $(patsubst %-clean,%,$@) clean
 
diff --git a/openwrt/toolchain/Makefile b/openwrt/toolchain/Makefile
index 361f7be5bb..9cc24d5362 100644
--- a/openwrt/toolchain/Makefile
+++ b/openwrt/toolchain/Makefile
@@ -30,18 +30,28 @@ $(TOOL_BUILD_DIR):
 	@mkdir -p $(TOOL_BUILD_DIR)
 
 %-prepare: $(TOOLCHAIN_STAMP_DIR) $(STAGING_DIR) $(TOOL_BUILD_DIR)
-	@[ -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@ ] || $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
+	@[ -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@ ] || { \
+		$(TRACE) toolchain/$(patsubst %-prepare,%,$@)/prepare; \
+		$(MAKE) -C $(patsubst %-prepare,%,$@) prepare; \
+	}
 	@touch $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@
 
 %-compile: %-prepare 
-	@[ -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@ ] || $(MAKE) -C $(patsubst %-compile,%,$@) compile
+	@[ -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@ ] || { \
+		$(TRACE) toolchain/$(patsubst %-compile,%,$@)/compile; \
+		$(MAKE) -C $(patsubst %-compile,%,$@) compile; \
+	}
 	@touch $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@
 
 %-install: %-compile
-	@[ -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@ ] || $(MAKE) -C $(patsubst %-install,%,$@) install
+	@[ -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@ ] || { \
+		$(TRACE) toolchain/$(patsubst %-install,%,$@)/install; \
+		$(MAKE) -C $(patsubst %-install,%,$@) install; \
+	}
 	@touch $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@
 
 %-clean:
+	$(TRACE) toolchain/$(patsubst %-clean,%,$@)/clean
 	@$(MAKE) -C $(patsubst %-clean,%,$@) clean
 	@rm -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$(patsubst %-clean,%,$@)-*
 
diff --git a/openwrt/toolchain/kernel-headers/Makefile b/openwrt/toolchain/kernel-headers/Makefile
index 49e8b2a03d..c567292fad 100644
--- a/openwrt/toolchain/kernel-headers/Makefile
+++ b/openwrt/toolchain/kernel-headers/Makefile
@@ -4,10 +4,11 @@ include $(TOPDIR)/rules.mk
 
 LINUX_HEADERS_VERSION=2.4.30
 LINUX_KERNEL_MD5SUM:=75d8ce40a3668603017cd186909efe8d
-LINUX_HEADERS_SITE=http://www.fi.kernel.org/pub/linux/kernel/v2.4 \
-		   http://www.fr.kernel.org/pub/linux/kernel/v2.4 \
-		   http://www.kernel.org/pub/linux/kernel/v2.4 \
-		   http://www.de.kernel.org/pub/linux/kernel/v2.4 
+LINUX_HEADERS_SITE= \
+		http://www.de.kernel.org/pub/linux/kernel/v2.4 \
+		http://www.fi.kernel.org/pub/linux/kernel/v2.4 \
+		http://www.fr.kernel.org/pub/linux/kernel/v2.4 \
+		http://www.kernel.org/pub/linux/kernel/v2.4 \
 
 LINUX_HEADERS_SOURCE=linux-$(LINUX_HEADERS_VERSION).tar.bz2
 LINUX_HEADERS_ARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
-- 
GitLab