Переглянути джерело

build: add `make modules` make target

`make modules` will generate a opkg repository containing kernel modules
matching the kernel of the Gluon images.
Matthias Schiffer 9 роки тому
батько
коміт
cbe66e9388
5 змінених файлів з 23 додано та 35 видалено
  1. 17 14
      Makefile
  2. 3 0
      docs/user/getting_started.rst
  3. 0 19
      include/Makefile.target
  4. 1 1
      include/config
  5. 2 1
      include/gluon.mk

+ 17 - 14
Makefile

@@ -68,11 +68,12 @@ prepare-target: FORCE
 all: prepare-target
 	+@$(GLUONMAKE) prepare
 	+@$(GLUONMAKE) images
+	+@$(GLUONMAKE) modules
 
 prepare: prepare-target
 	+@$(GLUONMAKE) $@
 
-clean download images: FORCE
+clean download images modules: FORCE
 	@$(CheckExternal)
 	@$(CheckTarget)
 	+@$(GLUONMAKE_EARLY) maybe-prepare-target
@@ -178,6 +179,10 @@ override SUBTARGET := $(GLUON_TARGET_$(GLUON_TARGET)_SUBTARGET)
 target_prepared_stamp := $(BOARD_BUILDDIR)/target-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
 
@@ -228,13 +233,6 @@ config: FORCE
 			| sed -e 's/ /\n/g'; \
 	) > $(BOARD_BUILDDIR)/config.tmp
 	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
 	rm $(GLUON_OPENWRTDIR)/tmp || true
@@ -284,8 +282,8 @@ toolchain: $(toolchain/stamp-install) $(tools/stamp-install)
 include $(INCLUDE_DIR)/kernel.mk
 
 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) -f $(GLUONDIR)/include/Makefile.target $(LINUX_DIR)/.modules 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) $(LINUX_DIR)/.modules TARGET_BUILD=1
 
 packages: $(package/stamp-compile)
 	$(_SINGLE)$(SUBMAKE) -r package/index
@@ -313,6 +311,14 @@ prepare: FORCE
 $(gluon_prepared_stamp):
 	+$(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
 
@@ -325,9 +331,6 @@ BIN_DIR = $(PROFILE_BUILDDIR)/images
 
 TARGET_DIR = $(PROFILE_BUILDDIR)/root
 
-PREPARED_RELEASE = $$(cat $(gluon_prepared_stamp))
-IMAGE_PREFIX = gluon-$(GLUON_SITE_CODE)-$(PREPARED_RELEASE)
-
 OPKG:= \
   IPKG_TMP="$(TMP_DIR)/ipkgtmp" \
   IPKG_INSTROOT="$(TARGET_DIR)" \
@@ -440,6 +443,6 @@ manifest: FORCE
 		) : \
 	) >> $(GLUON_BUILDDIR)/$(GLUON_BRANCH).manifest.tmp
 
-.PHONY: all images prepare clean gluon-tools manifest
+.PHONY: all images prepare modules clean gluon-tools manifest
 
 endif

+ 3 - 0
docs/user/getting_started.rst

@@ -126,6 +126,9 @@ GLUON_OUTPUTDIR
 GLUON_IMAGEDIR
   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
 ``make clean`` and ``make`` for all targets you want to build):

+ 0 - 19
include/Makefile.target

@@ -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

+ 1 - 1
include/config

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

+ 2 - 1
include/gluon.mk

@@ -9,8 +9,9 @@ GLUON_SITE_CONFIG := $(GLUON_SITEDIR)/site.conf
 
 GLUON_OUTPUTDIR ?= $(GLUONDIR)/output
 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)