2007-10-03 22:22:51 +03:00
|
|
|
#
|
2008-05-09 01:57:12 +03:00
|
|
|
# Copyright (C) 2007-2008 OpenWrt.org
|
2006-06-27 03:35:46 +03:00
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
2006-06-21 17:02:29 +03:00
|
|
|
|
2007-11-15 01:11:07 +02:00
|
|
|
ifneq ($(__target_inc),1)
|
|
|
|
__target_inc=1
|
|
|
|
|
|
|
|
# default device type
|
|
|
|
DEVICE_TYPE?=router
|
|
|
|
|
|
|
|
# Default packages - the really basic set
|
2011-03-07 04:49:24 +02:00
|
|
|
DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg hotplug2
|
2007-11-15 01:11:07 +02:00
|
|
|
# For router targets
|
2008-11-11 05:02:26 +02:00
|
|
|
DEFAULT_PACKAGES.router:=dnsmasq iptables ppp ppp-mod-pppoe kmod-ipt-nathelper firewall
|
2009-04-16 13:40:15 +03:00
|
|
|
DEFAULT_PACKAGES.bootloader:=
|
2007-11-15 01:11:07 +02:00
|
|
|
|
2007-09-08 22:55:42 +03:00
|
|
|
ifneq ($(DUMP),)
|
|
|
|
all: dumpinfo
|
|
|
|
endif
|
|
|
|
|
|
|
|
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}
|
2011-07-03 20:38:23 +03:00
|
|
|
ifeq ($(SUBTARGETS),)
|
|
|
|
SUBTARGETS:=$(strip $(patsubst $(PLATFORM_DIR)/%/target.mk,%,$(wildcard $(PLATFORM_DIR)/*/target.mk)))
|
|
|
|
endif
|
2007-09-08 22:55:42 +03:00
|
|
|
endif
|
|
|
|
|
|
|
|
TARGETID:=$(BOARD)$(if $(SUBTARGET),/$(SUBTARGET))
|
|
|
|
PLATFORM_SUBDIR:=$(PLATFORM_DIR)$(if $(SUBTARGET),/$(SUBTARGET))
|
|
|
|
|
|
|
|
ifneq ($(TARGET_BUILD),1)
|
2009-03-03 15:54:29 +02:00
|
|
|
ifndef DUMP
|
|
|
|
include $(PLATFORM_DIR)/Makefile
|
|
|
|
ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
|
|
|
|
include $(PLATFORM_SUBDIR)/target.mk
|
|
|
|
endif
|
2007-09-08 22:55:42 +03:00
|
|
|
endif
|
|
|
|
else
|
|
|
|
ifneq ($(SUBTARGET),)
|
|
|
|
-include ./$(SUBTARGET)/target.mk
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2011-07-03 20:38:23 +03:00
|
|
|
# Add device specific packages (here below to allow device type set from subtarget)
|
|
|
|
DEFAULT_PACKAGES += $(DEFAULT_PACKAGES.$(DEVICE_TYPE))
|
|
|
|
|
2007-09-08 22:55:42 +03:00
|
|
|
define Profile/Default
|
|
|
|
NAME:=
|
|
|
|
PACKAGES:=
|
|
|
|
endef
|
|
|
|
|
2007-11-15 01:11:07 +02:00
|
|
|
ifndef Profile
|
2007-09-08 22:55:42 +03:00
|
|
|
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: "; \
|
2010-08-19 15:49:37 +03:00
|
|
|
$(SH_FUNC) getvar "$(call shvar,Profile/$(1)/Config)"; \
|
2007-09-08 22:55:42 +03:00
|
|
|
echo "@@"; \
|
|
|
|
echo "Target-Profile-Description:"; \
|
2010-08-19 15:49:37 +03:00
|
|
|
$(SH_FUNC) getvar "$(call shvar,Profile/$(1)/Description)"; \
|
2007-09-08 22:55:42 +03:00
|
|
|
echo "@@"; \
|
|
|
|
echo;
|
2007-09-08 23:04:43 +03:00
|
|
|
ifeq ($(CONFIG_TARGET_$(call target_conf,$(BOARD)_$(if $(SUBTARGET),$(SUBTARGET)_)$(1))),y)
|
2007-09-08 22:55:42 +03:00
|
|
|
PROFILE=$(1)
|
2007-03-03 01:13:52 +02:00
|
|
|
endif
|
|
|
|
endef
|
2007-11-15 01:11:07 +02:00
|
|
|
endif
|
2007-03-03 01:13:52 +02:00
|
|
|
|
2007-10-03 22:22:51 +03:00
|
|
|
ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
|
|
|
|
define IncludeProfiles
|
|
|
|
-include $(PLATFORM_DIR)/profiles/*.mk
|
2007-09-28 04:23:56 +03:00
|
|
|
-include $(PLATFORM_SUBDIR)/profiles/*.mk
|
2007-10-03 22:22:51 +03:00
|
|
|
endef
|
|
|
|
else
|
|
|
|
define IncludeProfiles
|
|
|
|
-include $(PLATFORM_DIR)/profiles/*.mk
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(TARGET_BUILD),1)
|
|
|
|
$(eval $(call IncludeProfiles))
|
|
|
|
else
|
|
|
|
ifeq ($(DUMP),)
|
|
|
|
$(eval $(call IncludeProfiles))
|
2007-09-28 04:23:56 +03:00
|
|
|
endif
|
2007-09-08 23:04:43 +03:00
|
|
|
endif
|
2007-09-08 22:55:42 +03:00
|
|
|
|
2007-09-08 23:04:43 +03:00
|
|
|
$(eval $(call shexport,Target/Description))
|
2007-09-08 22:55:42 +03:00
|
|
|
|
2009-03-03 15:54:29 +02:00
|
|
|
ifneq ($(TARGET_BUILD)$(if $(DUMP),,1),)
|
|
|
|
include $(INCLUDE_DIR)/kernel-version.mk
|
|
|
|
endif
|
2007-09-08 22:55:42 +03:00
|
|
|
|
2010-06-26 23:42:58 +03:00
|
|
|
GENERIC_PLATFORM_DIR := $(TOPDIR)/target/linux/generic
|
2009-03-03 16:55:53 +02:00
|
|
|
GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/patches$(if $(wildcard $(GENERIC_PLATFORM_DIR)/patches-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER))
|
2008-10-19 00:43:30 +03:00
|
|
|
GENERIC_FILES_DIR := $(foreach dir,$(wildcard $(GENERIC_PLATFORM_DIR)/files $(GENERIC_PLATFORM_DIR)/files-$(KERNEL_PATCHVER)),"$(dir)")
|
2007-09-08 22:55:42 +03:00
|
|
|
|
2011-04-06 17:48:55 +03:00
|
|
|
__config_name_list = $(1)/config-$(KERNEL_PATCHVER) $(1)/config-default
|
|
|
|
__config_list = $(firstword $(wildcard $(call __config_name_list,$(1))))
|
|
|
|
find_kernel_config=$(if $(__config_list),$(__config_list),$(lastword $(__config_name_list)))
|
|
|
|
|
2011-04-18 00:47:44 +03:00
|
|
|
GENERIC_LINUX_CONFIG = $(call find_kernel_config,$(GENERIC_PLATFORM_DIR))
|
|
|
|
LINUX_TARGET_CONFIG = $(call find_kernel_config,$(PLATFORM_DIR))
|
2011-04-06 17:48:55 +03:00
|
|
|
ifneq ($(PLATFORM_DIR),$(PLATFORM_SUBDIR))
|
2011-04-18 00:47:44 +03:00
|
|
|
LINUX_SUBTARGET_CONFIG = $(call find_kernel_config,$(PLATFORM_SUBDIR))
|
2007-09-08 22:55:42 +03:00
|
|
|
endif
|
2011-04-06 17:48:55 +03:00
|
|
|
|
|
|
|
# config file list used for compiling
|
2011-04-18 00:47:44 +03:00
|
|
|
LINUX_KCONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG) $(LINUX_SUBTARGET_CONFIG) $(TOPDIR)/env/kernel-config)
|
2011-04-06 17:48:55 +03:00
|
|
|
|
|
|
|
# default config list for reconfiguring
|
|
|
|
# defaults to subtarget if subtarget exists and target does not
|
|
|
|
# defaults to target otherwise
|
2011-04-18 00:47:44 +03:00
|
|
|
USE_SUBTARGET_CONFIG = $(if $(wildcard $(LINUX_TARGET_CONFIG)),,$(if $(LINUX_SUBTARGET_CONFIG),1))
|
|
|
|
|
|
|
|
LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG) $(if $(USE_SUBTARGET_CONFIG),$(LINUX_SUBTARGET_CONFIG)))
|
|
|
|
LINUX_RECONFIG_TARGET = $(if $(USE_SUBTARGET_CONFIG),$(LINUX_SUBTARGET_CONFIG),$(LINUX_TARGET_CONFIG))
|
2011-04-06 17:48:55 +03:00
|
|
|
|
|
|
|
# select the config file to be cahnged by kernel_menuconfig/kernel_oldconfig
|
|
|
|
ifeq ($(CONFIG_TARGET),platform)
|
2011-04-18 00:47:44 +03:00
|
|
|
LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG))
|
|
|
|
LINUX_RECONFIG_TARGET = $(LINUX_TARGET_CONFIG)
|
2011-04-06 17:48:55 +03:00
|
|
|
endif
|
|
|
|
ifeq ($(CONFIG_TARGET),subtarget)
|
2011-04-18 00:47:44 +03:00
|
|
|
LINUX_RECONFIG_LIST = $(wildcard $(GENERIC_LINUX_CONFIG) $(LINUX_TARGET_CONFIG) $(LINUX_SUBTARGET_CONFIG))
|
|
|
|
LINUX_RECONFIG_TARGET = $(LINUX_SUBTARGET_CONFIG)
|
2011-04-06 17:48:55 +03:00
|
|
|
endif
|
|
|
|
ifeq ($(CONFIG_TARGET),env)
|
2011-04-18 00:47:44 +03:00
|
|
|
LINUX_RECONFIG_LIST = $(LINUX_KCONFIG_LIST)
|
|
|
|
LINUX_RECONFIG_TARGET = $(TOPDIR)/env/kernel-config
|
2011-04-06 17:48:55 +03:00
|
|
|
endif
|
|
|
|
|
|
|
|
__linux_confcmd = $(SCRIPT_DIR)/kconfig.pl $(2) $(patsubst %,+,$(wordlist 2,9999,$(1))) $(1)
|
|
|
|
|
|
|
|
LINUX_CONF_CMD = $(call __linux_confcmd,$(LINUX_KCONFIG_LIST),)
|
|
|
|
LINUX_RECONF_CMD = $(call __linux_confcmd,$(LINUX_RECONFIG_LIST),)
|
|
|
|
LINUX_RECONF_DIFF = $(call __linux_confcmd,$(filter-out $(LINUX_RECONFIG_TARGET),$(LINUX_RECONFIG_LIST)),'>')
|
2007-09-08 22:55:42 +03:00
|
|
|
|
|
|
|
ifeq ($(DUMP),1)
|
|
|
|
BuildTarget=$(BuildTargets/DumpCurrent)
|
|
|
|
|
|
|
|
ifneq ($(BOARD),)
|
|
|
|
TMP_CONFIG:=$(TMP_DIR)/.kconfig-$(call target_conf,$(TARGETID))
|
2011-04-06 17:48:55 +03:00
|
|
|
$(TMP_CONFIG): $(LINUX_KCONFIG_LIST)
|
|
|
|
$(LINUX_CONF_CMD) > $@ || rm -f $@
|
2007-09-08 22:55:42 +03:00
|
|
|
-include $(TMP_CONFIG)
|
|
|
|
.SILENT: $(TMP_CONFIG)
|
|
|
|
.PRECIOUS: $(TMP_CONFIG)
|
|
|
|
|
2008-04-20 12:46:45 +03:00
|
|
|
ifneq ($(CONFIG_GENERIC_GPIO),)
|
|
|
|
FEATURES += gpio
|
|
|
|
endif
|
2007-09-08 22:55:42 +03:00
|
|
|
ifneq ($(CONFIG_PCI),)
|
|
|
|
FEATURES += pci
|
|
|
|
endif
|
2009-06-02 12:50:43 +03:00
|
|
|
ifneq ($(CONFIG_PCIEPORTBUS),)
|
|
|
|
FEATURES += pcie
|
|
|
|
endif
|
2008-09-08 14:33:00 +03:00
|
|
|
ifneq ($(CONFIG_USB)$(CONFIG_USB_SUPPORT),)
|
2010-03-25 17:04:44 +02:00
|
|
|
ifneq ($(CONFIG_USB_ARCH_HAS_HCD)$(CONFIG_USB_EHCI_HCD),)
|
|
|
|
FEATURES += usb
|
|
|
|
endif
|
2007-09-08 22:55:42 +03:00
|
|
|
endif
|
|
|
|
ifneq ($(CONFIG_PCMCIA)$(CONFIG_PCCARD),)
|
|
|
|
FEATURES += pcmcia
|
|
|
|
endif
|
2007-10-26 00:08:46 +03:00
|
|
|
ifneq ($(CONFIG_VGA_CONSOLE)$(CONFIG_FB),)
|
|
|
|
FEATURES += display
|
|
|
|
endif
|
2007-09-08 22:55:42 +03:00
|
|
|
|
|
|
|
# remove duplicates
|
|
|
|
FEATURES:=$(sort $(FEATURES))
|
|
|
|
endif
|
2011-03-26 03:07:12 +02:00
|
|
|
DEFAULT_CFLAGS_i386=-O2 -pipe -march=i486 -fno-caller-saves
|
|
|
|
DEFAULT_CFLAGS_x86_64=-O2 -pipe -march=athlon64 -fno-caller-saves
|
|
|
|
DEFAULT_CFLAGS_m68k=-Os -pipe -mcfv4e -fno-caller-saves
|
|
|
|
DEFAULT_CFLAGS_mips=-Os -pipe -mips32 -mtune=mips32 -fno-caller-saves
|
2009-03-14 05:17:06 +02:00
|
|
|
DEFAULT_CFLAGS_mipsel=$(DEFAULT_CFLAGS_mips)
|
2011-03-26 03:07:12 +02:00
|
|
|
DEFAULT_CFLAGS_mips64=-Os -pipe -mips64 -mtune=mips64 -mabi=64 -fno-caller-saves
|
2009-04-18 20:03:55 +03:00
|
|
|
DEFAULT_CFLAGS_mips64el=$(DEFAULT_CFLAGS_mips64)
|
2011-03-26 03:07:12 +02:00
|
|
|
DEFAULT_CFLAGS_sparc=-Os -pipe -mcpu=ultrasparc -fno-caller-saves
|
|
|
|
DEFAULT_CFLAGS_arm=-Os -pipe -march=armv5te -mtune=xscale -fno-caller-saves
|
2009-03-14 05:17:06 +02:00
|
|
|
DEFAULT_CFLAGS_armeb=$(DEFAULT_CFLAGS_arm)
|
2011-03-26 03:07:12 +02:00
|
|
|
DEFAULT_CFLAGS=$(if $(DEFAULT_CFLAGS_$(ARCH)),$(DEFAULT_CFLAGS_$(ARCH)),-Os -pipe -fno-caller-saves)
|
2007-09-08 22:55:42 +03:00
|
|
|
endif
|
|
|
|
|
|
|
|
define BuildTargets/DumpCurrent
|
2007-10-20 22:10:06 +03:00
|
|
|
.PHONY: dumpinfo
|
2007-09-08 22:55:42 +03:00
|
|
|
dumpinfo:
|
|
|
|
@echo 'Target: $(TARGETID)'; \
|
|
|
|
echo 'Target-Board: $(BOARD)'; \
|
2009-08-03 14:44:28 +03:00
|
|
|
echo 'Target-Name: $(BOARDNAME)$(if $(SUBTARGETS),$(if $(SUBTARGET),))'; \
|
2007-09-08 22:55:42 +03:00
|
|
|
echo 'Target-Path: $(subst $(TOPDIR)/,,$(PWD))'; \
|
|
|
|
echo 'Target-Arch: $(ARCH)'; \
|
2010-09-12 23:49:54 +03:00
|
|
|
echo 'Target-Arch-Packages: $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(BOARD))'; \
|
2007-09-08 22:55:42 +03:00
|
|
|
echo 'Target-Features: $(FEATURES)'; \
|
2007-10-06 00:44:43 +03:00
|
|
|
echo 'Target-Depends: $(DEPENDS)'; \
|
2009-03-14 05:17:06 +02:00
|
|
|
echo 'Target-Optimization: $(if $(CFLAGS),$(CFLAGS),$(DEFAULT_CFLAGS))'; \
|
2007-09-08 22:55:42 +03:00
|
|
|
echo 'Linux-Version: $(LINUX_VERSION)'; \
|
|
|
|
echo 'Linux-Release: $(LINUX_RELEASE)'; \
|
|
|
|
echo 'Linux-Kernel-Arch: $(LINUX_KARCH)'; \
|
2011-07-04 14:21:37 +03:00
|
|
|
$(if $(SUBTARGET),,$(if $(DEFAULT_SUBTARGET), echo 'Default-Subtarget: $(DEFAULT_SUBTARGET)'; ))
|
2007-09-08 22:55:42 +03:00
|
|
|
echo 'Target-Description:'; \
|
2010-08-19 15:49:37 +03:00
|
|
|
$(SH_FUNC) getvar $(call shvar,Target/Description); \
|
2007-09-08 22:55:42 +03:00
|
|
|
echo '@@'; \
|
|
|
|
echo 'Default-Packages: $(DEFAULT_PACKAGES)'; \
|
|
|
|
$(DUMPINFO)
|
2007-10-20 22:10:06 +03:00
|
|
|
$(if $(SUBTARGET),,@$(foreach SUBTARGET,$(SUBTARGETS),$(SUBMAKE) -s DUMP=1 SUBTARGET=$(SUBTARGET); ))
|
2007-09-08 22:55:42 +03:00
|
|
|
endef
|
2007-03-03 01:36:59 +02:00
|
|
|
|
2007-09-08 22:55:42 +03:00
|
|
|
include $(INCLUDE_DIR)/kernel.mk
|
|
|
|
ifeq ($(TARGET_BUILD),1)
|
|
|
|
include $(INCLUDE_DIR)/kernel-build.mk
|
|
|
|
BuildTarget?=$(BuildKernel)
|
2007-01-10 23:52:28 +02:00
|
|
|
endif
|
2006-06-21 17:02:29 +03:00
|
|
|
|
2007-09-08 22:55:42 +03:00
|
|
|
endif #__target_inc
|