Просмотр исходного кода

major target cleanup. it is now possible to have subtargets that can override many target settings, including arch - merge adm5120, adm5120eb. target profiles still need to be adapted for subtargets

SVN-Revision: 8694
Felix Fietkau 18 лет назад
Родитель
Сommit
a9d683ca91
95 измененных файлов с 343 добавлено и 349 удалено
  1. 1 1
      Makefile
  2. 1 0
      include/image.mk
  3. 26 118
      include/kernel-build.mk
  4. 2 5
      include/kernel-defaults.mk
  5. 6 8
      include/kernel-version.mk
  6. 16 7
      include/kernel.mk
  7. 2 2
      include/scan.mk
  8. 2 2
      include/subdir.mk
  9. 138 8
      include/target.mk
  10. 1 2
      include/toplevel.mk
  11. 1 1
      package/acx/Makefile
  12. 1 1
      package/admswconfig/Makefile
  13. 1 1
      package/ar7-atm/Makefile
  14. 6 1
      package/base-files/Makefile
  15. 1 1
      package/bcm43xx-mac80211/Makefile
  16. 2 2
      package/broadcom-diag/Makefile
  17. 1 1
      package/broadcom-mmc/Makefile
  18. 2 2
      package/broadcom-wl/Makefile
  19. 1 1
      package/fonera-mp3-drv/Makefile
  20. 1 1
      package/fonera-mp3/Makefile
  21. 1 1
      package/foxboard-utils/Makefile
  22. 1 1
      package/hostapd/Makefile
  23. 1 1
      package/ipset/Makefile
  24. 1 1
      package/nvram/Makefile
  25. 1 1
      package/switch/Makefile
  26. 1 1
      package/util-linux/Makefile
  27. 2 2
      package/wlcompat/Makefile
  28. 1 1
      package/yamonenv/Makefile
  29. 7 3
      rules.mk
  30. 0 0
      scripts/kconfig.pl
  31. 13 45
      scripts/metadata.pl
  32. 1 1
      target/linux/Makefile
  33. 7 14
      target/linux/adm5120/Makefile
  34. 0 0
      target/linux/adm5120/router_be/config-2.6.22
  35. 0 0
      target/linux/adm5120/router_be/image/Makefile
  36. 0 0
      target/linux/adm5120/router_be/image/lzma-loader
  37. 0 0
      target/linux/adm5120/router_be/profiles/090-Zyxel.mk
  38. 0 0
      target/linux/adm5120/router_be/profiles/100-Texas.mk
  39. 0 0
      target/linux/adm5120/router_be/profiles/110-Atheros.mk
  40. 0 0
      target/linux/adm5120/router_be/profiles/110-None.mk
  41. 9 0
      target/linux/adm5120/router_be/target.mk
  42. 0 0
      target/linux/adm5120/router_le/base-files/default/sbin/wget2nand
  43. 0 0
      target/linux/adm5120/router_le/config-2.6.22
  44. 0 0
      target/linux/adm5120/router_le/profiles/100-Atheros.mk
  45. 0 0
      target/linux/adm5120/router_le/profiles/105-Texas.mk
  46. 0 0
      target/linux/adm5120/router_le/profiles/110-Ralink.mk
  47. 0 0
      target/linux/adm5120/router_le/profiles/200-None.mk
  48. 0 0
      target/linux/adm5120/router_le/profiles/Cellvision.mk
  49. 0 0
      target/linux/adm5120/router_le/profiles/RB1xx.mk
  50. 9 0
      target/linux/adm5120/router_le/target.mk
  51. 0 27
      target/linux/adm5120eb/Makefile
  52. 0 1
      target/linux/adm5120eb/files
  53. 0 1
      target/linux/adm5120eb/patches-2.6.22
  54. 4 3
      target/linux/amazon/Makefile
  55. 0 0
      target/linux/amazon/config-2.6.21
  56. 3 3
      target/linux/amcc/Makefile
  57. 0 0
      target/linux/amcc/config-2.6.21
  58. 3 3
      target/linux/ar7/Makefile
  59. 0 0
      target/linux/ar7/config-2.6.22
  60. 5 4
      target/linux/at91/Makefile
  61. 0 0
      target/linux/at91/config-2.6.22
  62. 5 4
      target/linux/atheros/Makefile
  63. 0 0
      target/linux/atheros/config-2.6.22
  64. 4 4
      target/linux/au1000/Makefile
  65. 0 0
      target/linux/au1000/config-2.6.22
  66. 3 6
      target/linux/avr32/Makefile
  67. 7 6
      target/linux/brcm-2.4/Makefile
  68. 0 0
      target/linux/brcm-2.4/config-2.4.34
  69. 4 4
      target/linux/brcm47xx/Makefile
  70. 0 0
      target/linux/brcm47xx/config-2.6.22
  71. 3 4
      target/linux/brcm63xx/Makefile
  72. 0 0
      target/linux/brcm63xx/config-2.6.22
  73. 7 8
      target/linux/etrax/Makefile
  74. 0 0
      target/linux/generic-2.4/config-default
  75. 0 0
      target/linux/generic-2.6/config-default
  76. 2 5
      target/linux/iop32x/Makefile
  77. 0 0
      target/linux/iop32x/config-2.6.21
  78. 2 5
      target/linux/ixp4xx/Makefile
  79. 0 0
      target/linux/ixp4xx/config-2.6.21
  80. 2 2
      target/linux/magicbox/Makefile
  81. 0 0
      target/linux/magicbox/config-2.6.22
  82. 3 3
      target/linux/pxa/Makefile
  83. 0 0
      target/linux/pxa/config-2.6.21
  84. 2 2
      target/linux/rb532/Makefile
  85. 0 0
      target/linux/rb532/config-2.6.22
  86. 5 5
      target/linux/rdc/Makefile
  87. 0 0
      target/linux/rdc/config-2.6.22
  88. 0 2
      target/linux/rdc/config/profile-wl153
  89. 2 2
      target/linux/sibyte/Makefile
  90. 0 0
      target/linux/sibyte/config-2.6.21
  91. 2 2
      target/linux/uml/Makefile
  92. 2 2
      target/linux/x86/Makefile
  93. 3 1
      toolchain/Makefile
  94. 1 1
      toolchain/gcc/Makefile
  95. 2 2
      toolchain/uClibc/Makefile

+ 1 - 1
Makefile

@@ -45,7 +45,7 @@ clean: FORCE
 	rm -rf $(TMP_DIR)
 
 dirclean: clean
-	rm -rf $(STAGING_DIR) $(STAGING_DIR_HOST) $(STAGING_DIR_TOOLCHAIN) $(BUILD_DIR_TOOLCHAIN) $(BUILD_DIR_HOST)
+	rm -rf $(STAGING_DIR) $(STAGING_DIR_HOST) $(STAGING_DIR_TOOLCHAIN) $(TOOLCHAIN_DIR) $(BUILD_DIR_HOST)
 
 # check prerequisites before starting to build
 prereq: $(package/stamp-prereq) $(target/stamp-prereq) ;

+ 1 - 0
include/image.mk

@@ -5,6 +5,7 @@
 # See /LICENSE for more information.
 #
 
+override TARGET_BUILD=
 include $(INCLUDE_DIR)/prereq.mk
 include $(INCLUDE_DIR)/kernel.mk
 include $(INCLUDE_DIR)/host.mk

+ 26 - 118
include/kernel-build.mk

@@ -1,60 +1,20 @@
-# 
+#
 # Copyright (C) 2006-2007 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
 #
-KERNEL_BUILD:=1
-
 include $(INCLUDE_DIR)/host.mk
-include $(INCLUDE_DIR)/kernel.mk
 include $(INCLUDE_DIR)/prereq.mk
 
-override MAKEFLAGS=
-
-GENERIC_LINUX_CONFIG:=$(GENERIC_PLATFORM_DIR)/config-$(shell [ -f "$(GENERIC_PLATFORM_DIR)/config-$(KERNEL_PATCHVER)" ] && echo "$(KERNEL_PATCHVER)" || echo template ) 
-LINUX_CONFIG_DIR ?= ./config$(shell [ -d "./config-$(KERNEL_PATCHVER)" ] && printf -- "-$(KERNEL_PATCHVER)" || true )
-LINUX_CONFIG ?= $(LINUX_CONFIG_DIR)/default
-
-ifneq ($(DUMP),)
-  TMP_CONFIG:=$(TMP_DIR)/.kconfig-$(BOARD)-$(KERNEL)
-  $(TMP_CONFIG): $(GENERIC_LINUX_CONFIG) $(LINUX_CONFIG)
-	$(SCRIPT_DIR)/config.pl + $^ > $@
-  -include $(TMP_CONFIG)
-  .SILENT: $(TMP_CONFIG)
+ifneq ($(DUMP),1)
+  override MAKEFLAGS=
 endif
 
