source: trunk/openwrt/openwrt-deliver.mk

Last change on this file was 919, checked in by amain, 2 years ago

octeon-native: fix boot cmdline configuration, firmware: create header and modules tar.gzs with default owner/group root

File size: 5.6 KB
Line 
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
18# The following function imports some environment variables
19# save in a special config file during OpenWrt's build process
20#
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
27#
28-include $(OPENWRT_SAVE_CONFIG_FILE)
29
30ERROR_MSG_NOCONF:=" not defined. Make sure OpenWrt build finished."
31
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  openwrt/deliver/install-sh
41  # end openwrt/deliver:
42
43openwrt/deliver/prepare: openwrt/deliver/import-config openwrt/deliver/check
44
45openwrt/deliver/import-config:
46        @echo OPENWRT_BIN_DIR=$(OPENWRT_BIN_DIR)
47        @echo OPENWRT_PACKAGE_DIR=$(OPENWRT_PACKAGE_DIR)
48        @echo OPENWRT_TMP_DIR=$(OPENWRT_TMP_DIR)
49        @echo OPENWRT_LINUX_VERSION=$(OPENWRT_LINUX_VERSION)
50        @echo OPENWRT_LINUX_UNAME_VERSION=$(OPENWRT_LINUX_UNAME_VERSION)
51        @echo OPENWRT_LINUX_DIR=$(OPENWRT_LINUX_DIR)
52
53openwrt/deliver/check: $(OPENWRT_BIN_DIR) openwrt/deliver/import-config
54  ifndef OPENWRT_PACKAGE_DIR
55        @echo OPENWRT_PACKAGE_DIR$(ERROR_MSG_NOCONF) && false
56  endif
57  ifndef OPENWRT_TMP_DIR
58        @echo OPENWRT_TMP_DIR$(ERROR_MSG_NOCONF) && false
59  endif
60  ifndef OPENWRT_LINUX_VERSION
61        @echo OPENWRT_LINUX_VERSION$(ERROR_MSG_NOCONF) && false
62  endif
63  ifndef OPENWRT_LINUX_UNAME_VERSION
64        @echo OPENWRT_LINUX_UNAME_VERSION$(ERROR_MSG_NOCONF) && false
65  endif
66  ifndef OPENWRT_LINUX_DIR
67        @echo OPENWRT_LINUX_DIR$(ERROR_MSG_NOCONF) && false
68  endif
69  ifndef OPENWRT_PACKAGE_DIR
70        @echo OPENWRT_PACKAGE_DIR$(ERROR_MSG_NOCONF) && false
71  endif
72
73openwrt/deliver/image: openwrt/deliver/prepare
74        mkdir -p $(INSTALL_DIR_OPENWRT)
75        find $(OPENWRT_BIN_DIR) -maxdepth 1 -type f | while read fname; do \
76                tfname=`basename $$fname`; \
77                tfname=`echo $$tfname | sed 's/openwrt/debwrt-firmware/'`; \
78                cp -av $$fname $(INSTALL_DIR_OPENWRT)/$$tfname; \
79        done
80
81openwrt/deliver/kernel-modules: openwrt/deliver/prepare
82        mkdir -p $(INSTALL_DIR_OPENWRT) $(INSTALL_DIR_OPENWRT_MODULES)
83        mkdir -p $(INSTALL_DIR_OPENWRT_MODULES)/lib/modules
84        cp -r $(OPENWRT_TMP_DIR)/modules/lib/modules/$(OPENWRT_LINUX_UNAME_VERSION) $(INSTALL_DIR_OPENWRT_MODULES)/lib/modules
85        rm -f $(INSTALL_DIR_OPENWRT_MODULES)/lib/modules/$(OPENWRT_LINUX_UNAME_VERSION)/build
86        rm -f $(INSTALL_DIR_OPENWRT_MODULES)/lib/modules/$(OPENWRT_LINUX_UNAME_VERSION)/source
87        find $(OPENWRT_PACKAGE_DIR) -name "kmod-*" | while read fkmod; do \
88            $(SCRIPT_EXTRACT_KMODPKG) $$fkmod $(INSTALL_DIR_OPENWRT_MODULES) $(TMP_DIR) || true; \
89        done
90        PATH="/sbin:/bin:/usr/sbin:/usr/bin" depmod -a -b $(INSTALL_DIR_OPENWRT_MODULES) $(OPENWRT_LINUX_UNAME_VERSION)
91        echo $(TARGET) >$(INSTALL_DIR_OPENWRT_MODULES)/lib/modules/debwrt.target
92        echo $(SUB_TARGET) >$(INSTALL_DIR_OPENWRT_MODULES)/lib/modules/debwrt.subtarget
93        tar cpzf $(INSTALL_DIR_OPENWRT)/$(MODULES_TAR_GZ) --owner=root --group=root -C $(INSTALL_DIR_OPENWRT_MODULES) .
94
95openwrt/deliver/kernel-headers: openwrt/deliver/prepare
96        rm -rf $(INSTALL_DIR_OPENWRT_HEADERS)
97        mkdir -p $(INSTALL_DIR_OPENWRT_HEADERS)
98        mkdir -p $(INSTALL_DIR_OPENWRT_HEADERS)/usr/src/linux-headers-$(OPENWRT_LINUX_UNAME_VERSION)
99        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)
100        # some overrides which are not cleanly installed by make headers_install
101        #cp $(OPENWRT_LINUX_DIR)/include/linux/switch.h $(INSTALL_DIR_OPENWRT_HEADERS)/usr/src/linux-headers-$(OPENWRT_LINUX_UNAME_VERSION)/include/linux/switch.h
102        cp $(OPENWRT_LINUX_DIR)/.config $(INSTALL_DIR_OPENWRT_HEADERS)/usr/src/linux-headers-$(OPENWRT_LINUX_UNAME_VERSION)
103        tar cpzf $(INSTALL_DIR_OPENWRT)/$(HEADERS_TAR_GZ) --owner=root --group=root -C $(INSTALL_DIR_OPENWRT_HEADERS) .
104
105openwrt/deliver/packages: openwrt/deliver/prepare
106        mkdir -p $(INSTALL_DIR_OPENWRT_PACKAGES)
107        cp -ra $(OPENWRT_PACKAGE_DIR)/* $(INSTALL_DIR_OPENWRT_PACKAGES)
108
109openwrt/deliver/config: openwrt/deliver/prepare
110        cp $(TOPDIR)/.config $(INSTALL_DIR_OPENWRT)/config-debwrt
111        cp $(OPENWRT_BUILD_DIR)/.config $(INSTALL_DIR_OPENWRT)/config-openwrt
112        cp $(OPENWRT_LINUX_DIR)/.config $(INSTALL_DIR_OPENWRT)/config-kernel-$(OPENWRT_LINUX_VERSION)
113        $(SCRIPT_GET_SVN_REVISION) $(OPENWRT_BUILD_DIR) > $(INSTALL_DIR_OPENWRT)/openwrt-svn-revision
114        $(SCRIPT_GET_SVN_REVISION) $(TOPDIR) > $(INSTALL_DIR_OPENWRT)/debwrt-svn-revision
115
116openwrt/deliver/install-sh: openwrt/deliver/prepare
117        cp openwrt/install.sh $(INSTALL_DIR_OPENWRT)
118
119openwrt/deliver/clean:
120        rm -rf $(INSTALL_DIR_OPENWRT)
121
Note: See TracBrowser for help on using the repository browser.