source: debwrt/trunk/openwrt/openwrt.mk @ 171

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

openwrt/all: is now only rebuild when debwrt's or openwrt's .config files have changed. Fixes ticket #91.

File size: 4.0 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
18OPENWRT_PATCHES_DIR=$(TOPDIR)/openwrt/patches
19
20openwrt/all: openwrt/build
21        $(MAKE) -C $(TOPDIR) openwrt/deliver
22        touch $@
23
24openwrt/build: openwrt/prepare
25ifeq ("$(origin V)", "command line")
26        $(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) V=$(V)
27else
28        $(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR)
29endif
30        touch $@
31
32openwrt/prepare: openwrt/checkout openwrt/patch openwrt/merge-config openwrt/download-link
33        touch $@
34
35openwrt/merge-config: .config $(OPENWRT_BUILD_DIR)/.config openwrt/checkout openwrt/patch
36        mkdir -p $(TMP_DIR)
37        @# Copy default OpenWrt settings
38        cp $(CONFIG_DIR)/openwrt.defconfig $(TMP_DIR)/.config_openwrt
39        @# Merge default OpenWrt settings with menu settings
40        cat .config | grep -v -e CONFIG_TARGET_BOARD -e "^#" >> $(TMP_DIR)/.config_openwrt
41        @# Merge default and menu settings with possibly altered settings in make menuconfig in OpenWrt
42        touch $(OPENWRT_BUILD_DIR)/.config
43        cp $(OPENWRT_BUILD_DIR)/.config $(OPENWRT_BUILD_DIR)/.config.org
44        @$(SCRIPT_KCONFIG) + $(OPENWRT_BUILD_DIR)/.config.org $(TMP_DIR)/.config_openwrt > $(OPENWRT_BUILD_DIR)/.config
45        @# Make sure the config is clean
46        $(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) defconfig
47        @# Copy DebWrt config to the build dir - used to set kernel compile options
48        cp .config $(OPENWRT_BUILD_DIR)/.config.debwrt
49        touch $@
50
51openwrt/download-link: openwrt/checkout
52ifneq ($(OPENWRT_DOWNLOAD_DIR),)
53        cd $(OPENWRT_BUILD_DIR) && if [ -d $(OPENWRT_DOWNLOAD_DIR) -a ! -e dl ]; then ln -snf $(OPENWRT_DOWNLOAD_DIR) dl; fi
54endif
55        touch $@
56
57openwrt/patch: openwrt/checkout
58        patch -d $(OPENWRT_BUILD_DIR) -p 0 -N < $(PATCHES_DIR_OPENWRT)/001_disable_all_openwrt_packages
59ifeq ($(IS_OPENWRT_TRUNK),y)
60        patch -d $(OPENWRT_BUILD_DIR) -p 0 -N < $(PATCHES_DIR_OPENWRT)/trunk/002_install_kernel_modules_and_merge_debwrt_config
61        patch -d $(OPENWRT_BUILD_DIR) -p 0 -N < $(PATCHES_DIR_OPENWRT)/trunk/005_make_empty_rootfs
62else ifeq ($(IS_OPENWRT_BACKFIRE),y)
63        patch -d $(OPENWRT_BUILD_DIR) -p 0 -N < $(PATCHES_DIR_OPENWRT)/backfire/002_install_kernel_modules_and_merge_debwrt_config
64        patch -d $(OPENWRT_BUILD_DIR) -p 0 -N < $(PATCHES_DIR_OPENWRT)/backfire/005_make_empty_rootfs
65endif
66        #patch -d $(OPENWRT_BUILD_DIR) -p 0 -N < $(PATCHES_DIR_OPENWRT)/003_set_kernel_version
67        patch -d $(OPENWRT_BUILD_DIR) -p 0 -N < $(PATCHES_DIR_OPENWRT)/004_save_environment_variables
68        touch $@
69
70openwrt/checkout:
71        rm -rf $(OPENWRT_BUILD_DIR)
72        mkdir -p $(OPENWRT_BUILD_DIR)
73ifeq ($(IS_OPENWRT_TRUNK),y)
74        cd $(OPENWRT_BUILD_DIR) && svn co svn://svn.openwrt.org/openwrt/trunk/ .
75else ifeq ($(IS_OPENWRT_BACKFIRE),y)
76        cd $(OPENWRT_BUILD_DIR) && svn co svn://svn.openwrt.org/openwrt/branches/backfire/ .
77else
78        cd $(OPENWRT_BUILD_DIR) && svn co -r $(OPENWRT_REVISION) svn://svn.openwrt.org/openwrt/trunk/ .
79endif
80        touch $@
81
82openwrt/update: openwrt/checkout
83ifeq ($(IS_OPENWRT_TRUNK),y)
84        cd $(OPENWRT_BUILD_DIR) && svn update svn://svn.openwrt.org/openwrt/trunk/ .
85else ifeq ($(IS_OPENWRT_BACKFIRE),y)
86        cd $(OPENWRT_BUILD_DIR) && svn update svn://svn.openwrt.org/openwrt/branches/backfire/ .
87else
88        cd $(OPENWRT_BUILD_DIR) && svn update -r $(OPENWRT_REVISION) svn://svn.openwrt.org/openwrt/trunk/ .
89endif
90
91openwrt/menuconfig: openwrt/prepare
92        $(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) menuconfig
93
94openwrt/clean:
95        rm -rf $(OPENWRT_BUILD_DIR)
96        rm -f openwrt/checkout
97        rm -f openwrt/patch
98
Note: See TracBrowser for help on using the repository browser.