build: add make modules make target

`make modules` will generate a opkg repository containing kernel modules
matching the kernel of the Gluon images.
This commit is contained in:
Matthias Schiffer 2015-10-13 21:36:19 +02:00
parent 53a7cf31f9
commit cbe66e9388
5 changed files with 23 additions and 35 deletions

View File

@ -68,11 +68,12 @@ prepare-target: FORCE
all: prepare-target all: prepare-target
+@$(GLUONMAKE) prepare +@$(GLUONMAKE) prepare
+@$(GLUONMAKE) images +@$(GLUONMAKE) images
+@$(GLUONMAKE) modules
prepare: prepare-target prepare: prepare-target
+@$(GLUONMAKE) $@ +@$(GLUONMAKE) $@
clean download images: FORCE clean download images modules: FORCE
@$(CheckExternal) @$(CheckExternal)
@$(CheckTarget) @$(CheckTarget)
+@$(GLUONMAKE_EARLY) maybe-prepare-target +@$(GLUONMAKE_EARLY) maybe-prepare-target
@ -178,6 +179,10 @@ override SUBTARGET := $(GLUON_TARGET_$(GLUON_TARGET)_SUBTARGET)
target_prepared_stamp := $(BOARD_BUILDDIR)/target-prepared target_prepared_stamp := $(BOARD_BUILDDIR)/target-prepared
gluon_prepared_stamp := $(BOARD_BUILDDIR)/prepared gluon_prepared_stamp := $(BOARD_BUILDDIR)/prepared
PREPARED_RELEASE = $$(cat $(gluon_prepared_stamp))
IMAGE_PREFIX = gluon-$(GLUON_SITE_CODE)-$(PREPARED_RELEASE)
MODULE_PREFIX = gluon-$(GLUON_SITE_CODE)-$(PREPARED_RELEASE)
include $(INCLUDE_DIR)/target.mk include $(INCLUDE_DIR)/target.mk
@ -228,13 +233,6 @@ config: FORCE
| sed -e 's/ /\n/g'; \ | sed -e 's/ /\n/g'; \
) > $(BOARD_BUILDDIR)/config.tmp ) > $(BOARD_BUILDDIR)/config.tmp
scripts/config/conf --defconfig=$(BOARD_BUILDDIR)/config.tmp Config.in scripts/config/conf --defconfig=$(BOARD_BUILDDIR)/config.tmp Config.in
mv .config $(BOARD_BUILDDIR)/config
echo 'CONFIG_ALL_KMODS=y' >> $(BOARD_BUILDDIR)/config.tmp
scripts/config/conf --defconfig=$(BOARD_BUILDDIR)/config.tmp Config.in
mv .config $(BOARD_BUILDDIR)/config-allmods
cp $(BOARD_BUILDDIR)/config .config
prepare-target: FORCE prepare-target: FORCE
rm $(GLUON_OPENWRTDIR)/tmp || true rm $(GLUON_OPENWRTDIR)/tmp || true
@ -284,8 +282,8 @@ toolchain: $(toolchain/stamp-install) $(tools/stamp-install)
include $(INCLUDE_DIR)/kernel.mk include $(INCLUDE_DIR)/kernel.mk
kernel: FORCE kernel: FORCE
+$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD) -f $(GLUONDIR)/include/Makefile.target $(LINUX_DIR)/.image TARGET_BUILD=1 +$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD) $(LINUX_DIR)/.image TARGET_BUILD=1
+$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD) -f $(GLUONDIR)/include/Makefile.target $(LINUX_DIR)/.modules TARGET_BUILD=1 +$(NO_TRACE_MAKE) -C $(TOPDIR)/target/linux/$(BOARD) $(LINUX_DIR)/.modules TARGET_BUILD=1
packages: $(package/stamp-compile) packages: $(package/stamp-compile)
$(_SINGLE)$(SUBMAKE) -r package/index $(_SINGLE)$(SUBMAKE) -r package/index
@ -313,6 +311,14 @@ prepare: FORCE
$(gluon_prepared_stamp): $(gluon_prepared_stamp):
+$(GLUONMAKE) prepare +$(GLUONMAKE) prepare
modules: FORCE $(gluon_prepared_stamp)
-rm -f $(GLUON_MODULEDIR)/*/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic)/*
-rmdir -p $(GLUON_MODULEDIR)/*/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic)
mkdir -p $(GLUON_MODULEDIR)/$(MODULE_PREFIX)/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic)
cp $(PACKAGE_DIR)/kmod-*.ipk $(GLUON_MODULEDIR)/$(MODULE_PREFIX)/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic)
$(_SINGLE)$(SUBMAKE) -r package/index PACKAGE_DIR=$(GLUON_MODULEDIR)/$(MODULE_PREFIX)/$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic)
include $(INCLUDE_DIR)/package-ipkg.mk include $(INCLUDE_DIR)/package-ipkg.mk
@ -325,9 +331,6 @@ BIN_DIR = $(PROFILE_BUILDDIR)/images
TARGET_DIR = $(PROFILE_BUILDDIR)/root TARGET_DIR = $(PROFILE_BUILDDIR)/root
PREPARED_RELEASE = $$(cat $(gluon_prepared_stamp))
IMAGE_PREFIX = gluon-$(GLUON_SITE_CODE)-$(PREPARED_RELEASE)
OPKG:= \ OPKG:= \
IPKG_TMP="$(TMP_DIR)/ipkgtmp" \ IPKG_TMP="$(TMP_DIR)/ipkgtmp" \
IPKG_INSTROOT="$(TARGET_DIR)" \ IPKG_INSTROOT="$(TARGET_DIR)" \
@ -440,6 +443,6 @@ manifest: FORCE
) : \ ) : \
) >> $(GLUON_BUILDDIR)/$(GLUON_BRANCH).manifest.tmp ) >> $(GLUON_BUILDDIR)/$(GLUON_BRANCH).manifest.tmp
.PHONY: all images prepare clean gluon-tools manifest .PHONY: all images prepare modules clean gluon-tools manifest
endif endif

