1 | # DebWrt - Debian on Embedded devices |
---|
2 | # |
---|
3 | # Copyright (C) 2010 Johan van Zoomeren <amain@debwrt.net> |
---|
4 | # Copyright (C) 2012 Elliott Mitchell <ehem+debwrt@m5p.com> |
---|
5 | # |
---|
6 | # This program is free software: you can redistribute it and/or modify |
---|
7 | # it under the terms of the GNU General Public License as published by |
---|
8 | # the Free Software Foundation, either version 3 of the License, or |
---|
9 | # (at your option) any later version. |
---|
10 | # |
---|
11 | # This program is distributed in the hope that it will be useful, |
---|
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | # GNU General Public License for more details. |
---|
15 | # |
---|
16 | # You should have received a copy of the GNU General Public License |
---|
17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
18 | |
---|
19 | OPENWRT_PATCHES_DIR=$(TOPDIR)/openwrt/patches |
---|
20 | |
---|
21 | openwrt/all: openwrt/build |
---|
22 | $(MAKE) -C $(TOPDIR) openwrt/deliver |
---|
23 | touch $@ |
---|
24 | |
---|
25 | openwrt/build: openwrt/prepare |
---|
26 | ifeq ("$(origin V)", "command line") |
---|
27 | $(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) $(CONFIG_OPENWRT_MAKE_OPTIONS) V=$(V) |
---|
28 | else |
---|
29 | $(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) $(CONFIG_OPENWRT_MAKE_OPTIONS) |
---|
30 | endif |
---|
31 | touch $@ |
---|
32 | |
---|
33 | openwrt/download: |
---|
34 | ifeq ("$(origin V)", "command line") |
---|
35 | $(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) download V=$(V) |
---|
36 | else |
---|
37 | $(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) download |
---|
38 | endif |
---|
39 | touch $@ |
---|
40 | |
---|
41 | openwrt/prepare: \ |
---|
42 | openwrt/checkout \ |
---|
43 | openwrt/patch \ |
---|
44 | openwrt/files-copy \ |
---|
45 | plugins/apply-openwrt \ |
---|
46 | openwrt/merge-config \ |
---|
47 | openwrt/download-link \ |
---|
48 | # end openwrt/prepare: |
---|
49 | touch $@ |
---|
50 | |
---|
51 | openwrt/merge-config: .config $(OPENWRT_BUILD_DIR)/.config openwrt/checkout openwrt/patch |
---|
52 | mkdir -p $(TMP_DIR) |
---|
53 | # Copy default OpenWrt settings |
---|
54 | cp $(CONFIG_DIR)/openwrt.defconfig $(TMP_DIR)/.config_openwrt |
---|
55 | # Merge default OpenWrt settings with DebWrt menu config settings |
---|
56 | #cat .config | grep -v -e CONFIG_TARGET_BOARD -e "^#" >> $(TMP_DIR)/.config_openwrt |
---|
57 | cat .config | grep -v -e CONFIG_TARGET_BOARD >> $(TMP_DIR)/.config_openwrt |
---|
58 | # Merge default and menu settings with possibly altered settings in make menuconfig in OpenWrt |
---|
59 | # note: settings manually made in OpenWrt menu config will be included! |
---|
60 | touch $(OPENWRT_BUILD_DIR)/.config |
---|
61 | cp $(OPENWRT_BUILD_DIR)/.config $(OPENWRT_BUILD_DIR)/.config.org |
---|
62 | $(SCRIPT_KCONFIG) + $(OPENWRT_BUILD_DIR)/.config.org $(TMP_DIR)/.config_openwrt > $(OPENWRT_BUILD_DIR)/.config |
---|
63 | # Filter out config options unknown to OpenWrt (e.g. pure kernel known options) / clean up OpenWrt config |
---|
64 | $(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) defconfig |
---|
65 | # Save .config to OpenWrt build-dir. During the OpenWrt build the .config kernel options are |
---|
66 | # merged with the OpenWrt's default kernel options for the target. In this phase any DebWrt/OpenWrt |
---|
67 | # specific options in the .config file are filtered out. See include/kernel-defaults.mk from OpenWrt. |
---|
68 | cp .config $(OPENWRT_BUILD_DIR)/.config.debwrt |
---|
69 | touch $@ |
---|
70 | |
---|
71 | $(OPENWRT_BUILD_DIR)/.config: openwrt/checkout |
---|
72 | [ ! -f $@ ] && touch $(OPENWRT_BUILD_DIR)/.config |
---|
73 | |
---|
74 | openwrt/download-link: openwrt/checkout |
---|
75 | ifneq ($(OPENWRT_DOWNLOAD_DIR),) |
---|
76 | cd $(OPENWRT_BUILD_DIR) && if [ -d $(OPENWRT_DOWNLOAD_DIR) -a ! -e dl ]; then ln -snf $(OPENWRT_DOWNLOAD_DIR) dl; fi |
---|
77 | endif |
---|
78 | touch $@ |
---|
79 | |
---|
80 | openwrt/patch: openwrt/checkout |
---|
81 | rev=$(call get_svn_revision,$(OPENWRT_BUILD_DIR)) ; \ |
---|
82 | find \ |
---|
83 | "$(OPENWRT_PATCHES_DIR)/all" "$(OPENWRT_PATCHES_DIR)/$(OPENWRT_BRANCH)" \ |
---|
84 | -name .svn -prune -o \! -type d -printf %f/%p\\n | \ |
---|
85 | gawk \ |
---|
86 | 'match($$1, "^[[:digit:]]+(-$(OPENWRT_BRANCH))?(-([[:digit:]]*):([[:digit:]]*))?_", revs) \ |
---|
87 | { if(revs[3] <= '$${rev}' && (!length(revs[4]) || revs[4] >= '$${rev}')) print }' | \ |
---|
88 | sort | sed -e's/^[^/]\+\///' | \ |
---|
89 | while read pat ; \ |
---|
90 | do \ |
---|
91 | if ! patch -d "$(OPENWRT_BUILD_DIR)" -p 0 -N < $${pat} ; \ |
---|
92 | then \ |
---|
93 | echo Failed applying patch: $${pat} > /dev/stderr ; \ |
---|
94 | rm -f openwrt/checkout "$(OPENWRT_BUILD_DIR)/.debwrt.checkout.stamp" ; \ |
---|
95 | exit 1 ; \ |
---|
96 | fi ; \ |
---|
97 | done ; \ |
---|
98 | touch $@ |
---|
99 | |
---|
100 | openwrt/unpatch: openwrt/checkout |
---|
101 | rev=$(call get_svn_revision,$(OPENWRT_BUILD_DIR)) ; \ |
---|
102 | find \ |
---|
103 | "$(OPENWRT_PATCHES_DIR)/all" "$(OPENWRT_PATCHES_DIR)/$(OPENWRT_BRANCH)" \ |
---|
104 | -name .svn -prune -o \! -type d -printf %f/%p\\n | \ |
---|
105 | gawk \ |
---|
106 | 'match($$1, "^[[:digit:]]+(-$(OPENWRT_BRANCH))?(-([[:digit:]]*):([[:digit:]]*))?_", revs) \ |
---|
107 | { if(revs[3] <= '$${rev}' && (!length(revs[4]) || revs[4] >= '$${rev}')) print }' | \ |
---|
108 | sort -r | sed -e's/^[^/]\+\///' | \ |
---|
109 | while read pat ; \ |
---|
110 | do \ |
---|
111 | if ! patch -d "$(OPENWRT_BUILD_DIR)" -p 0 -R < $${pat} ; \ |
---|
112 | then \ |
---|
113 | echo Failed removing patch: $${pat} > /dev/stderr ; \ |
---|
114 | rm -f openwrt/checkout "$(OPENWRT_BUILD_DIR)/.debwrt.checkout.stamp" ; \ |
---|
115 | exit 1 ; \ |
---|
116 | fi ; \ |
---|
117 | done ; \ |
---|
118 | rm openwrt/patch |
---|
119 | touch $@ |
---|
120 | |
---|
121 | |
---|
122 | openwrt/files-copy: openwrt/patch |
---|
123 | tar -C $(FILES_DIR_OPENWRT) --exclude-vcs -cpf - . | \ |
---|
124 | tar -C $(OPENWRT_BUILD_DIR) -xpf - && \ |
---|
125 | touch $@ |
---|
126 | |
---|
127 | ifeq ($(OPENWRT_BRANCH),trunk) |
---|
128 | OPENWRT_SUBVERSION:=$(CONFIG_OPENWRT_SVN_REPO_URL)/trunk/ |
---|
129 | else |
---|
130 | OPENWRT_SUBVERSION:=$(CONFIG_OPENWRT_SVN_REPO_URL)/branches/$(OPENWRT_BRANCH)/ |
---|
131 | endif |
---|
132 | |
---|
133 | $(OPENWRT_BUILD_DIR)/.debwrt.checkout.stamp: |
---|
134 | openwrt/checkout: $(OPENWRT_BUILD_DIR)/.debwrt.checkout.stamp |
---|
135 | rm -rf $(OPENWRT_BUILD_DIR) && \ |
---|
136 | svn co -r $(OPENWRT_REVISION) $(OPENWRT_SUBVERSION) $(OPENWRT_BUILD_DIR) && \ |
---|
137 | touch $@ $< |
---|
138 | |
---|
139 | openwrt/update: openwrt/checkout |
---|
140 | svn up -r $(OPENWRT_REVISION) $(OPENWRT_BUILD_DIR) |
---|
141 | |
---|
142 | openwrt/menuconfig: openwrt/prepare |
---|
143 | $(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) menuconfig |
---|
144 | |
---|
145 | # Tune kernel configuration |
---|
146 | openwrt/kernel_menuconfig: openwrt/prepare |
---|
147 | $(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) kernel_menuconfig |
---|
148 | rm -f openwrt/build |
---|
149 | |
---|
150 | openwrt/clean: |
---|
151 | -$(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) clean V=$(V) |
---|
152 | |
---|
153 | openwrt/dirclean: |
---|
154 | -$(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) dirclean V=$(V) |
---|
155 | |
---|
156 | openwrt/distclean: |
---|
157 | -$(SCRIPT_CLEAN_EXEC) $(MAKE) -C $(OPENWRT_BUILD_DIR) distclean V=$(V) |
---|
158 | |
---|
159 | openwrt/debwrt-clean: |
---|
160 | rm -rf $(OPENWRT_BUILD_DIR) |
---|
161 | rm -f openwrt/checkout |
---|
162 | rm -f openwrt/patch |
---|
163 | rm -f openwrt/files-copy |
---|
164 | |
---|