Current section
Files
Jump to
Current section
Files
package/openwrt-compat-wireless/openwrt-compat-wireless.mk
################################################################################
#
# openwrt-compat-wireless
#
################################################################################
#
# This is almost a copy/paste of linux-backports. OpenWRT heavily patches
# and uses an upstream version of linux-backports, though. We also patch in
# the wireless driver for the Linkit Smart 7688.
#
OPENWRT_COMPAT_WIRELESS_VERSION = 2016-05-12
OPENWRT_COMPAT_WIRELESS_SOURCE = compat-wireless-$(OPENWRT_COMPAT_WIRELESS_VERSION).tar.bz2
OPENWRT_COMPAT_WIRELESS_SITE = http://mirror2.openwrt.org/sources
OPENWRT_COMPAT_WIRELESS_LICENSE = GPLv2
OPENWRT_COMPAT_WIRELESS_LICENSE_FILES = COPYING
ifeq ($(BR2_PACKAGE_OPENWRT_COMPAT_WIRELESS_USE_DEFCONFIG),y)
OPENWRT_COMPAT_WIRELESS_KCONFIG_FILE = $(OPENWRT_COMPAT_WIRELESS_DIR)/defconfigs/$(call qstrip,$(BR2_PACKAGE_OPENWRT_COMPAT_WIRELESS_DEFCONFIG))
else ifeq ($(BR2_PACKAGE_OPENWRT_COMPAT_WIRELESS_USE_CUSTOM_CONFIG),y)
OPENWRT_COMPAT_WIRELESS_KCONFIG_FILE = $(call qstrip,$(BR2_PACKAGE_OPENWRT_COMPAT_WIRELESS_CUSTOM_CONFIG_FILE))
endif
OPENWRT_COMPAT_WIRELESS_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_PACKAGE_OPENWRT_COMPAT_WIRELESS_CONFIG_FRAGMENT_FILES))
OPENWRT_COMPAT_WIRELESS_KCONFIG_OPTS = $(OPENWRT_COMPAT_WIRELESS_MAKE_OPTS)
# Copy the db.txt that would have been used by the kernel over here
define OPENWRT_COMPAT_WIRELESS_COPY_DB_TXT
cp $(LINUX_DIR)/net/wireless/db.txt $(@D)/net/wireless/db.txt
endef
OPENWRT_COMPAT_WIRELESS_POST_PATCH_HOOKS += OPENWRT_COMPAT_WIRELESS_COPY_DB_TXT
# openwrt-compat-wireless' build system expects the config options to be present
# in the environment, and it is so when using their custom buildsystem,
# because they are set in the main Makefile, which then calls a second
# Makefile.
#
# In our case, we do not use that first Makefile. So, we parse the
# .config file, filter-out comment lines and put the rest as command
# line variables.
#
# OPENWRT_COMPAT_WIRELESS_MAKE_OPTS is used by the kconfig-package infra, while
# OPENWRT_COMPAT_WIRELESS_MODULE_MAKE_OPTS is used by the kernel-module infra.
#
OPENWRT_COMPAT_WIRELESS_MAKE_OPTS = \
BACKPORT_DIR=$(@D) \
KLIB_BUILD=$(LINUX_DIR) \
KLIB=$(TARGET_DIR)/lib/modules/$(LINUX_VERSION_PROBED) \
INSTALL_MOD_DIR=backports \
`sed -r -e '/^\#/d;' $(@D)/.config`
OPENWRT_COMPAT_WIRELESS_MODULE_MAKE_OPTS = $(OPENWRT_COMPAT_WIRELESS_MAKE_OPTS)
# This file is not automatically generated by 'oldconfig' that we use in
# the kconfig-package infrastructure. In the linux buildsystem, it is
# generated by running silentoldconfig, but that's not the case for
# openwrt-compat-wireless: it uses a hand-crafted rule to generate that file.
define OPENWRT_COMPAT_WIRELESS_KCONFIG_FIXUP_CMDS
$(MAKE) -C $(@D) $(OPENWRT_COMPAT_WIRELESS_MAKE_OPTS) backport-include/backport/autoconf.h
endef
# Checks to give errors that the user can understand
ifeq ($(BR_BUILDING),y)
ifeq ($(BR2_PACKAGE_OPENWRT_COMPAT_WIRELESS_USE_DEFCONFIG),y)
ifeq ($(call qstrip,$(BR2_PACKAGE_OPENWRT_COMPAT_WIRELESS_DEFCONFIG)),)
$(error No openwrt-compat-wireless defconfig name specified, check your BR2_PACKAGE_OPENWRT_COMPAT_WIRELESS_DEFCONFIG setting)
endif
endif
ifeq ($(BR2_PACKAGE_OPENWRT_COMPAT_WIRELESS_USE_CUSTOM_CONFIG),y)
ifeq ($(call qstrip,$(BR2_PACKAGE_OPENWRT_COMPAT_WIRELESS_CUSTOM_CONFIG_FILE)),)
$(error No openwrt-compat-wireless configuration file specified, check your BR2_PACKAGE_OPENWRT_COMPAT_WIRELESS_CUSTOM_CONFIG_FILE setting)
endif
endif
endif # BR_BUILDING
$(eval $(kernel-module))
$(eval $(kconfig-package))
# openwrt-compat-wireless' own .config file needs options from the kernel's own
# .config file. The dependencies handling in the infrastructure does not
# allow to express this kind of dependencies. Besides, linux.mk might
# not have been parsed yet, so the Linux build dir LINUX_DIR is not yet
# known. Thus, we use a "secondary expansion" so the rule is re-evaluated
# after all Makefiles are parsed, and thus at that time we will have the
# LINUX_DIR variable set to the proper value.
#
# Furthermore, we want to check the kernel version, since openwrt-compat-wireless
# only supports kernels >= 3.0. To avoid overriding openwrt-compat-wireless'
# .config rule defined in the kconfig-package infra, we use an
# intermediate stamp-file.
#
# Finally, it must also come after the call to kconfig-package, so we get
# OPENWRT_COMPAT_WIRELESS_DIR properly defined (because the target part of the
# rule is not re-evaluated).
#
$(OPENWRT_COMPAT_WIRELESS_DIR)/.config: $(OPENWRT_COMPAT_WIRELESS_DIR)/.stamp_check_kernel_version
.SECONDEXPANSION:
$(OPENWRT_COMPAT_WIRELESS_DIR)/.stamp_check_kernel_version: $$(LINUX_DIR)/.config
$(Q)LINUX_VERSION_PROBED=$(LINUX_VERSION_PROBED); \
if [ $${LINUX_VERSION_PROBED%%.*} -lt 3 ]; then \
printf "Linux version '%s' is too old for openwrt-compat-wireless (needs 3.0 or later)\n" \
"$${LINUX_VERSION_PROBED}"; \
exit 1; \
fi
$(Q)touch $(@)