source: trunk/openwrt/openwrt-deliver.mk @ 770

Last change on this file since 770 was 770, checked in by amain, 3 years ago

Install target dependent files during boot (sysV or systemd). This is needed because DebWrt rootfs image now are target independent. The target dependent files are installed via the debwrt-modules-*.gz file, which contains the target depending moduels and two files: /lib/modules/debwrt.target and /lib/modules/debwrt.subtarget. In case systemd does not work, sysvinit is installed as well (jessie+).

File size: 5.4 KB
RevLine 
[3]1# DebWrt - Debian on Embedded devices
2#
3# Copyright (C) 2010 Johan van Zoomeren <amain@debwrt.net>
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
[5]18# The following function imports some environment variables
19# save in a special config file during OpenWrt's build process
20#
[332]21# OPENWRT_BIN_DIR               - directory where OpenWrt firmware is stored
22# OPENWRT_PACKAGE_DIR           - directory where OpenWrt packages are stored
23# OPENWRT_TMP_DIR               - directory where OpenWrt stored all kernel modules
24# OPENWRT_LINUX_VERSION         - kernel version of the kernel build by OpenWrt
25# OPENWRT_LINUX_UNAME_VERSION   - uname kernel version of the kernel build by OpenWrt
26# OPENWRT_LINUX_DIR             - OpenWrt's kernel build directory
[5]27#
[10]28-include $(OPENWRT_SAVE_CONFIG_FILE)
[3]29
[5]30ERROR_MSG_NOCONF:=" not defined. Make sure OpenWrt build finished."
31
[185]32openwrt/deliver: \
33  openwrt/deliver/prepare \
34  openwrt/deliver/clean \
35  openwrt/deliver/image \
36  openwrt/deliver/kernel-modules \
37  openwrt/deliver/packages \
38  openwrt/deliver/config\
39  openwrt/deliver/kernel-headers \
40  # end openwrt/deliver:
[5]41
42openwrt/deliver/prepare: openwrt/deliver/import-config openwrt/deliver/check
43
44openwrt/deliver/import-config:
45        @echo OPENWRT_BIN_DIR=$(OPENWRT_BIN_DIR)
46        @echo OPENWRT_PACKAGE_DIR=$(OPENWRT_PACKAGE_DIR)
47        @echo OPENWRT_TMP_DIR=$(OPENWRT_TMP_DIR)
48        @echo OPENWRT_LINUX_VERSION=$(OPENWRT_LINUX_VERSION)
[332]49        @echo OPENWRT_LINUX_UNAME_VERSION=$(OPENWRT_LINUX_UNAME_VERSION)
[5]50        @echo OPENWRT_LINUX_DIR=$(OPENWRT_LINUX_DIR)
51
[517]52openwrt/deliver/check: $(OPENWRT_BIN_DIR) openwrt/deliver/import-config
[5]53  ifndef OPENWRT_PACKAGE_DIR
54        @echo OPENWRT_PACKAGE_DIR$(ERROR_MSG_NOCONF) && false
55  endif
56  ifndef OPENWRT_TMP_DIR
57        @echo OPENWRT_TMP_DIR$(ERROR_MSG_NOCONF) && false
58  endif
59  ifndef OPENWRT_LINUX_VERSION
60        @echo OPENWRT_LINUX_VERSION$(ERROR_MSG_NOCONF) && false
61  endif
[332]62  ifndef OPENWRT_LINUX_UNAME_VERSION
63        @echo OPENWRT_LINUX_UNAME_VERSION$(ERROR_MSG_NOCONF) && false
64  endif
[5]65  ifndef OPENWRT_LINUX_DIR
66        @echo OPENWRT_LINUX_DIR$(ERROR_MSG_NOCONF) && false
67  endif
68  ifndef OPENWRT_PACKAGE_DIR
69        @echo OPENWRT_PACKAGE_DIR$(ERROR_MSG_NOCONF) && false
70  endif
71
72openwrt/deliver/image: openwrt/deliver/prepare
[696]73        mkdir -p $(INSTALL_DIR_OPENWRT)
[517]74        find $(OPENWRT_BIN_DIR) -maxdepth 1 -type f | while read fname; do \
[59]75                tfname=`basename $$fname`; \
76                tfname=`echo $$tfname | sed 's/openwrt/debwrt-firmware/'`; \
[696]77                cp -av $$fname $(INSTALL_DIR_OPENWRT)/$$tfname; \
[59]78        done
[5]79
80openwrt/deliver/kernel-modules: openwrt/deliver/prepare
[696]81        mkdir -p $(INSTALL_DIR_OPENWRT) $(INSTALL_DIR_OPENWRT_MODULES)
[5]82        mkdir -p $(INSTALL_DIR_OPENWRT_MODULES)/lib/modules
[517]83        cp -r $(OPENWRT_TMP_DIR)/modules/lib/modules/$(OPENWRT_LINUX_UNAME_VERSION) $(INSTALL_DIR_OPENWRT_MODULES)/lib/modules
84        rm -f $(INSTALL_DIR_OPENWRT_MODULES)/lib/modules/$(OPENWRT_LINUX_UNAME_VERSION)/build
85        rm -f $(INSTALL_DIR_OPENWRT_MODULES)/lib/modules/$(OPENWRT_LINUX_UNAME_VERSION)/source
[5]86        find $(OPENWRT_PACKAGE_DIR) -name "kmod-*" | while read fkmod; do \
87            $(SCRIPT_EXTRACT_KMODPKG) $$fkmod $(INSTALL_DIR_OPENWRT_MODULES) $(TMP_DIR) || true; \
88        done
[517]89        PATH="/sbin:/bin:/usr/sbin:/usr/bin" depmod -a -b $(INSTALL_DIR_OPENWRT_MODULES) $(OPENWRT_LINUX_UNAME_VERSION)
[770]90        echo $(TARGET) >$(INSTALL_DIR_OPENWRT_MODULES)/lib/modules/debwrt.target
91        echo $(SUB_TARGET) >$(INSTALL_DIR_OPENWRT_MODULES)/lib/modules/debwrt.subtarget
[696]92        tar czf $(INSTALL_DIR_OPENWRT)/$(MODULES_TAR_GZ) -C $(INSTALL_DIR_OPENWRT_MODULES) .
[5]93
[11]94openwrt/deliver/kernel-headers: openwrt/deliver/prepare
[150]95        rm -rf $(INSTALL_DIR_OPENWRT_HEADERS)
[11]96        mkdir -p $(INSTALL_DIR_OPENWRT_HEADERS)
[517]97        mkdir -p $(INSTALL_DIR_OPENWRT_HEADERS)/usr/src/linux-headers-$(OPENWRT_LINUX_UNAME_VERSION)
[724]98        cd $(OPENWRT_LINUX_DIR) && $(MAKE) headers_install ARCH=$(patsubst %el,%,$(TARGET_ARCH_LINUX)) INSTALL_HDR_PATH=$(INSTALL_DIR_OPENWRT_HEADERS)/usr/src/linux-headers-$(OPENWRT_LINUX_UNAME_VERSION)
[150]99        # some overrides which are not cleanly installed by make headers_install
[563]100        #cp $(OPENWRT_LINUX_DIR)/include/linux/switch.h $(INSTALL_DIR_OPENWRT_HEADERS)/usr/src/linux-headers-$(OPENWRT_LINUX_UNAME_VERSION)/include/linux/switch.h
[517]101        cp $(OPENWRT_LINUX_DIR)/.config $(INSTALL_DIR_OPENWRT_HEADERS)/usr/src/linux-headers-$(OPENWRT_LINUX_UNAME_VERSION)
[696]102        tar czf $(INSTALL_DIR_OPENWRT)/$(HEADERS_TAR_GZ) -C $(INSTALL_DIR_OPENWRT_HEADERS) .
[11]103
[5]104openwrt/deliver/packages: openwrt/deliver/prepare
105        mkdir -p $(INSTALL_DIR_OPENWRT_PACKAGES)
106        cp -ra $(OPENWRT_PACKAGE_DIR)/* $(INSTALL_DIR_OPENWRT_PACKAGES)
107
108openwrt/deliver/config: openwrt/deliver/prepare
[696]109        cp $(TOPDIR)/.config $(INSTALL_DIR_OPENWRT)/config-debwrt
110        cp $(OPENWRT_BUILD_DIR)/.config $(INSTALL_DIR_OPENWRT)/config-openwrt
111        cp $(OPENWRT_LINUX_DIR)/.config $(INSTALL_DIR_OPENWRT)/config-kernel-$(OPENWRT_LINUX_VERSION)
[724]112        $(SCRIPT_GET_SVN_REVISION) $(OPENWRT_BUILD_DIR) > $(INSTALL_DIR_OPENWRT)/openwrt-svn-revision
[696]113        $(SCRIPT_GET_SVN_REVISION) $(TOPDIR) > $(INSTALL_DIR_OPENWRT)/debwrt-svn-revision
[5]114
115openwrt/deliver/clean:
[696]116        rm -rf $(INSTALL_DIR_OPENWRT)
[5]117
Note: See TracBrowser for help on using the repository browser.