-ifneq ($(CONFIG_PCI),)
-  FEATURES += pci
-endif
-ifneq ($(CONFIG_USB),)
-  FEATURES += usb
-endif
-ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),)
-  FEATURES += pcmcia
-endif
-
-# remove duplicates
-FEATURES:=$(sort $(FEATURES))
-
-ifeq ($(DUMP),1)
-  all: dumpinfo
-else
+ifneq ($(DUMP),1)
   all: compile
 endif
 
-ifneq (,$(findstring uml,$(BOARD)))
-  LINUX_KARCH:=um
-else
-  LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
-	-e 's/mipsel/mips/' \
-	-e 's/mipseb/mips/' \
-	-e 's/powerpc/ppc/' \
-	-e 's/sh[234]/sh/' \
-	-e 's/armeb/arm/' \
-  )
-endif
-
 STAMP_PREPARED:=$(LINUX_DIR)/.prepared
 STAMP_CONFIGURED:=$(LINUX_DIR)/.configured
 include $(INCLUDE_DIR)/quilt.mk
@@ -90,106 +50,54 @@ define BuildKernel
   $(STAMP_PREPARED): $(DL_DIR)/$(LINUX_SOURCE)
 	-rm -rf $(KERNEL_BUILD_DIR)
 	-mkdir -p $(KERNEL_BUILD_DIR)
-	$(call Kernel/Prepare)
+	$(Kernel/Prepare)
 	touch $$@
 
   $(STAMP_CONFIGURED): $(STAMP_PREPARED) $(LINUX_CONFIG) $(GENERIC_LINUX_CONFIG) $(TOPDIR)/.config
-	$(call Kernel/Configure)
+	$(Kernel/Configure)
 	touch $$@
 
   $(LINUX_DIR)/.modules: $(STAMP_CONFIGURED) $(LINUX_DIR)/.config FORCE
-	$(call Kernel/CompileModules)
+	$(Kernel/CompileModules)
 	touch $$@
 
   $(LINUX_DIR)/.image: $(STAMP_CONFIGURED) FORCE
-	$(call Kernel/CompileImage)
+	$(Kernel/CompileImage)
 	touch $$@
 	
   mostlyclean: FORCE
-	$(call Kernel/Clean)
-
-  ifeq ($(DUMP),1)
-    dumpinfo:
-		@echo 'Target: $(BOARD)'
-		@echo 'Target-Kernel: $(KERNEL)'
-		@echo 'Target-Name: $(BOARDNAME) [$(KERNEL)]'
-		@echo 'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'
-		@echo 'Target-Arch: $(ARCH)'
-		@echo 'Target-Features: $(FEATURES)'
-		@echo 'Linux-Version: $(LINUX_VERSION)'
-		@echo 'Linux-Release: $(LINUX_RELEASE)'
-		@echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'
-		@echo 'Target-Description:'
-		@getvar $(call shvar,Target/Description)
-		@echo '@@'
-		@echo 'Default-Packages: $(DEFAULT_PACKAGES)'
-    ifneq ($(DUMPINFO),)
-		@$(DUMPINFO)
-    endif
-  endif
+	$(Kernel/Clean)
 
   define BuildKernel
   endef
-endef
-
-define Profile/Default
-  NAME:=
-  PACKAGES:=
-endef
-
-confname=$(subst .,_,$(subst -,_,$(1)))
-define Profile
-  $(eval $(call Profile/Default))
-  $(eval $(call Profile/$(1)))
-  $(eval $(call shexport,Profile/$(1)/Config))
-  $(eval $(call shexport,Profile/$(1)/Description))
-  DUMPINFO += \
-	echo "Target-Profile: $(1)"; \
-	echo "Target-Profile-Name: $(NAME)"; \
-	echo "Target-Profile-Packages: $(PACKAGES)"; \
-	if [ -f ./config/profile-$(1) ]; then \
-		echo "Target-Profile-Kconfig: yes"; \
-	fi; \
-	echo "Target-Profile-Config: "; \
-	getvar "$(call shvar,Profile/$(1)/Config)"; \
-	echo "@@"; \
-	echo "Target-Profile-Description:"; \
-	getvar "$(call shvar,Profile/$(1)/Description)"; \
-	echo "@@"; \
-	echo;
-  ifeq ($(CONFIG_LINUX_$(call confname,$(KERNEL)_$(1))),y)
-    PROFILE=$(1)
-  endif
-endef
-
-$(eval $(call shexport,Target/Description))
 
-download: $(DL_DIR)/$(LINUX_SOURCE)
-prepare: $(STAMP_CONFIGURED)
-compile: $(LINUX_DIR)/.modules
-	$(MAKE) -C image compile
+  download: $(DL_DIR)/$(LINUX_SOURCE)
+  prepare: $(STAMP_CONFIGURED)
+  compile: $(LINUX_DIR)/.modules
+	$(MAKE) -C image compile TARGET_BUILD=
 
-oldconfig menuconfig: $(STAMP_PREPARED) FORCE
-	$(call Kernel/Configure)
-	$(SCRIPT_DIR)/config.pl '+' $(GENERIC_LINUX_CONFIG) $(LINUX_CONFIG) > $(LINUX_DIR)/.config
+  oldconfig menuconfig: $(STAMP_PREPARED) FORCE
+	$(Kernel/Configure)
+	$(LINUX_CONFCMD) > $(LINUX_DIR)/.config
 	$(MAKE) -C $(LINUX_DIR) $(KERNEL_MAKEOPTS) $@
-	$(SCRIPT_DIR)/config.pl '>' $(GENERIC_LINUX_CONFIG) $(LINUX_DIR)/.config > $(LINUX_CONFIG)
+	$(SCRIPT_DIR)/kconfig.pl '>' $(GENERIC_LINUX_CONFIG) $(LINUX_DIR)/.config > $(LINUX_CONFIG)
 
-install: $(LINUX_DIR)/.image
-	$(MAKE) -C image compile install
+  install: $(LINUX_DIR)/.image
+	TARGET_BUILD="" $(MAKE) -C image compile install
 
-clean: FORCE
-	rm -f $(STAMP_DIR)/.linux-compile
+  clean: FORCE
 	rm -rf $(KERNEL_BUILD_DIR)
 
-rebuild: FORCE
+  rebuild: FORCE
 	@$(MAKE) mostlyclean
 	@if [ -f $(LINUX_KERNEL) ]; then \
 		$(MAKE) clean; \
 	fi
 	@$(MAKE) compile
 
-image-prereq:
-	$(SUBMAKE) -s -C image prereq
+  image-prereq:
+	$(SUBMAKE) -s -C image prereq TARGET_BUILD=
 
-prereq: image-prereq
+  prereq: image-prereq
+
+endef

+ 2 - 5
include/kernel-defaults.mk

@@ -46,11 +46,9 @@ define Kernel/Configure/2.6
 	-$(MAKE) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" oldconfig prepare scripts
 endef
 define Kernel/Configure/Default
-	$(SCRIPT_DIR)/config.pl '+' $(GENERIC_LINUX_CONFIG) \
-		$(if $(wildcard ./config/profile-$(PROFILE)),'+' $(LINUX_CONFIG) ./config/profile-$(PROFILE), $(LINUX_CONFIG)) \
-		> $(LINUX_DIR)/.config.target
+	$(LINUX_CONFCMD) > $(LINUX_DIR)/.config.target
 	$(SCRIPT_DIR)/metadata.pl kconfig $(TMP_DIR)/.packageinfo $(TOPDIR)/.config > $(LINUX_DIR)/.config.override
-	$(SCRIPT_DIR)/config.pl 'm+' $(LINUX_DIR)/.config.target $(LINUX_DIR)/.config.override >$(LINUX_DIR)/.config
+	$(SCRIPT_DIR)/kconfig.pl 'm+' $(LINUX_DIR)/.config.target $(LINUX_DIR)/.config.override > $(LINUX_DIR)/.config
 	$(call Kernel/Configure/$(KERNEL))
 	rm -rf $(KERNEL_BUILD_DIR)/modules
 	@rm -f $(BUILD_DIR)/linux
@@ -88,7 +86,6 @@ define Kernel/CompileImage/Default
 endef
 
 define Kernel/Clean/Default
