last commit was missing a change...
[openwrt/openwrt.git] / include / kernel-build.mk
index 9a1e36328b74e0d605dd4b2365a7afdbf065806b..c06ca39403be9e631f6139a3cf40c8f13c5accca 100644 (file)
@@ -6,9 +6,16 @@
 #
 KERNEL_BUILD:=1
 
+include $(INCLUDE_DIR)/kernel-version.mk
+include $(INCLUDE_DIR)/host.mk
+include $(INCLUDE_DIR)/kernel.mk
 include $(INCLUDE_DIR)/prereq.mk
 
--include ./config
+LINUX_CONFIG ?= ./config/default
+
+-include $(GENERIC_PLATFORM_DIR)/config-template
+-include $(LINUX_CONFIG)
+
 ifneq ($(CONFIG_ATM),)
   FEATURES += atm
 endif
@@ -21,12 +28,15 @@ endif
 ifneq ($(CONFIG_PCMCIA),)
   FEATURES += pcmcia
 endif
+ifneq ($(CONFIG_VIDEO_DEV),)
+  FEATURES += video
+endif
 
 # remove duplicates
 FEATURES:=$(sort $(FEATURES))
 
 # For target profile selection - the default set
-DEFAULT_PACKAGES:=base-files libgcc uclibc bridge busybox dnsmasq dropbear iptables mtd ppp ppp-mod-pppoe mtd
+DEFAULT_PACKAGES:=base-files libgcc uclibc bridge busybox dnsmasq dropbear iptables mtd ppp ppp-mod-pppoe mtd kmod-ipt-nathelper
 
 ifeq ($(DUMP),1)
   all: dumpinfo
@@ -34,12 +44,6 @@ else
   all: compile
 endif
 
-include $(INCLUDE_DIR)/kernel-version.mk
-include $(INCLUDE_DIR)/host.mk
-include $(INCLUDE_DIR)/kernel.mk
-
-LINUX_CONFIG:=./config
-
 ifneq (,$(findstring uml,$(BOARD)))
   LINUX_KARCH:=um
 else
@@ -66,8 +70,9 @@ endif
 
 define Kernel/Prepare/Default
        bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS)
-       [ -d $(GENERIC_PLATFORM_DIR)/patches ] && $(PATCH) $(LINUX_DIR) $(GENERIC_PLATFORM_DIR)/patches 
-       [ -d ./patches ] && $(PATCH) $(LINUX_DIR) ./patches
+       if [ -d $(GENERIC_PLATFORM_DIR)/patches ]; then $(PATCH) $(LINUX_DIR) $(GENERIC_PLATFORM_DIR)/patches; fi
+       if [ -d ./files ]; then $(CP) ./files/* $(LINUX_DIR)/; fi
+       if [ -d ./patches ]; then $(PATCH) $(LINUX_DIR) ./patches; fi
 endef
 define Kernel/Prepare
        $(call Kernel/Prepare/Default)
@@ -87,8 +92,11 @@ define Kernel/Configure/2.6
        $(MAKE) $(KERNEL_MAKEOPTS) CC="$(KERNEL_CC)" oldconfig prepare scripts
 endef
 define Kernel/Configure/Default
-       @$(CP) $(LINUX_CONFIG) $(LINUX_DIR)/.config
-       $(call Kernel/Configure/$(KERNEL))
+       @if [ -f "./config/profile-$(PROFILE)" ]; then \
+               $(SCRIPT_DIR)/config.pl '+' $(GENERIC_PLATFORM_DIR)/config-template '+' $(LINUX_CONFIG) ./config/profile-$(PROFILE) > $(LINUX_DIR)/.config; \
+       else \
+               $(SCRIPT_DIR)/config.pl '+' $(GENERIC_PLATFORM_DIR)/config-template $(LINUX_CONFIG) > $(LINUX_DIR)/.config; \
+       fi
 endef
 define Kernel/Configure
        $(call Kernel/Configure/Default)
@@ -159,6 +167,7 @@ define BuildKernel
 
   $(LINUX_DIR)/.configured: $(LINUX_DIR)/.prepared $(LINUX_CONFIG)
        $(call Kernel/Configure)
+       $(call Kernel/Configure/$(KERNEL))
        touch $$@
 
   $(LINUX_DIR)/.modules: $(LINUX_DIR)/.configured
@@ -203,6 +212,7 @@ define Profile/Default
   PACKAGES:=
 endef
 
+confname=$(subst .,_,$(subst -,_,$(1)))
 define Profile
   $(eval $(call Profile/Default))
   $(eval $(call Profile/$(1)))
@@ -212,9 +222,15 @@ define Profile
        echo "Target-Profile-Name: $(NAME)"; \
        echo "Target-Profile-Packages: $(PACKAGES)"; \
        echo "Target-Profile-Description:"; \
+       if [ -f ./config/profile-$(1) ]; then \
+               echo "Target-Profile-Kconfig: yes"; \
+       fi; \
        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))
@@ -222,6 +238,12 @@ $(eval $(call shexport,Target/Description))
 download: $(DL_DIR)/$(LINUX_SOURCE)
 prepare: $(LINUX_DIR)/.configured $(TMP_DIR)/.kernel.mk
 compile: $(LINUX_DIR)/.modules
+menuconfig: $(LINUX_DIR)/.prepared FORCE
+       $(call Kernel/Configure)
+       $(SCRIPT_DIR)/config.pl '+' $(GENERIC_PLATFORM_DIR)/config-template $(LINUX_CONFIG) > $(LINUX_DIR)/.config
+       $(MAKE) -C $(LINUX_DIR) $(KERNEL_MAKEOPTS) menuconfig
+       $(SCRIPT_DIR)/config.pl '>' $(GENERIC_PLATFORM_DIR)/config-template $(LINUX_DIR)/.config > $(LINUX_CONFIG)
+
 install: $(LINUX_DIR)/.image
 
 clean: FORCE