View File

@ -126,6 +126,9 @@ GLUON_OUTPUTDIR
GLUON_IMAGEDIR GLUON_IMAGEDIR
Path where images will be stored. Defaults to ``$(GLUON_OUTPUTDIR)/images/``. Path where images will be stored. Defaults to ``$(GLUON_OUTPUTDIR)/images/``.
GLUON_MODULEDIR
Path where the kernel module opkg repository will be stored. Defaults to ``$(GLUON_OUTPUTDIR)/modules``.
So all in all, to update and rebuild a Gluon build tree, the following commands should be used (repeat the So all in all, to update and rebuild a Gluon build tree, the following commands should be used (repeat the
``make clean`` and ``make`` for all targets you want to build): ``make clean`` and ``make`` for all targets you want to build):

View File

@ -1,19 +0,0 @@
# code adjusted from openwrt/include/kernel-defaults.mk
override define Kernel/Configure
$(LINUX_CONF_CMD) > $(LINUX_DIR)/.config.target
# copy CONFIG_KERNEL_* settings over to .config.target
awk '/^(#[[:space:]]+)?CONFIG_KERNEL/{sub("CONFIG_KERNEL_","CONFIG_");print}' $(BOARD_BUILDDIR)/config-allmods >> $(LINUX_DIR)/.config.target
echo "# CONFIG_KALLSYMS_EXTRA_PASS is not set" >> $(LINUX_DIR)/.config.target
echo "# CONFIG_KALLSYMS_ALL is not set" >> $(LINUX_DIR)/.config.target
echo "# CONFIG_KALLSYMS_UNCOMPRESSED is not set" >> $(LINUX_DIR)/.config.target
$(SCRIPT_DIR)/metadata.pl kconfig $(TMP_DIR)/.packageinfo $(BOARD_BUILDDIR)/config-allmods $(KERNEL_PATCHVER) > $(LINUX_DIR)/.config.override
$(SCRIPT_DIR)/kconfig.pl 'm+' '+' $(LINUX_DIR)/.config.target /dev/null $(LINUX_DIR)/.config.override > $(LINUX_DIR)/.config
$(call Kernel/SetNoInitramfs)
rm -rf $(KERNEL_BUILD_DIR)/modules
$(_SINGLE) [ -d $(LINUX_DIR)/user_headers ] || $(MAKE) $(KERNEL_MAKEOPTS) INSTALL_HDR_PATH=$(LINUX_DIR)/user_headers headers_install
$(SH_FUNC) grep '=[ym]' $(LINUX_DIR)/.config | LC_ALL=C sort | md5s > $(LINUX_DIR)/.vermagic
endef
# The Makefile included here is $(TOPDIR)/target/linux/$(BOARD)/Makefile
include Makefile

View File

@ -1,7 +1,7 @@
CONFIG_IMAGEOPT=y CONFIG_IMAGEOPT=y
# CONFIG_PER_FEED_REPO is not set # CONFIG_PER_FEED_REPO is not set
CONFIG_DEVEL=y CONFIG_DEVEL=y
CONFIG_ALL_KMODS=y
CONFIG_BUSYBOX_CUSTOM=y CONFIG_BUSYBOX_CUSTOM=y
CONFIG_BUSYBOX_CONFIG_SHA512SUM=y CONFIG_BUSYBOX_CONFIG_SHA512SUM=y

View File

@ -9,8 +9,9 @@ GLUON_SITE_CONFIG := $(GLUON_SITEDIR)/site.conf
GLUON_OUTPUTDIR ?= $(GLUONDIR)/output GLUON_OUTPUTDIR ?= $(GLUONDIR)/output
GLUON_IMAGEDIR ?= $(GLUON_OUTPUTDIR)/images GLUON_IMAGEDIR ?= $(GLUON_OUTPUTDIR)/images
GLUON_MODULEDIR ?= $(GLUON_OUTPUTDIR)/modules
export GLUONDIR GLUON_SITEDIR GLUON_BUILDDIR GLUON_SITE_CONFIG GLUON_OUTPUTDIR GLUON_IMAGEDIR export GLUONDIR GLUON_SITEDIR GLUON_BUILDDIR GLUON_SITE_CONFIG GLUON_OUTPUTDIR GLUON_IMAGEDIR GLUON_MODULEDIR
BOARD_BUILDDIR = $(GLUON_BUILDDIR)/$(GLUON_TARGET) BOARD_BUILDDIR = $(GLUON_BUILDDIR)/$(GLUON_TARGET)