-	rm -f $(LINUX_DIR)/.linux-compile
 	rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.configured
 	rm -f $(LINUX_KERNEL)
 	$(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean

+ 6 - 8
include/kernel-version.mk

@@ -1,11 +1,9 @@
 # Use the default kernel version if the Makefile doesn't override it
 
-ifeq ($(LINUX_VERSION),)
-  ifeq ($(KERNEL),2.4)
-    LINUX_VERSION:=2.4.34
-  else
-    LINUX_VERSION:=2.6.21.5
-  endif
+ifeq ($(KERNEL),2.4)
+  LINUX_VERSION?=2.4.34
+else
+  LINUX_VERSION?=2.6.21.5
 endif
 LINUX_RELEASE?=1
 
@@ -22,6 +20,6 @@ endif
 # disable the md5sum check for unknown kernel versions
 LINUX_KERNEL_MD5SUM?=x
 
-KERNEL:=2.$(word 2,$(subst ., ,$(strip $(LINUX_VERSION))))
-KERNEL_PATCHVER:=$(shell echo $(LINUX_VERSION) | cut -d. -f1,2,3 | cut -d- -f1)
+KERNEL?=2.$(word 2,$(subst ., ,$(strip $(LINUX_VERSION))))
+KERNEL_PATCHVER=$(shell echo $(LINUX_VERSION) | cut -d. -f1,2,3 | cut -d- -f1)
 

+ 16 - 7
include/kernel.mk

@@ -5,15 +5,15 @@
 # See /LICENSE for more information.
 #
 
-include $(INCLUDE_DIR)/kernel-version.mk
+ifeq ($(__target_inc),)
+  include $(INCLUDE_DIR)/target.mk
+endif
 
 ifeq ($(DUMP),1)
   KERNEL?=<KERNEL>
   BOARD?=<BOARD>
   LINUX_VERSION?=<LINUX_VERSION>
 else
-  include $(INCLUDE_DIR)/target.mk
-
   export GCC_HONOUR_COPTS=s
 
   ifeq ($(KERNEL),2.6)
@@ -30,9 +30,8 @@ else
     KERNEL_CROSS:=$(TARGET_CROSS)
   endif
 
-  PLATFORM_DIR := $(TOPDIR)/target/linux/$(BOARD)
   PATCH_DIR ?= ./patches$(shell [ -d "./patches-$(KERNEL_PATCHVER)" ] && printf -- "-$(KERNEL_PATCHVER)" || true )
-  KERNEL_BUILD_DIR ?= $(BUILD_DIR_BASE)/linux-$(BOARD)$(if $(BUILD_SUFFIX),_$(BUILD_SUFFIX))
+  KERNEL_BUILD_DIR ?= $(BUILD_DIR_BASE)/linux-$(BOARD)$(if $(SUBTARGET),_$(SUBTARGET))$(if $(BUILD_SUFFIX),_$(BUILD_SUFFIX))
   LINUX_DIR ?= $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)
 
   MODULES_SUBDIR:=lib/modules/$(LINUX_VERSION)
@@ -46,8 +45,18 @@ else
 
   PKG_BUILD_DIR ?= $(KERNEL_BUILD_DIR)/$(PKG_NAME)$(if $(PKG_VERSION),-$(PKG_VERSION))
 endif
-GENERIC_PLATFORM_DIR := $(TOPDIR)/target/linux/generic-$(KERNEL)
-GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/patches$(shell [ -d "$(GENERIC_PLATFORM_DIR)/patches-$(KERNEL_PATCHVER)" ] && printf -- "-$(KERNEL_PATCHVER)" || true )
+
+ifneq (,$(findstring uml,$(BOARD)))
+  LINUX_KARCH:=um
+else
+  LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
+	-e 's/mipsel/mips/' \
+	-e 's/mipseb/mips/' \
+	-e 's/powerpc/ppc/' \
+	-e 's/sh[234]/sh/' \
+	-e 's/armeb/arm/' \
+  )
+endif
 
 
 define KernelPackage/Defaults

+ 2 - 2
include/scan.mk

@@ -27,14 +27,14 @@ define PackageDir
 	{ \
 		$$(call progress,Collecting $(SCAN_NAME) info: $(SCAN_DIR)/$(2)) \
 		echo Source-Makefile: $(SCAN_DIR)/$(2)/Makefile; \
-		$(NO_TRACE_MAKE) --no-print-dir DUMP=1 -C $(SCAN_DIR)/$(2) 2>/dev/null || echo "ERROR: please fix $(SCAN_DIR)/$(2)/Makefile" >&2; \
+		$(NO_TRACE_MAKE) --no-print-dir DUMP=1 -C $(SCAN_DIR)/$(2) $(SCAN_MAKEOPTS) 2>/dev/null || echo "ERROR: please fix $(SCAN_DIR)/$(2)/Makefile" >&2; \
 		echo; \
 	} > $$@ || true
 endef
 
 $(FILELIST):
 	rm -f tmp/info/.files-$(SCAN_TARGET)-*
