source: debwrt/trunk/openwrt/openwrt-deliver.mk @ 11

Last change on this file since 11 was 11, checked in by amain, 10 years ago

Create openWrt kernel headers image

File size: 5.5 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_DIR     - OpenWrt's kernel build directory
26#
27-include $(OPENWRT_SAVE_CONFIG_FILE)
28
29ERROR_MSG_NOCONF:=" not defined. Make sure OpenWrt build finished."
30
31openwrt/deliver: openwrt/deliver/prepare        openwrt/deliver/clean                   \
32                                 openwrt/deliver/image          openwrt/deliver/kernel-modules  \
33                                 openwrt/deliver/packages       openwrt/deliver/config              \
34                                 openwrt/deliver/kernel-headers
35
36openwrt/deliver/prepare: openwrt/deliver/import-config openwrt/deliver/check
37
38openwrt/deliver/import-config:
39        @echo OPENWRT_BIN_DIR=$(OPENWRT_BIN_DIR)
40        @echo OPENWRT_PACKAGE_DIR=$(OPENWRT_PACKAGE_DIR)
41        @echo OPENWRT_TMP_DIR=$(OPENWRT_TMP_DIR)
42        @echo OPENWRT_LINUX_VERSION=$(OPENWRT_LINUX_VERSION)
43        @echo OPENWRT_LINUX_DIR=$(OPENWRT_LINUX_DIR)
44
45openwrt/deliver/check: ${OPENWRT_BIN_DIR} openwrt/deliver/import-config
46  ifndef OPENWRT_PACKAGE_DIR
47        @echo OPENWRT_PACKAGE_DIR$(ERROR_MSG_NOCONF) && false
48  endif
49  ifndef OPENWRT_TMP_DIR
50        @echo OPENWRT_TMP_DIR$(ERROR_MSG_NOCONF) && false
51  endif
52  ifndef OPENWRT_LINUX_VERSION
53        @echo OPENWRT_LINUX_VERSION$(ERROR_MSG_NOCONF) && false
54  endif
55  ifndef OPENWRT_LINUX_DIR
56        @echo OPENWRT_LINUX_DIR$(ERROR_MSG_NOCONF) && false
57  endif
58  ifndef OPENWRT_PACKAGE_DIR
59        @echo OPENWRT_PACKAGE_DIR$(ERROR_MSG_NOCONF) && false
60  endif
61
62openwrt/deliver/image: openwrt/deliver/prepare
63        mkdir -p $(INSTALL_DIR)
64        if  [ "unknown" != $(call qstrip,$(CONFIG_OPENWRT_TARGET_IMAGE_NAME_BIN)) ]; then \
65                cp -a ${OPENWRT_BIN_DIR}/$(call qstrip,$(CONFIG_OPENWRT_TARGET_IMAGE_NAME_BIN)) $(INSTALL_DIR)/$(TARGET_IMAGE_NAME_BIN); \
66        else  \
67                echo "Failed to copy firmware BIN image. Configure image name in config/image_name.in"; \
68        fi
69        if  [ "unknown" != $(call qstrip,$(CONFIG_OPENWRT_TARGET_IMAGE_NAME_TRX)) ]; then \
70                cp -a ${OPENWRT_BIN_DIR}/$(call qstrip,$(CONFIG_OPENWRT_TARGET_IMAGE_NAME_TRX)) $(INSTALL_DIR)/$(TARGET_IMAGE_NAME_TRX); \
71        else  \
72                echo "Failed to copy firmware TRX image. Configure image name in config/image_name.in"; \
73        fi
74        if [ ! -e $(INSTALL_DIR)/$(TARGET_IMAGE_NAME_BIN) -a ! -e $(INSTALL_DIR)/$(TARGET_IMAGE_NAME_TRX) ]; then \
75                echo "Failed to copy a firmware image. Investigate." && false; \
76        fi
77
78openwrt/deliver/kernel-modules: openwrt/deliver/prepare
79        mkdir -p $(INSTALL_DIR) $(INSTALL_DIR_OPENWRT) $(INSTALL_DIR_OPENWRT_MODULES)
80        mkdir -p $(INSTALL_DIR_OPENWRT_MODULES)/lib/modules
81        cp -r ${OPENWRT_TMP_DIR}/modules/lib/modules/${OPENWRT_LINUX_VERSION} $(INSTALL_DIR_OPENWRT_MODULES)/lib/modules
82        rm -f $(INSTALL_DIR_OPENWRT_MODULES)/lib/modules/${OPENWRT_LINUX_VERSION}/build
83        rm -f $(INSTALL_DIR_OPENWRT_MODULES)/lib/modules/${OPENWRT_LINUX_VERSION}/source
84        find $(OPENWRT_PACKAGE_DIR) -name "kmod-*" | while read fkmod; do \
85            $(SCRIPT_EXTRACT_KMODPKG) $$fkmod $(INSTALL_DIR_OPENWRT_MODULES) $(TMP_DIR) || true; \
86        done
87        depmod -a -b $(INSTALL_DIR_OPENWRT_MODULES) ${OPENWRT_LINUX_VERSION}
88        tar czf $(INSTALL_DIR)/$(MODULES_TAR_GZ) -C $(INSTALL_DIR_OPENWRT_MODULES) .
89
90openwrt/deliver/kernel-headers: openwrt/deliver/prepare
91        mkdir -p $(INSTALL_DIR_OPENWRT_HEADERS)
92        mkdir -p $(INSTALL_DIR_OPENWRT_HEADERS)/usr/src/${OPENWRT_LINUX_VERSION}
93        cd $(OPENWRT_LINUX_DIR)
94        find . -path './include/*' -prune \
95                -o -path './scripts/*' -prune -o -type f \
96                \( -name 'Makefile*' -o -name 'Kconfig*' -o -name 'Kbuild*' -o \
97                -name '*.sh' -o -name '*.pl' -o -name '*.lds' \) \
98                -print | cpio -pd --preserve-modification-time
99        cp -a drivers/media/dvb/dvb-core/*.h $(INSTALL_DIR_OPENWRT_HEADERS)/usr/src/${OPENWRT_LINUX_VERSION}/drivers/media/dvb/dvb-core
100        cp -a drivers/media/video/*.h $(INSTALL_DIR_OPENWRT_HEADERS)/usr/src/${OPENWRT_LINUX_VERSION}/drivers/media/video
101        cp -a drivers/media/dvb/frontends/*.h $(INSTALL_DIR_OPENWRT_HEADERS)/usr/src/${OPENWRT_LINUX_VERSION}/drivers/media/dvb/frontends
102        cp -a scripts include $(INSTALL_DIR_OPENWRT_HEADERS)/usr/src/${OPENWRT_LINUX_VERSION}
103        (find arch -name include -type d -print | \
104                xargs -n1 -i: find : -type f) | \
105                cpio -pd --preserve-modification-time $(INSTALL_DIR_OPENWRT_HEADERS)/usr/src/${OPENWRT_LINUX_VERSION}
106
107openwrt/deliver/packages: openwrt/deliver/prepare
108        mkdir -p $(INSTALL_DIR_OPENWRT_PACKAGES)
109        cp -ra $(OPENWRT_PACKAGE_DIR)/* $(INSTALL_DIR_OPENWRT_PACKAGES)
110
111openwrt/deliver/config: openwrt/deliver/prepare
112        cp ${TOPDIR}/.config $(INSTALL_DIR)/config-debwrt
113        cp ${OPENWRT_BUILD_DIR}/.config $(INSTALL_DIR)/config-openwrt
114        cp ${OPENWRT_LINUX_DIR}/.config $(INSTALL_DIR)/config-kernel-${OPENWRT_LINUX_VERSION}
115
116openwrt/deliver/clean:
117        rm -rf $(INSTALL_DIR)
118
Note: See TracBrowser for help on using the repository browser.