-	$(call FIND_L, $(SCAN_DIR)) $(SCAN_EXTRA) -mindepth 1 $(if $(SCAN_DEPTH),-maxdepth $(SCAN_DEPTH)) -name Makefile | xargs grep -HE 'call (Build/DefaultTargets|Build(Package|Kernel)|.+Package)' | sed -e 's#^$(SCAN_DIR)/##' -e 's#/Makefile:.*##' | uniq > $@
+	$(call FIND_L, $(SCAN_DIR)) $(SCAN_EXTRA) -mindepth 1 $(if $(SCAN_DEPTH),-maxdepth $(SCAN_DEPTH)) -name Makefile | xargs grep -HE 'call (Build/DefaultTargets|Build(Package|Target)|.+Package)' | sed -e 's#^$(SCAN_DIR)/##' -e 's#/Makefile:.*##' | uniq > $@
 
 tmp/info/.files-$(SCAN_TARGET).mk: $(FILELIST)
 	( \

+ 2 - 2
include/subdir.mk

@@ -34,10 +34,10 @@ define subdir
   $(foreach target,$(SUBTARGETS),$(call subtarget,$(1),$(target)))
 endef
 
-# Parameters: <subdir> <name> <target>
+# Parameters: <subdir> <name> <target> <depends>
 define stampfile
   $(1)/stamp-$(3):=$(STAGING_DIR)/stamp/.$(2)_$(3)
-  $$($(1)/stamp-$(3)): $(TMP_DIR)/.build
+  $$($(1)/stamp-$(3)): $(TMP_DIR)/.build $(4)
 	@+$(SCRIPT_DIR)/timestamp.pl -n $$($(1)/stamp-$(3)) $(1) $(4) || \
 		$(MAKE) $$($(1)/flags-$(3)) $(1)/$(3)
 	@mkdir -p $$$$(dirname $$($(1)/stamp-$(3)))

+ 138 - 8
include/target.mk

@@ -5,17 +5,147 @@
 # See /LICENSE for more information.
 #
 
-define AddProfile
-  ifeq ($(CONFIG_LINUX_$(1)),y)
-    $(call Profile/$(1))
-    PROFILE=$$(ID)
+ifneq ($(DUMP),)
+  all: dumpinfo
+endif
+
+ifneq ($(__target_inc),1)
+__target_inc=1
+
+TARGET_BUILD?=0
+
+
+target_conf=$(subst .,_,$(subst -,_,$(subst /,_,$(1))))
+ifeq ($(DUMP),)
+  PLATFORM_DIR:=$(TOPDIR)/target/linux/$(BOARD)
+  SUBTARGET:=$(strip $(foreach subdir,$(patsubst $(PLATFORM_DIR)/%/target.mk,%,$(wildcard $(PLATFORM_DIR)/*/target.mk)),$(if $(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(subdir))),$(subdir))))
+else
+  PLATFORM_DIR:=${CURDIR}
+endif
+
+TARGETID:=$(BOARD)$(if $(SUBTARGET),/$(SUBTARGET))
+PLATFORM_SUBDIR:=$(PLATFORM_DIR)$(if $(SUBTARGET),/$(SUBTARGET))
+
+define Target
+  KERNEL_TARGETS+=$(1)
+  ifeq ($(DUMP),1)
+    ifeq ($(SUBTARGET),)
+      BuildTarget=$$(BuildTargets/DumpAll)
+    endif
+  endif
+endef
+
+ifneq ($(TARGET_BUILD),1)
+  include $(PLATFORM_DIR)/Makefile
+  ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
+    include $(PLATFORM_SUBDIR)/target.mk
+  endif
+else
+  ifneq ($(SUBTARGET),)
+    -include ./$(SUBTARGET)/target.mk
+  endif
+endif
+
+define Profile/Default
+  NAME:=
+  PACKAGES:=
+endef
+
+define Profile
+  $(eval $(call Profile/Default))
+  $(eval $(call Profile/$(1)))
+  $(eval $(call shexport,Profile/$(1)/Config))
+  $(eval $(call shexport,Profile/$(1)/Description))
+  DUMPINFO += \
+	echo "Target-Profile: $(1)"; \
+	echo "Target-Profile-Name: $(NAME)"; \
+	echo "Target-Profile-Packages: $(PACKAGES)"; \
+	if [ -f ./config/profile-$(1) ]; then \
+		echo "Target-Profile-Kconfig: yes"; \
+	fi; \
+	echo "Target-Profile-Config: "; \
+	getvar "$(call shvar,Profile/$(1)/Config)"; \
+	echo "@@"; \
+	echo "Target-Profile-Description:"; \
+	getvar "$(call shvar,Profile/$(1)/Description)"; \
+	echo "@@"; \
+	echo;
+  ifeq ($(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(if $(2),$(2)_)$(1))),y)
+    PROFILE=$(1)
   endif
 endef
 
--include $(TMP_DIR)/.target.mk
+$(eval $(call shexport,Target/Description))
+
+
+include $(INCLUDE_DIR)/kernel-version.mk
+
+GENERIC_PLATFORM_DIR := $(TOPDIR)/target/linux/generic-$(KERNEL)
+GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/patches$(shell [ -d "$(GENERIC_PLATFORM_DIR)/patches-$(KERNEL_PATCHVER)" ] && printf -- "-$(KERNEL_PATCHVER)" || true )
+
+GENERIC_LINUX_CONFIG:=$(firstword $(wildcard $(GENERIC_PLATFORM_DIR)/config-$(KERNEL_PATCHVER) $(GENERIC_PLATFORM_DIR)/config-default))
+LINUX_CONFIG?=$(firstword $(wildcard $(foreach subdir,$(PLATFORM_DIR) $(PLATFORM_SUBDIR),$(subdir)/config-$(KERNEL_PATCHVER) $(subdir)/config-default)))
+LINUX_SUBCONFIG?=$(firstword $(wildcard $(PLATFORM_SUBDIR)/config-$(KERNEL_PATCHVER) $(PLATFORM_SUBDIR)/config-default))
+ifeq ($(LINUX_CONFIG),$(LINUX_SUBCONFIG))
+  LINUX_SUBCONFIG:=
+endif
+LINUX_CONFCMD=$(if $(LINUX_CONFIG),$(SCRIPT_DIR)/kconfig.pl + $(GENERIC_LINUX_CONFIG) $(if $(LINUX_SUBCONFIG),+ $(LINUX_CONFIG) $(LINUX_SUBCONFIG),$(LINUX_CONFIG)),true)
+
+ifeq ($(DUMP),1)
+  BuildTarget=$(BuildTargets/DumpCurrent)
+
+  ifneq ($(BOARD),)
+    TMP_CONFIG:=$(TMP_DIR)/.kconfig-$(call target_conf,$(TARGETID))
+    $(TMP_CONFIG): $(GENERIC_LINUX_CONFIG) $(LINUX_CONFIG) $(LINUX_SUBCONFIG)
+		$(LINUX_CONFCMD) > $@ || rm -f $@
+    -include $(TMP_CONFIG)
+    .SILENT: $(TMP_CONFIG)
+    .PRECIOUS: $(TMP_CONFIG)
+
+    ifneq ($(CONFIG_PCI),)
+      FEATURES += pci
+    endif
+    ifneq ($(CONFIG_USB),)
+      FEATURES += usb
+    endif
+    ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),)
+      FEATURES += pcmcia
+    endif
+
+    # remove duplicates
+    FEATURES:=$(sort $(FEATURES))
+  endif
+endif
+
+define BuildTargets/DumpAll
+  dumpinfo:
+	@$(foreach SUBTARGET,$(KERNEL_TARGETS),$(SUBMAKE) -s DUMP=1 SUBTARGET=$(SUBTARGET); )
+endef
+
+define BuildTargets/DumpCurrent
+
+  dumpinfo:
+	@echo 'Target: $(TARGETID)'; \
+	 echo 'Target-Board: $(BOARD)'; \
+	 echo 'Target-Kernel: $(KERNEL)'; \
+	 echo 'Target-Name: $(BOARDNAME) [$(KERNEL)]'; \
+	 echo 'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'; \
+	 echo 'Target-Arch: $(ARCH)'; \
+	 echo 'Target-Features: $(FEATURES)'; \
+	 echo 'Linux-Version: $(LINUX_VERSION)'; \
+	 echo 'Linux-Release: $(LINUX_RELEASE)'; \
+	 echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'; \
+	 echo 'Target-Description:'; \
+	 getvar $(call shvar,Target/Description); \
+	 echo '@@'; \
+	 echo 'Default-Packages: $(DEFAULT_PACKAGES)'; \
+	 $(DUMPINFO)
+endef
 
-ifeq ($(IB),1)
-$(TMP_DIR)/.target.mk: $(TOPDIR)/.target.mk
-	$(CP) $< $@
+include $(INCLUDE_DIR)/kernel.mk
+ifeq ($(TARGET_BUILD),1)
+  include $(INCLUDE_DIR)/kernel-build.mk
+  BuildTarget?=$(BuildKernel)
 endif
 
+endif #__target_inc

+ 1 - 2
include/toplevel.mk

@@ -33,13 +33,12 @@ export SCAN_COOKIE
 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=""
+	+$(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="" SCAN_MAKEOPTS="TARGET_BUILD=1"
 	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; }
-	./scripts/metadata.pl target_mk < $(TMP_DIR)/.targetinfo > tmp/.target.mk
 	touch $(TOPDIR)/tmp/.build
 
 .config: ./scripts/config/conf prepare-tmpinfo

+ 1 - 1
package/acx/Makefile

@@ -26,7 +26,7 @@ include $(INCLUDE_DIR)/package.mk
 
 define KernelPackage/acx
   TITLE:=Driver for TI ACX1xx chipset
-  DEPENDS:=@LINUX_2_6 @!TARGET_AVR32 +wireless-tools
+  DEPENDS:=@LINUX_2_6 @!TARGET_avr32 +wireless-tools
   URL:=http://acx100.sourceforge.net/
   SUBMENU:=Wireless Drivers
   FILES:= $(PKG_BUILD_DIR)/acx.$(LINUX_KMOD_SUFFIX)

+ 1 - 1
package/admswconfig/Makefile

@@ -22,7 +22,7 @@ define Package/admswconfig
   SECTION:=utils
   CATEGORY:=Utilities
   TITLE:=ADM5120 Switch configuration tool
-  DEPENDS:=@TARGET_ADM5120||TARGET_ADM5120EB
+  DEPENDS:=@TARGET_adm5120
   URL:=http://sharon.esrac.ele.tue.nl/users/pe1rxq/linux-adm/admswconfig/
 endef
 

+ 1 - 1
package/ar7-atm/Makefile

@@ -21,7 +21,7 @@ include $(INCLUDE_DIR)/package.mk
 
 define KernelPackage/sangam-atm/Default
   SUBMENU:=Network Devices
-  DEPENDS:=@TARGET_AR7 +kmod-atm 
+  DEPENDS:=@TARGET_ar7 +kmod-atm 
   TITLE:=AR7 ADSL driver
   FILES:=$(PKG_BUILD_DIR)/tiatm.$(LINUX_KMOD_SUFFIX)
   AUTOLOAD:=$(call AutoLoad,50,tiatm)

+ 6 - 1
package/base-files/Makefile

@@ -71,7 +71,7 @@ endef
 define Package/libgcc
 $(call Package/gcc/Default)
   TITLE:=GCC support library
-  DEPENDS:=@!TARGET_AVR32 @!NATIVE_TOOLCHAIN
+  DEPENDS:=@!TARGET_avr32 @!NATIVE_TOOLCHAIN
 endef
 
 define Package/libssp
@@ -123,6 +123,11 @@ define Package/base-files$(TARGET)/install
 	if [ -d $(PLATFORM_DIR)/base-files/default/. ]; then \
 		$(CP) $(PLATFORM_DIR)/base-files/default/* $(1)/; \
 	fi
+	$(if $(filter-out $(PLATFORM_DIR),$(PLATFORM_SUBDIR)), \
+		if [ -d $(PLATFORM_SUBDIR)/base-files/default/. ]; then \
+			$(CP) $(PLATFORM_SUBDIR)/base-files/default/* $(1)/; \
+		fi \
+	)
 	if [ "$(PROFILE)" != "Default" ]; then \
 		if [ -d $(PLATFORM_DIR)/base-files/profile-$(PROFILE)/. ]; then \
 			$(CP) $(PLATFORM_DIR)/base-files/profile-$(PROFILE)/* $(1)/; \

+ 1 - 1
package/bcm43xx-mac80211/Makefile

@@ -20,7 +20,7 @@ endif
 define KernelPackage/bcm43xx-mac80211
   SUBMENU:=Wireless Drivers
   TITLE:=Broadcom 43xx wireless support
-  DEPENDS:=@TARGET_BRCM47XX +kmod-mac80211
+  DEPENDS:=@TARGET_brcm47xx +kmod-mac80211
   KCONFIG:=CONFIG_MAC80211
   FILES:=$(PKG_BUILD_DIR)/bcm43xx-mac80211.$(LINUX_KMOD_SUFFIX)
 #  AUTOLOAD:=$(call AutoLoad,30,bcm43xx-mac80211)

+ 2 - 2
package/broadcom-diag/Makefile

@@ -16,7 +16,7 @@ include $(INCLUDE_DIR)/package.mk
 
 define KernelPackage/diag
   SUBMENU:=Other modules
-  DEPENDS:=@TARGET_BRCM_2_4||TARGET_BRCM47XX
+  DEPENDS:=@TARGET_brcm_2_4||TARGET_brcm47xx
   TITLE:=Driver for router LEDs and Buttons
   FILES:=$(PKG_BUILD_DIR)/diag.$(LINUX_KMOD_SUFFIX)
 endef
@@ -27,7 +27,7 @@ define Build/Prepare
 endef
 
 ifeq ($(BOARD),brcm-2.4)
-	BUILDFLAGS=-DBCMDRIVER -I$(LINUX_DIR)/arch/mips/bcm947xx/include $(if $(CONFIG_LINUX_2_4),-DLINUX_2_4)
+	BUILDFLAGS=-DBCMDRIVER -I$(LINUX_DIR)/arch/mips/bcm947xx/include -DLINUX_2_4
 endif
 
 define Build/Compile

+ 1 - 1
package/broadcom-mmc/Makefile

@@ -23,7 +23,7 @@ MAKEFLAGS_KMOD:= -C "$(LINUX_DIR)" \
 
 define KernelPackage/broadcom-mmc
   SUBMENU:=Other modules
-  DEPENDS:=@TARGET_BRCM_2_4
+  DEPENDS:=@TARGET_brcm_2_4
   TITLE:=Kernel driver for the Linksys WRT54G MM/SD-Card Mod
   DESCRIPTION:=\
 	Kernel driver for the Linksys WRT54G MM/SD-Card Mod

+ 2 - 2
package/broadcom-wl/Makefile

@@ -25,13 +25,13 @@ define Package/broadcom-wl/Default
   CATEGORY:=Kernel modules
   DEPENDS:=@PACKAGE_kmod-brcm-wl||PACKAGE_kmod-brcm-wl-mimo
   SUBMENU:=Proprietary BCM43xx WiFi driver
-  SUBMENUDEP:=@TARGET_BRCM_2_4
+  SUBMENUDEP:=@TARGET_brcm_2_4
 endef
 
 define KernelPackage/brcm-wl/Default
   $(call Package/broadcom-wl/Default)
   SECTION:=kernel
-  DEPENDS:=@TARGET_BRCM_2_4
+  DEPENDS:=@TARGET_brcm_2_4
   TITLE:=Kernel driver for BCM43xx chipsets
   FILES:=$(PKG_BUILD_DIR)/kmod/wl$(1).o
   AUTOLOAD:=$(call AutoLoad,30,wl$(1))

+ 1 - 1
package/fonera-mp3-drv/Makefile

@@ -18,7 +18,7 @@ include $(INCLUDE_DIR)/package.mk
 
 define KernelPackage/fonera-mp3-driver
   SUBMENU:=Other modules
-  DEPENDS:=@TARGET_ATHEROS
+  DEPENDS:=@TARGET_atheros
   TITLE:=Fonera-MP3 driver (VS1011X)
   FILES:=$(PKG_BUILD_DIR)/mp3_drv.$(LINUX_KMOD_SUFFIX)
   AUTOLOAD:=$(call AutoLoad,25,mp3-drv)

+ 1 - 1
package/fonera-mp3/Makefile

@@ -19,7 +19,7 @@ include $(INCLUDE_DIR)/package.mk
 define Package/fonera-mp3d
   SECTION:=utils
   CATEGORY:=Utilities
-  DEPENDS:=@TARGET_ATHEROS
+  DEPENDS:=@TARGET_atheros
   TITLE:=Daemon for fonera-mp3
 endef
 

+ 1 - 1
package/foxboard-utils/Makefile

@@ -25,7 +25,7 @@ define Package/foxboard-utils
   CATEGORY:=Base system
   TITLE:=Foxboard base tools
   URL:=http://www.acmesystems.it
-  DEPENDS:=@TARGET_ETRAX
+  DEPENDS:=@TARGET_etrax
 endef
 
 define Package/foxboard-utils/description

+ 1 - 1
package/hostapd/Makefile

@@ -36,7 +36,7 @@ endef
 
 define Package/hostapd
 $(call Package/hostapd/Default)
-  DEPENDS:=+libopenssl @!TARGET_AVR32 @!TARGET_ETRAX
+  DEPENDS:=+libopenssl @!TARGET_avr32 @!TARGET_etrax
   TITLE+= (full)
 endef
 

+ 1 - 1
package/ipset/Makefile

@@ -21,7 +21,7 @@ include $(INCLUDE_DIR)/package.mk
 define Package/ipset
   SECTION:=net
   CATEGORY:=Network
-  DEPENDS:=@!TARGET_ETRAX
+  DEPENDS:=@!TARGET_etrax
   TITLE:=Netfilter ip sets administration utility
   URL:=http://ipset.netfilter.org/
 endef

+ 1 - 1
package/nvram/Makefile

@@ -16,7 +16,7 @@ include $(INCLUDE_DIR)/package.mk
 define Package/nvram
   SECTION:=utils
   CATEGORY:=Utilities
-  DEPENDS:=@TARGET_BRCM_2_4
+  DEPENDS:=@TARGET_brcm_2_4
   TITLE:=Broadcom config utility
 endef
 

+ 1 - 1
package/switch/Makefile

@@ -16,7 +16,7 @@ include $(INCLUDE_DIR)/package.mk
 
 define KernelPackage/switch
   SUBMENU:=Other modules
-  DEPENDS:=@TARGET_BRCM_2_4||TARGET_BRCM47XX
+  DEPENDS:=@TARGET_brcm_2_4||TARGET_brcm47xx
   TITLE:=Switch drivers
   FILES:= \
 	$(PKG_BUILD_DIR)/switch-core.$(LINUX_KMOD_SUFFIX) \

+ 1 - 1
package/util-linux/Makefile

@@ -21,7 +21,7 @@ include $(INCLUDE_DIR)/package.mk
 define Package/util-linux/Default
   SECTION:=utils
   CATEGORY:=Utilities
-  DEPENDS:=@!TARGET_ETRAX
+  DEPENDS:=@!TARGET_etrax
   URL:=http://www.kernel.org/pub/linux/utils/util-linux/
 endef
 

+ 2 - 2
package/wlcompat/Makefile

@@ -16,8 +16,8 @@ include $(INCLUDE_DIR)/package.mk
 
 define KernelPackage/wlcompat/Default
   SUBMENU:=Proprietary BCM43xx WiFi driver
-  SUBMENUDEP:=@TARGET_BRCM_2_4
-  DEPENDS:=@TARGET_BRCM_2_4 @PACKAGE_kmod-brcm-wl||PACKAGE_kmod-brcm-wl-mimo +wireless-tools
+  SUBMENUDEP:=@TARGET_brcm_2_4
+  DEPENDS:=@TARGET_brcm_2_4 @PACKAGE_kmod-brcm-wl||PACKAGE_kmod-brcm-wl-mimo +wireless-tools
   TITLE:=Broadcom wl wrapper module
 endef
 

+ 1 - 1
package/yamonenv/Makefile

@@ -23,7 +23,7 @@ include $(INCLUDE_DIR)/package.mk
 define Package/yamonenv
   SECTION:=utils
   CATEGORY:=Utilities
-  DEPENDS:=@TARGET_AU1000
+  DEPENDS:=@TARGET_au1000
   TITLE:=YAMON configuration utility
   URL:=http://meshcube.org/nylon/stable/sources/
 endef

+ 7 - 3
rules.mk

@@ -5,6 +5,9 @@
 # See /LICENSE for more information.
 #
 
+ifneq ($(__rules_inc),1)
+__rules_inc=1
+
 ifeq ($(DUMP),)
   -include $(TOPDIR)/.config
 endif
@@ -13,8 +16,6 @@ include $(TOPDIR)/include/verbose.mk
 
 TMP_DIR:=$(TOPDIR)/tmp
 
-include $(TOPDIR)/include/target.mk
-
 export SHELL=/usr/bin/env bash -c '. $(TOPDIR)/include/shell.sh; eval "$$2"' --
 
 define qstrip
@@ -23,6 +24,7 @@ endef
 #"))
 
 ARCH:=$(call qstrip,$(CONFIG_ARCH))
+BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD))
 TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION))
 BUILD_SUFFIX:=$(call qstrip,$(CONFIG_BUILD_SUFFIX))
 GCCV:=$(call qstrip,$(CONFIG_GCC_VERSION))
@@ -37,7 +39,7 @@ SCRIPT_DIR:=$(TOPDIR)/scripts
 BUILD_DIR_BASE:=$(TOPDIR)/build_dir
 BUILD_DIR:=$(BUILD_DIR_BASE)/$(ARCH)$(if $(BUILD_SUFFIX),_$(BUILD_SUFFIX))
 BUILD_DIR_HOST:=$(BUILD_DIR_BASE)/host
-BUILD_DIR_TOOLCHAIN:=$(BUILD_DIR_BASE)/toolchain-$(ARCH)
+BUILD_DIR_TOOLCHAIN:=$(BUILD_DIR_BASE)/toolchain-$(ARCH)_gcc$(GCCV)
 STAGING_DIR:=$(TOPDIR)/staging_dir/$(ARCH)
 STAGING_DIR_HOST:=$(TOPDIR)/staging_dir/host
 TOOLCHAIN_DIR:=$(TOPDIR)/staging_dir/toolchain-$(ARCH)_gcc$(GCCV)
@@ -133,3 +135,5 @@ endef
 all:
 FORCE: ;
 .PHONY: FORCE
+
+endif #__rules_inc

+ 0 - 0
scripts/config.pl → scripts/kconfig.pl


+ 13 - 45
scripts/metadata.pl

@@ -23,15 +23,16 @@ sub parse_target_metadata() {
 	while (<>) {
 		chomp;
 		/^Target:\s*(.+)\s*$/ and do {
-			my $conf = uc $1;
-			$conf =~ tr/\.-/__/;
+			my $conf = $1;
+			$conf =~ tr#/\.\-/#___#;
 			$target = {
+				id => $1,
 				conf => $conf,
-				board => $1,
 				profiles => []
 			};
 			push @target, $target;
 		};
+		/^Target-Board:\s*(.+)\s*$/ and $target->{board} = $1;
 		/^Target-Kernel:\s*(\d+\.\d+)\s*$/ and $target->{kernel} = $1;
 		/^Target-Name:\s*(.+)\s*$/ and $target->{name} = $1;
 		/^Target-Path:\s*(.+)\s*$/ and $target->{path} = $1;
@@ -198,45 +199,6 @@ sub merge_package_lists($$) {
 	return sort(@l);
 }
 
-sub gen_target_mk() {
-	my @target = parse_target_metadata();
-	
-	@target = sort {
-		$a->{board} cmp $b->{board}
-	} @target;
-	
-	foreach my $target (@target) {
-		my ($profiles_def, $profiles_eval);
-
-		foreach my $profile (@{$target->{profiles}}) {
-			$profiles_def .= "
-  define Profile/$target->{conf}\_$profile->{id}
-    ID:=$profile->{id}
-    NAME:=$profile->{name}
-    PACKAGES:=".join(" ", merge_package_lists($target->{packages}, $profile->{packages}))."\n";
-			$profile->{kconfig} and $profiles_def .= "    KCONFIG:=1\n";
-			$profiles_def .= "  endef";
-			$profiles_eval .= "
-\$(eval \$(call AddProfile,$target->{conf}\_$profile->{id}))"
-		}
-		print "
-ifeq (\$(CONFIG_TARGET_$target->{conf}),y)
-  define Target
-    KERNEL:=$target->{kernel}
-    BOARD:=$target->{board}
-    BOARDNAME:=$target->{name}
-    LINUX_VERSION:=$target->{version}
-    LINUX_RELEASE:=$target->{release}
-    LINUX_KARCH:=$target->{karch}
-    DEFAULT_PACKAGES:=".join(" ", @{$target->{packages}})."
-  endef$profiles_def
-endif$profiles_eval
-
-"
-	}
-	print "\$(eval \$(call Target))\n";
-}
-
 sub target_config_features(@) {
 	my $ret;
 
@@ -265,7 +227,7 @@ sub gen_target_config() {
 	print <<EOF;
 choice
 	prompt "Target System"
-	default TARGET_BRCM_2_4
+	default TARGET_brcm_2_4
 	reset if !DEVEL
 	
 EOF
@@ -298,6 +260,14 @@ EOF
 	print <<EOF;
 endchoice
 
+config TARGET_BOARD
+	string
+EOF
+	foreach my $target (@target) {
+		print "\t\tdefault \"".$target->{board}."\" if TARGET_".$target->{conf}."\n";
+	}
+	print <<EOF;
+
 choice
 	prompt "Target Profile"
 
@@ -559,7 +529,6 @@ EOF
 sub parse_command() {
 	my $cmd = shift @ARGV;
 	for ($cmd) {
-		/^target_mk$/ and return gen_target_mk();
 		/^target_config$/ and return gen_target_config();
 		/^package_mk$/ and return gen_package_mk();
 		/^package_config$/ and return gen_package_config();
@@ -567,7 +536,6 @@ sub parse_command() {
 	}
 	print <<EOF
 Available Commands:
-	$0 target_mk [file] 		Target metadata in makefile format
 	$0 target_config [file] 	Target metadata in Kconfig format
 	$0 package_mk [file]    	Package metadata in makefile format
 	$0 package_config [file] 	Package metadata in Kconfig format

+ 1 - 1
target/linux/Makefile

@@ -8,5 +8,5 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/target.mk
 
 prereq clean download prepare compile install menuconfig oldconfig update refresh: FORCE
-	$(MAKE) -C $(BOARD) $@
+	TARGET_BUILD=1 $(MAKE) -C $(BOARD) $@
 

+ 7 - 14
target/linux/adm5120/Makefile

@@ -1,27 +1,20 @@
 #
-# 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.
 #
+
 include $(TOPDIR)/rules.mk
 
-ARCH:=mipsel
 BOARD:=adm5120
-BOARDNAME:=ADM5120 (Little Endian)
-FEATURES:=squashfs jffs2 tgz broken
-
 LINUX_VERSION:=2.6.22.4
+FEATURES:=squashfs jffs2 tgz broken
 
-define Target/Description
-	Build firmware images for Infineon/ADMtek ADM5120 based boards
-	(e.g : RouterBoard RB1xx, Compex WP54G-WRT ...)
-endef
+include $(INCLUDE_DIR)/target.mk
 
-include $(INCLUDE_DIR)/kernel-build.mk
 DEFAULT_PACKAGES += admswconfig
 
-# include the profiles
--include profiles/*.mk
-
-$(eval $(call BuildKernel))
+$(eval $(call Target,router_be))
+$(eval $(call Target,router_le))
+$(eval $(call BuildTarget))

+ 0 - 0
target/linux/adm5120eb/config/default → target/linux/adm5120/router_be/config-2.6.22


+ 0 - 0
target/linux/adm5120eb/image/Makefile → target/linux/adm5120/router_be/image/Makefile


+ 0 - 0
target/linux/adm5120eb/image/lzma-loader → target/linux/adm5120/router_be/image/lzma-loader


+ 0 - 0
target/linux/adm5120eb/profiles/090-Zyxel.mk → target/linux/adm5120/router_be/profiles/090-Zyxel.mk


+ 0 - 0
target/linux/adm5120eb/profiles/100-Texas.mk → target/linux/adm5120/router_be/profiles/100-Texas.mk


+ 0 - 0
target/linux/adm5120eb/profiles/110-Atheros.mk → target/linux/adm5120/router_be/profiles/110-Atheros.mk


+ 0 - 0
target/linux/adm5120eb/profiles/110-None.mk → target/linux/adm5120/router_be/profiles/110-None.mk


+ 9 - 0
target/linux/adm5120/router_be/target.mk

@@ -0,0 +1,9 @@
+ARCH:=mips
+SUBTARGET:=router_be
+BOARDNAME:=ADM5120 Boards (Big Endian)
+
+define Target/Description
+	Build firmware images for Infineon/ADMTek ADM5120 based boards running in big-endian mode
+	(e.g : ZyXEL Prestige 335WT ...)
+endef
+

+ 0 - 0
target/linux/adm5120/base-files/default/sbin/wget2nand → target/linux/adm5120/router_le/base-files/default/sbin/wget2nand


+ 0 - 0
target/linux/adm5120/config/default → target/linux/adm5120/router_le/config-2.6.22


+ 0 - 0
target/linux/adm5120/profiles/100-Atheros.mk → target/linux/adm5120/router_le/profiles/100-Atheros.mk


+ 0 - 0
target/linux/adm5120/profiles/105-Texas.mk → target/linux/adm5120/router_le/profiles/105-Texas.mk


+ 0 - 0
target/linux/adm5120/profiles/110-Ralink.mk → target/linux/adm5120/router_le/profiles/110-Ralink.mk


+ 0 - 0
target/linux/adm5120/profiles/200-None.mk → target/linux/adm5120/router_le/profiles/200-None.mk


+ 0 - 0
target/linux/adm5120/profiles/Cellvision.mk → target/linux/adm5120/router_le/profiles/Cellvision.mk


+ 0 - 0
target/linux/adm5120/profiles/RB1xx.mk → target/linux/adm5120/router_le/profiles/RB1xx.mk


+ 9 - 0
target/linux/adm5120/router_le/target.mk

@@ -0,0 +1,9 @@
+ARCH:=mipsel
+SUBTARGET:=router_le
+BOARDNAME:=ADM5120 Boards (Little Endian)
+
+define Target/Description
+	Build firmware images for Infineon/ADMtek ADM5120 based boards
+	(e.g : RouterBoard RB1xx, Compex WP54G-WRT ...)
+endef
+

+ 0 - 27
target/linux/adm5120eb/Makefile

@@ -1,27 +0,0 @@
-#
-# Copyright (C) 2006 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-include $(TOPDIR)/rules.mk
-
-ARCH:=mips
-BOARD:=adm5120eb
-BOARDNAME:=ADM5120 (Big Endian)
-FEATURES:=squashfs pci usb broken
-
-LINUX_VERSION:=2.6.22.4
-
-define Target/Description
-	Build firmware images for Infineon/ADMTek ADM5120 based boards running in big-endian mode
-	(e.g : ZyXEL Prestige 335WT ...)
-endef
-
-include $(INCLUDE_DIR)/kernel-build.mk
-DEFAULT_PACKAGES += admswconfig
-
-# include the profiles
--include profiles/*.mk
-
-$(eval $(call BuildKernel))

+ 0 - 1
target/linux/adm5120eb/files

@@ -1 +0,0 @@
-../adm5120/files

+ 0 - 1
target/linux/adm5120eb/patches-2.6.22

@@ -1 +0,0 @@
-../adm5120/patches-2.6.22

+ 4 - 3
target/linux/amazon/Makefile

@@ -10,6 +10,9 @@ ARCH:=mips
 BOARD:=amazon
 BOARDNAME:=Infineon Amazon
 FEATURES:=squashfs jffs2 broken
+LINUX_VERSION:=2.6.21.5
+
+include $(INCLUDE_DIR)/target.mk
 
 define Target/Description
 	Build firmware images for Infineon Amazon boards
@@ -17,9 +20,7 @@ endef
 
 KERNELNAME:="uImage"
 
-include $(INCLUDE_DIR)/kernel-build.mk
-
 # include the profiles
 -include profiles/*.mk
 
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))

+ 0 - 0
target/linux/amazon/config/default → target/linux/amazon/config-2.6.21


+ 3 - 3
target/linux/amcc/Makefile

@@ -13,13 +13,13 @@ FEATURES:=jffs2
 
 LINUX_VERSION:=2.6.21.5
 
+include $(INCLUDE_DIR)/target.mk
+
 define Target/Description
 	Build firmware images for the AMCC Taishan evaluation board
 endef
 
-include $(INCLUDE_DIR)/kernel-build.mk
-
 # include the profiles
 -include profiles/*.mk
 
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))

+ 0 - 0
target/linux/amcc/config/default → target/linux/amcc/config-2.6.21


+ 3 - 3
target/linux/ar7/Makefile

@@ -13,12 +13,12 @@ FEATURES:=squashfs jffs2 atm
 
 LINUX_VERSION:=2.6.22.4
 
+include $(INCLUDE_DIR)/target.mk
+
 define Target/Description
 	Build firmware images for TI AR7 based routers
 endef
 
-include $(INCLUDE_DIR)/kernel-build.mk
-
 -include profiles/*.mk
 
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))

+ 0 - 0
target/linux/ar7/config/default → target/linux/ar7/config-2.6.22


+ 5 - 4
target/linux/at91/Makefile

@@ -14,14 +14,15 @@ FEATURES:=squashfs usb
 #LINUX_VERSION:=2.6.21.5
 LINUX_VERSION:=2.6.22.4
 
+include $(INCLUDE_DIR)/target.mk
+
+KERNELNAME:="uImage"
+
 define Target/Description
   Build fimware images for Figment Design Labs VersaLink board.
 endef
 
-include $(INCLUDE_DIR)/kernel-build.mk
-
 #include the profiles
 -include profiles/*.mk
 
-KERNELNAME:="uImage"
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))

+ 0 - 0
target/linux/at91/config/default → target/linux/at91/config-2.6.22


+ 5 - 4
target/linux/atheros/Makefile

@@ -13,14 +13,15 @@ FEATURES:=squashfs jffs2
 
 LINUX_VERSION:=2.6.22.4
 
+include $(INCLUDE_DIR)/target.mk
+
+DEFAULT_PACKAGES += kmod-madwifi
+
 define Target/Description
 	Build firmware images for Atheros SoC boards
 endef
 
-include $(INCLUDE_DIR)/kernel-build.mk
-DEFAULT_PACKAGES += kmod-madwifi
-
 # include the profiles
 -include profiles/*.mk
 
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))

+ 0 - 0
target/linux/atheros/config/default → target/linux/atheros/config-2.6.22


+ 4 - 4
target/linux/au1000/Makefile

@@ -13,14 +13,14 @@ FEATURES:=jffs2 usb pci
 
 LINUX_VERSION:=2.6.22.4
 
+include $(INCLUDE_DIR)/target.mk
+DEFAULT_PACKAGES += yamonenv
+
 define Target/Description
 	Build firmware for AMD Alchemy 1500 boards
 	(e.g. 4G-Systems Mesh/Access Cube ...)
 endef
 
-include $(INCLUDE_DIR)/kernel-build.mk
-DEFAULT_PACKAGES += yamonenv
-
 define Kernel/BuildImage
 	$(call Kernel/BuildImage/Default)
 	$(CP) $(LINUX_DIR)/arch/mips/boot/compressed/images/zImage.flash.srec $(LINUX_DIR)/zImage.flash.srec
@@ -30,5 +30,5 @@ endef
 # include the profiles
 -include profiles/*.mk
 
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))
 

+ 0 - 0
target/linux/au1000/config/default → target/linux/au1000/config-2.6.22


+ 3 - 6
target/linux/avr32/Makefile

@@ -10,18 +10,15 @@ ARCH:=avr32
 BOARD:=avr32
 BOARDNAME:=Atmel AVR32
 FEATURES:=squashfs
-
 LINUX_VERSION:=2.6.22.4
 
+include $(INCLUDE_DIR)/target.mk
+
 define Target/Description
   Build firmware images for ATNGW100 board
 endef
 
-KERNEL:=2.6
-
-include $(INCLUDE_DIR)/kernel-build.mk
-
 #include the profiles
 -include profiles/*.mk
 
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))

+ 7 - 6
target/linux/brcm-2.4/Makefile

@@ -11,17 +11,18 @@ BOARD:=brcm-2.4
 BOARDNAME:=Broadcom BCM947xx/953xx
 FEATURES:=squashfs
 
+KERNEL:=2.4
+
+include $(INCLUDE_DIR)/target.mk
+
+DEFAULT_PACKAGES += kmod-switch kmod-diag nvram 
+
 define Target/Description
 	Build firmware images for Broadcom based routers
 	(e.g. Linksys WRT54G(S), Asus WL-500g, Motorola WR850G)
 endef
 
-KERNEL:=2.4
-
-include $(INCLUDE_DIR)/kernel-build.mk
-DEFAULT_PACKAGES += kmod-switch kmod-diag nvram
-
 # include the profiles
 -include profiles/*.mk
 
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))

+ 0 - 0
target/linux/brcm-2.4/config/default → target/linux/brcm-2.4/config-2.4.34


+ 4 - 4
target/linux/brcm47xx/Makefile

@@ -13,15 +13,15 @@ FEATURES:=squashfs usb
 
 LINUX_VERSION:=2.6.22.4
 
+include $(INCLUDE_DIR)/target.mk
+DEFAULT_PACKAGES += kmod-switch kmod-diag
+
 define Target/Description
 	Build firmware images for Broadcom based routers
 	(e.g. Netgear WGT634U)
 endef
 
-include $(INCLUDE_DIR)/kernel-build.mk
-DEFAULT_PACKAGES += kmod-switch kmod-diag
-
 # include the profiles
 -include profiles/*.mk
 
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))

+ 0 - 0
target/linux/brcm47xx/config/default → target/linux/brcm47xx/config-2.6.22


+ 3 - 4
target/linux/brcm63xx/Makefile

@@ -10,17 +10,16 @@ ARCH:=mips
 BOARD:=brcm63xx
 BOARDNAME:=Broadcom BCM963xx
 FEATURES:=squashfs jffs2 broken usb atm
-
 LINUX_VERSION:=2.6.22.4
 
+include $(INCLUDE_DIR)/target.mk
+
 define Target/Description
 	Build firmware images for Broadcom based xDSL/routers
 	(e.g. Inventel Livebox, Siemens SE515)
 endef
 
-include $(INCLUDE_DIR)/kernel-build.mk
-
 # include the profiles
 -include profiles/*.mk
 
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))

+ 0 - 0
target/linux/brcm63xx/config/default → target/linux/brcm63xx/config-2.6.22


+ 7 - 8
target/linux/etrax/Makefile

@@ -12,7 +12,10 @@ BOARDNAME:=Foxboard (ETRAX 100LX)
 FEATURES:=squashfs jffs2
 LINUX_VERSION:=2.6.19.2
 
-include $(INCLUDE_DIR)/kernel-build.mk
+include $(INCLUDE_DIR)/target.mk
+
+KERNELNAME:="zImage"
+DEFAULT_PACKAGES += foxboard-utils
 
 define Target/Description
 	Build fimware images for the FOXBOARD made by acmesystems.it
@@ -31,14 +34,10 @@ define Kernel/Prepare
 	$(call Kernel/Prepare/Fox)
 endef
 
-DEFAULT_PACKAGES += foxboard-utils
+#include the profiles
+-include profiles/*.mk
 
+$(eval $(call BuildTarget))
 $(eval $(call RequireCommand,/usr/local/cris/gcc-cris, \
 	Please install the binary cris toolchain. \
 ))
-
-#include the profiles
--include profiles/*.mk
-
-KERNELNAME:="zImage"
-$(eval $(call BuildKernel))

+ 0 - 0
target/linux/generic-2.4/config-template → target/linux/generic-2.4/config-default


+ 0 - 0
target/linux/generic-2.6/config-template → target/linux/generic-2.6/config-default


+ 2 - 5
target/linux/iop32x/Makefile

@@ -13,12 +13,9 @@ FEATURES:=squashfs jffs2
 
 LINUX_VERSION:=2.6.21.5
 
-define Target/Description
-endef
-
-include $(INCLUDE_DIR)/kernel-build.mk
+include $(INCLUDE_DIR)/target.mk
 
 # include the profiles
 -include profiles/*.mk
 
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))

+ 0 - 0
target/linux/iop32x/config/default → target/linux/iop32x/config-2.6.21


+ 2 - 5
target/linux/ixp4xx/Makefile

@@ -13,12 +13,9 @@ FEATURES:=squashfs
 
 LINUX_VERSION:=2.6.21.6
 
-define Target/Description
-endef
-
-include $(INCLUDE_DIR)/kernel-build.mk
+include $(INCLUDE_DIR)/target.mk
 
 # include the profiles
 -include profiles/*.mk
 
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))

+ 0 - 0
target/linux/ixp4xx/config/default → target/linux/ixp4xx/config-2.6.21


+ 2 - 2
target/linux/magicbox/Makefile

@@ -13,9 +13,9 @@ FEATURES:=squashfs jffs2
 
 LINUX_VERSION:=2.6.22.4
 
-include $(INCLUDE_DIR)/kernel-build.mk
+include $(INCLUDE_DIR)/target.mk
 
 # include the profiles
 -include profiles/*.mk
 
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))

+ 0 - 0
target/linux/magicbox/config/default → target/linux/magicbox/config-2.6.22


+ 3 - 3
target/linux/pxa/Makefile

@@ -13,13 +13,13 @@ FEATURES:=jffs2 broken
 
 LINUX_VERSION:=2.6.21.5
 
+include $(INCLUDE_DIR)/target.mk
+
 define Target/Description
 	Stub for boards based on intel PXA
 endef
 
-include $(INCLUDE_DIR)/kernel-build.mk
-
 # include the profiles
 -include profiles/*.mk
 
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))

+ 0 - 0
target/linux/pxa/config/default → target/linux/pxa/config-2.6.21


+ 2 - 2
target/linux/rb532/Makefile

@@ -13,9 +13,9 @@ FEATURES:=jffs2 pci tgz
 
 LINUX_VERSION:=2.6.22.4
 
-include $(INCLUDE_DIR)/kernel-build.mk
+include $(INCLUDE_DIR)/target.mk
 
 # include the profiles
 -include profiles/*.mk
 
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))

+ 0 - 0
target/linux/rb532/config/default → target/linux/rb532/config-2.6.22


+ 5 - 5
target/linux/rdc/Makefile

@@ -13,15 +13,15 @@ FEATURES:=squashfs jffs2 broken
 
 LINUX_VERSION:=2.6.22.4
 
+include $(INCLUDE_DIR)/target.mk
+
 define Target/Description
         Build firmware images for RDC321x based routers
         (e.g. Airlink101 AR525W, Linksys WRT54R, Sitecom WL-153)
 endef
 
-include $(INCLUDE_DIR)/kernel-build.mk
-
 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
-    define Kernel/SetInitramfs
+  define Kernel/SetInitramfs
 	echo "r6040 parent=wlan0" > $(TARGET_DIR)/etc/modules.d/99-r6040
 	$(RM) $(TARGET_DIR)/sbin/init
 	ln -s /etc/preinit $(TARGET_DIR)/sbin/init
@@ -29,10 +29,10 @@ ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
 	sed -i 's,/sbin/init,/bin/busybox init,g' $(TARGET_DIR)/init
 	mv $(TARGET_DIR)/init $(TARGET_DIR)/linuxrc
 	sed -i 's,eth0,eth1,g' $(TARGET_DIR)/etc/config/network
-    endef
+  endef
 endif
 
 # include the profiles
 -include profiles/*.mk
 
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))

+ 0 - 0
target/linux/rdc/config/default → target/linux/rdc/config-2.6.22


+ 0 - 2
target/linux/rdc/config/profile-wl153

@@ -1,2 +0,0 @@
-# CONFIG_MTD_RDC3210_ALLOW_JFFS2 is not set
-CONFIG_MTD_RDC3210_SIZE=0x200000

+ 2 - 2
target/linux/sibyte/Makefile

@@ -13,9 +13,9 @@ FEATURES:=broken
 
 LINUX_VERSION:=2.6.21.5
 
-include $(INCLUDE_DIR)/kernel-build.mk
+include $(INCLUDE_DIR)/target.mk
 
 # include the profiles
 -include profiles/*.mk
 
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))

+ 0 - 0
target/linux/sibyte/config/default → target/linux/sibyte/config-2.6.21


+ 2 - 2
target/linux/uml/Makefile

@@ -25,11 +25,11 @@ LINUX_CONFIG:=$(CURDIR)/config/$(ARCH)
 
 LINUX_VERSION:=2.6.22.4
 
-include $(INCLUDE_DIR)/kernel-build.mk
+include $(INCLUDE_DIR)/target.mk
 
 # include the profiles
 -include profiles/*.mk
 
 endif
 
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))

+ 2 - 2
target/linux/x86/Makefile

@@ -13,11 +13,11 @@ FEATURES:=squashfs jffs2 ext2
 
 LINUX_VERSION:=2.6.22.4
 
-include $(INCLUDE_DIR)/kernel-build.mk
+include $(INCLUDE_DIR)/target.mk
 DEFAULT_PACKAGES += kmod-natsemi kmod-ne2k-pci
 
 # include the profiles
 -include profiles/*.mk
 
-$(eval $(call BuildKernel))
+$(eval $(call BuildTarget))
 

+ 3 - 1
toolchain/Makefile

@@ -39,6 +39,8 @@ $(curdir)//prepare = $(STAGING_DIR)/.prepared $(TOOLCHAIN_DIR)/info.mk
 $(curdir)//compile = $(1)/prepare
 $(curdir)//install = $(1)/compile
 
-$(eval $(call stampfile,$(curdir),toolchain,install))
+$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed:
+
+$(eval $(call stampfile,$(curdir),toolchain,install,$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed))
 $(eval $(call subdir,$(curdir)))
 

+ 1 - 1
toolchain/gcc/Makefile

@@ -33,7 +33,7 @@ BUILD_DIR_HOST:=$(BUILD_DIR_TOOLCHAIN)
 
 include $(INCLUDE_DIR)/host-build.mk
 
-STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed
+STAMP_BUILT:=$(STAGING_DIR)/stamp/.gcc-initial_installed
 BUILD_DIR1:=$(BUILD_DIR_HOST)/gcc-$(PKG_VERSION)-initial
 BUILD_DIR2:=$(BUILD_DIR_HOST)/gcc-$(PKG_VERSION)-final
 

+ 2 - 2
toolchain/uClibc/Makefile

@@ -22,8 +22,8 @@ PKG_BUILD_DIR:=$(BUILD_DIR_HOST)/uClibc-$(PKG_VERSION)$(PKG_EXTRAVERSION)
 
 include $(INCLUDE_DIR)/host-build.mk
 
-STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.uclibc_installed
-STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.uclibc-utils_installed
+STAMP_BUILT:=$(STAGING_DIR)/stamp/.uclibc_installed
+STAMP_INSTALLED:=$(STAGING_DIR)/stamp/.uclibc-utils_installed
 
 UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
 		-e 's/i.86/i386/' \